/codebase-health:audit [scope] [--fix] [--medium <value>] [--docs-only|--code-only|--config-only|--arch-only]from codebase-health
Audits a codebase for drift between docs, config, code, and architecture. Verifies factual claims via parallel subagent fan-out, severity-rates findings, and reports read-only. Supports --fix to delegate remediation to implementation/verification lanes.
Ships in codebase-health. Installing the plugin adds it to Claude Code.
What the skill costs in Claude's context, stage by stage
Name and description: Claude knows it exists.
SKILL.md joins the conversation and stays.
Read when SKILL.md points to them.
Collect these with individual Bash calls, one command per call, never combined into a single invocation:
git branch --show-currentgit status --porcelain | head -20git diff --name-only HEADThe pipe is the bound and belongs in the command. A read-time cap ("read only the first 20 entries") bounds nothing: the cap applies only after the command's output has come back. What a large output returns is in Output limits.
Treat a failure (not a repository, git unavailable) as an unknown value and carry on. Keep these as separate body Bash calls rather than pre-compute lines (gather-block convention, "The pre-compute block runs as one shell invocation").
Pointer for how injected commands run: How injected commands run.
Arguments: $ARGUMENTS
Parse $ARGUMENTS for:
--fix: after reporting, hand the findings off to the remediation lanes
(/implementation:implement then /verification:confirm) rather than fixing inline. See
Remediation. Per the naming doctrine's verb
contract, bare audit is READ-ONLY. It reports at Phase 3 and stops; remediation intent sits
behind this explicit override. (--review-only is also accepted and means the bare read-only
default.)--medium <value>: governs only the offer of a rendered view
(Rendered view).--docs-only: only documentation checks--code-only: only code-quality checks--config-only: only configuration checks--arch-only: only architecture checksIf no filter is specified, audit every active dimension, the Phase 1 per-file fan-out makes
dimension order irrelevant (each file gets its own subagent). Enumerate primary-sources across all
active dimensions and dispatch per file.
The audit itself (Phases 0–3) is self-contained. Phase 2 names an adjacent capability,
documentation-research tools (MCP docs servers, library-docs lookers-up, web search). Having one is
optional; using one when your setup provides it is not, per Phase 2's external-research step. With no
such tool, follow the inline graceful-degrade guidance, which confidence-tags the
externally-unverifiable part needs-review rather than guessing.
This skill verifies factual claims in a repo's docs, config, code, and architecture notes against the repo's actual state. Seven adjacent lanes each own a different kind of drift, and this skill owns none of them.
This table is a router for the operator, not a dispatch list for this skill. Bare audit is
READ-ONLY, and some of these lanes mutate: /discipline:recheck-against-upstream says to "Correct
each forward now: fix gaps toward upstream", and others carry a fix mode. Invoking one from inside a
read-only run would let this skill edit the repo through a sibling, which its own verb contract
forbids. So a request that belongs to another lane is reported as uncovered, and that lane is
named as the next thing the operator can run rather than invoked here. Name the lane whether or
not its plugin is installed, and never assert that an absent one is available. --fix authorizes
remediation of this skill's own findings only; it does not extend to running a sibling's.
Each row states its own invocation form, since one row is an agent and the rest are skills.
| The drift is about | Owner |
|---|---|
| Whether a page deserves to exist: derivable from the code it describes, aspirational, or redundant. Also doc freshness scoped to a change under review | the review plugin's doc-drift-detector agent, so invoke it with the Agent tool as @review:doc-drift-detector, or run /review:fanout run-everything. Name that mode: fanout's default lifecycle-tiered mode never dispatches this agent, only run-everything does, so an unqualified /review:fanout can finish without ever reaching the owner. The dispatch rule is the question asked, not the scope swept: whether a page should exist is the agent's, it runs a derivability admission gate this skill has no equivalent of; whether a page's claims are TRUE is always this skill's, repo-wide included. --docs-only is this skill's own exhaustive claim pass and never routes out |
| A session's own working assumptions: base-branch movement, a stale handoff, a referenced PR, issue, or branch whose state has since changed | /session-flow:reanchor |
| Whether the surface in flight still matches the CURRENT official upstream docs | /discipline:recheck-against-upstream |
| Prose restating an external source with no pointer, and verification stamps past their expiry window | /attribution:audit |
Claude Code's own configuration and instruction surfaces: settings.json, .mcp.json, hooks, permissions, environment variables, and the text of CLAUDE.md, AGENTS.md, and .claude/rules/ judged against current model capability or against how Claude Code actually behaves | /harness-config:audit, with /harness-config:audit-automation-gaps for automation-landscape gaps and /harness-config:audit-instructions for instruction-surface drift. Phase 0 reads those instruction files here too, but only as the convention lens: a claim they make about this repo is this skill's to verify, a claim they make about the harness or a prescription aimed at the model is not |
| What moved in the instruction-placement findings since the last placement audit | /instruction-placement:delta |
| What moved in the enforcement surface since the last enforcement audit | /overengineering:delta |
The last two are delta lanes over their own prior runs, not over this audit's findings. This skill keeps no baseline and reports no deltas: each run is a full pass.
Per-dimension audit targets. primary-sources (where claims live), verification-sources (where
to verify), and example-claims (illustrative { claim, verify-via } rows for the claim-extraction
pass). Come from the consuming repo's tracked config, resolved additively across three layers:
~/.claude/codebase-health.md (user-global, optional): one Read of that literal path, ~ kept; never Glob for it, spell out a home directory, or search the home tree.claude/codebase-health.md (team, tracked).claude/codebase-health.local.md (personal override, gitignored)The four bundled dimensions are documentation, configuration, code-quality, and
architecture; the config may tune their globs, remove a dimension, or add custom ones.
Merge semantics when the same dimension name appears in two layers: additive by default. The
later layer's primary-sources and verification-sources globs UNION with the earlier layer's (not
replace), and example-claims concatenate with duplicate claim text collapsed. A layer removes an
inherited dimension by declaring it with empty source lists (an explicit opt-out), never by silent
omission. This keeps a personal override purely additive to team config unless it deliberately zeroes a
dimension out.
Settle targets by this ladder:
/codebase-health:setup, so the next run is
deterministic.docs/**/*.md + README.md + any
agent-instruction files; the other dimensions require inference or config. Skip a dimension
you cannot ground rather than guessing.Never hardcode a repo layout; read a declared value, infer-and-record, or ask.
Caller effort for this run is ${CLAUDE_EFFORT}. If that reads as a literal placeholder rather than
an effort level, this body was read directly instead of skill-loaded, so the substitution never
ran: treat the run as high and audit every resolved dimension. Pointer for the token and the
levels it carries:
Available string substitutions.
Effort selects a prefix of the resolved dimension list, in the declaration order the ladder above settled. It never adds a dimension the config removed, and never reorders one:
| Effort | Dimensions audited | External research (Phase 2) |
|---|---|---|
low | the first resolved dimension only, documentation under the bundled set | skipped |
medium | the first two, documentation and configuration under the bundled set | run for Phase 2's listed claim types among the two audited dimensions |
high, xhigh, max | every resolved dimension | run wherever the tooling exists |
Two rules keep a narrowed run honest. Name the skipped dimensions in the report, in the
"Required sections after the findings table", so an unaudited dimension never reads as a clean one.
And when effort skips external research, the claim itself is still not skipped: take the same
graceful-degrade path Phase 2 already defines for a missing research tool, verifying what the local
repo can confirm and confidence-tagging the externally-unverifiable part needs-review.
Research follows the audited prefix, not a named dimension. Phase 2's claim-type list
(best-practice, library API, configuration behavior) still decides which claims need a tool, and
medium collects those types only from the two dimensions this run actually audits.
For any audit run (Phases 0–3), copy
${CLAUDE_PLUGIN_ROOT}/skills/audit/templates/checklist.md into wherever the consuming
repo keeps working task notes (or keep it in-response). Tick each phase as completed. Remediation is
delegated to the implementation/verification lanes and is not part of this checklist.
Before auditing, load what "correct" looks like in this repo:
.claude/rules/ files (where present). Conventions, naming rules,
enforcement expectations. Read every one of them here, whether or not it is already in context:
a path-scoped rule may not have loaded yet, and this phase needs the whole convention set before
any file is opened. Do not assume a dispatched agent carries the instruction files either; which
ones reach it depends on the agent. Pointers: when a rule file loads,
Path-specific rules; what a
dispatched agent receives,
What loads at startup.verification-sources name.These define the lens through which findings are evaluated. A claim contradicting repo conventions is a finding; one following them is a verified non-issue. You cannot make that judgment without reading conventions first.
The goal is exhaustive verification, not sampling. Every factual claim in every relevant file must be checked against reality. The most common audit failure is skipping items.
Discovery runs as a parallel subagent fan-out. One agent per primary-source file, NOT a single sequential pass. A single context skips claims as it fills, which is the most common way an audit misses drift; a fresh context per file does not. Each agent applies the claim-extraction method (read top-to-bottom → extract every factual claim → verify each independently → record), fenced per the scope-fencing rules of the discovery method linked below.
Scope first (cost gate): require a [scope] or dimension filter (--docs-only
etc.) for large targets; if the enumerated list exceeds ~20 files, confirm with the user before
dispatching. Never fan out the whole repo unprompted: one subagent per doc, config, and source
file is a very large token cost.
Full method. Claim-extraction steps, the verify-ALL-claims-on-a-line rule,
enumerate/scope/dispatch/collect detail with the scope-fencing rules, and the per-finding report
format. In
${CLAUDE_PLUGIN_ROOT}/skills/audit/context/discovery-method.md.
Dimension-specific claim guidance:
${CLAUDE_PLUGIN_ROOT}/skills/audit/reference/audit-checklist.md.
Re-read each finding to confirm accuracy. This is the false-positive gate. Every finding must survive scrutiny before being reported.
Validate independently, not by self-review. When Phase 1 ran as a fan-out, dispatch the false-positive gate as a SEPARATE subagent that re-verifies each finding against the source of truth. Do NOT let the discovering agent grade its own findings. A model re-checking its own work rubber-stamps it; an independent agent re-reading the doc claim AND the actual code catches both false positives and miscategorized-but-correct claims. Where the finding set is high-stakes and correlated blind spots are the risk, prefer a cross-vendor advisor when one is installed and set up, e.g. the OpenAI Codex plugin, when its documented surface can take this artifact, invoked per its own docs, with the fresh-context same-vendor subagent as the stated fallback, never a route to a command that may not resolve. Fence each validator to read-only (its findings' files + verification-sources).
The verification level decides the separate validator. Run
bash "${CLAUDE_PLUGIN_ROOT}/lib/read-verification.sh" --plugin codebase-health --skill audit and
copy its line into the report
(levels).
standard is the rule above. strict dispatches the separate validator even when Phase 1 ran
inline. Under light, and off, which acts as light here, dispatch no validator and never grade
the findings yourself in its place: report them as unverified with
verification: skipped (<level>) in the summary.
When your setup provides documentation-research tools (MCP docs servers, library-docs lookers-up, web search), use them to validate findings involving:
Cross-reference research results against the repo's conventions (loaded in Phase 0). External consensus matters, but repo conventions are the primary lens, a pattern unusual industry-wide may be intentionally chosen here.
Graceful degrade when no research tool is available: do not skip the claim and do not guess.
Verify whatever the local repo can confirm, then confidence-tag the externally-unverifiable part as
needs-review (below) so it surfaces for human judgment rather than being asserted or dropped.
If uncertain, it is NOT a finding. Ambiguous items go to needs-review and are separated from
confirmed findings in output. The cost of a false positive (eroding trust in the audit) exceeds the
cost of missing a marginal issue (catchable next run).
${CLAUDE_PLUGIN_ROOT}/skills/audit/reference/category-playbook.mdFix order matters. See the playbook for why: Config Drift → Missing Enforcement → Code Quality → Doc Drift.
Open with a Needs you line naming anything waiting on the user: a finding whose fix turns on a
decision (which of two conflicting sources is right, a planned-versus-abandoned call), or the
config-gap observations to persist. Write "Needs you: none" when nothing waits. Then use this exact table with consistent error/warning/info severity:
| # | Severity | Category | File:Line | Description | Verification |
|---|---|---|---|---|---|
| 1 | error | doc-drift | <convention-file>:<line> | Doc claims suppression includes rule X but actual list is Y;Z | Read <build-config>:<line> |
example-claims this run showed are worth
adding to the tracked .claude/codebase-health.md (e.g. a source tree that held drift but wasn't
a configured primary-source). Offer to persist them via /codebase-health:setup apply so the
next run covers them deterministically.If the audit finds no discrepancies, report a clean bill of health:
/codebase-health:setup apply.Genre: reports. The report feeds a fix pass (/implementation:implement), so it offers a view and
never builds one. The report stays the record; a view is a second presentation of it, never a
place a finding first appears. In a session with no one reading, skip this section. When medium
resolves to terminal, make no offer and print no unavailable line. Otherwise, with
visualization:visualize installed, offer it in one line after the report, before any --fix
handoff. Without that plugin, say in one line that the optional view is unavailable, and never
hand-build an HTML file, chart or extra markdown file instead.
Resolve medium first with the shared resolver. <option> is this plugin's medium option,
${user_config.medium}, or "" when that reads empty or unsubstituted; never put a ${user_config.*} string in a shell command. Add --argument only when the run has a --medium value:
node "${CLAUDE_PLUGIN_ROOT}/lib/view-settings.mjs" resolve --lane codebase-health:audit --option "<option>" [--argument <the --medium value>]
It prints one JSON line, then the report line naming the medium and what decided it, then any
notice; print the report line and the notices after the report as they stand. Leave the
rendered-views files to the resolver, never an audit target and never read or listed in any phase: it weighs the argument and each scope, and never
publishes on a team file's say-so. On exit 2 with --argument, report the --medium value and
run it again without --argument. On exit 2 without it, or when node is missing, report that in
one line and take the null row.
The JSON's medium | Offer |
|---|---|
terminal | None: the report is the whole deliverable. |
null (no setting decided) | Offered; when taken, visualization:visualize picks the medium itself. |
| Any other value | Offered; when taken, passes that value to visualization:visualize. |
Without --fix (the default, including every model auto-invocation): present the full
report, then the rendered-view offer line when one applies, and STOP; the Phase 3 report is
the deliverable.
With --fix: present the full Phase 3 report, then hand off to the remediation lanes below.
The audit ends at the Phase 3 report: the findings table, verified-non-issues proof, drift patterns, fix priority, enforcement escalation, and config-gap observations ARE the deliverable. Fixing, verifying, self-reviewing, and retrospecting are separate lanes owned end-to-end by other plugins; re-implementing them here would duplicate those skills, so this skill delegates instead.
Route remediation to the dedicated lanes (soft dependencies. Use when the plugin is installed):
/implementation:implement (when the implementation plugin is installed). Hand it the
Phase 3 findings, whose "Fix priority" section already carries the Config Drift → Missing
Enforcement → Code Quality → Doc Drift order (see
reference/category-playbook.md); that lane owns the fix cadence:
TDD, build/test at each checkpoint, and the post-fix simplification pass./verification:confirm (when the verification plugin is installed). Confirms the
fixes against the repo's own build/test/lint gates with no regressions, and covers the self-review
and retrospective that the fix lane hands it.With --fix, present the Phase 3 findings and output an explicit user-directed suggestion to run
/implementation:implement with those findings, then /verification:confirm. Do NOT auto-invoke
either skill, the user drives both. When those plugins are not installed, say so and stop: the
Phase 3 findings table is the handoff, to be remediated manually in the reported fix-priority order.
Never re-inline a fix/verify/review/retro loop here.
What SKILL.md sets; muted values are Claude Code's defaults
npx claudepluginhub melodic-software/claude-code-plugins --plugin codebase-health2 skills in this plugin
Other plugins' skills for the same job