Tutorial · Claude Code · Legal

Build an agent that reads
your contract PDFs
and flags risky clauses.

A step-by-step tutorial. By the end, you drop a contract PDF into a folder and, in two minutes, you get back an analysis sheet that lists the 12 critical clauses, quotes the problematic passages, and gives you an overall risk score. Plan for 60 minutes of setup and about €20 a month.

14 min read 1h setup All levels
Jérémy Sagnier Jérémy Sagnier · I test AI every day · I share what actually helped me Published · Updated April 20, 2026
What you'll walk away with

The result, in 30 seconds

  • You drop a contract PDF into an inbox/ folder. The agent reads it, scans it for 12 critical clauses, and produces an analysis sheet in analyses/ in under two minutes.
  • The sheet gives you a risk score, quotes the problematic clauses with page numbers, and offers you the three points to negotiate before signing.
  • Estimated cost: about €1 of API usage (billed per request) per month for 4 contracts, plus €20 for Claude Pro. A mandatory legal disclaimer protects your liability.

Brand new to AI?

If some terms lose you (Claude Code, terminal, agent, MCP, skill…), start with the beginner's guide first and keep the glossary open in another tab. You'll come back here with the basics.

— Read this first

Before you start, a disclaimer.

This agent does not replace a lawyer. It's a first-pass filtering tool that helps you spot the points to dig into before you pay for a real legal consultation.

If you're signing a contract that commits more than €10,000 or sensitive intellectual property, always get it validated by a lawyer. The agent will save you prep time and won't miss the classic traps. It doesn't carry a lawyer's professional liability.

The subject falls under YMYL (Your Money Your Life): decisions with a heavy financial or legal impact. The analyses produced here are indicative — never personalized legal advice. For any high-stakes contract (partnership, M&A, fundraising, IP, exit), a lawyer is still mandatory — the agent preps the conversation, it doesn't replace it.

Every sheet the agent produces will include an explicit disclaimer. Keep that disclaimer — it protects you. No final decision should rest on the agent alone.

Official page for the Claude Legal plugin launched by Anthropic in February 2026
The official Claude Legal plugin launched by Anthropic in February 2026 — proof that the contract use case is now validated by the vendor
— What you'll need

The prerequisites before you start.

  • A Mac (the commands are similar on Linux, different on Windows).
  • A Claude Pro subscription at €20 a month, or a direct API account if you handle very sensitive contracts (see the security section).
  • A dedicated folder on your Mac to receive the contracts to analyze.
  • An hour of your time for the initial setup.
Official Anthropic documentation on Claude's support for PDF files
The official Anthropic docs on PDF support — Claude has read PDFs natively since late 2024
— Step 1

Step 1 — Install Claude Code.

If you haven't already, open Terminal and paste:

curl -fsSL https://claude.ai/install.sh | bash

Then run:

claude

Log in with your Claude.ai account. Type /exit to quit.

— Step 2

Step 2 — Create your project.

In Terminal, create the folder structure:

mkdir -p ~/contrats-agent/inbox
mkdir -p ~/contrats-agent/analyses
mkdir -p ~/contrats-agent/archives
mkdir -p ~/contrats-agent/.claude/commands
cd ~/contrats-agent
  • inbox/ receives the new contracts to analyze
  • analyses/ receives the analysis sheets the agent produces
  • archives/ stores the contracts already processed
— Step 3

Step 3 — Give the agent permission to read your folder.

So the agent can read the PDFs you drop into inbox/, you need to add a filesystem MCP (a small bridge that gives Claude controlled access to one specific folder on your Mac; see also the MCP spec). Paste this command:

claude mcp add filesystem npx @modelcontextprotocol/server-filesystem ~/contrats-agent

This command gives Claude Code permission to read and write in ~/contrats-agent, and only there. The agent can't access the rest of your Mac.

To check the MCP is active, launch Claude Code and type /mcp. You should see filesystem in the list.

— Step 4

Step 4 — Write the system prompt.

This is the most important part. The system prompt (the background instructions the agent keeps in mind on every exchange) frames everything else. Create a CLAUDE.md file at the root of ~/contrats-agent with exactly this content:

# Contract Reader Agent

## Role
You are a junior contract analyst. You assist a professional
in reviewing a contract before signing. You never replace
a lawyer: you do a methodical first-pass filter.

## Context
- Contracts received as PDFs in `inbox/`
- Analyses written in Markdown in `analyses/` (same name as the PDF)
- Processed contracts moved to `archives/`
- Default governing law: French
- If the contract is in English, flag it at the top of the sheet

