Inferensys

Prompt

Legal Contract Risk Review RAG Prompt

A practical prompt playbook for using Legal Contract Risk Review RAG Prompt in production AI workflows.
Legal team reviewing EU AI Act compliance documents on laptop in modern office, coffee cups and papers on table, casual meeting.
PROMPT PLAYBOOK

When to Use This Prompt

A practical guide to deploying the Legal Contract Risk Review RAG Prompt for identifying risk patterns in agreements using retrieved clause context.

This prompt is designed for contract review systems that must identify risk patterns across agreements using retrieved clause context. The primary job-to-be-done is surfacing one-sided indemnification, uncapped liability, auto-renewal traps, missing termination rights, and other structural risks from a set of retrieved contract chunks. The ideal user is a legal operations team, contract analyst, or AI engineer building a RAG pipeline over a contract repository who needs structured, citable risk findings—not a lawyer seeking a final legal opinion. The prompt assumes that a retrieval step has already occurred and that the [CONTEXT] placeholder will be populated with the most relevant clauses from one or more agreements. Without this retrieved context, the prompt has nothing to ground its analysis and should not be used.

Use this prompt when your system needs to produce risk findings with clause citations, risk severity ratings (e.g., Critical, High, Medium, Low), market-standard comparisons, and suggested fallback positions. It is appropriate for internal contract review workflows where the output will be reviewed by a human before any negotiation or decision. Do not use this prompt for generating legal advice, making final risk determinations, or reviewing contracts outside the retrieved context window. It is also not suitable for contracts where the governing law imposes unique statutory requirements not reflected in the retrieved clauses, or for real-time negotiation support where latency constraints prevent human review of the AI's findings. In regulated environments, always pair this prompt with a human-in-the-loop approval step and log every output for auditability.

Before integrating this prompt into a production system, you should have a clear eval strategy that measures both false-positive risk flagging (flagging a clause as risky when it is market-standard) and missed risk categories (failing to flag a genuinely one-sided provision). The prompt's value comes from its structured output schema, which makes it easy to validate that every finding includes a clause citation, a severity rating, and a suggested fallback. If your contract repository contains agreements from multiple jurisdictions or industries, consider adding a [JURISDICTION] or [INDUSTRY] placeholder to help the model calibrate its market-standard comparisons. The next section provides the copy-ready prompt template you can adapt for your own contract review pipeline.

PRACTICAL GUARDRAILS

Use Case Fit

Where the Legal Contract Risk Review RAG Prompt delivers value and where it introduces unacceptable risk. Use these cards to decide if this prompt fits your contract review workflow before integrating it into a production system.

01

Good Fit: High-Volume Contract Triage

Use when: You need to screen hundreds of standard-form agreements for common risk patterns before attorney review. Guardrail: Configure the prompt to output structured risk flags with clause citations so reviewers can prioritize the highest-risk contracts without reading every page.

02

Bad Fit: Novel or Bespoke Agreement Structures

Avoid when: Contracts use heavily negotiated, non-standard language or novel deal structures that fall outside the model's training distribution. Guardrail: Implement a confidence threshold that routes low-certainty extractions to human review and logs the contract type for prompt improvement.

03

Required Input: Clean, Machine-Readable Contract Text

Risk: Scanned PDFs, handwritten amendments, or poorly OCR'd documents produce garbled clause text that triggers false risk flags or missed extractions. Guardrail: Pre-process documents with layout-aware extraction and reject inputs below a minimum text quality score before they reach the RAG prompt.

04

Required Input: Defined Risk Taxonomy

Risk: Without a clear risk category schema, the model invents inconsistent severity labels or flags trivial issues as critical. Guardrail: Supply a closed-set risk taxonomy in the prompt with definitions and examples for each category, and validate outputs against the allowed enum values.

05

Operational Risk: False-Positive Risk Flagging

Risk: The model over-flags standard market terms as risks, creating alert fatigue and eroding reviewer trust in the system. Guardrail: Run a calibration eval against attorney-labeled contracts and tune the prompt to distinguish market-standard language from true deviations before production deployment.

06

