AI Contract Review Agents: A Developer's Guide
Build contract review tooling that extracts clauses, checks them against a playbook, cites the contract text and leaves every decision to a lawyer.
Contract review is mostly a search problem with judgment at the end: find the clauses that matter, compare each one with what your side is willing to accept, and propose changes. Software can do much of the finding and comparing. The judgment, and the signature, belong to a lawyer. This guide shows how to build the first part so that the second part is easy to do well.
An earlier version of this post promised a dramatic cut in review time, quoted an analyst who could not be traced, and named tools we could not verify. All of that has been removed. Nothing here is legal advice.
What the agent does and what it never does
| Step | Software can | A lawyer owns |
|---|---|---|
| Clause extraction | Find clause types and copy their exact text into a fixed schema | Spot-checking extractions, especially “not found” results |
| Playbook check | Apply the team’s written positions as explicit rules | Writing and updating the playbook |
| Citations | Point each finding back to the exact contract text | Reading the cited text in context |
| Redlines | Draft suggested changes from approved fallback language | Accepting, editing or rejecting every change |
| Signing and sending | Nothing | Everything |
The last row is not a technicality. North Carolina’s 2024 Formal Ethics Opinion 1 says that a lawyer who uses AI on a client matter is “fully responsible for the use and impact of AI” in that case. Design the tool so a person has to act before anything leaves the building. Our piece on designing human-AI collaboration covers approval and handoff patterns in more depth.
Step 1: extract clauses into a schema
Start with extraction, because every later step depends on it. Ask for a small, flat set of clause types and require the model to copy the clause text verbatim. Anthropic’s structured outputs feature constrains Claude’s reply to a JSON schema; in Python you pass a Pydantic model to client.messages.parse() and read parsed_output. This example is adapted from the official documentation:
from anthropic import Anthropic
from pydantic import BaseModel
class Clause(BaseModel):
clause_type: str # one of the types named in the prompt
section: str # e.g. "12.2"
quote: str # exact text copied from the contract
summary: str
class Extraction(BaseModel):
clauses: list[Clause]
client = Anthropic()
contract = open("msa.txt").read()
response = client.messages.parse(
model="claude-opus-5-5",
max_tokens=4096,
messages=[{"role": "user", "content":
"Find these clause types: governing_law, limitation_of_liability, "
"auto_renewal, assignment, termination. For each one present, copy "
"the clause text exactly into quote. Omit types that are absent.\n\n"
+ contract}],
output_format=Extraction,
)
if response.stop_reason in ("refusal", "max_tokens"):
raise RuntimeError("Send this contract to manual review")
clauses = response.parsed_output.clauses
Three details from the documentation matter here. A refusal (stop_reason: "refusal") or a reply cut off at the token limit ("max_tokens") may not match the schema, so treat both as “a person looks at this one”. Enum values are not guaranteed to keep their exact capitalisation, which is why this example uses plain strings and normalises them in code. And schemas have complexity limits, including a cap on optional fields per request, so keep the model flat and mark fields required. For background on how schemas work in tool calls, see function calling vs tool use.
Step 2: tie every finding back to the text
A summary that cannot be traced to the contract is not useful to a reviewer. There are two practical ways to get traceability.
Verify the quotes yourself. Because the schema asks for the exact clause text, your code can confirm each quote really appears in the document and flag any that don’t:
def norm(s):
return " ".join(s.split()).lower()
body = norm(contract)
unverified = [c for c in clauses if norm(c.quote) not in body]
Anything in unverified is either paraphrased or invented, and goes to a person.
Use the Citations API. With citations enabled on a document, Claude’s answer comes back with pointers into the source: character ranges for plain text, page ranges for PDFs. Anthropic says these are guaranteed to be “valid pointers to the provided documents”, and the quoted cited_text doesn’t count toward output tokens. The catch: citations and structured outputs can’t be combined, and the API rejects such a request with a 400 error. The docs suggest asking for one “field: value” line per item and parsing those lines in your own code, so each value keeps its own citations. They also warn that a prompt demanding JSON only can leave you with few or no citations.
Step 3: write the playbook as explicit rules
A playbook is your side’s position on each clause: what is acceptable, what to push back on, and what fallback wording is approved. Keep it as data the legal team can read and edit, not as instructions buried in a prompt. Deterministic checks are easy to test and easy to explain:
PLAYBOOK = {
"governing_law": {"required": True, "allowed": ["new york", "delaware"]},
"limitation_of_liability": {"required": True},
"auto_renewal": {"required": False, "strike": True},
}
def check(clauses):
found = {c.clause_type.strip().lower(): c for c in clauses}
issues = []
for ctype, rule in PLAYBOOK.items():
c = found.get(ctype)
if c is None and rule["required"]:
issues.append((ctype, "missing", None))
elif c and rule.get("strike"):
issues.append((ctype, "playbook says strike", c.quote))
elif c and "allowed" in rule and not any(a in c.quote.lower() for a in rule["allowed"]):
issues.append((ctype, "not an approved option", c.quote))
return issues
Substring matching is deliberately crude. Where a rule needs reading comprehension (is this liability cap mutual?), ask the model a narrow yes/no question about one quoted clause and record its answer next to the rule ID, so the reviewer can see which rule fired and why.
Step 4: suggest redlines, don’t apply them
For each issue, draft a change using the playbook’s approved fallback text rather than free-form wording, and attach the rule ID and the cited original. Put suggestions into tracked changes or comments in the lawyer’s editor. Never accept changes automatically, send anything to the counterparty, or trigger signature. Keep a log of what the model saw and proposed; the DC Bar’s Opinion 388 reminds lawyers to think about their obligations regarding the client file when AI is involved.
Evaluate on CUAD before real contracts
The Contract Understanding Atticus Dataset (CUAD) is the standard public benchmark for this task. It contains more than 13,000 labels in 510 commercial contracts, marked under the supervision of experienced lawyers across 41 clause types, and the Atticus Project publishes it under CC BY 4.0. The paper on arXiv frames the job as highlighting the parts of a contract a human should review, and its authors found Transformer models showed “nascent performance” with “substantial room for improvement” at the time. The official repository includes code and fine-tuned RoBERTa and DeBERTa checkpoints.
Measure recall per clause type first: a missed indemnity clause hurts more than an extra highlight. Then build a smaller test set from your own contract templates, scored by your lawyers. Our guide to LLM evaluation metrics explains how to set up exact-match and judged evals.
Confidentiality and vendor terms
Contracts are client confidential information, so the vendor’s data terms are part of your design. Check them on the vendor’s own pages, not in a sales deck. For Anthropic’s commercial products, the Commercial Terms say customers keep rights to their inputs and own their outputs, and that Anthropic “may not train models on Customer Content from Services.” The privacy center adds that feedback sent through the thumbs buttons can be used for training, and that organisation owners on Team or Enterprise plans can switch that button off. Consumer plans fall under separate terms.
The North Carolina opinion lists questions to ask any provider, drawn from earlier guidance: does the contract say how confidential information is handled and secured, and how data is returned or destroyed if the service ends? The DC opinion adds two of its own: can the provider or other outsiders see what you submit, and could your inputs shape answers given to later users? It warns that anonymising inputs is weaker protection than it looks. More on securing AI systems sits in our security and privacy hub.
Professional responsibility in brief
Both opinions treat AI much like a nonlawyer assistant: allowed, but supervised. North Carolina concludes a lawyer may use AI if it is used competently, securely and with proper supervision, and may share client documents with a third-party AI program only after being satisfied it is secure enough. It adds that handing substantive work to an AI tool can require the client’s advance informed consent. The DC opinion ties use to the duties of competence, confidentiality, candour and supervision, says lawyers billing by the hour can only bill time actually spent, and expects lawyers to review and validate output before relying on it. Check the rules and opinions where you practise.
Commercial tools, in their own words
If you would rather buy than build, vendors cover the same ground. Spellbook says it can “Surgically redline contracts”, turn a team’s standards into checklists enforced on every review, and that zero data retention means its model providers do not train on or store your data. Harvey lists AI contract review and negotiation among its products. These are the vendors’ descriptions of their own products, not results we have tested.
Honest limits
Extraction quality varies by clause type and drafting style, and a model can miss a clause entirely, which no quote check will catch. Playbooks go stale. Ethics guidance differs by jurisdiction and keeps changing; the two opinions here are examples, not a survey.
Written by AI Agents Directory
Editorial team
Facts in this guide are checked against official documentation and repositories, which are linked in the article.