## Method (mandatory)
1. Read the whole contract (if more than 20 pages, iterate by range)
2. Identify the parties, the subject, the term, the amounts
3. Scan the 12 critical clauses (list below)
4. For each clause found: quote the exact passage + page number + level (RED, ORANGE, YELLOW, or GREEN)
5. Spot the missing clauses that should exist (example: a GDPR clause in a contract handling personal data)
6. Produce the sheet in the format required below
7. Move the processed PDF to `archives/`

## The 12 critical clauses to scan
1. Liability and cap
2. Automatic renewal
3. Termination (notice, penalties)
4. Intellectual property
5. Non-compete and exclusivity
6. Confidentiality
7. Payment (terms, penalties)
8. Unilateral modification
9. Jurisdiction and governing law
10. SLA and warranties
11. GDPR and processing
12. Force majeure

## Limits
- Never definitive legal advice
- Always quote the exact passage + page number
- If ambiguous, say "to be confirmed by a lawyer"
- Do not invent case law or article numbers
- If the PDF is unreadable, ask for a better version

## Output format
# Analysis sheet — [name of the PDF]
**Analysis date**: YYYY-MM-DD | **Pages**: X | **Overall score**: 🔴/🟠/🟡/🟢 X/10

## Summary
- Parties: ...
- Subject: ...
- Amount: ...
- Signing planned: ...

## Critical red flags (🔴 negotiate before signing)
[Numbered list with quote + page + level]

## Orange flags (🟠 to clarify)

## Yellow points (🟡)

## Missing clauses to request
[e.g., GDPR clause missing, force majeure absent]

## Recommendation
[Clear verdict]

---
⚠️ Analysis generated by an AI for informational purposes only.
It does not constitute legal advice. For any contract committing
more than €10,000, consult a lawyer.
— Step 5

Step 5 — Create your slash command.

Create the file .claude/commands/analyze.md — the slash command (a custom shortcut like /my-command) — with:

---
description: Analyze a contract PDF
arguments:
  - name: file
    description: Name of the PDF in inbox/
---
Run the analysis of the contract `inbox/$file`.

Follow the method defined in CLAUDE.md:
1. Read the whole PDF.
2. Scan the 12 critical clauses.
3. Produce the sheet in the required format.
4. Write the sheet to `analyses/$file.md`.
5. Move the PDF from `inbox/` to `archives/`.

Don't ask any questions. Execute, then display a summary.

You can now run the analysis of a contract by typing /analyze my-contract.pdf.

— Step 6

Step 6 — First test.

Download a sample contract to test with. If you don't have one handy, grab a public NDA template from lawinsider.com and save it to inbox/nda-test.pdf.

In Terminal, run:

cd ~/contrats-agent
claude

Then:

/analyze nda-test.pdf

The agent reads the PDF (thirty seconds to two minutes depending on length), produces the sheet in analyses/nda-test.pdf.md, and moves the PDF into archives/.

What you should get in the sheet:

# Analysis sheet — nda-test.pdf
**Date**: 2026-04-20 | **Pages**: 5 | **Overall score**: 🟠 7/10

## Summary
- Parties: Disclosing Party (Client) ↔ Receiving Party (you)
- Subject: Protection of confidential information
- Term: 3 years post-contract

## Critical red flags (🔴)
1. **Art. 4 — Perpetual confidentiality** (p.2)
   > "The confidentiality obligations shall survive indefinitely."
   Term too long, out of line with standard practice in France.

## Orange flags (🟠)
2. **Art. 6 — Jurisdiction** (p.4)
   > "This Agreement shall be governed by the laws of Delaware."
   Foreign forum, costly in the event of a dispute.

## Missing clauses to request
- No GDPR clause even though personal data may be shared.

## Recommendation
🟠 To clarify before signing. Ask to limit the confidentiality
term to 5 years and to specify French law.
— Step 7

Step 7 — Automate on file drop.

So the agent automatically analyzes any PDF dropped into inbox/, we use a Claude Code hook (an automatic trigger that runs a command when a specific event happens) that watches for file changes.

Create the file .claude/settings.json with:

{
  "hooks": {
    "FileChanged": [
      {
        "matcher": "inbox/*.pdf",
        "command": "claude -p '/analyze $(basename $CLAUDE_CHANGED_FILE)' --output-format json >> analyses/log.jsonl"
      }
    ]
  }
}

From now on, every time you drop a PDF into inbox/ (from Finder, for example), the agent triggers itself. You'll find the analysis sheet in analyses/ within a few minutes.

— Security

The security of contract data.

Contracts contain sensitive data. Before you throw them at the Claude API, check these three points.