Operational Risk: Missed Risk Categories

Risk: The model fails to identify novel or domain-specific risk patterns not represented in the few-shot examples or taxonomy. Guardrail: Maintain a human review loop that captures missed risks, feeds them back into the prompt as new examples, and tracks recall improvement over successive prompt versions.

PROMPT PLAYBOOK

Copy-Ready Prompt Template

A production-ready prompt for generating risk reviews from contract clauses, with placeholders for your retrieval context, risk taxonomy, and output constraints.

This template is designed to be the core instruction set for your RAG answer generation step. It forces the model to act as a contract risk analyst, grounding every finding in a specific clause from the provided context. The prompt is structured to prevent the two most common failure modes in legal AI: hallucinated clause references and risk severity inflation. Before pasting this into your harness, ensure your retrieval step has already returned the most relevant clauses for the contract under review. The prompt expects a curated context window, not a full document dump.

code
You are a contract risk analyst. Review the provided contract clauses against the risk categories below. For each risk identified, you must cite the exact clause text that triggered the finding.

[CONTEXT]
The following clauses were retrieved from the contract under review:
---
[RETRIEVED_CLAUSES]
---

[RISK_CATEGORIES]
Analyze the clauses for the following risk categories. For each category, provide a severity rating of LOW, MEDIUM, HIGH, or CRITICAL based on the definitions provided:
- Indemnification: [INDEMNIFICATION_RISK_DEFINITION]
- Limitation of Liability: [LIABILITY_RISK_DEFINITION]
- Termination: [TERMINATION_RISK_DEFINITION]
- Data Privacy & Security: [DATA_PRIVACY_RISK_DEFINITION]
- Payment & Penalties: [PAYMENT_RISK_DEFINITION]

[OUTPUT_SCHEMA]
Return a valid JSON array of risk findings. Do not include any text outside the JSON structure. Each object must have the following keys:
- "risk_category": string (must match one of the provided categories)
- "severity": string (LOW, MEDIUM, HIGH, or CRITICAL)
- "finding_summary": string (a one-sentence summary of the risk)
- "source_clause_text": string (the verbatim text from [RETRIEVED_CLAUSES] that supports this finding)
- "market_standard_comparison": string (a brief note on how this deviates from standard market positions)
- "suggested_fallback": string (a concise suggested fallback position for negotiation)

[CONSTRAINTS]
1. If no risk is found for a category, do not include it in the output array.
2. Do not infer risks from clauses not present in [RETRIEVED_CLAUSES].
3. If the retrieved context is insufficient to assess a category confidently, output a finding with severity "UNCLEAR" and state what information is missing in the finding_summary.
4. Do not provide legal advice. The suggested_fallback is a commercial negotiation starting point, not a legal recommendation.

To adapt this template, start by replacing the [RISK_CATEGORIES] with your organization's specific risk taxonomy. The definitions for each category should be precise enough that a non-lawyer can understand the boundary between MEDIUM and HIGH severity. If your retrieval system returns metadata like clause headings or section numbers, inject them into the [RETRIEVED_CLAUSES] block to improve citation accuracy. The [OUTPUT_SCHEMA] is designed for direct ingestion by a downstream risk dashboard; if your application expects a different shape, modify the JSON schema but preserve the source_clause_text field as a non-negotiable grounding mechanism. For high-stakes reviews, always route findings with CRITICAL or UNCLEAR severity to a human review queue before they reach end users.

IMPLEMENTATION TABLE

Prompt Variables

Required and optional inputs for the Legal Contract Risk Review RAG Prompt. Validate each variable before assembly to prevent silent failures in production.

PlaceholderPurposeExampleValidation Notes

[CONTRACT_TEXT]

Full text of the agreement to review, chunked or passed as retrieved context

"MASTER SERVICES AGREEMENT... IN WITNESS WHEREOF..."

Must be non-empty string. Check for truncation if > context window. Strip scanner artifacts before passing.

[CONTRACT_TYPE]

Document category to scope risk taxonomy and market-standard comparisons

"SaaS Subscription Agreement"

