Inferensys

Prompt

Domain-Adapted Grounding Prompt for Legal Q&A

A practical prompt playbook for deploying jurisdiction-aware legal Q&A with strict citation rules, unauthorized practice of law detection, and explicit limitation language.
Developer doing prompt engineering on laptop, prompt variations visible on screen, casual coding session.
PROMPT PLAYBOOK

When to Use This Prompt

Defines the ideal job-to-be-done, user profile, required inputs, and strict boundaries for deploying a jurisdiction-aware legal Q&A prompt.

This prompt is designed for legal tech product teams building Retrieval-Augmented Generation (RAG) systems that must answer questions strictly from a closed universe of legal documents—case law, statutes, regulations, or contracts. The primary job-to-be-done is to provide attorneys, paralegals, or self-service legal consumers with answers that are not only fluent but forensically grounded in the provided context. The ideal user is an AI engineer or product manager who needs the model to enforce jurisdiction-aware citation formats (like Bluebook or neutral citation), surface precedent dating, and include explicit limitation language, all while refusing to speculate beyond the retrieved text.

You should use this prompt when your application surfaces legal information where factual accuracy and source fidelity are non-negotiable. The required context for every call is a set of retrieved document chunks, each with pre-processed metadata including a unique source identifier, jurisdiction, and date. The prompt template expects placeholders like [JURISDICTION] and [CITATION_STYLE] to be resolved by your application logic before the request is sent to the model. This ensures the model's output adheres to the specific citation rules of the target jurisdiction, rather than defaulting to a generic or incorrect format.

Do not use this prompt for general Q&A, clinical evidence synthesis, or financial audit workflows. Those domains require fundamentally different citation standards, uncertainty quantification, and regulatory guardrails. For example, a financial audit prompt would prioritize materiality thresholds and control IDs over case citations and precedent dating. Using this legal prompt outside its domain will result in misapplied citation formats and inappropriate limitation language, creating a false sense of precision. The next step after understanding this boundary is to copy the prompt template and begin adapting the [CONSTRAINTS] and [OUTPUT_SCHEMA] sections to your specific document corpus and user interface.

PRACTICAL GUARDRAILS

Use Case Fit

Where this prompt works, where it fails, and the operational preconditions required before deploying it in a legal RAG product.

01

Good Fit: Jurisdiction-Specific Q&A

Use when: the knowledge base is scoped to a specific jurisdiction, court, or regulatory body. The prompt's citation format and precedent dating rules produce the highest accuracy when the source documents share a common legal taxonomy. Guardrail: Validate that retrieval is filtered by jurisdiction metadata before the prompt receives context.

02

Bad Fit: General Legal Advice

Avoid when: the user expects a definitive legal opinion or advice on a course of action. This prompt is designed for grounded synthesis, not for applying law to facts. Guardrail: Pair this prompt with a separate classification step that detects advice-seeking queries and routes them to a human review queue with an explicit disclaimer.

03

Required Inputs

What you must provide: retrieved legal document chunks with metadata (jurisdiction, date, court, docket number), the user's question, and a defined citation style (e.g., Bluebook, neutral citation). Guardrail: Implement a pre-flight check in the application harness that rejects the request if any required metadata field is missing from the retrieved context.

04

Operational Risk: Unauthorized Practice of Law

Risk: A fluent, well-cited answer can appear authoritative enough that a user treats it as legal counsel, creating regulatory and liability exposure. Guardrail: The system message must include a mandatory, non-removable disclaimer that is prepended to every response. Monitor production logs for users attempting to strip the disclaimer via prompt injection.

05

Operational Risk: Precedent Recency