Which Claude plan to use?

  • Claude Pro (€20/month): since August 2025, your conversations are no longer used to train the models unless you've opted in or you're on the old consent model. Retention: 5 years by default. Acceptable for standard contracts of an independent consultant, not for a law firm.
  • Claude for Work / Enterprise: zero training by default, with an optional Zero Data Retention (ZDR) — Anthropic stores nothing after processing. Mandatory for law firms, legal departments, sensitive M&A deals. The DPA (Data Processing Agreement) is available on request for Pro / Team / Enterprise accounts.
  • Direct Claude API (pay-as-you-go, billed per usage): no training by default, ZDR available on request.

Do you need to anonymize before sending?

For very sensitive contracts, a 20-line Python script replaces the parties' names, company registration numbers, and IBANs with placeholders (neutral markers like [CLIENT_1] that stand in for the real values) before sending to the agent. You then get the sheet back and swap the placeholders back in on the human side. It's not necessary for standard NDAs (non-disclosure agreements, standard B2B).

GDPR

If you analyze your clients' contracts on their behalf, you become a processor in the sense of Article 28 of the GDPR. You have to sign a data-processing agreement with your clients that frames this use. See also France's CNIL guidance on AI and the GDPR for the full framework.

— What to watch out for

The three pitfalls to avoid.

Pitfall 1 — Poor-quality scanned PDFs.