Must match allowed enum: MSA, SOW, NDA, DPA, License, Employment, Lease, null. Controls which risk categories are active.

[JURISDICTION]

Governing law to calibrate enforceability and fallback positions

"Delaware, USA"

Must be non-empty string. Map to known jurisdiction list. If unrecognized, flag for human review and default to general principles.

[PARTY_ROLE]

Which side the reviewer represents to orient risk assessment

"Customer"

Must be one of: Customer, Vendor, Licensor, Licensee, Employer, Employee, Disclosing Party, Receiving Party. Controls risk direction.

[RISK_CATEGORIES]

Specific risk types to scan for; null means all categories

["Indemnification", "Limitation of Liability", "Termination"]

Must be array of strings or null. Validate each entry against known taxonomy. Unknown categories trigger warning but not rejection.

[MARKET_BENCHMARKS]

Reference standards for comparison; null disables market comparison

["BSA Cloud SLA Benchmarks 2024", "Internal Playbook v3"]

Must be array of strings or null. Each benchmark must have retrievable reference text. Missing benchmark data triggers partial output with gap flag.

[OUTPUT_SCHEMA]

Expected JSON structure for downstream ingestion

{"findings": [...], "metadata": {...}}

Must be valid JSON Schema or type definition string. Validate parseable before prompt assembly. Schema mismatch triggers output repair retry.

[CONFIDENCE_THRESHOLD]

Minimum confidence score for auto-inclusion; below threshold findings go to review queue

0.75

Must be float between 0.0 and 1.0. Null defaults to 0.7. Findings below threshold still returned with low_confidence flag set to true.

PROMPT PLAYBOOK

Implementation Harness Notes

How to wire the Legal Contract Risk Review RAG Prompt into a production contract review application with validation, retries, logging, and human review gates.

The Legal Contract Risk Review RAG Prompt is designed to operate inside a retrieval-augmented generation pipeline, not as a standalone chat interaction. The application layer is responsible for assembling the prompt with retrieved contract clauses, market-standard references, and the target contract text before sending it to the model. This prompt expects structured inputs: the full contract text or extracted clauses in [CONTRACT_TEXT], a set of retrieved reference materials in [RETRIEVED_CONTEXT] that may include market-standard clauses, regulatory guidance, and prior risk assessments, and a [RISK_CATEGORIES] list defining which risk types to scan for. The application must handle chunking and retrieval before prompt assembly—this prompt does not perform its own search.

Wire the prompt into a pipeline with these stages: (1) Contract ingestion and clause segmentation using a document parser that preserves section numbering and clause boundaries. (2) Retrieval against a vector store or hybrid search index containing market-standard clauses, regulatory texts, and historical risk findings. (3) Prompt assembly where [CONTRACT_TEXT] receives the target clause or full contract, [RETRIEVED_CONTEXT] receives the top-k retrieved references with metadata, and [RISK_CATEGORIES] receives the configured risk taxonomy. (4) Model call with structured output constraints—use response_format with a JSON schema matching the expected risk finding structure including risk_id, clause_reference, risk_category, severity, finding, market_comparison, and suggested_fallback. (5) Post-processing validation that checks every clause_reference actually exists in the source contract, every severity value matches the allowed enum, and no finding lacks a supporting citation. (6) Human review routing where findings above a severity threshold or flagged with low confidence are queued for attorney review before appearing in the final report.

For model choice, prefer models with strong structured output support and long-context handling—GPT-4o, Claude 3.5 Sonnet, or equivalent. Set temperature to 0 or near-zero to maximize consistency across repeated reviews of the same contract. Implement retry logic with exponential backoff for schema validation failures: if the output fails JSON schema validation, retry up to 2 times with the validation error message appended to the prompt as a correction hint. Log every model call with the contract identifier, retrieval query, prompt version, model response, validation result, and human review outcome. This audit trail is critical for legal workflows where every risk flag must be traceable. Never skip human review for high-severity findings or findings in regulated contract types—this prompt identifies patterns, it does not make legal determinations.

IMPLEMENTATION TABLE

Expected Output Contract

