Investigate a bug using structured differential diagnosis. Use when the user says "diagnose", "investigate this", "what's causing this", or "figure out why".
Investigate a bug systematically by gathering evidence, forming multiple hypotheses, and testing each before proposing any fix. This prevents the "guess and fix" anti-pattern.
Gather the symptom from $ARGUMENTS or ask the user. Document:
Collect evidence — read logs, error output, and relevant source code:
docs/LINEAR_SNAPSHOT.md for related tracked bugsgit log --oneline -20 and git diff HEAD~5Form hypotheses — generate 2-4 distinct possible causes:
Hypothesis 1: [cause] — Evidence for: [X] | Evidence against: [Y]
Hypothesis 2: [cause] — Evidence for: [X] | Evidence against: [Y]
Hypothesis 3: [cause] — Evidence for: [X] | Evidence against: [Y]
Test each hypothesis — for each one, find confirming or disconfirming evidence:
Report findings in structured format:
## Diagnosis: [symptom summary]
### Evidence Collected
- [evidence 1 with file:line]
- [evidence 2 with file:line]
### Hypotheses Tested
1. [hypothesis] — [CONFIRMED/RULED OUT/INCONCLUSIVE]
Evidence: [what confirmed or ruled it out]
2. [hypothesis] — [CONFIRMED/RULED OUT/INCONCLUSIVE]
Evidence: [what confirmed or ruled it out]
### Root Cause
[Most likely cause with supporting evidence]
### Recommended Fix
[Specific fix with file:line targets]
[What could go wrong with this fix]
### What This Is NOT
[Ruled-out causes — prevents revisiting dead ends]
Record the verdict on the tracked issue. A diagnosis that stays in the session is lost — the next session re-reads the same unconfirmed theory and re-does the same work. If the bug is tracked in Linear:
linear issue comment add ENG-123 -b "**Root Cause:** CONFIRMED — <file:line>
**Reproduced by:** <exact command, steps, or test that shows the failure>
**Evidence:** <what confirmed it, with file:line or log output>
**Ruled out:** <hypotheses eliminated, and what eliminated them>
**Observed at:** <short sha> on <branch>"
CONFIRMED only when a hypothesis
reached that verdict with evidence. This status is /fix-issue's entry
condition — writing it on a theory defeats the gate./document-bug to create the issue first.Do NOT implement the fix — present the diagnosis and let the user decide.
/document-bug to log findings in Linear if the bug isn't already trackedUNCONFIRMED root cause to a
CONFIRMED one. /fix-issue will not fix a bug that has not been through it