agentleFS
rhain-rrhain-r/legal-due-diligence-orchestrator/CLAUDE.md

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
  1. Very specific:

    No agent framework. agent/llm.py defines a one-method ModelClient protocol.

    line 77
  2. Very specific:

    If uv sync fails with a Python minor-version link error on Windows, pass the interpreter explicitly — see docs/setup-guide.md § …

    line 91
  3. Distinctive:

    Test the rejection paths, not just the happy path.

    line 102
  4. Very specific:

    No new hardcoded model names outside config.py.

    line 110
  5. Distinctive:

    No new top-level directory.

    line 111
  6. Distinctive:

    If agent behavior changed, say so explicitly in the PR body.

    line 112
  7. Very specific:

    Ask rather than guess on: compliance rule semantics, what counts as a "materially equivalent" clause, and any change to the Finding or …

    line 116

≈ “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.

Keep what fits and drop the rest. Your version, ready for your agents.
Files
CLAUDE.md

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

  1. No finding without a citation. PRESENT and NON_COMPLIANT require at least one verified Citation. MISSING requires SearchEvidence and must carry zero citations. Enforced by validators in agent/schemas.py — do not weaken them.
  2. 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.
  3. 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.
  4. A verifier failure is never agreement. Errors return needs_human.
  5. Never commit client documents. *.pdf is git-ignored except for synthetic fixtures we authored ourselves.
  6. Determinism where possible. Ingestion, citation checking, retrieval, and scoring are plain Python and unit-testable. Only reasoning goes to a model.
  7. 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

ConcernChoice
Python3.12 pinned via uv (requires-python >=3.10,<3.14)
ReasoningAnthropic Claude — planner and workers
VerificationGoogle Gemini — different lab on purpose
PDF parsingpypdf (not the abandoned PyPDF2)
ValidationPydantic v2, extra="forbid"
CLITyper + Rich
Test / lintpytest (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 --verbose

If 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 annotations at the top of every module. Type hints on every public function.
  • System prompts live in agent/prompts/*.md, loaded via config.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 pytest passes 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.

Download now (ZIP)

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
What did you use it for? e.g. Reviewing pull requests in a Rails app

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.