If the PDF is a blurry scan or a photo taken on your phone, Claude can hallucinate (the technical term for generating plausible but false content — here, inventing clauses that don't exist). Simple rule: if the sheet contains clauses with no page number, or whose quote looks odd, ask for a text version of the contract or have it re-scanned at good quality.

Pitfall 2 — Contracts over 100 pages.

Claude Code reads up to 20 pages per call (because of the context window — the maximum amount of text the model can read at once). On a 100-page contract, you have to iterate by range. The simplest approach: split the PDF into sections (main contract, technical appendices, pricing appendices) and run /analyze on each section.

Pitfall 3 — Trusting the agent 100%.

The agent is reliable at spotting the classic clauses. It can miss the subtleties specific to your sector. Always re-read the sheet, open the PDF on the human side for the flagged clauses, and consult a lawyer for any significant commitment.

— The numbers

What it actually costs.

Plausible scenario: an independent consultant who signs 4 contracts a month, each about 20 pages.

Luminance's website, a leading LegalTech platform for contract analysis
Luminance, one of the LegalTech leaders — for comparison, their offering starts at several thousand euros a month
Ironclad's website, a mainstream CLM platform for managing the contract lifecycle
Ironclad, mainstream CLM — enterprise, pricing on quote
Spellbook's website, a legal-AI Word add-in for lawyers
Spellbook, a Word add-in for lawyers — a direct competitor at $99 a month
Before the agent After the agent
Time per contract 1 hr 30 of careful reading 2 min agent + 20 min human review
Monthly total (4 contracts) 6 hrs 1 hr 30
Time saved 4 hrs 30 a month
Financial equivalent (€100/hr) €450 a month
Monthly API cost ~$1.5
Monthly Claude Pro cost €20

The math tips in your favor by the second contract of the month.

— To go further

Variants by contract type (replace the base prompt).

If you mostly handle freelance contracts, add this focus to the system prompt:

Freelance-specific focus:
- Daily rate or fixed fee clearly defined?
- Intellectual property of the deliverables (background IP protected?)
- Abusive exclusivity clause (outside the client's sector)
- Payment term (French LME law: 60 days maximum in France)
- Non-compete with financial consideration (otherwise unenforceable)

If you handle SaaS contracts, focus on:

SaaS-specific focus (software online by subscription):
- Quantified SLA (Service Level Agreement, a quality commitment: uptime %, support response time)
- Data storage (EU or US? subprocessors listed?)
- Exit terms: export format, timeline, cost after termination
- DPA attached (Data Processing Agreement, GDPR Art. 28)
- Liability cap (cap = X months of subscription)

If you handle commercial leases:

Commercial-lease-specific focus (France):
- Term: 3/6/9 or uncapped?
- Charges: who bears the property tax?
- Rent indexation: ILC or ILAT index?
- Permitted use of the premises (authorized activity)
- Termination clause (grace period?)
— Over to you

And you, what contracts do you handle?

If you've installed the agent, three questions to calibrate the next version of the tutorial:

  1. What types of contracts do you mostly handle?
  2. Which clause did the agent miss at the start?
  3. Did you tweak the prompt after a week of use?

Reply to this email with your situation. I read everything, I reply.

I can be wrong. This agent evolves with the versions of Claude Code and the model's PDF capabilities. If a command stops working, write to me.

Want more Claude Code agent tutorials? The agent that sorts your Gmail inbox tutorial (same mechanics, less sensitive data), the Hermes Agent step by step (more advanced, multi-tool), and the general guide to AI agents for the mental framework.

— FAQ

Contract agent FAQ.

My contracts are confidential — do I need a local LLM?

Not necessarily. For standard freelance or SaaS contracts, the Anthropic API or Claude Pro are enough (no training by default). For M&A deals, a law firm's client contracts, or highly sensitive material, you'll want Claude for Work / Enterprise with ZDR, or a local model (Mistral 7B via Ollama).

What are ZDR and the DPA at Anthropic?

ZDR (Zero Data Retention) guarantees that Anthropic stores no data you send once it's processed — not even 30 days for compliance. The DPA (Data Processing Agreement) is the data-processing contract in the GDPR sense: it frames Anthropic's obligations. The DPA is available on Pro / Team / Enterprise on request; ZDR is included with Enterprise.

How many contract pages can the agent analyze at once?

Comfortably up to 20 pages in a single pass (the context-window limit to stay accurate). Beyond that, up to 100 pages by splitting into several passes by section (preamble, pricing, term, technical clauses, appendices). Above 100 pages, you're better off with a dedicated tool like Luminance or Spellbook, or doing summarized pre-analysis before the overall analysis.

What format do Claude Code hooks use?

Claude Code hooks are defined in .claude/settings.json with a { event, matcher, command } structure. For this agent we use a hook that triggers /analyze when a PDF is added to inbox/. The matcher accepts glob patterns; the possible events are PreToolUse, PostToolUse, UserPromptSubmit, Stop.

Legal YMYL use cases: can you do without a lawyer?

No, and the agent doesn't claim otherwise. It saves 80% of your pre-reading time by pulling out the 12 critical clauses, the risk score, and the areas to dig into. For signing high-stakes contracts (partnership, M&A, fundraising, IP, exit), a lawyer is still mandatory — the agent preps the conversation, it doesn't replace it. YMYL cases (health, finance, law) = a non-negotiable human safety net.

Can the agent rewrite or negotiate the clauses?

No, this tutorial stays read-only: analysis + sheet + risk score. To generate counter-proposals, you'd need a different system prompt (drafting) and cross-reference several reference templates (lawinsider.com). The risk otherwise: the agent invents wording that looks right but opens a loophole. Better to keep analysis and drafting separate.

Does it work with Word .docx files?

Claude's native support covers PDFs (since late 2024). For Word, two options: convert the .docx to PDF before dropping it into inbox/, or add an MCP that can read .docx files (for example an unstructured-io MCP, or a pandoc docx → md script as pre-processing). PDF remains the most reliable format for preserving a contract's layout.

GDPR: what do I do if I process my clients' contracts?

You become a processor in the sense of Article 28 of the GDPR toward your clients. You have to sign a data-processing agreement with them that explicitly mentions the use of the Anthropic LLM, the confidentiality guarantees, the retention period, and the processing location. On Anthropic's side, enable the DPA and ideally ZDR. See also France's CNIL guidance on AI and the GDPR.

How much does it cost per month and what's included?

Budget €20 for Claude Pro (interface + Claude Code on the subscription) + ~$1.5/month of API from Anthropic for 4 contracts analyzed/month on top. That's ~€21.5/month, versus $99/month for Spellbook or several thousand euros for Luminance / Ironclad. Price can be verified on Anthropic's official pricing page.

Difference from Spellbook, Luminance, or Ironclad?

Spellbook ($99/month) targets lawyers with a Word add-in to draft and negotiate in the flow. Luminance and Ironclad are enterprise CLM platforms (several thousand euros/month) that cover the whole contract lifecycle — multi-user, audit trail, CRM integrations. The DIY agent targets the freelancer / solo entrepreneur: €21/month, prompt under your control, no seat fee — in exchange, no guided drafting, no team workflow, no built-in e-signature.

Spot an error?

Outdated info, a number that's moved, a stale source? Write to me at sagnier.jeremy@gmail.com · I fix it within 48h max and note the update date at the top of the article. Field feedback is worth a thousand times more than the articles — I read everything, I reply.

Jérémy Sagnier
Thanks for reading this far 👋

Shall we keep going?

I test AI for real and share what works, with no jargon and no hype. If this article helped you, the easiest way to never miss anything is my Friday letter. And if you've got a question or a doubt: reply to me, I read everything.

Get the newsletter → Read more articles