Systematic Debugging
A structured 4-phase methodology for diagnosing and fixing non-obvious bugs. Prevents
the common failure modes of "shotgun debugging" (random changes hoping something sticks)
and "symptom patching" (fixing the visible error without understanding the cause).
When to Use
- A bug has resisted one or more quick-fix attempts
- The bug only appears in certain environments (prod but not dev, intermittent)
- The cause is unclear after an initial look
- A "fixed" bug keeps coming back
- Multiple engineers have looked at it without resolution
When NOT to Use
| Instead of systematic-debugging | Use |
|---------------------------------|-----|
| Obvious typo or off-by-one | Fix directly |
| Build/compilation failure | fix-build-errors skill |
| Performance problem (not a bug) | profiling tools |
| Security vulnerability | security-scan skill |
The 4-Phase Process
Phase 1 — Reproduce
A bug you cannot reproduce reliably cannot be debugged reliably.
Goal: Get a 100% reproducible test case that triggers the bug on demand.
# 1. Note the exact symptoms: error message, stack trace, request/response
# 2. Identify the minimum inputs that trigger it
# 3. Write a failing test that captures the reproduction
# Find the code path involved
Select-String -Path "src\\**\\*.ts" -Pattern "<error keyword>"
# Check recent changes
git --no-pager log --oneline -20
git --no-pager diff HEAD~5 -- <suspect file>
Reproduction criteria:
- [ ] Bug triggers on demand with a specific input or sequence
- [ ] Bug does NOT trigger with a slightly different (correct) input
- [ ] Reproduction is encoded as a failing test
When it is safe, run the minimal reproduction at least twice and record both commands and outputs;
one observation is not proof of reproducibility. If outcomes vary, label the reproduction status
intermittent rather than hiding the variation.
Before handing the issue to diagnosis or another session, produce a reproduction brief with:
- target and commit
- runtime, OS, lockfile, and feature flags
- expected behavior as an observation, without a cause hypothesis
- actual behavior as an observation, without a cause hypothesis
- minimal steps and fixtures
- status:
yes,no, orintermittent - commands, logs, traces, or other evidence
- unknowns and the next hypothesis to test
The brief is the handoff artifact at the reproduce-before-repair boundary already enforced here