Defines the strict JSON schema, field types, and validation rules for the risk review output. Use this contract to build post-generation validation before the output reaches a user or database.

Field or ElementType or FormatRequiredValidation Rule

risk_findings

array of objects

Must be a non-empty array. If no risks are found, return a single object with risk_id 'NONE' and severity 'INFO'.

risk_findings[].risk_id

string

Must match pattern 'RISK-[0-9]{4}'. Must be unique within the array.

risk_findings[].clause_citation

string

Must contain a direct quote from [RETRIEVED_CONTEXT] enclosed in double quotes. Validate substring existence in the source.

risk_findings[].severity

enum: CRITICAL, HIGH, MEDIUM, LOW, INFO

Must be one of the defined enum values. CRITICAL triggers an immediate human review flag in the application layer.

risk_findings[].risk_category

string

Must match one of the predefined categories in [RISK_TAXONOMY]. If no match, set to 'OTHER' and log for taxonomy review.

risk_findings[].market_standard_comparison

string or null

If not null, must contain a reference to a specific market standard document or practice. Null is allowed when no comparison is available.

risk_findings[].suggested_fallback

string

Must be a non-empty string proposing a concrete alternative clause or negotiation position. Cannot be a generic statement like 'negotiate better terms'.

processing_metadata.confidence_score

number (0.0-1.0)

Must be a float between 0.0 and 1.0. If below [CONFIDENCE_THRESHOLD], the entire output must be routed for human review.

PRACTICAL GUARDRAILS

Common Failure Modes

What breaks first when using RAG for legal contract risk review and how to guard against it.

01

False-Positive Risk Flagging

What to watch: The model flags standard, market-acceptable clauses as high-risk because it lacks industry benchmarking context. This erodes user trust and creates alert fatigue. Guardrail: Include market-standard language examples and acceptable risk thresholds in the system prompt. Require the model to compare against provided benchmarks before flagging, and route all high-severity flags for human review.

02

Missed Risk Categories

What to watch: The model overlooks assignment, change-of-control, or most-favored-nation clauses because retrieval didn't surface them or the prompt didn't explicitly enumerate the risk taxonomy. Guardrail: Provide a closed, exhaustive risk category checklist in the prompt. Run a post-generation completeness check that verifies every required category was addressed, and trigger a re-retrieval if categories are missing.

03

Citation Drift and Clause Hallucination

What to watch: The model fabricates clause text or attributes a finding to Section 8.2 when the actual clause is in Section 9.1. This is catastrophic for legal workflows where precision is non-negotiable. Guardrail: Require verbatim quote extraction with exact section references. Implement a post-generation string-match validator that verifies quoted text exists in the retrieved chunks. If verification fails, regenerate with stricter grounding instructions.

04

Jurisdiction Overgeneralization

What to watch: The model applies Delaware contract law reasoning to a contract governed by English law, or assumes US-style risk standards for an APAC agreement. Guardrail: Extract governing law and jurisdiction from the contract metadata first. Include jurisdiction-specific guidance in the prompt context. If jurisdiction cannot be determined, flag the output with an explicit scope limitation and require human confirmation.

05

Context Window Saturation on Long Contracts

What to watch: A 120-page MSA saturates the context window, causing the model to ignore clauses in the middle or end of the document. Risk findings become front-loaded and incomplete. Guardrail: Chunk the contract by article or schedule before retrieval. Run risk review per-chunk with a final synthesis step. Validate that every major contract section produced at least one retrieval hit before generating the final report.

06

Severity Inflation Under Ambiguity

What to watch: When a clause is ambiguous, the model defaults to high-severity ratings because it cannot resolve the ambiguity. This produces an overly alarming report that requires extensive human triage. Guardrail: Add a confidence score requirement to every risk finding. When confidence is low due to ambiguity, cap the severity at medium and add an explicit 'requires legal interpretation' flag. Never allow high-severity ratings on low-confidence findings.

IMPLEMENTATION TABLE

Evaluation Rubric

Criteria for evaluating the quality of a Legal Contract Risk Review RAG output before shipping to production. Each row defines a pass standard, a failure signal, and a concrete test method.