Risk: The model may cite a case that has been overturned or superseded without the retrieved context explicitly stating so. Guardrail: Add a post-generation validation step that checks cited cases against a current authority database (e.g., Shepard's) if available, or flags any citation older than a configurable threshold for human review.

06

Operational Risk: Citation Hallucination

Risk: The model may generate a plausible but fictitious case citation that mimics the required legal format. Guardrail: Implement a strict post-processing regex validator that extracts all citations and verifies they exist as substrings within the provided source context. Any citation not found in the source material triggers a retry or human escalation.

PROMPT PLAYBOOK

Copy-Ready Prompt Template

A copy-ready system prompt that enforces jurisdiction-aware citation rules, explicit limitation language, and strict evidence grounding for legal Q&A systems.

This template is designed to be pasted directly into your system instructions or user message template. It enforces strict evidence grounding, legal citation formatting, and explicit limitation language that prevents the model from presenting itself as legal counsel. Replace every square-bracket placeholder with your application's specific values before deployment. The prompt includes mandatory abstention triggers, citation format requirements, and jurisdiction-scoping rules that make it suitable for production legal Q&A systems where incorrect answers carry regulatory risk.

text
You are a legal research assistant operating under strict evidence-grounding rules. Your purpose is to help users understand legal documents, precedents, and statutes by synthesizing answers exclusively from the provided context. You are not a lawyer, and you must never provide legal advice, recommend courses of action, or predict case outcomes.

## Core Grounding Rules
1. Every factual claim in your answer must be directly supported by at least one passage in the provided [CONTEXT].
2. If the [CONTEXT] does not contain sufficient evidence to answer the question, you must abstain rather than guess or draw on general legal knowledge.
3. When multiple sources in the [CONTEXT] conflict, you must surface the conflict explicitly rather than choosing one side.
4. Direct quotes from the [CONTEXT] must be enclosed in quotation marks and must not exceed [MAX_QUOTE_LENGTH] words per quote.

## Citation Format
- Cite sources using the [CITATION_FORMAT] standard (e.g., Bluebook, ALWD, or jurisdiction-specific format).
- For case law: include case name, citation, court, and year. Example: [CASE_CITATION_EXAMPLE]
- For statutes: include title, section, and jurisdiction. Example: [STATUTE_CITATION_EXAMPLE]
- For regulations: include CFR or state equivalent reference. Example: [REGULATION_CITATION_EXAMPLE]
- Inline citations must appear immediately after the claim they support using the format: [CITATION_PLACEMENT_RULE]

## Jurisdiction Scope
- This system is configured for [JURISDICTION_NAME] law only.
- If the [CONTEXT] references law from other jurisdictions, note the jurisdiction explicitly and do not apply it to [JURISDICTION_NAME] questions.
- When a question implicates multiple jurisdictions, identify which parts of the answer apply to which jurisdiction.

## Temporal Rules
- Always note the date of each cited authority.
- If a cited case has been overturned, superseded, or depublished, flag this explicitly with the subsequent treatment.
- Prefer the most recent authority when multiple sources address the same point, but note older authority if it remains good law.

## Abstention Triggers
You must abstain from answering when:
1. The [CONTEXT] lacks evidence to support a complete answer.
2. The question asks for legal advice, strategy recommendations, or outcome predictions.
3. The question requires applying law to specific facts in a way that constitutes legal judgment.
4. The [CONTEXT] contains ambiguous or contradictory authority that cannot be resolved without legal interpretation.

When abstaining, use this format:
"I cannot answer this question because [SPECIFIC_REASON]. The provided context [WHAT_CONTEXT_CONTAINS_OR_LACKS]. To address this question, you would need [WHAT_WOULD_BE_REQUIRED]."

## Answer Structure
For answerable questions, structure your response as:
1. **Direct Answer**: A concise answer grounded in the [CONTEXT].
2. **Supporting Authority**: The specific sources supporting each claim, with proper citations.
3. **Limitations**: Explicit caveats about what the answer does not cover, including jurisdictional limits, temporal scope, and factual assumptions.
4. **Conflict Notes** (if applicable): Any contradictory authority found in the [CONTEXT].

## Prohibited Language
Never use phrases that imply you are providing legal advice, including:
- "You should..."
- "I recommend..."
- "The best course of action is..."
- "Based on my analysis..."
- "You have a strong case..."

Instead, use:
- "The authority indicates..."
- "According to [CITATION], ..."
- "The [CONTEXT] shows..."
- "One interpretation supported by the sources is..."

## Input
[CONTEXT]: [RETRIEVED_DOCUMENTS]
[QUESTION]: [USER_QUERY]
[JURISDICTION]: [JURISDICTION_NAME]
[DATE]: [CURRENT_DATE]

After pasting this template, you must configure the placeholder values to match your application's legal domain and jurisdiction. The [CITATION_FORMAT] placeholder should be replaced with the specific citation standard your system must follow—Bluebook for U.S. legal systems, ALWD for academic legal writing, or a jurisdiction-specific format. The [MAX_QUOTE_LENGTH] constraint should be set based on fair use considerations and your legal team's guidance; typical values range from 50 to 150 words. The [JURISDICTION_NAME] placeholder scopes the entire prompt to a specific legal system, which is critical for preventing cross-jurisdictional misapplication of authority.

Before deploying this prompt to production, you must pair it with an evaluation harness that checks for citation format compliance, unauthorized legal advice detection, and abstention accuracy. The eval should include test cases where the context is insufficient, where the question requests legal advice, and where sources conflict. Run these evals against a golden dataset of legal questions with known correct citations and expected abstention triggers. Human review remains mandatory for any answer that will be shown to end users in a legal context—this prompt reduces risk but does not eliminate the need for qualified legal review.

IMPLEMENTATION TABLE

Prompt Variables

Required and optional inputs for the Domain-Adapted Grounding Prompt. Each placeholder must be populated before the prompt is assembled and sent to the model. Validation notes describe how to programmatically check the input before injection.

PlaceholderPurposeExampleValidation Notes

[USER_QUERY]

The user's legal question as submitted

What are the notice requirements for terminating a commercial lease in California?

Non-empty string. Check length > 10 chars. Reject if it contains only a document reference without a question.

[RETRIEVED_CONTEXT]

Array of retrieved legal passages with metadata

[{"text": "Cal. Civ. Code § 1946...", "source": "California Civil Code", "date": "2024-01-01", "jurisdiction": "CA"}]

Must be a valid JSON array. Each object requires 'text' and 'source' fields. Reject if array is empty; route to abstention flow instead.

[JURISDICTION]

The governing legal jurisdiction for the answer

California

Must match a value in the allowed jurisdiction taxonomy. If null, prompt must instruct the model to state the assumed jurisdiction explicitly.

[CITATION_STYLE]

The required legal citation format

Bluebook

Must be one of the enumerated styles: 'Bluebook', 'California Style Manual', 'ALWD', or 'Custom'. If 'Custom', a [CITATION_TEMPLATE] must also be provided.

[CITATION_TEMPLATE]

Custom citation format string when [CITATION_STYLE] is 'Custom'

{Source}, {Section} ({Year})

Required only if [CITATION_STYLE] is 'Custom'. Must contain at least one token from the available metadata fields. Validate with a regex for balanced braces.

[MAX_QUOTE_LENGTH]

Maximum word count for any single verbatim quote from source material

50

Integer between 20 and 200. If null, default to 50. Values below 20 risk losing essential legal phrasing; values above 200 risk copyright or fair use concerns.

[OUTPUT_SCHEMA]

JSON schema the final answer must conform to

{"type": "object", "properties": {"answer": {"type": "string"}, "citations": {"type": "array"}}, "required": ["answer", "citations"]}

Must be a valid JSON Schema object. Parse and validate before prompt assembly. If null, the prompt defaults to a structured text format with explicit citation markers.

[DISCLAIMER_TEXT]

Mandatory disclaimer appended to every response

This does not constitute legal advice. Consult a qualified attorney licensed in your jurisdiction.

Non-empty string. If null, the system must inject a hardcoded default disclaimer. Validate that the string does not contain any user-supplied input to prevent injection.

PROMPT PLAYBOOK

Implementation Harness Notes

How to wire the Domain-Adapted Grounding Prompt into a production legal Q&A application with validation, retries, and human review gates.

This prompt is designed to be the final synthesis step in a RAG pipeline, not a standalone chatbot. The application layer must handle retrieval, evidence ranking, and context assembly before the prompt is ever called. The prompt expects a curated set of retrieved legal passages, relevant jurisdiction metadata, and a clearly defined output schema. Do not pass raw search results or unranked document chunks directly into this prompt; the grounding guarantees only hold when the input context has already been filtered for relevance and authority.

Wire the prompt into a structured generation call with response_format set to the JSON schema defined in the output contract. Use a model with strong instruction-following and legal reasoning capabilities—GPT-4o or Claude 3.5 Sonnet are appropriate starting points. Set temperature to 0.0 or 0.1 to minimize citation format drift. Implement a post-generation validation layer that checks: (1) every citation matches a provided source ID, (2) no citation references a source outside the input context, (3) direct quotes do not exceed the stated character limit, and (4) the abstention flag is present and correctly set when evidence is insufficient. If validation fails, retry once with the validation errors injected into the [CONSTRAINTS] block as explicit correction instructions. After two failures, escalate to a human review queue rather than looping indefinitely.

For high-stakes legal workflows, add a mandatory human approval step before any answer reaches the end user. The harness should log the full prompt payload, retrieved context, model response, validation results, and reviewer decision for audit purposes. Implement a confidence gate: if the model's self-reported confidence score falls below a configurable threshold (start with 0.7 and calibrate against your domain), route the answer to review even if validation passes. Monitor production for unauthorized legal advice patterns—phrases like 'you should file' or 'your legal obligation is'—using a secondary classifier prompt that flags responses for immediate human interception. Never deploy this prompt without a mechanism to detect and block the model from generating legal advice, as the grounding instructions reduce but do not eliminate this risk.

The prompt works best when the retrieval system pre-annotates passages with jurisdiction, court level, and date metadata. Pass these annotations in the context block so the model can apply the correct citation format and recency preferences. If your knowledge base spans multiple jurisdictions, include a [JURISDICTION_RULES] placeholder that maps jurisdiction codes to citation style requirements. Test the full harness with a golden dataset of 50-100 legal questions paired with known-good context sets, and measure citation format compliance, abstention accuracy, and unauthorized advice detection rates before any production release.

PRACTICAL GUARDRAILS

Common Failure Modes

When deploying a domain-adapted grounding prompt for legal Q&A, these failures surface first in production. Each card identifies a specific breakage pattern and the operational guardrail that catches it before users see bad output.

01

Citation Format Drift

What to watch: The model gradually abandons the required legal citation format (e.g., Bluebook, vendor-specific neutral citations) and reverts to informal references or markdown links. This happens most when retrieved chunks lack clean metadata or when the prompt is long and the format instruction gets diluted. Guardrail: Add a post-generation validator that regex-checks every citation against the expected pattern and triggers a repair prompt if compliance drops below 95%.

02

Unauthorized Legal Advice Creep

What to watch: The model shifts from summarizing retrieved legal content to making recommendations, predicting outcomes, or using imperative language like 'you should file.' This is especially dangerous in pro se or client-facing systems. Guardrail: Deploy a classifier prompt that scores every answer for advisory language before release. Route answers scoring above threshold to a human review queue with the flagged spans highlighted.

03

Precedent Dating Errors

What to watch: The model cites cases with wrong years, treats overturned precedent as current, or fails to note when a cited case predates a controlling statute. Retrieved chunks often lack explicit date metadata, so the model guesses. Guardrail: Require date extraction from source metadata in the retrieval pipeline and include a constraint that every cited precedent must include its year. Run a date-consistency check that flags citations where the year conflicts with the governing statute's effective date.

04

Jurisdiction Confusion

What to watch: The model blends authority from multiple jurisdictions without labeling which rules apply where. A question about California law gets answered with a mix of federal, Delaware, and California precedent presented as equally binding. Guardrail: Include a jurisdiction field in the retrieval filter and surface it in the prompt as a non-negotiable constraint. Add an eval check that counts cross-jurisdictional citations and fails answers where unlabeled foreign authority exceeds zero.

05

Limitation Language Omission

What to watch: The model produces confident, fluent answers but drops the required limitation language ('This is not legal advice,' 'Consult an attorney,' 'Based only on the provided documents'). This happens when the answer is long and the model optimizes for conciseness. Guardrail: Append the limitation statement as a required final paragraph in the output schema rather than relying on the model to remember it. Validate presence with a simple string match before the answer reaches the user.

06

Silent Abstention Failure

What to watch: When retrieved evidence is insufficient, the model fabricates a plausible-sounding answer instead of triggering the abstention path. This is the highest-risk failure mode in legal Q&A because users trust the output. Guardrail: Run a pre-answer evidence sufficiency check that scores retrieval quality. If the score is below threshold, force the abstention template. Pair this with a post-answer hallucination detector that compares generated claims against source chunks and flags unsupported statements for human review.

IMPLEMENTATION TABLE

Evaluation Rubric

How to test output quality before shipping. Use this rubric to evaluate the Domain-Adapted Grounding Prompt for Legal Q&A against key failure modes in legal RAG systems.

CriterionPass StandardFailure SignalTest Method

Citation Format Compliance

Every citation matches the required jurisdiction format (e.g., Bluebook, neutral citation) and includes a document identifier from [RETRIEVED_CONTEXT].

Citation uses an incorrect style, omits a required element like a pin-point page, or invents a citation not present in the source metadata.

Parse all citations with a regex for the target format. Assert that each extracted citation string exists verbatim in [RETRIEVED_CONTEXT] metadata.

Unauthorized Legal Advice Detection

The output contains no unqualified legal advice, predictions of outcome, or statements that could be interpreted as establishing an attorney-client relationship. A mandatory disclaimer is present.

The output includes phrases like 'you will win,' 'you should sue,' or provides a specific course of legal action without a qualifying disclaimer.

Run a classifier prompt (LLM-as-judge) trained to detect unauthorized practice of law. Flag any output with a confidence score above 0.7 for manual review.

Precedent Dating and Recency

All cited cases or statutes include a date. The answer explicitly notes if a cited precedent has been subsequently overturned, criticized, or is from a non-binding jurisdiction, based on [RETRIEVED_CONTEXT].

A case is cited without a year, or a statute is cited without an effective date. The answer treats overturned precedent as good law.

For each cited legal authority, assert that a four-digit year is present. Cross-reference the case name and year against a known 'overturned' list in the test dataset to check for negative treatment flags.

Source Grounding and Fabrication

Every factual claim about a case, statute, or legal principle is directly supported by at least one passage in [RETRIEVED_CONTEXT]. No hallucinated case names or holdings.

The answer includes a case name, holding, or statutory rule that cannot be found in the provided context. The model invents a legal principle to fill a gap.

Use a claim extraction prompt to break the answer into atomic claims. For each claim, run a semantic similarity check against all chunks in [RETRIEVED_CONTEXT]. A claim with a similarity score below 0.8 is a failure.

Limitation and Abstention Language

The answer explicitly states its limitations, including jurisdictional boundaries and the fact that it is not a substitute for a human lawyer. It abstains if [RETRIEVED_CONTEXT] is empty or irrelevant.

The answer provides a confident, unqualified response when the context is insufficient or clearly from the wrong jurisdiction. No abstention or limitation language is present.

Test with an empty [RETRIEVED_CONTEXT] and an out-of-jurisdiction query. Assert that the output contains a predefined abstention phrase like 'I cannot answer this question based on the provided documents.'

Quote Fidelity and Paraphrase Drift

Any direct quote is enclosed in quotation marks and is a character-perfect match with the source text. Paraphrased text does not alter the original legal meaning.

A direct quote is missing quotation marks, has altered wording, or a paraphrase changes a critical legal nuance (e.g., 'may' vs. 'shall').

Extract all quoted strings. For each, assert a case-insensitive exact match exists in [RETRIEVED_CONTEXT]. Use an LLM judge to compare paraphrased statements against the source for semantic drift on key legal terms.

Conflict and Ambiguity Surfacing

When sources conflict or are ambiguous, the answer explicitly describes the conflict, attributes each position to its source, and does not falsely resolve the ambiguity.

The answer picks one side of a legal split without acknowledging the other, or synthesizes a single 'average' rule that misrepresents both sources.

Provide [RETRIEVED_CONTEXT] containing two passages with contradictory holdings. Assert that the output contains both a 'however' or 'conversely' conjunction and names both conflicting sources.

Structured Output Schema Validity

The final output is a valid JSON object that strictly conforms to the [OUTPUT_SCHEMA], including all required fields like answer_text, citations, limitations, and abstention_triggered.

The output is a raw string, is missing a required field like citations, or contains a malformed JSON structure that fails to parse.

Run a JSON schema validator against the model's output using the exact [OUTPUT_SCHEMA] provided in the prompt. Any validation error is an automatic failure.

ADAPTATION OPTIONS

Adapt This Prompt

How to adapt

Add a strict JSON output schema with fields: answer_text, citations (array of {source_id, passage_ref, quote_snippet, relevance}), abstention_flags (array of {question_part, reason, suggested_retrieval}), and unauthorized_advice_check (boolean with explanation).

Wire in a validation harness that checks: (1) every citation maps to a real source chunk ID, (2) quote snippets appear verbatim in the source, (3) abstention triggers when confidence is below threshold. Add retry logic: if validation fails, re-prompt with the specific failure message and the original context.

Include the full [JURISDICTION_RULES] block specifying citation format (e.g., Bluebook Rule 10 for cases, Rule 15 for statutes), date-precedence rules, and mandatory limitation language: "This response does not constitute legal advice. Consult a licensed attorney in [JURISDICTION] for specific guidance."

Watch for

  • Silent format drift where the model returns valid JSON but moves citations to a non-standard field.
  • Missing human review for answers flagged as borderline UPL—automate the flag but require human sign-off before delivery.
  • Citation coverage gaps: the model may cite only one of three relevant passages, creating a misleadingly narrow answer.
Prasad Kumkar

About the author

Prasad Kumkar

CEO & MD, Inference Systems

Prasad Kumkar is the CEO & MD of Inference Systems and writes about AI systems architecture, LLM infrastructure, model serving, evaluation, and production deployment. Over 5+ years, he has worked across computer vision models, L5 autonomous vehicle systems, and LLM research, with a focus on taking complex AI ideas into real-world engineering systems.

His work and writing cover AI systems, large language models, AI agents, multimodal systems, autonomous systems, inference optimization, RAG, evaluation, and production AI engineering.