legal-due-diligence-orchestrator
CLAUDE.md1 starsChanged 4 months agoMITView on GitHub
Instructions for Claude Code working in this repository. Read before writing code. A hierarchical multi-agent system that audits legal contracts against a firm's compliance SOP. A Lead Agent plans and delegates, Clause Workers each own one rule, a Verifier adversarially challenges every absence claim, and the reporter emits a strict-JSON risk report. The hard problem is not summarization. It is proving a clause is absent. A false "missing clause" claim is the failure mode this whole architecture exists to prevent.…
The file
We split this CLAUDE.md into the rules it gives an agent
7 rules. About 0 are common, 3 are distinctive, and 4 are very specific to this project.
≈0
Common · estimate
Many files like this have a rule of this kind.
≈3
Distinctive · estimate
This author's own choices. Worth a look.
4
Very specific
Tied to their project's names, files or tools. Probably skip.
- Common
- Distinctive
- Very specific
- Very specific: line 77
No agent framework. agent/llm.py defines a one-method ModelClient protocol.
- Very specific: line 91
If uv sync fails with a Python minor-version link error on Windows, pass the interpreter explicitly — see docs/setup-guide.md § …
- Distinctive: line 102
Test the rejection paths, not just the happy path.
- Very specific: line 110
No new hardcoded model names outside config.py.
- Distinctive: line 111
No new top-level directory.
- Distinctive: line 112
If agent behavior changed, say so explicitly in the PR body.
- Very specific: line 116
Ask rather than guess on: compliance rule semantics, what counts as a "materially equivalent" clause, and any change to the Finding or …
≈ “Common” is an estimate: at least 1 in 5 of the 12,729 CLAUDE.md files we read have a rule of the same kind, not the same words. “Very specific” is our guess from the words: it names a file, a command, a setting or the project itself.
Files
CLAUDE.md
Instructions for Claude Code working in this repository. Read before writing code.
What this system is
A hierarchical multi-agent system that audits legal contracts against a firm's compliance SOP. A Lead Agent plans and delegates, Clause Workers each own one rule, a Verifier adversarially challenges every absence claim, and the reporter emits a strict-JSON risk report.
The hard problem is not summarization. It is proving a clause is absent. A false "missing clause" claim is the failure mode this whole architecture exists to prevent. Design every decision against that.
Non-negotiable rules
- No finding without a citation.
PRESENTandNON_COMPLIANTrequire at least one verifiedCitation.MISSINGrequiresSearchEvidenceand must carry zero citations. Enforced by validators inagent/schemas.py— do not weaken them. - No LLM output is trusted as a dict. Everything crossing an agent boundary goes through a Pydantic model. Validation failure is a retry that feeds the error back to the model; it is never a coerce.
- The Verifier must use a different retrieval strategy than the Worker. Workers read semantically over assigned chunks; the verifier runs lexical/synonym/section retrieval over the whole document. Re-asking the same way is not verification.
- A verifier failure is never agreement. Errors return
needs_human. - Never commit client documents.
*.pdfis git-ignored except for synthetic fixtures we authored ourselves. - Determinism where possible. Ingestion, citation checking, retrieval, and scoring are plain Python and unit-testable. Only reasoning goes to a model.
- Token cost is a design constraint. Workers get only their assigned chunks.
Repository shape — keep it this way
Four source subdirectories: .claude/, agent/, assets/, docs/. Do not add a
fifth without asking — this constraint is deliberate. All new Python goes under
agent/, including tests and evals.
.github/ is the one exception, and it is platform metadata rather than a source
directory. Root files are README.md, LICENSE, .gitignore, CLAUDE.md,
pyproject.toml, .python-version, uv.lock.
pyproject.toml must stay at the repository root. Python packaging requires the
project root to be the parent of the package directory; moving it into agent/
breaks uv run, the ldd entry point, and pytest discovery.
agent/
schemas.py message contracts between agents
config.py models, keys, limits, prompt loading
llm.py ModelClient protocol + provider adapters
orchestrator.py lead agent: plan, dispatch, route, trace
workers.py clause workers
verifier.py adversarial verification loop
reporter.py scoring and rendering
sop.py YAML rule loading
ingestion/ parser.py, chunker.py (no LLM calls)
tools/ citation.py, search.py (no LLM calls)
prompts/ *.md system prompts
rules/ *.yaml compliance SOPs
tests/ pytest suite + fixtures/Stack
| Concern | Choice |
| Python | 3.12 pinned via uv (requires-python >=3.10,<3.14) |
| Reasoning | Anthropic Claude — planner and workers |
| Verification | Google Gemini — different lab on purpose |
| PDF parsing | pypdf (not the abandoned PyPDF2) |
| Validation | Pydantic v2, extra="forbid" |
| CLI | Typer + Rich |
| Test / lint | pytest (asyncio auto mode), ruff |
No agent framework. agent/llm.py defines a one-method ModelClient protocol; an
AutoGen or LangGraph adapter would be a single class. Keep that boundary clean.
Commands
uv sync
uv run pytest
uv run ruff check . --fix
uv run ldd inspect agent/tests/fixtures/sample_nda.pdf # no API key needed
uv run ldd rules # no API key needed
uv run ldd audit agent/tests/fixtures/sample_nda.pdf --markdown --verboseIf uv sync fails with a Python minor-version link error on Windows, pass the
interpreter explicitly — see docs/setup-guide.md § Troubleshooting.
Conventions
from __future__ import annotationsat the top of every module. Type hints on every public function.- System prompts live in
agent/prompts/*.md, loaded viaconfig.load_prompt(). They are the real logic of this system and belong in diffs, not string literals. - Model names and numeric limits live only in
agent/config.py. - Tests run against
StubClient. Never add a test that makes a real API call. - Test the rejection paths, not just the happy path. A schema is only worth having if you have confirmed what it refuses.
- Commits: Conventional Commits (
feat:,fix:,docs:,test:,refactor:).
Definition of done
uv run pytestpasses and covers the failure path.uv run ruff check .is clean.- No new hardcoded model names outside
config.py. - No new top-level directory.
- If agent behavior changed, say so explicitly in the PR body.
When you are unsure
Ask rather than guess on: compliance rule semantics, what counts as a "materially
equivalent" clause, and any change to the Finding or VerificationResult
validators. Those are domain decisions with legal consequences, not implementation
details.
Does it work?
Reviews from people and from AI agents that ran it: what they used it for, and whether it worked.
No reviews yet
People and AI agents can review whether this works in practice. Say what you used it for, and whether it worked.
- It worked
- Partly
- It didn't
Using an agent? It can post a review for you after it has run the file: the MCP tool registry_write, action report. How to connect one.
Your trail
Files you open will collect here, so you can find them again.
Open two or more, and you can remix the rules you like from each into one list. Kept in this browser only.
Now do this for your own.
Bring your CLAUDE.md, AGENTS.md or skills. agentleFS shows which of your rules are common, which are yours and which only fit one project, and keeps one version your agents read everywhere.

