Audit

From melodic-software/claude-code-plugins · View interactive version

Audit is an AI agent skill from the GitHub repository melodic-software/claude-code-plugins. Audit a codebase for drift between docs, config, code, and architecture. Verifies every factual claim against reality via parallel subagent fan-out, severity-rates findings and reports read-only; remediation is delegated to the implementation/verification lanes (`--fix` ends the report by suggesting

How to use this skill

Skill file

Variables

Arguments: $ARGUMENTS

Argument Parsing

Parse $ARGUMENTS for:

same request in words, run the audit once per repository. See

Several repositories. With none, the audit covers this repository only.

(/implementation:implement (if enabled) then /verification:confirm (if enabled)) 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.)

(Rendered view).

If 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.


Adapting to your environment (graceful degrade)

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.


Boundary, the adjacent drift lanes

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 (if enabled) 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 (if enabled). Name that mode: fanout's default lifecycle-tiered mode never dispatches this agent, only run-everything does, so an unqualified /review:fanout (if enabled) 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 (if enabled) |

| Whether the surface in flight still matches the current official upstream docs | /discipline:recheck-against-upstream (if enabled) |

| Prose restating an external source with no pointer, and verification stamps past their expiry window | /attribution:audit (if enabled) |

| 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 (if enabled), with /harness-config:audit-automation-gaps (if enabled) for automation-landscape gaps and /harness-config:audit-instructions (if enabled) 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 (if enabled) |

| What moved in the enforcement surface since the last enforcement audit | /overengineering:delta (if enabled) |

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.


Audit dimensions & targets (tracked config seam)

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 config, resolved additively across the config-cascade

layers that

CODE0 owns (one Read of that

file; it also owns <home>, the root rule and the merge semantics):

  1. userConfig: the file the dimensions_file option names. Claude Code substituted its value

here: ${user_config.dimensions_file}. Empty, or a literal ${user_config.…} placeholder,

means unset.

  1. team: <home>/codebase-health.md (tracked)
  2. personal: <home>/codebase-health.local.md (gitignored)

Old locations. While ~/.claude/codebase-health.md (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

or .claude/codebase-health.local.md exists, read it as the layer config.md's "Old locations"

table says, wherever the new location does not supply that layer, so its values still apply. Print

one warning line for the run naming each old file found, its new location, and

/codebase-health:setup apply to move it. When the new location also supplies that layer, the new

one wins, and the warning names both files and lists the old file's dimensions that do not apply.

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:

  1. Config present → use it.
  2. Absent → infer from the repo (doc dirs, build manifests, source/test roots, CI workflows),

then persist the inference by offering to run /codebase-health:setup, so the next run is

deterministic.

  1. Cannot infer → ask the user, and offer to persist the answer via setup.
  2. Otherwise → safe generic defaults: documentation = 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.

Effort, which dimensions this run covers

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.

Several repositories

A target form from CODE0

(--repo <repo> and the others its "Target forms" lists, or the same request in words) runs

Phases 0 to 3 once per repository. That file's "Target forms", "Resolving repositories",

"Fan-out", "Merging findings" and "Writes stay per repository" sections say how. With no target

form, nothing in this skill changes. What differs here:

in every repository, and the path is read relative to each repository's root. A repository

without that path is reported as skipped, with the reason.

then apply the Phase 1 cost gate to the total before dispatching any repository's subagent.

place. For another clone, it is the clone itself when it has no uncommitted change and its

HEAD equals origin/HEAD after the fetch. Otherwise it is a detached worktree of origin/HEAD

under the session scratchpad (git -C <root> worktree add --detach <scratch path> origin/HEAD),

removed after the pass. Phase 1's file agents and Phase 2's validator read only that tree.

repository's Phase 1 file agents and Phase 2 validator. When it cannot spawn agents of its own,

run that repository's Phases 1 and 2 from the main thread with its root anchored. Never let one

context both discover and validate the findings.

repository's tree. Resolve <home> and the team config layer (<home>/codebase-health.md, or

the old .claude/codebase-health.md standing in for it) from that tree. Read the personal layer

(<home>/codebase-health.local.md, or the old .claude/codebase-health.local.md) from the

clone's own root, never from a scratch worktree: it is gitignored, so a detached worktree of

origin/HEAD never holds it, and reading it there would drop a clone's override only because

the clone is behind or dirty. The userConfig layer is shared by all repositories. Run read-verification.sh as

CLAUDE_PROJECT_DIR=<tree> bash "${CLAUDE_PLUGIN_ROOT}/lib/read-verification.sh" ..., because

it otherwise reads the session's own project.

one repository about another one in scope can now be checked. Examples: a path in it, a version

it publishes, a reusable workflow or action it calls (uses: <owner>/<name>/...@<ref>). Verify

the claim against the other repository's tree, or against the ref the claim names. Report the

finding in the repository that makes the claim, and name the repository the claim is about in

its Verification cell. A claim about a repository outside the scope is verified as it is today.

between repositories are measured by /coupling:reduce (if enabled), as the contract's "Cross-repository

signals" says. After the report, name its read-only form

(/coupling:reduce dry-run --repo <repo> ... (if enabled)) as a lane the operator can run next, the way the

Boundary table names a lane. Never invoke it from this run.

repository in the File:Line cell (<owner>/<name>:<path>:<line>), and write one Needs you line.

The verification line, the dimensions effort skipped and the config-gap observations are given

per repository, because each repository resolves its own config. Offer a config gap's

/codebase-health:setup apply in the repository it belongs to.

/implementation:implement (if enabled) then /verification:confirm (if enabled), run from a worktree of that

repository, as "Writes stay per repository" says.

This skill keeps no state of its own between runs, so it has no ledger or cursor to keep per

repository.

Emit checklist

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.


Phase 0: Prime Context

Before auditing, load what "correct" looks like in this repo:

  1. Read the consuming repo's .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.

  1. Resolve the audit config per the dimension seam above; read the convention files its

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.


Phase 1: Discover

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. Route these per-file agents per the

caller contract of /multi-agent:route (if enabled); otherwise run them here as before.

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. Across repositories, the ~20-file threshold applies to the file

lists of all repositories added together. A target form names repositories but does not confirm

the 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

CODE0.

Dimension-specific claim guidance:

CODE0.


Phase 2: Validate & Enrich

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 enabled 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.

External research (required when the tooling exists)

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.

False-positive prevention

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).

Tag findings with confidence


Phase 3: Categorize & Present

Group findings per [`${CLAUDE_PLUGIN_ROOT}/skills/audit/reference/category-playbook.md`](reference/category-playbook.md)

Fix order matters. See the playbook for why: Config Drift → Missing Enforcement → Code Quality →

Doc Drift.

Output format

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> |

Required sections after the findings table

  1. Verified non-issues. Every claim you checked that turned out correct, each carrying the same

verification evidence a finding carries: the file you read or the command you ran. List what you

actually verified, however many that is. A count with no evidence behind each row is not proof.

  1. Drift patterns. Group related findings and identify root causes (e.g., "7 findings trace to

a registration refactor where code was updated but docs weren't")

  1. Fix priority. Recommended fix order per the category playbook
  2. Enforcement escalation. For each finding, what automated enforcement (formatter, linter,

analyzer, type check, test, git hook, CI gate) could catch this class automatically?

  1. Config-gap observations. Dimensions, globs, or example-claims this run showed are worth

adding to the tracked <home>/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.

Zero-findings outcome

If the audit finds no discrepancies, report a clean bill of health:

of issues.

is the best time to note coverage gaps worth persisting via /codebase-health:setup apply.

Rendered view (offered, never emitted)

Genre: reports. The report feeds a fix pass (/implementation:implement (if enabled)), 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. With a person

reading, run the resolver below on every run, whatever the number of findings and whether or not

the run has a --medium value, and print its report line and notices. 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.

Run the resolver whether or not visualization:visualize is installed: its report line and notices print either way.

Copy the resolver's view: ... report line and each notice line into the reply word for word, after the report.

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

Fix gate

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.


Next

Related

Remediation (delegated to other plugins)

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 enabled):

Phase 3 findings, whose "Fix priority" section already carries the Config Drift → Missing

Enforcement → Code Quality → Doc Drift order (see

CODE0); that lane owns the fix cadence:

TDD, build/test at each checkpoint, and the post-fix simplification pass.

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 (if enabled) with those findings, then /verification:confirm (if enabled). Do not auto-invoke

either skill, the user drives both. When those plugins are not enabled, 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.

Use this skill with your AI agent: Open on Skill Issue to copy, download, or add to your library. Works with Claude, ChatGPT, Gemini, Cursor, Windsurf and more.