Systematic Debugging
Iron Law
code
NO FIXES WITHOUT ROOT CAUSE INVESTIGATION FIRST
Haven't completed Phase 1? Cannot propose fixes.
Phase 1: Root Cause Investigation
BEFORE attempting ANY fix:
- •Read error messages carefully — full stack trace, line numbers, error codes. Don't skip past them.
- •Reproduce consistently — exact steps, every time. Not reproducible? Gather more data, don't guess.
- •Check recent changes — git diff, recent commits, new deps, config changes.
- •Gather evidence at boundaries — in multi-component systems, log what enters/exits each component. Run once to see WHERE it breaks.
- •Trace data flow — where does the bad value originate? Trace backward to source.
Phase 2: Pattern Analysis
- •Find similar WORKING code in the codebase
- •Compare working vs broken — list every difference
- •Don't assume "that can't matter"
Phase 3: Hypothesis and Fix
- •State hypothesis: "X is root cause because Y"
- •Make the SMALLEST change to test it
- •ONE variable at a time
- •Didn't work? New hypothesis. Don't stack fixes.
Phase 4: Verification
- •Create failing test reproducing the bug (use TDD skill)
- •Apply fix
- •Test passes? Other tests still pass? Done.
- •Test fails? Back to Phase 1 with new info.
If 3+ fixes failed: STOP. Question the architecture. Discuss with user before attempting more.
Red Flags — STOP, Return to Phase 1
- •"Quick fix for now, investigate later"
- •"Just try changing X and see"
- •"I don't fully understand but this might work"
- •Proposing solutions before reading error messages
- •"One more fix attempt" after 2+ failures
- •Each fix reveals new problem in different place
Common Rationalizations
| Excuse | Reality |
|---|---|
| "Issue is simple" | Simple issues have root causes too |
| "Emergency, no time" | Systematic is faster than thrashing |
| "Just try this first" | First fix sets the pattern. Do it right. |
| "I see the problem" | Seeing symptoms ≠ understanding root cause |