/crucible:debuggingfrom crucible
Systematic debugging workflow that locates root causes before fixing bugs, test failures, or unexpected behavior. Dispatches investigation to subagents with structured status reporting.
Ships in crucible. 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.
All subagent dispatches use disk-mediated dispatch. See shared/dispatch-convention.md for the full protocol.
Random fixes waste time and create new bugs. Quick patches mask underlying issues.
Core principle: ALWAYS find root cause before attempting fixes. Symptom fixes are failure.
Violating the letter of this process is violating the spirit of debugging.
Models: Quick structural mapping requests fast; investigation, synthesis, and implementation request high. The Claude Code examples use current reference aliases such as model: haiku and model: opus; other harnesses map supported profiles or omit unsupported model fields per shared/model-tier-policy.md.
Between every agent dispatch and every agent completion, output a status update to the user. This is NOT optional — the user cannot see agent activity without your narration.
Every status update must include:
After compaction: Re-read the session state from the scratch directory (see Session State below) and output current status before continuing.
This requirement exists because: Debugging sessions can involve multiple investigation rounds and fix attempts. Without narration, the user has no visibility into which hypotheses have been tried, what evidence was found, or why the orchestrator is pursuing a particular path.
Execution model: The orchestrator dispatches all investigation and implementation to subagents. The orchestrator NEVER reads code, edits files, or runs tests directly. It forms hypotheses, dispatches work, and makes decisions based on subagent reports.
Depth principle: When in doubt, dispatch MORE investigation agents, not fewer. A bug that looks simple from the surface often has a complex root cause. Spinning up 4-6 focused investigators in parallel costs minutes; missing the root cause costs hours.
Write a status file to ~/.claude/projects/<hash>/memory/pipeline-status.md at every narration point. This file is overwritten (not appended) and provides ambient awareness for the user in a second terminal.
Write the status file at every point where the Communication Requirement mandates narration: before dispatch, after completion, phase transitions, health changes, escalations, and after compaction recovery.
The status file uses this structure (overwritten in full each time):
# Pipeline Status
**Updated:** <current timestamp>
**Started:** <timestamp from first write — persisted across compaction>
**Skill:** debugging
**Phase:** <current phase, e.g. "Synthesis", "4 — Implementation">
**Health:** <GREEN|YELLOW|RED>
**Suggested Action:** <omit when GREEN; concrete one-sentence action when YELLOW/RED>
**Elapsed:** <computed from Started>
## Recent Events
- [HH:MM] <most recent event>
- [HH:MM] <previous event>
(last 5 events, newest first)
Append after the shared header:
## Investigation
- Hypothesis: "Missing null check in event handler dispatch chain"
- Cycle: 2 of 4 max
- Phase 4 fix attempts: 1 (WIP commit pending verification)
## Compression State
Goal: [original user request / bug report]
Key Decisions:
- [accumulated decisions, max 10]
Active Constraints:
- [constraints affecting remaining investigation]
Next Steps:
1. [immediate next action]
2. [subsequent actions]
Health transitions are one-directional within a phase: GREEN -> YELLOW -> RED. Phase boundaries reset to GREEN.
When health is YELLOW or RED, include **Suggested Action:** with a concrete, context-specific sentence (e.g., "Third hypothesis attempted. Consider narrowing the search space or providing additional context.").
Output concise inline status alongside the status file write:
Phase 1 [cycle 2] Investigating: null check hypothesis | GREEN | 34m--- separatorsAfter compaction, before re-writing the status file:
0. Read the ## Compression State section from pipeline-status.md — recover Goal, Key Decisions, Active Constraints, and Next Steps. If absent, skip to step 1.
pipeline-status.md to recover Started timestamp and Recent Events bufferSession Index: path, or if globbing ~/.claude/projects/<hash>/memory/session-index/*/summary.md finds a recent file, read summary.md. Include the Activity Timeline, Files Modified, and Key Decisions sections in the post-compaction narration. If no session index exists, skip silently — this step is purely additive. If summary.md lacks detail for a specific event type (e.g., errors, hypothesis changes, file modifications), use /recall to query events.jsonl with filters for targeted recovery.The debugging skill writes session state to disk at every phase transition, not just on failure. This ensures compaction recovery works regardless of when it occurs.
Scratch directory: /tmp/crucible-debug-<session-id>/ where <session-id> is a timestamp generated at the start of the debugging session.
Write at each phase transition:
phase-state.md: current phase, cycle count, current hypothesis (if formed), and
wip-sha-<cycle>: (where <cycle> is the same N as pre-debug-fix-cycle-N — the
current hypothesis cycle's Phase 4 WIP commit SHA, once recorded — see Commit Strategy;
never drop a given cycle's key on a subsequent phase-transition write)hypothesis-log.md: running hypothesis log (updated at Phase 3, after Phase 4 results)synthesis-report.md: latest synthesis report (written after Synthesis completes)implementation-details.md: cumulative record of implementation attempts — what was tried, which files changed, regressions encountered, why it failed (appended after each Phase 4)where-else-state.md: Phase 4.5 state — pre-Phase-4.5 SHA, generalized pattern, siblings found/fixed/remaining (written during Phase 4.5, read during compaction recovery)scope-check-<cycle>.md (where <cycle> is the hypothesis cycle count, the same N as pre-debug-fix-cycle-N): Phase 4.4 state for the current hypothesis cycle — verdict (from the closed set in Phase 4.4, including the skip/unparseable outcomes), flagged paths, and confidence, or the reason no usable verdict exists (written after Phase 4.4 runs or is skipped, read during compaction recovery)At each phase transition, in addition to writing session state files, emit a Compression State Block into the conversation. The block captures the reasoning layer (goal, decisions, constraints, next steps) that the session state files do not.
Emit a Compression State Block at:
Context hygiene: After synthesis completes, raw Phase 1 investigation reports are superseded by the synthesis report. The orchestrator should rely on the synthesis report going forward, not the raw reports. After Phase 4 completes (success or failure), the Phase 2 pattern analysis report is superseded by the implementation results. This keeps the orchestrator lean across long sessions.
Compaction recovery:
0. Check for handoff manifests (handoff-*-to-*.md) in the scratch directory. If the most recent manifest exists, use its Inputs, Decisions, and Constraints to reconstruct state for the current phase — this supersedes session state files for phase-boundary recovery. If no manifest exists, continue with standard recovery.
phase-state.md to determine current phase and cycle.hypothesis-log.md for hypothesis history.synthesis-report.md for latest investigation findings.implementation-details.md for prior fix attempts.
scope-check-<cycle>.md for the current hypothesis cycle (if it exists) — written for every Phase 4.4 outcome, including SKIPPED-BELOW-THRESHOLD, SKIPPED-NO-WIP-COMMIT, SKIPPED-HEAD-MISMATCH, and UNPARSEABLE, not only a usable judge verdict — so a resumed run knows Phase 4.4 already ran (or was correctly skipped) for this cycle and does not re-dispatch the scope judge blindly — presence means Phase 4.4 is done for this cycle and Phase 4.5 may proceed, EXCEPT when the recorded outcome is SKIPPED-NO-WIP-COMMIT or SKIPPED-HEAD-MISMATCH, which are halts, not completions: do not proceed to Phase 4.5. For SKIPPED-NO-WIP-COMMIT, resolve the commit failure, then re-enter Phase 4.4 from the top for this cycle and overwrite the file. For SKIPPED-HEAD-MISMATCH, resolve per case (a) or (b) as applicable, overwrite scope-check-<cycle>.md with the resulting outcome, before proceeding.where-else-state.md (if exists) for Phase 4.5 progress — which siblings have been fixed, which remain.Cleanup: Delete scratch directory and .pipeline-active marker after debugging completes (Phase 5 passes clean or escalation to user).
At major phase boundaries (0→1, Synthesis→3, 3.5→4, 4.5→5), write a handoff manifest to the scratch directory instead of emitting a Compression State Block. The manifest defines exactly what the next phase needs — an allowlist. Everything not on the manifest is shed.
Format:
# Phase Handoff: N → M
**Timestamp:** ISO-8601
**Goal:** [original bug report, verbatim]
## Inputs for Phase M
- **[Input name]:** [disk path or inline value]
## Decisions Carried Forward
- [DEC-N] [decision]: [reasoning, one line]
## Active Constraints
- [constraint affecting remaining work]
## Shed Receipt
- [what was shed] → [where it lives on disk]
Rules:
## Compression State in pipeline-status.md with manifest contents.NO FIXES WITHOUT ROOT CAUSE INVESTIGATION FIRST
If you haven't dispatched Phase 1 investigation and received findings back, you cannot propose fixes. If you haven't received a synthesis report, you cannot form a hypothesis. If you haven't formed a hypothesis, you cannot dispatch implementation.
Use for ANY technical issue:
Use this ESPECIALLY when:
Don't skip when:
All investigation and implementation is delegated to subagents via the Agent tool. The orchestrator handles hypothesis formation, dispatch decisions, and escalation -- nothing else.
| Phase | Agent | Model | Rationale |
|---|---|---|---|
| Phase 1 | Error Analysis | Opus | Deep code reading and call-chain tracing |
| Phase 1 | Change Analysis | Opus | Cross-file diff analysis |
| Phase 1 | Evidence Gathering | Opus | Multi-component data flow tracing |
| Phase 1 | Reproduction | Opus | Complex reproduction requires reasoning |
| Phase 1 | Deep Dive (any) | Opus | Specialized investigation |
| Synthesis | Consolidation | Opus | Cross-referencing, contradiction detection, and causal reasoning — not just summarization |
| Phase 2 | Pattern Analysis | Opus | Exhaustive comparison requires depth |
| Phase 4 | Implementation | Opus | TDD + root cause fix |
| Phase 4.4 | Scope judge | Sonnet | Semantic traceability check — hypothesis text vs. fix diff, no repo context |
| Phase 4.5 | "Where Else?" scan | Opus | Cross-codebase pattern matching and sibling fixing |
| Phase 5 | Red-team | Opus | Adversarial analysis |
| Phase 5 | Code review | Opus or Sonnet | Lead decides by fix complexity |
| Phase 5 | Test gap writer | Opus | Test authoring requires reasoning |
Bug reported / test failure / unexpected behavior
|
v
Orchestrator: Parse initial context (error message, failing test, user description)
|
v
Phase 0: Repro & scope coherence gate (pass silently / ask one question / flag-and-proceed)
| then Load codebase context (crucible:cartographer-skill)
|
v
Phase 1: Dispatch 3-6 parallel investigation subagents
| +-- Error Analysis agent (always)
| +-- Change Analysis agent (always)
| +-- Evidence Gathering agent (conditional -- multi-component systems)
| +-- Reproduction agent (conditional -- intermittent/unclear bugs)
| +-- Deep Dive agents (conditional -- 1-2 focused on specific subsystems)
|
v
Synthesis agent: Consolidate all Phase 1 findings -> concise root-cause analysis
|
v
Phase 2: Pattern Analysis agent (skipped if synthesis identified obvious root cause)
|
v
Phase 3: Orchestrator forms hypothesis (no subagent -- lightweight decision-making)
|
v
Phase 3.5: Hypothesis Red-Team (crucible:quality-gate on hypothesis)
| -> Survives? Proceed to Phase 4.
| -> Torn apart? Reform hypothesis or loop back to Phase 1.
|
v
Phase 4: Implementation agent (TDD: failing test, fix, verify)
|
v
Orchestrator: Verify fix -> Success? Phase 4.4. Failed? Cleanup, log, loop back.
-> 3 failures? Escalate to user. If checkpoints exist: "Checkpoints available from prior fix cycles. Restore to a known-good state before manual investigation?"
|
v
Phase 4.4: Scope judge — did the fix stay inside the hypothesis? (skipped on small fixes; halts if no WIP commit was created, or if HEAD cannot be confirmed to be this cycle's WIP commit)
|
v
Phase 4.5: "Where Else?" scan — find and fix sibling locations
|
v
Phase 5: Quality-gate the fix (crucible:quality-gate) + Code review (crucible:temper)
|
v
Test Gap Writer (if reviews flagged missing coverage)
|
v
Done.
Before any dispatch work, check for a crashed prior debugging session:
<scratch>/.pipeline-active (where <scratch> is ~/.claude/projects/<hash>/memory/)pipeline_id set to current session ID, skill set to "debugging", phase set to "0", start_time set to current ISO-8601 timestamp, scratch_dir and dispatch_dir paths, branch from git branch --show-current, baseline_sha from git rev-parse HEAD). Proceed to Phase 0.pipeline_id: Compaction recovery (existing behavior). Do not re-write the marker.pipeline_id: Previous debugging session crashed. Check marker's branch against current branch — if mismatched, warn the user which branch the crashed session was on. Present to user:
"Previous debugging session on branch [marker.branch] crashed. Start fresh? [yes]" Delete the stale marker. Write a fresh marker. Proceed to Phase 0. (Full replay orchestration for debugging is deferred -- detection and cleanup only for now.)
Marker cleanup: Delete .pipeline-active after debugging completes (Phase 5 passes clean or escalation to user), alongside the existing scratch directory cleanup.
Repro & scope coherence gate (runs first, before context load). Before spending the cartographer load and a 3–6-way parallel Opus investigation, confirm the report carries the minimum signal to aim it. This is a cheap, orchestrator-local check — no subagent — against the bug report / user description for three coherence signals:
Decision (best-effort and fast — a well-formed report passes silently with zero added friction):
pass.asked-then-proceeded. When running autonomously — this debugging run was itself dispatched by a parent orchestrator via a dispatch file (no human typed the bug report), or you are otherwise unsure whether a human is in the loop — do NOT block: proceed and apply the Reproduction-lead routing in the next bullet (defaulting toward proceed here is what keeps an autonomous pipeline from hanging on an unanswered question).repro-lead-proceeded.The gate routes toward debugging's own Phase 1 Reproduction investigator from the front door; it never silently blocks — it either passes, asks exactly one clarifying question, or flags-and-proceeds (the recorded [DEC-N] outcome line below IS the flag — there is no separate surfaced warning), mirroring the best-effort discipline of the grudge pre-flight below. Record the gate outcome (pass | asked-then-proceeded | repro-lead-proceeded) as a [DEC-N] line under ## Decisions Carried Forward in the Phase 0→1 handoff, so Synthesis and later phases see why Reproduction was prioritized.
Before any investigation dispatch, use crucible:cartographer-skill (load mode) to pull module context for the area being investigated. If module files exist, include them in every investigator's dispatch file so agents start with structural knowledge instead of wasting turns rediscovering the codebase.
Defect signature loading (for investigators):
defect-signatures/*.md (excluding *.non-matches.md) from the cartographer storage directoryModules field and match against the investigation area's modules:
Path: fieldPath: valueModules directory prefixes[DEFECT_SIGNATURES] section of investigator-prompt.md:
Last loaded update: Loading is pure-read. After all investigator dispatches complete, batch-update the Last loaded field to today on all signatures that were loaded.Grudge pre-flight (regression-oracle, #271): Also query the Book of Grudges for the files under investigation and include any matches in the investigators' dispatch files — a past regression on these files is a prime hypothesis. Resolve the helper by absolute path from the plugin root — plugin_root="$(realpath "<this-skill-base-dir>/../..")" — and run python3 "$plugin_root/scripts/grudge_query.py" <files under investigation…>. Best-effort: if unresolved, emit a one-line stderr warning and continue — never block the investigation. See skills/grudge/SKILL.md.
If cartographer data doesn't exist for the relevant area, dispatch a quick Explore agent (subagent_type="Explore", requested profile fast; Claude Code maps it to model: haiku) to map the relevant directories and note key files. Include its findings in investigator prompts.
Check the project's CLAUDE.md for a ## Debugging Domains table:
| Signal | Domain | Skills | Context |
|--------|--------|--------|---------|
| file paths contain `/UI/`, `USS`, `VisualElement` | ui | mockup-builder, mock-to-unity, ui-verify | docs/mockups/ |
| error mentions `GridWorld`, `Tile`, `hex` | grid | - | grid system architecture |
Signal types: File path patterns (regex against paths in error/stack trace), error message patterns (regex against error text), user description keywords. Evaluate signals in order; load context for all matching domains.
When domain is detected:
When no domain table exists: Proceed normally. Domain detection is opt-in.
When a referenced skill doesn't exist: Log a warning and proceed without domain enrichment. Never fail on missing config.
Before dispatching investigation agents:
handoff-0-to-1.md with:
## Compression State in pipeline-status.md.Prompt template: ./investigator-prompt.md
Dispatch 3-6 investigation subagents in parallel using the Agent tool in a single message. All subagents use subagent_type="general-purpose" and request the high profile; Claude Code maps that to model: opus. Pass all known context (error messages, stack traces, file paths, user description, and cartographer module context from Phase 0) verbatim to each agent -- do not make them search for context you already have.
Bias toward MORE agents, not fewer. Each investigator is cheap. Missing a root cause is expensive. When in doubt about whether to dispatch an additional agent, dispatch it.
Always dispatch:
Error Analysis Agent -- Read error messages, stack traces, and logs. Identify the exact failure point, error codes, and what the error is telling us. Trace the call chain backward to the originating bad value.
Change Analysis Agent -- Check recent changes via git diff, recent commits, new dependencies, config changes, and environmental differences. Identify what changed that could cause this.
Conditionally dispatch (lean toward dispatching):
Evidence Gathering Agent -- For multi-component systems (CI pipelines, API chains, layered architectures). Add diagnostic instrumentation at component boundaries. Log what enters and exits each component. Run once, report where the data flow breaks.
Reproduction Agent -- For intermittent, timing-dependent, or unclear bugs. Attempt to reproduce consistently. Document exact steps, frequency, and conditions. If not reproducible, gather more data rather than guessing.
Deep Dive Agent(s) -- For bugs touching multiple subsystems, dispatch 1-2 additional agents each focused on a specific subsystem or code path. Give each a narrow scope: "Investigate how [specific subsystem] handles [specific scenario]." These agents read deeply into a single area rather than scanning broadly.
Dependency/Environment Agent -- For bugs that might be caused by version mismatches, missing registrations, configuration drift, or framework behavior changes. Check DI registrations, package versions, framework release notes, and environment state.
| Bug Characteristics | Agents to Dispatch |
|---|---|
| Test failure with clear stack trace | Error + Change + Deep Dive (on the failing subsystem) |
| Vague "something broke" across multiple systems | All six agent types |
| Intermittent / timing-dependent issue | Error + Change + Reproduction + Deep Dive |
| Multi-layer system failure (CI, API chain) | Error + Change + Evidence Gathering + Deep Dive per layer |
| Performance regression | Error + Change + Evidence Gathering + Deep Dive (hot path) |
| "It worked yesterday" | Error + Change + Dependency/Environment |
| Framework/library update broke things | Error + Change + Dependency/Environment + Deep Dive |
Every investigation subagent prompt MUST include the context self-monitoring block from ./investigator-prompt.md. Investigators reading large codebases are prime candidates for context exhaustion. If an agent hits 50%+ utilization with significant investigation remaining, it must report partial findings immediately rather than silently degrading.
Prompt template: ./synthesis-prompt.md
After all Phase 1 agents report back, dispatch a single Synthesis agent (requested profile high; Claude Code maps it to model: opus) that receives all Phase 1 reports verbatim.
Trust-but-verify: The synthesis agent does NOT take investigator claims at face value. It cross-references findings between agents, flags contradictions, and identifies claims that lack concrete evidence (file paths, line numbers, stack traces). Speculative findings are downgraded. Concrete artifacts outrank plausible theories.
The Synthesis agent produces:
Skip-ahead rule: If all Phase 1 agents converge on the same root cause with concrete evidence (not just speculation) and the Synthesis agent confirms it as obvious, the orchestrator may skip Phase 2 and proceed directly to Phase 3 (hypothesis formation).
Prompt template: ./pattern-analyst-prompt.md
Dispatch a single Pattern Analysis agent that receives the synthesis report.
The Pattern Analysis agent:
When to skip: The orchestrator skips Phase 2 when the synthesis report identifies an obvious root cause with high confidence (all investigation agents agree, clear evidence chain).
Before the orchestrator forms a hypothesis (whether Phase 2 ran or was skipped):
handoff-synthesis-to-3.md with:
## Compression State in pipeline-status.md.This phase stays local to the orchestrator. No subagent dispatch.
The orchestrator:
Hypothesis discipline:
Maintain a running log across cycles:
## Cycle 1
- Hypothesis: "[specific hypothesis]"
- Based on: [which reports informed this]
- Result: [filled in after Phase 4 completes]
## Cycle 2
- Hypothesis: "[specific hypothesis]"
- Based on: [which reports informed this]
- Result: [filled in after Phase 4 completes]
Before dispatching the Phase 4 implementer, invoke crucible:quality-gate on the hypothesis with artifact type "hypothesis".
The quality gate challenges:
dead_ends)If hypothesis survives: Proceed to Phase 4. If hypothesis is torn apart: Reform the hypothesis or dispatch additional investigation (back to Phase 1) without wasting a full TDD cycle.
Before dispatching the implementation agent:
handoff-3.5-to-4.md with:
## Compression State in pipeline-status.md.RECOMMENDED SUB-SKILL: Use crucible:checkpoint — create checkpoint with reason "pre-debug-fix-cycle-N" (where N is the hypothesis cycle count) before dispatching the implementation agent. If the fix attempt fails or introduces regressions, this checkpoint allows clean rollback without relying on WIP commit revert mechanics.
Prompt template: ./implementer-prompt.md
Dispatch a single Implementation agent that receives:
implementation-details.md in the scratch directory)The Implementation agent follows strict TDD:
Implementation discipline:
crucible:test-driven-development for proper TDD workflow.After Phase 4 completes, if the implementer modified any files, create a WIP commit regardless of outcome:
git commit -m "fix(wip): [hypothesis summary]" # on success
git commit -m "fix(wip-failed): [hypothesis summary]" # on failure or regressions
Immediately after the commit succeeds, record its SHA (git rev-parse HEAD) to
phase-state.md as wip-sha-<cycle>: (this cycle's key) — this is the durable record
Phase 4.4's gate (1) cites as its comparison operand, so it survives a compaction between
this commit and Phase 4.4.
This gives every outcome path a clean revert target (git revert <sha>), gives Phase 5 code review a real diff, and isolates Phase 5 test modifications from the core fix. If the full pipeline succeeds, the final commit message is amended to drop the (wip) prefix. If Phase 5 requires changes (test audit updates, gap test additions), those are committed as separate follow-up commits.
On loop-back (failed fix or user-requested revert), git revert <wip-sha-cycle> (this cycle's recorded SHA) cleanly undoes all Phase 4 changes including new files.
If Phase 4.5 ran (sibling commits exist): use git revert <pre-4.5-sha>..HEAD instead of git revert <wip-sha-cycle>. This reverts all sibling commits plus the original WIP commit in one operation. See Phase 4.5 below.
Phase 4.5 sibling commits: Each sibling fix uses the prefix fix(sibling): with a descriptive message. Example: fix(sibling): add icon initialization to StashScreen.OnEnable
Prototype of shared/dispatch-convention.md → Scope Anchoring, tier 2 (#562).
EXPERIMENTAL. This phase is a #562 spike prototype, not a hardened pattern, and is
advisory-only: it runs the judge, records the verdict to disk, and surfaces it — it
never reverts, resets, or re-dispatches anything, so there is no destructive step for a
crash to interrupt. Its accuracy numbers come from a different input shape than the one
it actually feeds the judge (see "Unmeasured input shape" below), and its output format
has a known, declared conflict with shared/return-convention.md (see
shared/dispatch-convention.md's Scope Anchoring section). Do not copy this phase into
another skill until those gaps are closed.
Phase 4's implementation discipline ("ONE change at a time. No 'while I'm here' improvements. No bundled refactoring.") is prose the implementer is asked to honor with nothing checking it. Tier 1 (a pre-declared file allow-list) does not apply here — the hypothesis names a root cause, not the file set the fix will need. This phase adds a read-only check: it flags likely scope expansion for a human, or a later review phase, to weigh — it does not act on what it finds.
Unmeasured input shape: the #562 spike's six cases all used issue/finding text
(request-shaped, with an enumerable ask list); none used a Phase 3 hypothesis (a causal
assertion with no enumerable ask list). This adoption feeds the judge a hypothesis, the
one input shape the spike never measured — so the spike's accuracy numbers do not
transfer to it unexamined. Treat the first several runs as calibration: compare the
verdict against what Phase 5's red-team flags. This is a primed cross-check, not an
independent one — the Phase 4.5→5 handoff already carries the Phase 4.4 [DEC-N]
(flagged paths and confidence) into Phase 5's context (see Phase Handoff: 4.5 → 5 below),
so a systematic bias toward unrequested-expansion on a single-item ask list can be
masked if the red-teamer's own read is anchored on having seen the judge's flags first.
Weigh agreement accordingly.
One rule governs when this phase runs: Phase 4.4 runs immediately before Phase 4.5,
whenever the pipeline is about to reach Phase 4.5. (The SKIPPED-NO-WIP-COMMIT branch
of gate (1) below is a defensive fallback for the case where Commit Strategy's own
guarantee — a WIP commit always gets created — somehow did not hold; it does not describe
a normal path into this phase.)
In practice that is the "Fix works, no regressions" outcome in Loop-back, Cleanup, and
Escalation below — the only outcome that proceeds to Phase 4.5. It does not run on
either loop-back path: not on the regression path ("Fix works but introduces regressions"
— the original fix stays, but the pipeline starts a new investigation cycle instead of
proceeding to Phase 4.5; that retained fix is never scope-judged by Phase 4.4 — the judge
only ever sees the current cycle's HEAD commit against the current cycle's hypothesis, so
a later cycle's own success reaches Phase 4.4 judging only that later cycle's own WIP
commit, and the retained fix is reviewed by Phase 5 only), and not on the fix-failed path
(the WIP commit is reverted, so there is nothing left to scope). It runs again on the
Phase 4 of whichever cycle next reaches the success outcome, judging that cycle's own WIP
commit against its own hypothesis.
Evaluate the two gates below in this order — (1) then (2) — never (2) first:
(1) Requires a Phase 4 WIP commit, and it must be HEAD. Phase 4.4 only runs on the
"Fix works, no regressions" outcome, which is exactly the outcome where the Commit
Strategy above always creates a WIP commit (the implementer modified files to fix the
bug). The "test passes immediately, bug already resolved" outcome is a different
Loop-back outcome — it bypasses Phase 4.4 (and Phase 4.5) entirely on its own terms, not
because no WIP commit exists for the case this phase actually handles. Confirm identity,
not just existence: git rev-parse HEAD must equal phase-state.md's wip-sha-<cycle>:
for the current cycle only (see Commit Strategy above, which records it immediately
after the WIP commit succeeds) — HEAD alone is not proof, since it silently resolves to
whatever commit came before if the WIP commit was never created, or to a later commit if
one landed on top (e.g. a pre-commit hook's auto-fix commit, or the "preserve reproduction
test" commit pattern used elsewhere in this skill). A wip-sha-<cycle>: belonging to any
other cycle is never a valid comparison operand or case-(a) operand for this cycle's gate
(1) — treat it as absent. This gate has two distinct failure modes, and each gets its own
outcome token and remedy — do not conflate them:
SKIPPED-NO-WIP-COMMIT — the Commit Strategy step itself observably failed for this
cycle (e.g. git commit exited non-zero, a pre-commit hook blocked it), and no WIP
commit was created at all. If this happens, write SKIPPED-NO-WIP-COMMIT to
scope-check-<cycle>.md (see "Record the outcome" below) and STOP: the commit failure
must be resolved (retry after fixing the hook failure, or escalate) before Phase
4.5, which requires the WIP commit's SHA. Phase 4.4 does not itself resolve it. If the
commit failure is resolved and the WIP commit is created, re-enter Phase 4.4 from the
top for this cycle and overwrite scope-check-<cycle>.md with the resulting outcome.SKIPPED-HEAD-MISMATCH — the identity check cannot confirm HEAD is this cycle's
WIP commit, for either of two reasons: (a) phase-state.md has a wip-sha-<cycle>: for
this cycle but it is not HEAD — e.g. a pre-commit hook appended a follow-up commit, or
the implementer made a second commit on top; or (b) phase-state.md has no
wip-sha-<cycle>: for this cycle at all (including when only a prior cycle's key is
present — that is never a valid operand for this cycle, per gate (1) above) and the
Commit Strategy step was not observed to fail — the identity operand is missing, and
HEAD cannot supply it, since a value read from HEAD is not evidence about HEAD. Do
not attempt to recover wip-sha-<cycle>: mechanically from git log -1 or any other
inspection of HEAD in case (b). Neither case is a commit failure (in (a) a commit
exists; in (b) no commit failure was observed; if one was observed, this is
SKIPPED-NO-WIP-COMMIT, above) — do not apply the SKIPPED-NO-WIP-COMMIT remedy
(telling the user to fix a hook failure that did not occur is itself the defect this
token exists to avoid). If this happens, write SKIPPED-HEAD-MISMATCH to
scope-check-<cycle>.md. For (a): either evaluate gate (2) against the recorded
wip-sha-<cycle>: (git show --numstat --format='' <wip-sha-cycle> in place of HEAD)
and, if it passes, judge that commit directly (git show --format='' <wip-sha-cycle> in
place of HEAD), or escalate. For (b): there is no recorded commit to judge directly —
escalate, naming the missing wip-sha-<cycle>: as the cause, and ask the user to
confirm which commit is this cycle's WIP commit before Phase 4.4 proceeds. Record the
confirmed SHA to phase-state.md as wip-sha-: before proceeding — it is the
operand Phase 4.5 and the Loop-back revert paths read. Once the remedy resolves — gate
(2) resolves to a judged verdict or a below-threshold skip, or the escalation settles on
one — overwrite scope-check-<cycle>.md with the resulting outcome (IN-SCOPE,
SCOPE-EXPANSION, UNPARSEABLE, or SKIPPED-BELOW-THRESHOLD) so the recovery key
records the completed check, not the resolved mismatch.Both are outcomes that do not terminate the phase for the cycle in the ordinary
done-for-this-cycle sense — see the exception in "Record the outcome" and Compaction
Recovery below. Do not evaluate gate (2) against HEAD until this gate passes; case (a)'s
remedy above is the only route by which gate (2) may be evaluated against a different
operand, and it is permitted.
(2) Runs when the Phase 4 WIP commit (confirmed by gate (1) to be HEAD) is
non-trivial: >1 non-test file changed OR >40 changed lines (insertions + deletions,
from git show --numstat --format='' HEAD) in non-test files. (--numstat gives full,
unabbreviated paths and insertions/deletions
as two summable integers, unlike --stat, which truncates long paths; count a binary
file as one changed non-test file with 0 lines, and use the post-rename path for
classification when --numstat reports a rename.) A test file is a file whose
basename matches test_*, *_test.*, *.test.*, *.spec.*, *_spec.*, *Test.*,
*Tests.*, or (in this repo) check_* (Crucible's structural checkers), or whose path
contains a tests/, test/, spec/, __tests__/ or evals/ segment — a purpose-based
rule, not an invocation-based one: scripts/run_tests.sh invokes plenty of production
scripts (e.g. scripts/rcpt_verify.py --selftest) that are not themselves test files, and
classifying everything it invokes as a test file would make the below-threshold branch
swallow diffs that should be judged. A path following a test convention this list does not
name still counts as a test file; when genuinely ambiguous, count it as a non-test
file — the cost of running the judge unnecessarily is bounded; the cost of skipping it is
losing the check entirely. Phase 4's TDD cycle guarantees at least one
test file plus one source file on every fix, so counting test files toward the threshold
would make the "below this, skip" branch unreachable. Below the threshold the judge's
fixed cost outweighs what it can find — skip it, writing SKIPPED-BELOW-THRESHOLD to
scope-check-<cycle>.md rather than skipping silently, so a resumed run knows why no
judge ran this cycle. This threshold assumes a Sonnet judge; no agent def binds that tier
today (harness-adapter.md Mapping 1b — prose model words are descriptive, not binding),
so an orchestrator on a larger model pays proportionally more and the threshold is
correspondingly miscalibrated (see shared/dispatch-convention.md's Cost paragraph).
Ordering is load-bearing: Phase 4.4 runs AFTER the Phase 4 WIP commit and BEFORE Phase 4.5. Phase 4.5 fixes analogous siblings by design; a judge shown only the original hypothesis would flag every sibling commit as unrequested expansion. Judge the Phase 4 fix alone.
Dispatch one judge (model tier sonnet) using shared/scope-judge-prompt.md, disk-
mediated per shared/dispatch-convention.md. It receives exactly two substitutions and
nothing else:
{{TASK}} — the hypothesis text as it stood when Phase 4 was dispatched for this cycle
(i.e. the post-Phase-3.5 reform if the hypothesis was reformed, and this cycle's entry
if the pipeline has looped back), verbatim (not the investigation
synthesis, not the implementation report, not the implementation-details log){{DIFF}} — git show --format='' HEAD, the Phase 4 WIP commit's own diff (Phase 4.4
runs immediately after that commit, so HEAD names it directly — no dependence on the
undefined <pre-fix-sha> placeholder used elsewhere in this skill). --format=''
suppresses the commit message, which matters for the same reason the judge gets no
other repo context: a commit message states the author's own rationalization of the
change, which is exactly what the judge must not see.The verdict is advisory only. The judge returns VERDICT: IN-SCOPE | SCOPE-EXPANSION,
a flagged path list, per-hunk classifications, and a confidence (see
shared/scope-judge-prompt.md's ## Confidence section — Phase 4.4 gates no
tree-modifying action on confidence, at any level. The one place confidence is
consulted is routing: CONFIDENCE: low is an unusable return per the canonical trigger
list below, and is recorded as UNPARSEABLE). If the
return is unusable (unparseable per the canonical trigger list in
shared/dispatch-convention.md's Scope Anchoring tier
2, "Reading the verdict" — do not re-specify that list here): record a
[DEC-N] line noting the scope check did not produce a usable verdict, write
UNPARSEABLE to scope-check-<cycle>.md (see "Record the outcome" below), and proceed to
Phase 4.5. Do not re-dispatch the judge; do not block on it.
Record the outcome to disk before proceeding, for every branch above (judge ran,
skipped below threshold, skipped for no WIP commit, skipped for a HEAD mismatch, or
unparseable) — <scratch-dir>/scope-check-<cycle>.md (the session scratch directory
/tmp/crucible-debug-<session-id>/, same as the other Session State files — do not use
the <scratch> token, which names the persistent memory directory instead), holding one
verdict from the closed set {IN-SCOPE, SCOPE-EXPANSION, UNPARSEABLE, SKIPPED-BELOW-THRESHOLD, SKIPPED-NO-WIP-COMMIT, SKIPPED-HEAD-MISMATCH} plus a
one-line reason, and — when the judge actually ran — the flagged path list and
confidence. Writing the file on every branch, not only when the judge produced a usable
verdict, is what makes it a reliable recovery marker: compaction recovery keys on this
file's presence for the current cycle (see Compaction Recovery below) to know Phase
4.4 already ran (or was correctly skipped) for this cycle and must not be re-dispatched —
a file written only on some branches would let a resumed run silently re-run Phase 4.4 on
the branches that didn't write one, defeating "one-shot check by design." There is
nothing destructive to resume into either way, since Phase 4.4 never modifies the tree.
Presence means done and Phase 4.5 may proceed, except when the recorded outcome is
SKIPPED-NO-WIP-COMMIT or SKIPPED-HEAD-MISMATCH — both are transient/blocking by
design (see gate (1) above) and must be resolved (and, for either halt token, overwritten
once it is resolved — see gate (1) above for what each token's remedy overwrites the file
with) rather than treated as a terminal record that clears the cycle to proceed.
IN-SCOPE → record a [DEC-N] line and proceed to Phase 4.5.SCOPE-EXPANSION → record a [DEC-N] line naming the flagged paths and the verdict's
confidence, surface the verdict to the user, and proceed to Phase 4.5. Phase 4.4
never reverts, resets, re-dispatches the implementer, or otherwise modifies the tree —
at any confidence level. The flagged paths are information for the orchestrator and
for Phase 5's red-teamer to weigh, not a trigger for action, and Phase 4.4 has no
interaction with the 3-failure escalation counter: it never counts as, and never
causes, a Phase 4 fix attempt.Either way, record the [DEC-N] line under Decisions Carried Forward in the Phase
4.5→5 handoff. Known gap: the 4.5→5 Phase Handoff Manifest's Inputs for Phase 5
allowlist does not yet name the scope-check file itself, so the red-teamer sees the
decision but not the judge's full classification output — do not assume it is visible
unless the orchestrator surfaces it directly. This is a known gap in the #562 prototype,
not yet filed as a follow-up issue.
The judge never edits anything and never re-runs. One dispatch, one verdict.
RECOMMENDED SUB-SKILL: Use crucible:checkpoint — create checkpoint with reason "pre-where-else" before dispatching the scan agent. This replaces the need to manually track the pre-Phase-4.5 SHA for revert mechanics — the checkpoint captures the full working directory state.
After Phase 4 succeeds, the WIP commit is created, and Phase 4.4 has recorded an outcome other than SKIPPED-NO-WIP-COMMIT or SKIPPED-HEAD-MISMATCH (see Phase 4.4's gate (1) above — either of those two outcomes is a halt, not a completion, and must be resolved before Phase 4.5 can run), dispatch the "Where Else?" scan agent to find and fix analogous locations in the codebase that have the same bug pattern. Phase 4.5 does NOT run on loop-back paths (fix failed, regressions found).
Prompt template: ./where-else-prompt.md
Pre-Phase-4.5 SHA: Immediately after the Phase 4 WIP commit succeeds, record its SHA. This is the last commit before any sibling work begins. Store it in where-else-state.md in the scratch directory.
The scan agent receives three sources of information:
git diff <pre-fix-sha>..HEAD. The structural pattern of what changed: what was missing, what was added, and what makes a location "analogous."When dispatching the Phase 4.5 scan agent, load matching defect signatures from cartographer as additional context:
Last loaded: never as oldest. Sort by Last loaded descending. Tiebreak by Date descending.Path: field; match if any target file path starts with the module's Path: value. Fall back to directory prefix matching if no cartographer modules exist.fix(sibling): <description>where-else-state.md in the scratch directory## Where Else? Scan Report
### Generalized Pattern
[2-3 sentence pattern description]
### Candidates Evaluated: N
### Siblings Fixed: N
- [file:path] — [commit SHA] — Justification: [why this matches]
- ...
### Siblings Skipped: N
- [file:path] — Reason: [why this doesn't match]
- ...
### Siblings Reverted: N
- [file:path] — Test failure: [summary of what failed]
- ...
Phase 4.5 maintains state in <scratch-dir>/where-else-state.md to survive session compaction. The file is updated after each sibling fix. On compaction recovery, the agent reads this file to:
After the Phase 4.5 scan agent reports back, persist the scan results as a cartographer defect signature. This is orchestrator-managed — the recorder only writes files.
Skip condition: Do not write a signature when Phase 4.5 reports "No analogous locations found" (0 candidates evaluated). A pattern with no siblings and no non-matches has no evaluation ledger worth persisting.
Step 1: Dedup check (orchestrator)
~/.claude/projects/<hash>/memory/cartographer/defect-signatures/*.md (excluding *.non-matches.md)## Generalized Pattern section only (each is 2-3 sentences; 20 patterns is ~1000-1500 tokens)update_path to the existing file path (the recorder will merge into it rather than creating new)Step 2: Pre-write pruning (orchestrator) When count of existing signatures would exceed 20 after writing:
Last loaded: never AND Date is less than 30 days oldLast loaded date ascending; Last loaded: never sorts oldestDate fieldStep 3: Dispatch recorder (orchestrator)
Dispatch a Sonnet cartographer recorder agent using crucible:cartographer-skill recorder-prompt.md with the "Record defect signature" directive. Provide:
update_path if dedup found a match (from Step 1)Step 4: Post-recorder validation (orchestrator) After the recorder returns, validate:
Modules field contains valid cartographer module names or directory prefixes
If validation fails, log the failure — the signature is not surfaced to consumers.Step 5: Rename on merge (orchestrator)
If update_path was provided (merge case): rename the file to use today's date prefix while keeping the original slug. YYYY-MM-DD-<slug>.md becomes <today>-<slug>.md. If a companion non-match file exists, rename it to match. This ensures merged signatures do not lose age protection.
Ordering: Dispatch the recorder and wait for completion, then perform the Last loaded batch update (see below). This prevents write races between the recorder and the batch update targeting the same file.
Last loaded batch update: After all subagent dispatches for the current phase complete (including the recorder), batch-update the Last loaded field on all defect signatures that were loaded during Phase 0 or Phase 4.5. The recorder sets Last loaded to today on update_path writes, so skip those files during the batch update.
Over-count recovery: If count exceeds 20 after a failed prune (e.g., all signatures are age-protected), the next invocation's pre-recorder pruning pass cleans up before writing.
Before invoking the quality gate on the fix:
handoff-4.5-to-5.md with:
git diff <pre-fix-sha>..HEAD), conventions path, test file paths, Where Else report path (or "no siblings found"), defect signature path (if written)[DEC-N]## Compression State in pipeline-status.md.RECOMMENDED SUB-SKILL: Use crucible:checkpoint — create checkpoint with reason "pre-debug-gate" before invoking the quality gate. If gate fix rounds degrade the fix, this is the rollback target.
After Phase 4.5 completes (or Phase 4 succeeds if no Phase 4.5 ran), the orchestrator runs quality gates before declaring done:
Step 1: Quality-gate the fix — Invoke crucible:quality-gate with artifact type "code" against the changed code. Quality-gate dispatches fresh red-team reviewers to adversarially review the fix for:
Quality-gate handles iteration tracking, stagnation detection, compaction recovery, and user checkpoints. Do NOT invoke crucible:red-team directly — always go through quality-gate for iteration management.
Step 2: Code review — After red-teaming passes clean, invoke crucible:temper against the full diff (from before debugging started to HEAD). The code reviewer checks implementation quality, test coverage, and adherence to project conventions.
If code review finds Critical or Important issues, fix them and re-review per the standard code review loop.
Step 2.5: Test suite audit — Invoke crucible:test-coverage (if available) against the changed code and affected test files. This audits whether existing tests need updating, removal, or modification after the fix. Three categories:
If crucible:test-coverage is not available, skip this step. The test gap writer (Step 3) handles missing coverage but NOT stale/misleading existing tests — this step fills that gap.
The test-coverage skill handles its own fix dispatch and revert-on-failure logic internally. It returns a structured report with actions taken.
Step 3: Test gap writer — If the code reviewer or red-teamer identified missing test coverage for the fix, dispatch a Test Gap Writer agent (Opus) using ./test-gap-writer-prompt.md. Input: reviewer gap findings + fix diff + test-coverage audit report (if available from Step 2.5). The agent writes tests only for gaps specifically flagged in the review — no scope creep. Before writing a new test for a flagged gap, verify no existing test already covers this path (it may have been updated by the test-coverage audit). Tests should PASS immediately since the behavior already exists from the fix. The agent reports per-test PASS/FAIL results. Skipped when reviews report zero coverage gaps.
If all tests PASS: Debugging workflow is complete.
Record the grudge (regression-oracle, #271). Once the root cause is confirmed and the fix is verified, record a grudge so this bug can never silently re-ship. Best-effort (a failed record logs to stderr and never fails the workflow): resolve the helper by absolute path from the plugin root — plugin_root="$(realpath "<this-skill-base-dir>/../..")" — and run python3 "$plugin_root/scripts/grudge_append.py" --symptom "<observable failure>" --root-cause "<confirmed cause>" --files "<comma-separated files_touched>" --signature "<optional regex/snippet fingerprint>" --commit "$(git rev-parse HEAD)" --repro "<minimal repro>" --why "<why it kept happening>". See skills/grudge/SKILL.md.
If some tests FAIL (gaps reveal incomplete fix coverage):
fix: address test gap failures for debugging fix), debugging workflow is completeIf Phase 5 quality-gate escalates (stagnation or round limit): Present the quality-gate findings to the user alongside the fix. The user decides:
<pre-4.5-sha>..HEAD if Phase 4.5 ran) and loop back to Phase 1 with the quality-gate findings as new investigation contextThis is user-gated, not automatic. The orchestrator does not decide whether to loop back from Phase 5 on its own.
Only after all gates pass clean (and any test gaps are filled or escalated) is the debugging workflow complete.
Throughout the debugging session, the orchestrator appends timestamped entries to /tmp/crucible-metrics-<session-id>.log.
Dispatch measurement protocol: On every subagent dispatch, the orchestrator follows the enriched manifest protocol from shared/dispatch-convention.md:
input_chars and model_tier in the manifest entry.output_chars and tool_calls (if available) in the manifest completion entry.At completion, read the metrics log and manifest, then compute and report:
-- Debugging Complete ---------------------------------------
Subagents dispatched: 12 (8 Opus, 4 Sonnet)
Active work time: 1h 15m
Wall clock time: 3h 42m
Hypothesis cycles: 3
Quality gate rounds: 2 (hypothesis: 1, fix: 1)
Est. input tokens: ~15,200 (60,800 chars)
Est. output tokens: ~9,800 (39,200 chars)
Token estimate note: Based on dispatch file sizes (chars/4). Actual consumption may vary +/-30%.
-------------------------------------------------------------
Additional debugging metric: hypothesis cycles (number of hypothesis → investigate → implement cycles before resolution).
Efficiency summary computation: Read manifest.jsonl from the dispatch directory. Sum input_chars and output_chars across all completed entries (skip nulls). Divide each by 4 for token estimates. Count comparable dispatches grouped by model_profile; report raw model_tier separately when useful. Include these in the debugging completion report alongside existing metrics.
Maintain a decision journal at /tmp/crucible-decisions-<session-id>.log:
[timestamp] DECISION: <type> | choice=<what> | reason=<why> | alternatives=<rejected>
Decision types:
investigator-count — why N investigators dispatchedskip-phase-2 — why Phase 2 was skipped (or not)gate-round — hypothesis red-team results per roundescalation — why orchestrator escalatedhypothesis-reform — why hypothesis was reformed after red-teamscope-check — Phase 4.4 verdict and, on SCOPE-EXPANSION, flagged pathsAfter the Implementation agent reports back, the orchestrator evaluates four possible outcomes:
Fix works, no regressions -- Log the result in the hypothesis log. Proceed to Phase 4.4 (scope check), then Phase 4.5 ("Where Else?" blast radius scan). After Phase 4.5 completes, proceed to Phase 5. After Phase 5 passes clean:
v=1, ts=now, skill="debugging", outcome from fix verification,
duration_m from session timing, branch from git, files_touched from git diff --name-only,
metrics={hypotheses count, root_cause_category from fix, where_else_hits count}~/.claude/projects/<hash>/memory/chronicle/signals.jsonlTest passes immediately (no fix applied) -- The implementer's reproduction test passed before any fix was written. Two possibilities:
git revert <wip-sha-cycle>, this cycle's recorded SHA) to remove the non-reproducing test. Loop back to Phase 3 to reform the hypothesis, or Phase 1 if the root cause itself is in question.Fix works but introduces regressions -- Start a new investigation cycle targeting the regressions. The original fix stays; the regressions are a new bug. This path does not proceed to Phase 4.5, so Phase 4.4 does not run on it either (see Phase 4.4's "One rule governs when this phase runs" rule above) — the retained original fix is reviewed by Phase 5's red-team, not by Phase 4.4, whenever the pipeline eventually reaches Phase 5. Critical: Pass the original bug context (hypothesis, fix applied, original root cause) to the new investigation agents as background context, with the constraint: "The original fix must not be reverted. Investigate why the fix caused regressions and propose an additive solution."
Fix does not resolve the issue -- Before looping back:
git revert <wip-sha-cycle> (this cycle's recorded SHA; see Commit Strategy above). This cleanly undoes all Phase 4 changes including any new files created during refactoring. If Phase 4.5 ran (sibling commits exist): use git revert <pre-4.5-sha>..HEAD instead of git revert <wip-sha-cycle> to revert all sibling commits plus the original WIP commit.
git checkout <wip-sha-cycle> -- <test-file-path>) and commit it separately (test: preserve reproduction test from cycle N).git status and report any remaining modifications or untracked files. If any remain, clean them up before proceeding.Context Preservation: Session state is written to disk at every phase transition (see Session State and Compaction Recovery above). On failed cycles, additionally append implementation details (fix attempted, files changed, regressions, why it failed) to implementation-details.md in the scratch directory. This gives the next Phase 4 implementer actionable context about what was tried at the code level, not just the hypothesis level.
Stagnation ownership: The debugging skill's stagnation detector owns cycle-to-cycle decisions (loop back vs escalate). Quality-gate's stagnation detector owns within-gate decisions (round-to-round within a single Phase 3.5 or Phase 5 invocation). When quality-gate escalates within a gate (e.g., hypothesis keeps getting torn apart), the debugging orchestrator counts that as a failed cycle and updates the hypothesis log accordingly before deciding whether to loop back. Quality-gate history from prior invocations does not carry over — each gate invocation starts fresh.
Track a stagnation metric across cycles — the hypothesis specificity score:
| Metric | What to Track |
|---|---|
| Root causes identified | How many distinct root causes were surfaced across all investigators |
| Evidence strength | How many findings had concrete evidence (file:line, stack trace, git blame) vs speculation |
| New information | Did this cycle surface information that was NOT available in prior cycles? |
Stagnation rule: If Cycle N+1 surfaces no new information compared to Cycle N (same root causes, same evidence, same gaps), the orchestrator STOPS and escalates immediately. Do not dispatch Cycle N+2 — the investigation is stuck, not progressing.
Confirm before auto-escalating on judgment-call stagnation. The "no new information" test is unambiguous when both sides are identical (zero new evidence, zero new files touched, identical hypothesis list) — auto-escalate in that case. But when Cycle N+1 surfaced some new content that the orchestrator judges immaterial ("technically a new file but same module", "another instance of the same null check"), surface the side-by-side comparison to the user before escalating:
[debugging] Stagnation candidate — Cycle N vs N+1:
- Cycle N hypotheses: <list>
- Cycle N+1 hypotheses: <list>
- New evidence in N+1: <delta or "none material in my judgment">
Escalate to user, or dispatch Cycle N+2 with a different angle?
The user has context the model lacks about which "new" findings are actually load-bearing for their mental model. Default-on-away: escalate (matches the conservative-on-stuck instinct). The zero-delta auto-escalate path stays silent.
| Cycle | Action |
|---|---|
| 1 | Normal flow — dispatch 3-6 investigators |
| 2 | Loop back with learnings. Dispatch MORE agents than Cycle 1. Explicitly exclude paths already ruled out. |
| 3 | Final attempt — investigation agents are instructed to look for something fundamentally different from previous hypotheses. Add Deep Dive agents targeting areas not yet investigated. |
| 4 | No dispatch. Present the full hypothesis log to the user. Flag as likely architectural problem. Discuss fundamentals before attempting more fixes. |
Stagnation overrides cycle count: If stagnation is detected at any cycle (even Cycle 2), escalate immediately rather than waiting for Cycle 4.
Pattern indicating architectural problem (Cycle 4 or stagnation escalation):
This is NOT a failed hypothesis -- this is a wrong architecture. Discuss with your human partner before attempting more fixes.
| Phase | Agent(s) | Key Activities | Success Criteria |
|---|---|---|---|
| 0. Context | Cartographer + optional Explore | Load module context for investigators | Codebase context ready for prompts |
| 1. Investigation | 3-6 parallel subagents (Opus) | Read errors, check changes, gather evidence, deep dive, reproduce | Raw findings collected |
| Synthesis | 1 subagent (Opus) | Consolidate, cross-reference, rank by evidence quality | Concise root-cause analysis |
| 2. Pattern | 1 subagent (Opus, skippable) | Find working examples, compare exhaustively | Differences identified |
| 3. Hypothesis | Orchestrator (no subagent) | Form hypothesis, check log | Specific testable hypothesis |
| 3.5 Red-Team | Quality gate (on hypothesis) | Challenge hypothesis completeness | Hypothesis survives or is reformed |
| 4. Implementation | 1 subagent (Opus) | TDD fix cycle with evidence log | Bug resolved, tests pass, TDD log |
| 4.4. Scope Check | 1 subagent (Sonnet, advisory) | Judge whether the Phase 4 fix stayed inside the hypothesis (sub-phase of 4→4.5; skipped on small fixes) | Verdict recorded to disk; never blocks on the judge's verdict (halts if the Phase 4 WIP commit was never created, or if HEAD cannot be confirmed against phase-state.md's wip-sha-:) |
| 4.5. Where Else? | 1 subagent (Opus) + 1 recorder (Sonnet) | Find and fix sibling locations; persist defect signature | Siblings fixed, signature written (if 1+ candidates) |
| 5. Quality Gate | Red-team + code review | Adversarial review, quality check | Both pass clean |
| 5b. Test Audit | Test coverage skill (conditional) | Audit existing tests for staleness after fix | Stale tests updated/removed |
| 5c. Test Gaps | Test gap writer (Opus, conditional) | Write tests for reviewer-flagged gaps | All gap tests pass |
This skill produces hypotheses (Phase 3.5) and fixes (Phase 5).
When used standalone: Debugging is the outermost orchestrator and MUST invoke quality-gate at Phase 3.5 (on hypotheses) and Phase 5 (on fixes). These gates are non-negotiable regardless of fix size — a "one-liner" fix is not exempt.
When used as a sub-skill: The parent orchestrator is responsible for dispatching gates (per the Invocation Convention: "Skills NEVER self-invoke quality-gate"). If you are unsure whether you are standalone or a sub-skill, invoke the gate — double-gating is preferable to no gating.
The only legitimate skip is at Phase 5 when there is no code change (bug was already resolved). Do not extrapolate from this — it applies only to the specific "no code change" scenario, not to "small" or "trivial" changes.
Gate tracking: Before declaring done, verify that Phase 3.5 (hypothesis gate) and Phase 5 (fix gate, unless legitimately skipped for no-code-change) each show round count >= 1 with clean final rounds. If any gate was skipped with explicit user approval, record it as USER_SKIP.
If you catch yourself thinking:
Orchestrator discipline violations:
Communication violations:
Classic debugging traps (still apply):
Quality gate violations:
Compression State violations:
ALL of these mean: STOP. Return to the correct phase.
If 3+ cycles failed: Escalate to user. Question the architecture. Do not dispatch Cycle 4 agents.
Watch for these redirections:
When you see these: STOP. Return to Phase 1. Dispatch fresh investigation.
| Excuse | Reality |
|---|---|
| "Issue is simple, don't need process" | Simple issues have root causes too. Process is fast for simple bugs. |
| "Emergency, no time for process" | Systematic debugging is FASTER than guess-and-check thrashing. |
| "Just try this first, then investigate" | First fix sets the pattern. Do it right from the start. |
| "I'll write test after confirming fix works" | Untested fixes don't stick. Test first proves it. |
| "Multiple fixes at once saves time" | Can't isolate what worked. Causes new bugs. |
| "Reference too long, I'll adapt the pattern" | Partial understanding guarantees bugs. Read it completely. |
| "I see the problem, let me fix it" | Seeing symptoms does not equal understanding root cause. |
| "One more fix attempt" (after 2+ failures) | 3+ failures = architectural problem. Question pattern, don't fix again. |
| "Let me just peek at the code real quick" | Orchestrators dispatch, they don't investigate. Send a subagent. |
| "I'll dispatch implementation without a hypothesis" | No hypothesis = no direction. The agent will guess. Form the hypothesis first. |
The rationalizations above are self-originated — you talking yourself out of process. The traps below are user-originated — the user (reasonably, in good faith) providing a diagnosis that tempts you to skip investigation. These are harder to resist because accommodating the user feels helpful.
| User says | You think | Reality |
|---|---|---|
| "I found the bug, here's the fix" | "Their analysis looks right, I'll verify quickly and apply" | User diagnoses are hypotheses, not conclusions. Verify independently — plausible ≠ confirmed. |
| "The stack trace points right to it" | "The evidence is clear, skip to fix" | Stack traces show where errors surface, not where they originate. The throw site is often a symptom, not the cause. |
| "This is blocking N engineers" | "Speed matters more than process right now" | A wrong fix under time pressure creates two problems: the original bug plus the bad fix. Systematic debugging is faster than guess-and-check, especially under pressure. |
| "Same bug as last sprint" | "Apply the same fix pattern" | Same symptom ≠ same cause. The prior fix may have been incomplete, or a different root cause produces identical symptoms. |
| "Just add error handling around it" | "That'll prevent the crash at least" | Error handling that silences the symptom is camouflage, not a fix. The root cause persists and will surface elsewhere. |
| "It's obviously X, I just need you to fix it" | "The user has more context, trust their judgment" | Trust their observations (symptoms, timeline, reproduction steps). Verify their conclusions (root cause, fix). These are different things. |
| "We can investigate later, just patch it now" | "Pragmatism — ship the fix, investigate in a follow-up" | 'Investigate later' means 'never investigate.' The patch becomes the permanent fix. Do it right now. |
If systematic investigation reveals issue is truly environmental, timing-dependent, or external:
But: 95% of "no root cause" cases are incomplete investigation. Dispatch more agents before concluding this.
Prompt templates (used when dispatching subagents):
./investigator-prompt.md -- Phase 1 investigation agent prompt./synthesis-prompt.md -- Synthesis agent prompt./pattern-analyst-prompt.md -- Phase 2 pattern analysis agent prompt./implementer-prompt.md -- Phase 4 implementation agent prompt./where-else-prompt.md -- Phase 4.5 "Where Else?" scan agent prompt./test-gap-writer-prompt.md -- Phase 5 test gap writer prompt (when reviews flag missing coverage)Supporting techniques (available in this directory):
root-cause-tracing.md -- Trace bugs backward through call stack to find original triggerdefense-in-depth.md -- Add validation at multiple layers after finding root causecondition-based-waiting.md -- Replace arbitrary timeouts with condition pollingRelated skills:
crucible:test-driven-development -- Implementation agent follows TDD for Phase 4crucible:verify -- Verify fix worked before claiming successcrucible:parallel -- Phase 1 parallel dispatch patterncrucible:quality-gate -- Adversarial review in Phase 5 (iteration tracking, stagnation detection, compaction recovery)crucible:red-team -- Invoked indirectly via quality-gate (stagnation detection pattern also used in loop-back)crucible:test-coverage -- Phase 5 Step 2.5: audit existing tests for staleness, needed updates, or removal after the fix (if available)Does not dispatch /recon or /assay -- uses specialized investigation agents (Error Analysis, Change Analysis, Evidence Gathering, Reproduction) that are categorically different from structural investigation. Hypothesis evaluation uses quality-gate, not assay. See #147 for rationale.
Required skills:
crucible:cartographer-skill -- Phase 0: load module context for investigators and defect signatures. Phase 4 completion: record discoveries. Phase 4.5 completion: persist defect signature via recorder dispatch.Recommended skills:
crucible:forge -- Retrospective after fix verified (captures debugging lessons)crucible:checkpoint -- Shadow git checkpoints before implementation, sibling fixes, and quality gate (pre-debug-fix-cycle-N, pre-where-else, pre-debug-gate). Provides structured rollback for fix attempts and sibling work.From debugging sessions:
condition-based-waiting.md (opens in a new tab)defense-in-depth.md (opens in a new tab)evals/evals.json (opens in a new tab)implementer-prompt.md (opens in a new tab)investigator-prompt.md (opens in a new tab)pattern-analyst-prompt.md (opens in a new tab)root-cause-tracing.md (opens in a new tab)synthesis-prompt.md (opens in a new tab)test-gap-writer-prompt.md (opens in a new tab)where-else-prompt.md (opens in a new tab)What SKILL.md sets; muted values are Claude Code's defaults
Generated from the plugin's indexed repository (raddue/crucible) — no native marketplace selected
npx claudepluginhub p/raddue-crucible51 skills in this plugin
/adrWrite, supersede, and maintain Architecture Decision Records (docs/decisions/) for technical choices that had real, seriously-considered alternatives and would be costly to reverse. Use on "write an ADR", "record this decision", or when recording a choice that a design or PR already settled. Matches the target repo's existing ADR convention before imposing one, and declines with a reason when a decision does not meet the bar — not for routine design docs, implementation plans, session handoffs, the pre-push/merge wrap-up itself (that belongs to `finish` / `merge-pr`), or answering "why did we choose X" from an ADR that already exists (that's a read, owned by `recall` / `recon`)./adversarial-testerUse after completing an implementation to find unknown failure modes. Reads the implementation diff and writes up to 5 tests designed to make it break — per-task, scoped to that single implementation (for a fully-assembled multi-component feature, use inquisitor to hunt cross-component bugs). Triggers on 'break it', 'adversarial test', 'stress test implementation', 'find weaknesses', or any task seeking to expose unknown failure modes in a single implementation./assayRecon-informed approach evaluator. Weighs competing options against codebase constraints and returns structured recommendations with confidence scoring, kill criteria, and evidence grounding. Consumes recon briefs or caller context. Used by design, spec, migrate. Triggers on /assay, 'evaluate approaches', 'which option', 'compare alternatives'./auditAdversarial review of code subsystems or non-code artifacts (design docs, plans, concepts) through parallel analytical lenses. Triggers on 'audit', 'review subsystem', 'audit this design', 'review this plan', 'audit concept', 'check the save system', 'examine the UI code', or any task requesting adversarial review of existing artifacts./buildUse when starting any feature development, building new functionality, implementing a design, or going from idea to working code. Triggers on "build", "implement", "add feature", or any task requiring design-through-execution./cartographer-skillUse when exploring unfamiliar code and want to persist what you learn, when starting a task and want to consult known codebase structure, or when collaborators need module-specific context for implementation or reviewOther plugins' skills for the same job