| name | systematic-debugging |
| description | Use when encountering any bug, test failure, or unexpected behavior before proposing fixes |
Systematic Debugging
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.
The Iron Law
NO FIXES WITHOUT ROOT CAUSE INVESTIGATION FIRST
If you haven't completed Phase 1, you cannot propose fixes.
When to Use
Use for ANY technical issue:
- Test failures
- Bugs in production
- Unexpected behavior
- Performance problems
- Build failures
- Integration issues
Use ESPECIALLY when:
- Under time pressure (emergencies make guessing tempting)
- "Just one quick fix" seems obvious
- You've already tried multiple fixes
- Previous fix didn't work
The Four Phases
Complete each phase before proceeding to the next.
Phase 1: Root Cause Investigation
BEFORE attempting ANY fix:
Read Error Messages Carefully
- Don't skip past errors or warnings
- They often contain the exact solution
- Read stack traces completely
- Note line numbers, file paths, error codes
Reproduce Consistently
- Can you trigger it reliably?
- What are the exact steps?
- Does it happen every time?
- If not reproducible → gather more data, don't guess
Check Recent Changes
- What changed that could cause this?
- Git diff, recent commits
- New dependencies, config changes
- Environmental differences
Gather Evidence
- Add diagnostic logging if needed
- Check each component boundary
- Verify data at each layer
Phase 2: Hypothesis Formation
Only after gathering evidence:
- Form a specific hypothesis about the root cause
- Predict what fixing it would change
- Identify how to verify the hypothesis
Phase 3: Minimal Fix
- Fix the ROOT CAUSE, not symptoms
- Make the smallest change possible
- Don't refactor while fixing
- One fix at a time
Phase 4: Verification
- Confirm the original issue is resolved
- Run full test suite
- Check for regressions
- Verify the fix addresses the hypothesis
After 3 Consecutive Failures
- STOP all further edits immediately
- REVERT to last known working state
- DOCUMENT what was attempted and what failed
- CONSULT Oracle with full failure context
- If Oracle cannot resolve → ASK USER
Anti-Patterns (NEVER DO)
- Shotgun debugging (random changes hoping something works)
- Fixing symptoms without understanding cause
- Multiple simultaneous changes
- Deleting failing tests to "pass"
- Leaving code in broken state