CriterionPass StandardFailure SignalTest Method

Clause Citation Accuracy

Every risk finding cites a specific clause or section from [RETRIEVED_CONTRACT_CHUNKS] that contains the identified risk language.

A risk is flagged but the cited clause text does not contain the risk pattern, or the citation is a hallucinated section number.

LLM-as-Judge: For each finding, verify the cited text is present in the source chunk and semantically matches the risk description.

Risk Severity Calibration

Severity ratings (Critical, High, Medium, Low) align with the [RISK_TAXONOMY] definitions. A 'Critical' finding must involve uncapped liability, automatic termination, or regulatory non-compliance.

A minor formatting issue is rated 'High' or a true uncapped liability clause is rated 'Low'.

Rule-based check: Map the finding's risk category and clause type against the severity matrix in [RISK_TAXONOMY]. Flag mismatches.

Market Standard Comparison Grounding

Any claim about a 'market standard' or 'typical' position is explicitly linked to a source in [MARKET_STANDARDS_KNOWLEDGE_BASE] or flagged as an internal model generalization.

The output states 'This is not market standard' without a citation or a clear caveat that this is a model-generated generalization.

Assertion check: Scan output for 'market standard' or 'typical' phrases. Verify each has an adjacent citation or the explicit disclaimer '[Note: Market-standard assessment is a model generalization]'.

Fallback Position Actionability

Each suggested fallback position is a specific, revisable clause draft or a concrete negotiation instruction, not a vague recommendation.

A fallback suggestion is 'Negotiate better terms' or 'Reduce the risk' without specific language or a target position.

Human review: A legal SME reviews a sample of fallback suggestions and rates them as 'Actionable' or 'Vague'. Target >90% Actionable.

False Positive Risk Flagging Rate

Fewer than 10% of flagged risks are false positives (i.e., a clause is flagged as risky but a legal reviewer determines it is standard and benign).

A standard 'Entire Agreement' or 'Governing Law' clause is repeatedly flagged as high risk.

Golden dataset eval: Run the prompt on a set of 50 pre-labeled contracts. Measure precision (True Positives / Total Flagged). Target precision > 0.9.

Missed Risk Category Recall

All instances of pre-defined critical risk categories in [RISK_TAXONOMY] (e.g., uncapped liability, auto-renewal, IP assignment) present in the contract are identified.

A contract contains an uncapped indemnification clause, but the output reports 'No critical risks found'.

Golden dataset eval: Run the prompt on contracts with known injected risks. Measure recall (True Positives / (True Positives + False Negatives)). Target recall > 0.95 on critical categories.

Output Schema Compliance

The final output is valid JSON that strictly conforms to the [OUTPUT_SCHEMA], with all required fields present and correctly typed.

The model returns a markdown list instead of JSON, or the risk_findings array contains objects missing the required clause_citation field.

Automated schema validation: Parse the output with a JSON schema validator using the defined [OUTPUT_SCHEMA]. Fail the test on any validation errors.

Uncertainty Disclosure

When the model has low confidence in a finding or the evidence is ambiguous, the finding includes an uncertainty_flag: true and a confidence_rationale field.

A finding about a complex, ambiguous indemnification clause is presented with high certainty and no caveats.

Keyword and field check: Verify that any finding with a confidence score below the [CONFIDENCE_THRESHOLD] has uncertainty_flag: true and a non-empty confidence_rationale.

ADAPTATION OPTIONS

Adapt This Prompt

How to adapt

Start with the base prompt and a small set of 5–10 known contracts. Remove strict output schema requirements initially. Use a single model call with the retrieved clauses injected into [CONTEXT]. Focus on getting risk categories and severity ratings directionally correct before tightening format.

Simplify the prompt to:

  • Extract risks from [CONTEXT]
  • Rate severity as Low/Medium/High/Critical
  • Cite the specific clause text

Watch for

  • Over-flagging: the model marks standard clauses as high risk
  • Missing severity justification: ratings without supporting clause evidence
  • Format inconsistency across contract types (NDA vs. MSA vs. SaaS agreement)
  • No abstention when retrieved context is insufficient
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.