Multi-agent diagnostic pipeline for complex/intermittent bugs. Orchestrates Investigator → Verifier → Solver → Lead Programmer with enforced handoff contracts. Use ONLY for non-obvious failures (root cause unclear, reproduction unstable, fixes reverted). NOT for trivial bugs with known cause — fix them directly.
Install with Codex or Claude Copy this prompt, paste it into Codex, Claude, or another assistant, and let it review the skill page and install it for you.
A direct command skips the review prompt. Inspect the source before running it.
Multi-agent diagnostic pipeline for complex/intermittent bugs. Orchestrates Investigator → Verifier → Solver → Lead Programmer with enforced handoff contracts. Use ONLY for non-obvious failures (root cause unclear, reproduction unstable, fixes reverted). NOT for trivial bugs with known cause — fix them directly.
paths
[]
effort
4
allowed-tools
Read, Glob, Grep, Write, Edit, Bash, Task
user-invocable
true
when_to_use
When a bug is reproducible but cause is unknown, when a 'fix' has been reverted 2+ times, or when a symptom appears in unfamiliar code. Do NOT use for typos, obvious nulls, or one-line logic errors.
{"task_id":"BUG-417","symptom":"POST /api/orders returns 500 when cart has ≥10 items","reproduction":{"steps":["...","..."],"frequency":"100% | intermittent (~30%) | once","environment":"staging-eu-west-1"},"hypothesis":{"root_cause":"OrderService.calculateTotal() N+1 query exhausts pool when cart.items.length > 9","confidence":"high | medium | low","falsifiable_by":"Run with pool_size=50; if error disappears, cause confirmed"},"evidence":[{"type":"log","ref":".investigations/BUG-417/pg-pool-exhausted.log","summary":"..."},{"type":"code","ref":"src/services/order.service.ts:142","summary":"Unbounded .map+await"}],"unknowns":["Why only eu-west-1?","When did this start?"],"next_agent":"verifier"}
Quality gate (Lead Programmer rejects if):
hypothesis.falsifiable_by is vague ("check if it works")
evidence has fewer than 2 items (unverifiable)
unknowns is empty but confidence: low (contradictory)
Stage 2 — Verification
Agent:verifierGoal: Attempt to refute the hypothesis. Only confirmed if refutation fails.
Inputs
investigation.json (from Stage 1)
Access to staging/test environment
Required output — verification.json
{"task_id":"BUG-417","status":"confirmed | refuted | inconclusive","triangulation":[{"method":"reproduce_with_fix_applied","result":"Error gone with pool_size=50"},{"method":"reproduce_without_fix","result":"Error returns at 10 items"},{"method":"adjacent_test_case","result":"9 items = OK, 10 items = fail → threshold confirmed"}],"counter_hypotheses_ruled_out":["DB slowness (ruled out: p99 < 50ms)","Network flaps (ruled out: no packet loss in window)"],"confidence":"high","recommendation":"Proceed to solver — cause confirmed necessary AND sufficient"}
Decision flow
status
Next action
confirmed
Hand off to solver
refuted
Return to investigator with counter-evidence. Max 2 round-trips.
inconclusive
STOP. Surface to user with all evidence. Do NOT proceed to solver.
Stage 3 — Solution
Agent:solverGoal: Generate 3 solution options with explicit tradeoffs; never pick silently.
Required output — solution.json
{"task_id":"BUG-417","options":[{"name":"Quick","description":"Increase pool_size from 20 → 50 in db.ts","scope_loc":1,"risk_tier":"Low","tradeoff":"Masks root cause; higher RAM; future growth hits same wall"},{"name":"Strategic","description":"Rewrite calculateTotal() to batch via IN-clause","scope_loc":40,"risk_tier":"Medium","tradeoff":"Fixes N+1 permanently; requires regression test on discount logic"},{"name":"Future-Proof","description":"Introduce DataLoader pattern across service layer","scope_loc":300,"risk_tier":"High","tradeoff":"Eliminates entire class of N+1 bugs; 2-3 day refactor; needs ADR"}],"recommendation":"Strategic — best risk/value ratio. Quick only if release is < 24h."}
Quality gate
All 3 options must have distinct scope (not three flavors of the same fix)
tradeoff must state what is sacrificed, not just "takes longer"
recommendation must cite a criterion (time budget, risk tier, blast radius)
Acceptance criteria derived from investigation.hypothesis.falsifiable_by
Append ledger entry (Rule 15) to production/traces/decision_ledger.jsonl:
{"ts":"2026-04-17T14:22:00Z","session":"main","agent_id":"lead-programmer","task_id":"BUG-417","request":"/diagnose BUG-417","reasoning":"Verified N+1 as necessary+sufficient; selected Strategic per solver recommendation","choice":"Strategic refactor of calculateTotal()","outcome":"pass","risk_tier":"Medium","duration_s":1840}
Artifact storage
All intermediate reports MUST be saved to .investigations/<task_id>/: