/spec-audit — Does the Code Match the Spec?
Second-hand summaries lie in both directions. This audit reads the actual
code and the actual spec, then reports exactly where they disagree and which
side is wrong — it never silently picks a winner.
Report format, ruling grammar, severity tiers, JSON trailer, degradation
rules, and routing table: see _shared/audit-report-contract.md. Task refs
via the task-manager adapter ({task_prefix}-###).
Invocation
/spec-audit specs/export.md src/export/ # explicit spec + code area
/spec-audit csv-export # feature name → resolve to specs + changed files
Procedure
- Load the authorities. The spec document(s), and the project rule file
(CLAUDE.md). Precedence: rules > spec. A rule/spec conflict is itself a
finding, resolved in the rules' favor.
- Decompose the spec into checkable requirements. One falsifiable line
each, with spec file:line.
- Read the implementation first-hand. The changed files, plus whatever
they wire into. Grep for each requirement's footprint; run behavior checks
where executable.
- Classify every divergence on the defect-kind axis:
ABSENT — required behavior in the spec, not in the code
PARTIAL — started, presented as complete, isn't
WRONG — implemented contradicting the spec's stated behavior
EXTRA — built but never specified (scope creep or stale spec)
Each carries a severity tier, spec-side file:line AND code-side file:line,
and a per-requirement ruling (CONFIRMED match / REFUTED divergence /
UNVERIFIED).
- Adjudicate each divergence: state explicitly whether the spec or the
code should change, and the proposed fix.
EXTRA findings check drift in
both directions — a stale spec is a spec bug, not a code bug.
- Report: conformance summary, findings most-severe-first, JSON trailer,
verdict line logged via
/verdict:
AUDIT: spec-audit | <spec vs area> | <pass|fail|inconclusive> | <blocking>/<total> findings
Rules
- Never rule from a summary, changelog, or PR description — code only.
- A requirement you couldn't trace is UNVERIFIED, not assumed present.
- Out-of-scope findings route per the shared table (rule breach →
rules-audit; spec-mandated complexity worth challenging → pragmatism-audit;
functional proof needed → validate-completion).
Judgment weave
- A full spec-audit is
/drift with adjudication: batch refutation of a
spec's claims against the code.
- WRONG-vs-stale-spec calls that feel borderline →
/escalate; adjudicated
ones → /precedent for next time; all verdicts → /verdict.
spec-citation hook enforces spec references at edit time; this audit is
the after-the-fact sweep of the same failure class.
Composes with
/completion-audit — consumes this unit's trailer at session scope.
/drift — lighter spec-vs-code sweep without adjudication.
/rules-audit — same comparison engine, different authority (rule file).
/gate — repeated drift in one spec area earns a standing gate.
1---2name: spec-audit3description: Code-vs-spec comparator. Reads the source first-hand and compares it against written specification documents, classifying every divergence as absent, partial, wrong, or extra — with file:line on both sides and an explicit call on which artifact should change. Project rules (CLAUDE.md) outrank specs. Use before PRs, after spec'd feature work, or when spec drift is suspected.4---56# /spec-audit — Does the Code Match the Spec?78Second-hand summaries lie in both directions. This audit reads the actual9code and the actual spec, then reports exactly where they disagree and which10side is wrong — it never silently picks a winner.1112Report format, ruling grammar, severity tiers, JSON trailer, degradation13rules, and routing table: see `_shared/audit-report-contract.md`. Task refs14via the task-manager adapter (`{task_prefix}-###`).1516## Invocation1718```19/spec-audit specs/export.md src/export/ # explicit spec + code area20/spec-audit csv-export # feature name → resolve to specs + changed files21```2223## Procedure24251. **Load the authorities.** The spec document(s), and the project rule file26 (CLAUDE.md). Precedence: rules > spec. A rule/spec conflict is itself a27 finding, resolved in the rules' favor.282. **Decompose the spec into checkable requirements.** One falsifiable line29 each, with spec file:line.303. **Read the implementation first-hand.** The changed files, plus whatever31 they wire into. Grep for each requirement's footprint; run behavior checks32 where executable.334. **Classify every divergence** on the defect-kind axis:34 - `ABSENT` — required behavior in the spec, not in the code35 - `PARTIAL` — started, presented as complete, isn't36 - `WRONG` — implemented contradicting the spec's stated behavior37 - `EXTRA` — built but never specified (scope creep or stale spec)38 Each carries a severity tier, spec-side file:line AND code-side file:line,39 and a per-requirement ruling (CONFIRMED match / REFUTED divergence /40 UNVERIFIED).415. **Adjudicate each divergence:** state explicitly whether the spec or the42 code should change, and the proposed fix. `EXTRA` findings check drift in43 both directions — a stale spec is a spec bug, not a code bug.446. **Report:** conformance summary, findings most-severe-first, JSON trailer,45 verdict line logged via `/verdict`:4647```48AUDIT: spec-audit | <spec vs area> | <pass|fail|inconclusive> | <blocking>/<total> findings49```5051## Rules5253- Never rule from a summary, changelog, or PR description — code only.54- A requirement you couldn't trace is UNVERIFIED, not assumed present.55- Out-of-scope findings route per the shared table (rule breach →56 rules-audit; spec-mandated complexity worth challenging → pragmatism-audit;57 functional proof needed → validate-completion).5859## Judgment weave6061- A full spec-audit is `/drift` with adjudication: batch refutation of a62 spec's claims against the code.63- WRONG-vs-stale-spec calls that feel borderline → `/escalate`; adjudicated64 ones → `/precedent` for next time; all verdicts → `/verdict`.65- `spec-citation` hook enforces spec references at edit time; this audit is66 the after-the-fact sweep of the same failure class.6768## Composes with6970- `/completion-audit` — consumes this unit's trailer at session scope.71- `/drift` — lighter spec-vs-code sweep without adjudication.72- `/rules-audit` — same comparison engine, different authority (rule file).73- `/gate` — repeated drift in one spec area earns a standing gate.