This prompt is designed for a specific, high-stakes job: analyzing how a single retrieved legal case applies to a new fact pattern. It is not a general legal chatbot. The ideal user is a legal professional or a legal AI product team that has already built a retrieval pipeline. The prompt assumes that a RAG system has surfaced a candidate case, and the model's task is to perform a structured, disciplined analysis. This includes extracting the case's core holding, assessing factual similarity to the user's scenario, noting whether the case is binding or merely persuasive authority in the relevant jurisdiction, and identifying key factors that distinguish the precedent from the current matter.
Prompt
Legal Precedent Analysis Prompt for RAG

When to Use This Prompt
Defines the job-to-be-done, required inputs, and high-stakes boundaries for the Legal Precedent Analysis Prompt in a RAG pipeline.
Use this prompt when the primary failure mode is the overgeneralization of a precedent's scope—a common and dangerous error where a model incorrectly assumes a case applies more broadly than it does. The prompt enforces strict citation discipline by requiring direct quotes for key holdings and explicitly separates binding from persuasive authority. It also includes built-in abstention logic: if the retrieved context is insufficient to perform a reliable analysis, the model is instructed to state that clearly rather than fabricate a connection. This makes it suitable for integration into a legal research tool where a wrong answer is far more costly than no answer.
Do not use this prompt for open-ended legal Q&A, for analyzing multiple cases simultaneously, or for providing legal advice. It is a single-case analysis tool. Before deploying, you must ensure your retrieval system is providing the correct case as context; this prompt will not correct a retrieval error. The next step is to wire this prompt into an application harness with strict output validation, as covered in the Implementation Harness section. For production use, always pair this with a human review step for any analysis that informs a legal filing, client advice, or a judicial decision.
Use Case Fit
Where the Legal Precedent Analysis Prompt for RAG works well and where it introduces unacceptable risk. Use these cards to decide if this prompt fits your workflow before you integrate it into a product.
Good Fit: Jurisdiction-Bound Analysis
Use when: the fact pattern and retrieved precedents share a known jurisdiction, and the system must produce holding summaries with binding-authority notes. Guardrail: include a jurisdiction field in the input schema and reject analysis when jurisdiction is missing or ambiguous.
Bad Fit: Unsupervised Legal Advice
Avoid when: the output will be shown directly to a client or end user without attorney review. Risk: the model may overgeneralize a holding or miss a distinguishing fact, creating liability. Guardrail: the prompt must label all output as a draft research memo requiring human review before any reliance.
Required Inputs
What you must provide: a specific fact pattern, retrieved case passages with full citations, and the target jurisdiction. Risk: missing any of these causes the model to invent facts or ignore binding authority. Guardrail: validate all three inputs are present before calling the model; abort with a clear error message if any are absent.
Operational Risk: Precedent Overgeneralization
What to watch: the model applies a case holding to facts that are materially different without flagging the distinction. Guardrail: add an explicit output section titled 'Distinguishing Factors' and use an eval that fails the response if this section is empty when factual differences exist in the retrieved context.
Operational Risk: Citation Hallucination
What to watch: the model generates a plausible-sounding case name, citation, or holding that does not appear in the retrieved passages. Guardrail: implement a post-generation verification step that checks every cited case name and legal principle against the provided context; flag any unsupported citation for human review.
Variant: Multi-Jurisdiction Conflict
Use when: retrieved precedents span multiple jurisdictions with conflicting holdings. Risk: the model may silently pick one jurisdiction's rule without noting the conflict. Guardrail: add a 'Jurisdictional Conflict' output section that surfaces contradictory authority and instructs the model to abstain from choosing a winner without explicit user instruction.
Copy-Ready Prompt Template
A production-ready system prompt for generating legal precedent analysis from retrieved case law, designed to be copied and adapted with your application's runtime values.
This prompt template is the core instruction set for a legal RAG system that analyzes how precedent applies to a given fact pattern. It is designed to be placed in your model's system instructions, with square-bracket placeholders replaced at runtime by your application's retrieval pipeline, user input, and output schema requirements. The prompt enforces strict citation discipline, jurisdictional scoping, and explicit separation of factual similarity assessment from binding authority analysis. It also includes built-in abstention logic for when retrieved context is insufficient.
textYou are a legal research analyst AI. Your task is to analyze how retrieved legal precedent applies to a given fact pattern. You must ground every statement in the provided [CONTEXT], which contains case law excerpts retrieved from a legal database. ## INPUTS - Fact Pattern: [FACT_PATTERN] - Jurisdiction: [JURISDICTION] - Procedural Posture (if known): [PROCEDURAL_POSTURE] ## RETRIEVED CONTEXT [CONTEXT] ## OUTPUT REQUIREMENTS Generate a structured analysis in valid JSON matching the [OUTPUT_SCHEMA] below. Do not include any text outside the JSON object. ## ANALYSIS RULES 1. **Case Holding Extraction**: For each case in [CONTEXT], extract the core holding in 1-2 sentences. Cite the case name and year. 2. **Factual Similarity Assessment**: Compare the [FACT_PATTERN] to each case's material facts. Rate similarity as High, Medium, or Low with a one-sentence justification grounded in specific facts from both the pattern and the case. 3. **Binding Authority Notes**: For each case, state whether it is binding, persuasive, or distinguishable in [JURISDICTION]. Include the court level and jurisdictional scope. If the case is from a different jurisdiction, explain its persuasive value or lack thereof. 4. **Distinguishing Factors**: Identify specific factual or procedural differences that could limit a precedent's applicability. Be precise: cite the differing fact from the [FACT_PATTERN] and the corresponding fact from the case. 5. **Synthesis and Risk Assessment**: Provide a 2-3 paragraph synthesis of how the precedent landscape applies to the [FACT_PATTERN]. Include an assessment of litigation risk or outcome likelihood, explicitly labeled as "Assessment, Not Prediction." 6. **Abstention**: If [CONTEXT] contains no cases from [JURISDICTION] or no cases with Medium or High factual similarity, state "Insufficient on-point authority retrieved" in the synthesis and do not fabricate applicability. If [CONTEXT] is empty, return {"error": "No context retrieved."} ## CITATION FORMAT - Inline citations: (Case Name, Year, Court) - Pinpoint citations to specific sections if available in [CONTEXT] - Do not cite cases not present in [CONTEXT] ## CONSTRAINTS - Do not provide legal advice. Label all outcome assessments as "Assessment, Not Prediction." - Do not invent case names, holdings, or procedural history. - If the [FACT_PATTERN] involves [RISK_LEVEL] risk (e.g., criminal liability, constitutional claims), append "[HUMAN_REVIEW_REQUIRED]" to the synthesis field. - Limit direct quotes from cases to 50 words each. ## OUTPUT SCHEMA [OUTPUT_SCHEMA]
To adapt this template, replace each square-bracket placeholder with your application's runtime values. [CONTEXT] should be populated by your retrieval pipeline with the top-k case law chunks. [FACT_PATTERN] is the user's case description. [JURISDICTION] should be a structured value like "Ninth Circuit, Federal" or "Delaware Chancery Court" to enable binding-authority logic. [OUTPUT_SCHEMA] should be a JSON Schema object defining the exact fields your downstream application expects—at minimum, include case_analyses (array), synthesis (string), and human_review_flag (boolean). [RISK_LEVEL] should be set by your application's classification layer before prompt assembly. If your system cannot determine risk level, default to requiring human review. Before deploying, validate the prompt against your golden dataset of fact patterns with known precedent outcomes, and run eval checks for citation hallucination, jurisdictional misattribution, and overgeneralization of precedent scope.
Prompt Variables
Inputs the prompt needs to work reliably. Validate these before sending the prompt. Each variable must be populated with concrete, well-formed data to prevent hallucination, misattribution, or scope errors in legal precedent analysis.
| Placeholder | Purpose | Example | Validation Notes |
|---|---|---|---|
[FACT_PATTERN] | The specific fact scenario to analyze against retrieved precedent | The defendant accessed a shared network drive without explicit authorization but with a valid company login after hours. | Must be a complete narrative paragraph. Check for minimum 50 characters and presence of legally relevant actors, actions, and context. Reject if purely hypothetical without concrete details. |
[RETRIEVED_CASES] | The set of retrieved precedent cases with full metadata | Case 1: Smith v. Jones, 2023, 9th Cir. Holding: unauthorized access requires circumvention of technical barriers. Full text: [excerpt]. Case 2: ... | Each case must include case name, year, court, holding, and full text excerpt. Validate that holding text is present and non-empty. Reject if any case is missing jurisdiction or year. Minimum 1 case, maximum 10 to avoid context dilution. |
[JURISDICTION] | The governing jurisdiction for the analysis | 9th Circuit, United States federal court | Must be a recognized jurisdiction name. Validate against a controlled vocabulary of valid jurisdictions. Reject if ambiguous or missing. Used to determine binding versus persuasive authority. |
[ANALYSIS_SCOPE] | The specific legal questions or issues to address | Whether the fact pattern constitutes unauthorized access under the CFAA; whether the shared drive access implies authorization. | Must contain at least one explicit legal question. Validate that each question is a complete interrogative sentence. Reject if scope is empty or contains only generic instructions like 'analyze the case.' |
[OUTPUT_SCHEMA] | The required structure for the analysis output | {"case_holdings": [...], "factual_similarity": {...}, "binding_authority": {...}, "distinguishing_factors": [...], "synthesis": "..."} | Must be a valid JSON schema or structured format specification. Validate parseability. Reject if schema is missing required fields: case_holdings, factual_similarity, binding_authority, distinguishing_factors, synthesis. |
[CONFIDENCE_THRESHOLD] | Minimum confidence level required for assertions in the analysis | 0.85 | Must be a float between 0.0 and 1.0. Validate numeric range. If confidence for any assertion falls below this threshold, the output must include explicit uncertainty language. Null allowed if no threshold is enforced. |
[MAX_QUOTE_LENGTH] | Maximum character length for direct quotes from precedent | 300 | Must be a positive integer. Validate type and range. Used to prevent excessive quotation that could violate fair use or overwhelm analysis. Reject if less than 50 or greater than 1000. |
[HUMAN_REVIEW_REQUIRED] | Flag indicating whether output requires human attorney review before use | Must be boolean. If true, output must include a prominent disclaimer and the system must route to a review queue. If false, log a warning for high-risk legal workflows. Default to true for any analysis involving binding authority claims. |
Implementation Harness Notes
How to wire the Legal Precedent Analysis prompt into a production RAG application with validation, retries, and human review gates.
The Legal Precedent Analysis prompt is designed to operate inside a retrieval-augmented generation (RAG) pipeline, not as a standalone chat interaction. The application layer is responsible for assembling the correct context before the prompt is ever sent to the model. This means your retrieval step must surface the specific case opinions, statutes, and secondary sources relevant to the user's fact pattern. A naive keyword search will fail here. You need a hybrid retrieval strategy that combines dense vector search over case embeddings with metadata filtering on jurisdiction, court level, and date ranges. Without this pre-filtering, the model will receive irrelevant precedent and produce analysis that looks plausible but applies the wrong binding authority.
Once the prompt returns a response, the first gate is structural validation. The output schema expects a JSON object with case_holdings, factual_similarity_assessment, binding_authority_notes, and distinguishing_factors arrays. Your harness must parse this JSON immediately and check for missing required fields, empty arrays where content is expected, and malformed citation strings. If validation fails, do not show the user a broken partial answer. Instead, trigger a retry loop that feeds the validation error back to the model with the original context and a repair instruction. Limit retries to two attempts. If the model still cannot produce valid JSON, escalate to a human reviewer with the original query, retrieved context, and both failed attempts logged for diagnosis.
The highest-risk failure mode for legal RAG is overgeneralization of precedent scope. The model may cite a case correctly but apply its holding to a jurisdiction where it is not binding, or fail to note that a decision was overturned or limited by a later ruling. Your harness must include a post-generation Shepardizing check where possible. If your system has access to a citator API or a database of subsequent treatment, run every cited case through it. Flag any citation where the treatment is negative, the case was overturned, or the holding was narrowed. Append these flags to the output before it reaches the user. If you cannot perform automated citator checks, the output must carry a prominent, hardcoded warning that citation treatment has not been verified and the user must Shepardize all authorities before relying on the analysis.
Human review gating is mandatory for any output that will be used in a filing, client advice, or substantive legal work. Your harness should classify the [RISK_LEVEL] input parameter. If the risk level is high or the output contains a binding_authority_notes entry that identifies controlling precedent in the user's jurisdiction, route the complete analysis to a review queue. The review interface should display the generated analysis side-by-side with the retrieved source passages so the reviewer can verify each holding extraction and similarity claim against the original text. Log the reviewer's action—approve, edit, or reject—along with a timestamp and reviewer identity for audit trail purposes.
For model choice, prefer a model with strong legal reasoning benchmarks and a large context window. The prompt template expects substantial retrieved context, often multiple full case summaries. A context window of at least 128K tokens is recommended. If you are using a model with a smaller context window, you must implement aggressive context pruning before the prompt assembly step, ranking retrieved passages by relevance and dropping low-scoring results. This pruning itself introduces risk of omitting relevant authority, so log which passages were dropped and make them available in the review interface.
Finally, evaluation and monitoring must be continuous. Build a golden dataset of fact patterns with known relevant precedent and expected holding extractions. Run this dataset against every prompt version before release. Measure citation precision (are cited cases real and correctly attributed?), holding accuracy (does the extracted holding match the actual holding?), and jurisdictional correctness (does the analysis correctly identify binding vs. persuasive authority?). In production, monitor the rate of validation failures, retry escalations, and human reviewer rejections. A rising rejection rate is your leading indicator that retrieval quality has degraded or the prompt needs revision.
Common Failure Modes
Legal precedent analysis prompts fail in predictable ways. These are the most common failure modes when applying RAG to case law, along with practical mitigations to deploy before production.
Jurisdictional Overgeneralization
What to watch: The model applies precedent from one jurisdiction as binding in another, ignoring that district court rulings from one circuit are merely persuasive elsewhere. This is the most common and dangerous failure in legal RAG. Guardrail: Require the prompt to explicitly state the jurisdiction of each cited case and classify it as binding, persuasive, or inapplicable. Add a post-generation validator that checks whether any cited case falls outside the target jurisdiction without an explicit persuasive-authority label.
Holding Drift and Scope Creep
What to watch: The model extracts a broad principle from a narrow holding, treating dicta as binding or extending a case's ratio decidendi beyond its actual facts. This produces analysis that sounds authoritative but misrepresents what the case actually decided. Guardrail: Include a constraint requiring the model to quote the exact holding language before paraphrasing. Add an eval step that compares the generated holding summary against the source text for over-extension, flagging any claim not directly traceable to a quoted passage.
Temporal Precedent Inversion
What to watch: The model treats an older case as controlling when a newer decision from the same court has modified or overturned it, or fails to recognize that a cited case was subsequently reversed, abrogated, or superseded by statute. Guardrail: Include a temporal-ordering instruction requiring the model to note the date of each cited authority and check for subsequent treatment. Pair this with retrieval that prioritizes recency and includes Shepard's-style subsequent-history metadata when available.
Factual Similarity Overstatement
What to watch: The model asserts that a precedent is directly on point when the factual similarity is superficial, ignoring material distinguishing factors that would change the outcome. This creates false confidence in the analysis. Guardrail: Require the prompt to produce an explicit distinguishing-factors section that identifies at least one material difference between the instant facts and each cited case. Add a human-review gate for any analysis where the model cannot identify a meaningful distinction.
Citation Hallucination Under Retrieval Gaps
What to watch: When retrieval fails to return relevant precedent, the model fabricates case names, citations, or holdings that sound plausible but do not exist. This is especially dangerous in legal contexts where fabricated authority can mislead practitioners. Guardrail: Add an abstention instruction requiring the model to state 'No directly applicable precedent was retrieved' rather than generating unsupported analysis. Implement a citation-verification step that checks every generated citation against the retrieval set and flags any case not present in the source documents.
Procedural Posture Confusion
What to watch: The model applies a standard of review or procedural rule from a case without recognizing that the procedural posture (summary judgment, motion to dismiss, appeal standard) materially limits the holding's applicability. A ruling on a 12(b)(6) motion does not carry the same weight as a summary judgment decision on the same issue. Guardrail: Include a required field for procedural posture in the output schema, and instruct the model to assess whether the procedural context of each cited case matches the instant matter. Flag mismatches for human review.
Evaluation Rubric
Score each dimension on a pass/fail basis for your golden dataset. This rubric is designed to catch the most common failure modes in legal RAG: hallucinated citations, overgeneralized holdings, and missing jurisdictional analysis.
| Criterion | Pass Standard | Failure Signal | Test Method |
|---|---|---|---|
Citation Hallucination | Every case citation in the output exactly matches a case in [RETRIEVED_CONTEXT]. No fabricated volume, page, or reporter numbers. | Output contains a case name or citation string not found verbatim in the source documents. | Parse output for citation patterns. Cross-reference each against a set of valid citations extracted from [RETRIEVED_CONTEXT]. Fail if any citation is not in the set. |
Holding Fidelity | The extracted holding of a precedent case is a faithful paraphrase of the court's stated rule. No elements are added or omitted. | The output attributes a legal rule to a case that the case does not establish, or omits a key element of the actual holding. | For each case discussed, use an LLM judge to compare the output's holding statement against the source text of the case. Fail if the judge identifies a material addition or omission. |
Factual Similarity Grounding | Every factual comparison between the instant pattern and a precedent is explicitly tied to a specific fact in [INPUT_FACT_PATTERN] and a specific fact in the source case. | The output makes a vague similarity claim like 'the facts are analogous' without citing the specific facts being compared. | Use a regex check to ensure every sentence containing 'similar' or 'analogous' also contains a direct quote or a specific fact reference from both the input and the source. |
Jurisdictional Binding Authority | The analysis correctly identifies whether a cited case is binding, persuasive, or distinguishable based on the jurisdiction provided in [JURISDICTION]. | The output treats a case from a different circuit or a lower court as binding authority without noting the distinction. | Provide a pre-defined mapping of cited cases to their jurisdictional status. Assert that the output's characterization matches this mapping. Fail on mismatch. |
Distinguishing Factors Identification | If a precedent is factually similar, the output identifies at least one material factual difference that could distinguish the case, or explicitly states that none exist. | The output presents a precedent as directly controlling without any analysis of potential distinguishing factors. | Use an LLM judge to verify that for each case deemed 'controlling', the output includes a 'Distinguishing Factors' section or an explicit statement of no material differences. |
Uncertainty Calibration | The output uses calibrated language ('likely', 'may', 'a court could find') for predictive statements and avoids definitive conclusions about the outcome. | The output states definitively how a court 'will' rule or that a precedent 'clearly' controls a novel fact pattern. | Use a keyword scan for absolute terms ('will', 'clearly', 'definitely', 'must'). Fail if these terms are used in a predictive context without a direct on-point citation. |
Source Abstention | The output generates 'Insufficient Information' for any sub-question where [RETRIEVED_CONTEXT] contains no relevant evidence. | The model provides a general legal answer or a speculative analysis for a question not addressed by the retrieved documents. | Include a question in your golden dataset that is unanswerable from the provided context. Fail if the output does not contain an abstention signal like 'Insufficient Information' or 'Not Addressed'. |
Enabling Efficiency, Speed & Accuracy
Intelligent Analysis, Decision & Execution
We build AI systems for teams that need search across company data, workflow automation across tools, or AI features inside products and internal software.
Talk to Us
Search across company data
Give teams answers from docs, tickets, runbooks, and product data with sources and permissions.
Useful when people spend too long searching or get different answers from different systems.

