claude-md-doctor
Give your CLAUDE.md — or AGENTS.md — a checkup.
Vitals, lab work, diagnoses, prescriptions — and a backtest of every rule
against your own session history.
No CLAUDE.md yet? The doctor mines your sessions and drafts one — every
line with receipts.
Linters check the file. Analytics grade your sessions. The doctor
cross-examines one against the other — and cites receipts.
Quickstart
As a Claude Code plugin (recommended):
/plugin marketplace add agent-clinic/claude-md-doctor
then install claude-md-doctor from the /plugin menu. Or via the
skills.sh CLI:
npx skills add agent-clinic/claude-md-doctor
Or bare: copy skills/claude-md-doctor/ into ~/.claude/skills/.
Then, in any repo, just ask — "give my CLAUDE.md a checkup" — or invoke
directly: /claude-md-doctor:claude-md-doctor (bare install:
/claude-md-doctor). The report lands in .claude-md-doctor/report.html
plus machine-readable report.json.
Requires Python 3.9+ (standard library only). Everything runs locally;
nothing leaves your machine.
What the exam covers
- Vitals — effective size vs the official guidance ("target under 200
lines per CLAUDE.md file" — Claude Code memory docs),
estimated token cost per session, structure, and pathology markers: stock
/init boilerplate never pruned, emphasis saturation, changelog accretion.
- Records check — does everything the file points at exist? Dead file
paths, paths from a teammate's machine,
@imports that don't resolve,
pnpm/make commands with no matching script, .claude/rules/ scopes
that match zero files.
- Checkable claims — countable assertions ("2,100 tests across 180
files", "9 UI components; no dialog") verified against the repo. Inlined
numbers rot; the doctor catches them.
- The report — a single self-contained HTML page: chart grade, chief
complaint, per-finding evidence, the session-adherence History table, and
concrete prescriptions, each footnoted with the official doc or study
behind it (the evidence base lives in docs/RESEARCH.md).
It understands the real memory surface: CLAUDE.md, .claude/CLAUDE.md,
CLAUDE.local.md, nested files, .claude/rules/*.md (with paths: scopes),
@imports (depth 4, backtick-aware), claudeMdExcludes, ancestor
directories — and it treats the pointer-to-AGENTS.md pattern as healthy,
examining the target, while flagging the broken variant (pointer text without
@, which Claude Code never actually loads). A repo with an AGENTS.md but no
CLAUDE.md at all gets the doctor's simplest prescription: the official
one-line pointer, so Claude Code stops loading nothing.
The backtest — check if CLAUDE.md actually works in your sessions
Your own Claude Code session transcripts (~/.claude/projects/…) already
record whether past sessions actually followed each rule in your CLAUDE.md.
The doctor decomposes the file into rules and replays them against that
history — per rule, a verdict with receipts:
| Rule | Opportunities | Compliance | Verdict |
|---|
| Never import the legacy API types | 12 | 100% | healthy |
Run verify before you finish | 2 | 0% | ignored |
| Never hardcode a colour | 0 | — | inert |
Behind every number: matched excerpts, and for finish-ordering rules a
session-timeline strip showing exactly what ran after the last edit.
Two ideas drive the verdicts (full taxonomy). Every rule
gets an enforcement class — the cheapest reliable detector:
| Class | Detector | Binds |
|---|
hook | gate over tool calls (commands, edits, orderings) — prevents | the agent |
linter/test | static analysis over the code itself | every agent and every human |
judge | LLM audit, post-hoc, with a stated reliability ceiling | audit only |
~70% of real-world directives land in the first two — laws waiting to be
passed. And every violation is triaged by cause, because the cause picks
the medicine: