/ccmaf:healthcheckfrom ccmaf
Deep periodic audit across framework integrity, code quality, contracts, state files and tests (CCMAF v2)
Ships in ccmaf. Installing the plugin adds it to Claude Code.
This command runs only in a CCMAF v2 project. Check
.claude/.framework-version before doing anything else:
.claude/.framework-version — this
isn't a CCMAF-scaffolded project") and stop.FRAMEWORK_LINE=v2 → say "this is a v1-line CCMAF
project — use the bundled /healthcheck or migrate" and stop.FRAMEWORK_LINE=v2 → continue.Deep audit across framework integrity, code quality, contracts, state files, and tests. On-demand companion to the always-on self-checks (doctor.sh per cold start, insights/analyse.sh weekly). Use this when:
Takes 5-15 minutes. Writes findings to .claude/review-findings.md
as each part completes — same file reviewer uses. Context is
ephemeral: persist findings between parts, never hold them in
memory waiting for the end.
/healthcheck — single audit pass (default). Use most of the time./healthcheck --verify N — determinism mode. Run the audit N
times (typically 3) on an unchanged tree and report variance.
Required before building any automation that consumes /healthcheck's
output (contract-drift detectors, doctor-time aggregators, dashboards,
etc.). Add --perturb to test robustness to semantics-preserving
input changes (formatting, comment reflow) on a throwaway copy — the
stronger gate, since a finding that flips on a cosmetic edit is fragile.
Add --pin to freeze detector input across runs, isolating model
nondeterminism from environmental drift when plain --verify shows
variance. See "Determinism mode" section at the end for full protocol.
Lesson learned: the 2026-04-26 stability experiment uncovered BUG-001
(44→34→30 monotonic decay on unchanged tree) — the historical
drift-count trend that motivated proposed automation could not be
trusted as decision input. Determinism mode is the standard test
before any consumer goes in.Below is a runbook. Follow in order.
Figure out what this project is BEFORE running expensive reviews. Auto-detect and adapt — don't require the user to configure anything unless truly ambiguous.
0.0. Rotate prior findings (FIRST STEP — DO THIS BEFORE ANYTHING
ELSE). If .claude/review-findings.md exists, move it to
.claude/review-findings/<ISO-timestamp>.md (creating the
review-findings/ directory if needed). Start this run with no
.claude/review-findings.md file at all — Part 1.4 will create it
fresh on first append.
This rotation is non-negotiable. If the file persists across runs, subagents in subsequent runs will read it (to find an insertion point or just for context) and anchor on prior runs' findings, producing monotonically decaying counts that look like convergence but are actually self-suppression. Document case: 2026-04-26 detector-stability experiment, 44→34→30 across 3 unchanged-tree runs, with the run-2 subagent writing literal "Alignment with Run 1... confirming detector stability" — that is the failure mode this step prevents.
0.1. Load optional overrides. If .claude/healthcheck.conf exists,
source it. It may set any of:
HEALTHCHECK_SOURCE_DIRS, HEALTHCHECK_TEST_DIRS, HEALTHCHECK_TEST_CMD,
HEALTHCHECK_LINT_CMD, HEALTHCHECK_FW_WINDOW, HEALTHCHECK_REVIEW_FOCUS.
Unset values fall through to auto-detect.
0.2. Auto-detect source + test dirs (only where not overridden).
Priority order:
CLAUDE.md "Commands" section for cd <dir> patterns —
that's the canonical project root.src/,
tests/, app/, lib/, then the framework's 01_Project/,
01_Project/src/, 01_Project/tests/. Legacy layouts last:
02_src/, 02_src/*/, 03_tests/..claude/healthcheck.conf
so future runs skip this step.0.3. Detect test + lint commands (only where not overridden).
Read CLAUDE.md "Commands" section. Match common patterns:
npm test, pytest, go test, cargo test, dotnet test,
npm run lint, ruff check, eslint, golangci-lint.
If neither found, Part 5 (automated checks) auto-skips with a note in the findings.
0.4. Detect contracts.
<!-- contract:ID blocks → contracts live in
ECOSYSTEM.md.contracts/ directory at project root → per-file contracts.0.5. Detect if there's any project code at all.
If 0.2 returned no source dirs AND no test dirs, the framework instance holds no project (e.g., fresh clone before code arrives, or the upstream framework repo itself). Parts 2 and 3 auto-skip (no project code to review, no contract/reconciler-full sweep to run against it) — Part 1 (framework integrity) and Part 4 (state-file consistency) still run.
0.6. Tell the user what was detected. Before running any expensive step, summarise the detected shape (mode, project name, source/test dirs, test/lint cmds, contracts strategy, what gets skipped) and ask for confirmation via AskUserQuestion:
healthcheck.conf discussion)Once confirmed, continue.
1.1. Fast invariants. Run bash ${CLAUDE_PLUGIN_ROOT}/doctor/doctor.sh.
Capture any findings from .framework-doctor-findings.md.
1.2. Behavioural drift. Run bash ${CLAUDE_PLUGIN_ROOT}/insights/analyse.sh --force
and bash ${CLAUDE_PLUGIN_ROOT}/insights/report.sh. Capture .framework-insight-alert.md
if it appears; include the report summary either way.
1.3. Recent framework change detection. In v2, core's own code and prose
are machine-wide plugin content (versioned via claude plugin update), not
tracked in this project's git history — so a project-local git diff can no
longer see an in-place framework code change the way v1's diff did. It CAN
still see project-scaffold drift (custom agents, bare-alias command files,
the SCAFFOLD_REV pin). Check for changes in the last
HEALTHCHECK_FW_WINDOW commits (default 10) across what remains in-project:
# Clamp the window to the history that exists: HEAD~N on a repo with <= N
# commits is an unknown revision, and a swallowed git error must never read
# as "no changes" (that silently skipped the deep audit on young repos).
win="${HEALTHCHECK_FW_WINDOW:-10}"
total="$(git rev-list --count HEAD 2>/dev/null)" || total=0
if [ "$total" -gt "$win" ]; then base="HEAD~$win"
else base="$(git hash-object -t tree /dev/null)" # empty tree: every commit is in the window
fi
git diff --name-only "$base" -- \
.claude/agents/ .claude/commands/ .claude/.framework-version \
|| echo "HEALTHCHECK-FW-WINDOW: git diff failed — treat as CHANGED"
If changes detected → deep framework audit via reviewer subagent:
Spawn a ccmaf:reviewer subagent (fall back to the bare reviewer
name if the namespaced type does not resolve) with this prompt. Prepend
the shape detected in Part 0 so the subagent doesn't re-derive it
(scoped-anchor rule — shape context only, never findings):
Detected shape (from Part 0): source dirs:
<HEALTHCHECK_SOURCE_DIRS or "none — framework-only">; state root:.claude/; contracts:<ECOSYSTEM.md | contracts/ | none>.Independence rule. Do NOT read
.claude/review-findings.mdbefore forming your audit. That file is write-only for you. The orchestrator handles deduplication and aggregation. Form your findings independently from the source files alone.Perform a complete integrity audit of the framework. The goal is to verify that every reference resolves, nothing is orphaned, nothing contradicts, and nothing is redundant. Treat the framework as a connected graph — if any node is unreachable, dangling, or in conflict, flag it.
Reference integrity. Every pointer must resolve:
- CLAUDE.md Cold Start paths → files/dirs exist?
${CLAUDE_PLUGIN_ROOT}/agent_docs/OPERATIONS.mdreferences → resolve?- ECOSYSTEM.md contract blocks → cross-references valid? Contracts referenced by TASKS.md actually exist in ECOSYSTEM.md?
- DECISIONS.md index entries → resolve?
- Commands referencing plugin paths (
${CLAUDE_PLUGIN_ROOT}/agent_docs/,${CLAUDE_PLUGIN_ROOT}/doctor/, etc.) → paths resolve inside the installed plugin? Commands referencing project-relative paths (docs/,contracts/) → exist in the project?- Agent definitions referencing
${CLAUDE_PLUGIN_ROOT}/agent_docs/files → those files exist?settings.json— in v2 it carries permissions only (hooks arrive via plugins, not settings.json registrations) — confirm it still parses as valid JSON and its permissions block is well-formed; it should NOT contain hook-command paths to verify.- Also run
bash ${CLAUDE_PLUGIN_ROOT}/doctor/doctor.shif not already run and fold its findings in.Conflict and contradiction detection.
- Agent scope boundaries — does any agent's scope overlap with another's? (e.g., two agents both claim to write contracts)
- Agent tool lists vs descriptions — does any agent have tools it shouldn't? (e.g., reviewer with Write)
- Command instructions — do any contradict the core plugin's digest (
${CLAUDE_PLUGIN_ROOT}/DIGEST.md) rules?- Hook behaviour vs command expectations — do hooks enforce rules that commands assume won't be enforced?
- Contract markers — does any command or agent reference a
status:draftcontract as if it's stable?- GOTCHAS.md items marked FIXED — does the fix actually exist in the code/config, or is it stale?
Redundancy detection.
- Duplicate files covering the same concern (old reference files superseded by agent_docs)?
- Commands duplicating each other's behaviour?
- Hooks overlapping in what they check?
- agent_docs entries repeating information already in CLAUDE.md or ECOSYSTEM.md?
Security and hygiene.
- settings.json deny rules cover .env, .ssh, .aws, secrets, credentials?
- .gitignore covers .env, .env.*, settings.local.json, worktrees/, .drift-state, telemetry/, flag files?
- No secrets or API keys in agent definitions, commands, hooks, or skills?
- Hook scripts don't execute untrusted input or download from URLs?
Output discipline — findings about a safety or security control. When a finding concerns a safety/security control (e.g. the destructive-command guard hook), record the weakness class and the defensive remediation only — never a working bypass, a runnable payload, or a list of destructive commands. Naming the class and the fix is a complete finding: do not treat class-level as under-delivering or add concrete specifics to compensate. Cite the control and its test fixtures by file:line, and frame fixes as "add coverage / a fixture asserting the guard blocks ". Keep class-level precision (e.g. "matches literal strings but doesn't normalise paths", "covers filesystem roots but not raw device nodes") — precise and defensive, not vague.
Return findings categorised as:
- BROKEN (blocks work or produces incorrect behaviour)
- CONFLICT (two parts of the framework contradict each other)
- ORPHANED (exists but nothing references it)
- REDUNDANT (duplicates something else — note what it duplicates)
- STALE (exists and is referenced but content is outdated)
- OK (checked, no issues)
If no framework changes detected (the command above succeeded with
empty output) → skip the deep audit. A git failure (the treat as CHANGED line) is NOT "no changes" — run the deep audit instead. Doctor +
insights output alone is sufficient — the framework hasn't moved.
1.4. PERSIST. Append findings to .claude/review-findings.md
with a timestamped header. Use this shape:
## /healthcheck — Part 1 Framework Integrity — <ISO timestamp>
<findings>
Release from context before moving to Part 2.
Spawn a ccmaf:reviewer subagent (fall back to the bare reviewer
name if the namespaced type does not resolve). Prompt template (fill in
the detected sources):
Independence rule. Do NOT read
.claude/review-findings.mdbefore forming your audit. That file is write-only for you. Audit the source from scratch.Review
<HEALTHCHECK_SOURCE_DIRS>and<HEALTHCHECK_TEST_DIRS>for: bugs, dead code, edge cases, concurrency / async correctness, test gaps, and any stack-specific correctness (framework/library usage, security surface, performance red flags).Additional focus areas:
<HEALTHCHECK_REVIEW_FOCUS>(from config, optional).Do NOT load state files. Return findings grouped by severity (CRITICAL / HIGH / MEDIUM / LOW) with file:line, issue, impact, and suggested fix. If a suggested fix names a specific API, library, flag, or value, mark it VERIFIED or UNVERIFIED (behavioral-principles §4) — a quick-read guess must not read as a decision to a later session.
Output discipline — findings about a safety or security control. For any finding on a safety/security control, record the weakness class and the defensive fix only — never a working bypass, a runnable payload, or a destructive-command list. Naming the class and the fix is a complete finding; do not add concrete specifics to compensate. Frame fixes as "add coverage for ". Keep class-level precision, not vague.
PERSIST to .claude/review-findings.md. Release from context.
Gate: skip only if Part 0.5 found no project code at all (not "skip
if no contracts" — reconciler's other three categories, duplicate/seam/
convention drift, have value even on a project with zero contract:
blocks; the old narrower gate would silently skip those on a
contracts-free project).
Spawn a ccmaf:reconciler subagent (fall back to the bare
reconciler name if the namespaced type does not resolve), full mode.
Prompt:
Reconcile in
fullmode: whole-repo sweep, no delta. Deterministic tools first (jscpd if present, export inventories, name-similarity greps, compiler/type-check where available) — spend judgment only on the candidate list they surface.Contract category — for each
<!-- contract:ID status:stable -->block in ECOSYSTEM.md (orcontracts/): read the contract, find the implementation, verify signatures/params/return types/behaviour match. Also verify ECOSYSTEM.md module boundaries and architecture.md's Module Structure against the actual layout. Report contract findings using: MISMATCH (contract says X, code does Y) / MISSING (code exists, no contract) / DRIFT (contract exists, signature changed unannounced) — same vocabulary healthcheck has always used, so this replaces the Reviewer's old contract-verification pass rather than duplicating it.Duplicate / seam / convention categories — per your agent definition.
On success, write the findings JSON (
.claude/console/reconcile/<scope-id>.json, gated on.claude/console/existing) and touch.claude/telemetry/.last-reconcile.Return per your Return Format section, plus the MISMATCH/MISSING/DRIFT lines inline so they can be persisted below.
PERSIST the returned findings (contract lines in MISMATCH/MISSING/DRIFT
form, other categories as-is) to .claude/review-findings.md. Release from
context.
Spawn a ccmaf:reviewer subagent (fall back to the bare reviewer
name if the namespaced type does not resolve). Prompt:
Independence rule. Do NOT read
.claude/review-findings.mdbefore forming your audit. That file is write-only for you. Cross-check from the state files themselves.Cross-check the project's state files (do NOT load source code):
TASKS.md— valid statuses, no stuck tasks, Done entries have commit refsSTATUS.md— matches TASKS.md board; if "tests passing" is claimed, does the project have a passing test run?DECISIONS.md— no contradictions between entriesECOSYSTEM.md— module boundary section matches project layoutGOTCHAS.md— items marked FIXED have evidence in code/configCLAUDE.md— referenced paths and folder structure match realityclaude-progress.txt— rolling summary reflects recent session logReturn:
- MISALIGNMENT (must fix — state files disagree with each other or with reality)
- STALE (should update — item is old enough to be revised)
PERSIST to .claude/review-findings.md. Release from context.
Runs after Part 4's PERSIST completes (the parts are sequential — persist-and-release means there is no concurrent window). To save a round-trip, issue these shell commands in the same turn as Part 4's persist step:
HEALTHCHECK_TEST_CMD or CLAUDE.md Commands section).HEALTHCHECK_LINT_CMD or CLAUDE.md Commands section).Capture non-zero exits and append the relevant output to
.claude/review-findings.md. Keep it compact — paste failure lines
only, not entire test logs.
Before proceeding to fixes, ask the user via AskUserQuestion:
Creating a checkpoint commit means if the fix phase runs out of context or crashes, the audit survives. This is the most valuable disk write the command produces.
Read from .claude/review-findings.md now — not from conversation
memory. The ephemeral-context rule applies to YOU as much as to any
other agent.
Each part reports in its own vocabulary — Part 1: BROKEN / CONFLICT /
ORPHANED / REDUNDANT / STALE / OK; Part 2: CRITICAL / HIGH / MEDIUM / LOW;
Part 3: MISMATCH / MISSING / DRIFT (+ the reconciler's own categories);
Part 4: MISALIGNMENT / STALE. Map every label onto one of three tiers
(these tiers are also what --verify counts):
TASKS.md (feature lane or
Bug-Fix Lane as appropriate). Each task includes a reference back to
the findings file entry.
Should-fix — HIGH / MEDIUM / MISSING / DRIFT → create tasks at
normal priority (same back-reference rule).FRAMEWORK-SUGGESTIONS.md if they're
framework-level, otherwise in GOTCHAS.md.TASKS.md and STATUS.md —
do not defer state updates. Hooks will block session end otherwise..claude/telemetry/.last-healthcheck with the current ISO
timestamp — a local record of the last run. Nothing reads it
automatically: there is no cold-start healthcheck nudge.claude-progress.txt with the session summary.This command is linear (parts in sequence, though subagents within
a part may parallelise). A 10-minute audit isn't cheap, so it
shouldn't become ritual. Nothing schedules or nudges it — there is no
cold-start healthcheck reminder; run it deliberately. For a cadence,
wire /loop or the schedule skill around this command directly.
/healthcheck --verify N)Purpose. Verify the audit produces stable findings on an unchanged tree. This is the standard test BEFORE any framework code is written to consume /healthcheck output (drift detectors, aggregators, doctor invariants, alerting). Without it, you risk shipping automation against a non-deterministic input — exactly the trap BUG-001 caught on 2026-04-26.
N. Default 3. Lower is statistically weak; higher is overkill for most cases. Use 5+ only if early runs show small variance you want to characterise more precisely.
Protocol.
git status shows clean. If not, stash
or commit first — variance between runs must be attributable to the
detector, not edits..claude/review-findings.md → .claude/review-findings/<ISO>.md
at the start of every run. Each of the N runs starts from a clean
review-findings.md. Confirm this is happening before run 2 starts.Output. Write the comparison to
.claude/review-findings/_determinism-<ISO>.md (underscore prefix to
sort it visibly at top). Format:
# /healthcheck --verify N=<N> — <ISO>
## Per-run totals
| Run | Blocking | Should-fix | Advisory | TOTAL |
| --- | -------- | ---------- | -------- | ----- |
| 1 | … | … | … | … |
| 2 | … | … | … | … |
| N | … | … | … | … |
## Variance
- Total max-min: …
- Stddev (N≥3): …
- Item overlap (in all runs): …%
## Verdict
- Stable / Unstable / Decaying-or-Growing
## Consumer guidance
- (one paragraph: is it safe to build automation against this output?)
/healthcheck --verify N --perturb)Why. Plain --verify repeats identical input and measures variance —
it catches feedback channels and priming (BUG-001), but it does NOT catch
the failure you most care about for a detector: a finding that flips when
the input changes cosmetically. A reviewer that flags a bug only when a
file has trailing whitespace, or that loses a finding when a comment is
reworded, is fragile regardless of how stable it looks under repetition.
Perturbation mode tests robustness to semantics-preserving input changes
(the LLM-as-judge "perturbation suite" technique), which is the real
determinism property.
Safety — never touch the real tree. All perturbation happens on a throwaway copy. Create a worktree or copy first:
git worktree add ../_verify-perturb HEAD # or: cp -r the tree to a tempdir
Run every perturbed audit there; remove it when done
(git worktree remove ../_verify-perturb). The real working tree is never
modified.
Protocol (replaces step 2 of the base protocol; keeps 1, 3–6).
2p. Run 1 = baseline on the unperturbed copy. For runs 2…N, apply ONE semantics-preserving transform to the copy before auditing, each chosen to change text without changing meaning:
Added comparison dimension — fragile findings. Beyond the base variance/overlap report, compute: of the findings on the baseline, which disappeared under a perturbation that changed no semantics, and which new findings appeared? Those are fragile — they depend on incidental text, not real defects.
Added verdict.
Output. Extend the _determinism-<ISO>.md report with a section:
## Perturbation robustness (--perturb)
| Run | Perturbation | Findings vs baseline | Fragile (vanished/new) |
| --- | -------------------- | -------------------- | ---------------------- |
| 1 | none (baseline) | — | — |
| 2 | format-only | … | … |
| N | comment reflow | … | … |
Robust / Fragile — <one line: are findings invariant to cosmetic change?>
/healthcheck --verify N --pin)Why. Plain --verify repeats on an "unchanged tree" — but an
unchanged tree is not the same as identical detector input. An
LLM-driven check (the Reviewer, a healthcheck subagent) also consumes
things that can drift between runs even on a clean tree: git output
ordering, file mtimes, tool results, directory-listing order, a freshly
re-read file. So when plain --verify shows variance, you cannot tell
model nondeterminism (the LLM gave different findings for the same
input) from environmental drift (the input the LLM saw actually
differed). They need opposite fixes. --pin separates them.
--perturb and --pin are mirror images: --perturb deliberately
varies input to test robustness; --pin deliberately freezes input to
isolate the model.
Mechanism (what we can and can't do). We don't control Claude Code's model client, so we can't stub the LLM and replay it token-for-token. What we CAN do is pin the input half: snapshot the exact bytes the detector consumed on run 1 — the diff, the contract text, the file contents, any tool output embedded in the subagent prompt — to a fixture, then feed that same frozen snapshot to runs 2…N instead of letting each run re-derive its input from the live tree.
Protocol (replaces step 2; keeps 1, 3–6).
2pin. Run 1 — capture. Run the check; as you assemble each subagent's
prompt, also write the full input it received (embedded file contents,
diff, contract blocks, tool results) verbatim to
.claude/review-findings/_pinned-input-<ISO>/. This is the snapshot.
2pin-b. Runs 2…N — replay the snapshot. Feed each subagent the pinned
snapshot as its input verbatim. Do NOT let it re-read the live tree or
re-run tools — the whole point is byte-identical input. (No priming
language, same as base protocol.)
Attribution verdict (this is the payoff).
--verify showed was
environmental drift. Fix the environment, not the prompt: pin tool
outputs, sort directory listings, freeze timestamps, snapshot git state.Output. Add to _determinism-<ISO>.md:
## Input-pinning attribution (--pin)
- Snapshot: .claude/review-findings/_pinned-input-<ISO>/
- Findings on pinned input across runs: stable / varying
- Attribution: model-nondeterministic / environmental-drift
- Recommended fix: <per-criterion+ensemble | pin the drifting input source>
When NOT to run. Don't make these modes a periodic cadence. They're
expensive (N× the cost of /healthcheck) and only matter as a gate before
automation. Plain --verify is the minimum gate. Add --perturb when the
consumer treats findings as ground truth (drift trendlines, auto-filed
tasks). Add --pin when plain --verify showed variance and you need to
know whether to fix the model layer or the environment before proceeding.
Once a consumer ships against verified output, you don't re-run unless
/healthcheck itself changes.
Doctor pairs with this. When a new framework file is added that
references .claude/review-findings.md or its rotated archive, doctor
should warn if /healthcheck hasn't been run in --verify mode
recently — see doctor.sh Check 9.
What the command file sets; muted values are Claude Code's defaults
7-day visitors to each command page
npx claudepluginhub drushegh/ccmaf --plugin ccmafOther plugins' commands for the same job
16 commands in this plugin
/analyseContext checkArchitect analysis of requirements and existing code into a design and task breakdown (CCMAF v2)/board-healContext checkReconcile the TASKS.md board with reality — advance stranded tasks, backfill verify seeds, fix IDs (CCMAF v2)/bugContext checkLog an ad-hoc bug into the TASKS.md Bug-Fix Lane in the shared on-disk bug shape (CCMAF v2)/build/ccmaf:build — the thin build loopTHIN build loop — dispatch against plan specs with budgets, receipts, integration gate, staged review (CCMAF v2)/housekeepingContext checkFramework maintenance — rolling summary, state archiving and distillation, feedback reconciliation (CCMAF v2)/init/ccmaf:init — scaffold a CCMAF v2 projectScaffold this project onto the CCMAF v2 framework (state files, settings, aliases, feature opt-ins)