Automate internal workflows
Use AI to route work, draft outputs, trigger actions, and keep approvals and logs in place.
Useful when repetitive work moves across multiple tools and teams.

Add AI to products and internal tools
Build assistants, guided actions, or decision support into the software your team or customers already use.
Useful when AI needs to be part of the product, not a separate tool.
Adapt This Prompt
How to adapt
Start with the base prompt and a small set of 5–10 precedent documents. Remove strict output schema requirements initially. Use a frontier model (GPT-4o, Claude 3.5 Sonnet) with default temperature. Focus on getting the analysis structure right before adding validation.
Replace the [OUTPUT_SCHEMA] placeholder with a simple markdown structure:
- Holding
- Factual Similarity
- Binding Authority
- Distinguishing Factors
Watch for
- The model overgeneralizing a single precedent to cover the entire fact pattern
- Missing jurisdiction checks when the model isn't forced to validate authority
- Analysis that reads like a case brief rather than an application to the specific facts in [FACT_PATTERN]
- No explicit flag when retrieved precedent is persuasive rather than binding

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.
Partnered with leading AI, data, and software stack.
How We Work
Custom AI workflows for your Business
One-fit-all AI don't work for modern businesses. At Inferensys, we aim to understand your business & custom requirements; which we use to define most efficient agentic workflows, the data, and the tools for your business.
01
Review the use case
We understand the task, the users, and where AI can actually help.
Read more02
Pick the right approach
We define what needs search, automation, or product integration.
Read more03
Build the first useful version
We implement the part that proves the value first.
Read more04
Improve from there
We add the checks and visibility needed to keep it useful.
Read moreThe first call is a practical review of your use case and the right next step.
Talk to Us