name: plan-audit description: Audits the codebase strictly up to the current active/completed phase or stage of an implementation plan (either an implementation_plan.md artifact or a staged docs/.md file from /plan-stage), fixing gaps and unintended mocks while preserving intentional stubs for future phases/stages, and verifies with build/test commands.
Phase- / Stage-Scoped Plan vs. Codebase Audit
When invoked (e.g., /plan-audit, /plan-audit Phase 2, or /plan-audit Stage 2 docs/MY_PLAN.md), execute this strict boundary-scoped audit:
1. Establish the Phase / Stage Boundary
- Locate the target plan from either:
- An explicitly specified plan file path (such as
docs/<PLAN_FILENAME>.mdgenerated by/plan-stage), or - The active
implementation_plan.mdartifact.
- An explicitly specified plan file path (such as
- Identify the Target Boundary (
N) (specified by the user/orchestrator or inferred as the most recently completed phase or stage). - Partition the plan into two strict zones:
- In-Scope (
Phases 1 through NorStages 1 through N): Must be 100% production-ready, wired up, and bug-free. - Out-of-Scope (
Phases/Stages N+1 and beyond): Future work. Do NOT implement these yet. - Final Phase/Stage Rule: When
Nis the final phase or stage of the plan, Out-of-Scope is empty and zeroSTUB(...)placeholders may remain anywhere in the codebase.
- In-Scope (
2. Hunt Gaps & Defects in Phases/Stages 1 through N
- Requirement Check: Compare every line item in
Phases/Stages 1 through Nagainst the codebase. Flag any skipped logic, missing edge cases, or broken types. - Unintended Mocks: Search modified files for
TODO,FIXME,mock,stub,placeholder, or hardcoded dummy data.- If it belongs to
Phases/Stages 1 through N: Delete the mock and write the real implementation. - If it belongs to
Phases/Stages N+1+: Leave it untouched, provided it is explicitly tagged (e.g.,// STUB(Phase 3): ...or// STUB(Stage 3 / <Item>): ...) and does not break compilation or runtime execution.
- If it belongs to
- Dead Code & Wiring: Verify that all functions, routes, state handlers, and UI elements from
Phases/Stages 1 through Nare actively imported and connected.
3. Remediate & Run Automated Verification Gate
- Fix every
GAP, bug, and unintended mock found withinPhases/Stages 1 through N. - Zero-Diff Clean Pass Rule: If zero gaps, defects, unintended mocks, or failing checks are found, make zero file edits (no formatting tweaks, cosmetic refactors, or comment churn) and report
0fixes made. - Inspect the project root (e.g.,
package.json,pyproject.toml,Cargo.toml,go.mod,Makefile) to identify the project's type-checker, linter, build, and test commands. - Run those verification commands via the terminal:
- Type-check / Build: Confirm zero compilation or type errors (including verifying that future
STUB(...)placeholders satisfy strict types). - Tests: Run existing unit/integration tests for
Phases/Stages 1 through N. If a newly implemented feature lacks basic test coverage, write and run tests for it.
- Type-check / Build: Confirm zero compilation or type errors (including verifying that future
- If any check fails, diagnose and fix the failure, then re-run until all checks pass.
4. Final Audit Report
Output a concise Phase/Stage 1–N Audit Summary containing:
- A table mapping each requirement in
Phases/Stages 1 through Nto its status (PASSorFIXED) and file path. - A list of preserved future stubs (
STUB(Phase X)/STUB(Stage X / <Item>)). - Confirmation of passing build, type-check, and test outputs before asking to proceed to
Phase/Stage N+1.
Automated / Subagent Mode
When invoked by an automated orchestrator (such as /plan-execute):
- Do not edit the plan's
## Stage Tracker(the orchestrator owns status transitions). - Do not pause to ask the user whether to proceed — return the requested structured audit output directly.