| name | debugging |
| description | Systematic root cause analysis — find the cause before fixing. |
| needs | ["verification"] |
Debugging
Iron Law: NO FIXES WITHOUT ROOT CAUSE INVESTIGATION.
Phase 1: Root Cause
Before any fix:
- Read error completely — stack traces, line numbers, error codes
- Reproduce consistently — exact steps to trigger
- Check recent changes —
git diff, new deps, config changes
- Trace data flow — where does the bad value originate?
Multi-component tracing:
grep -rn "VARIABLE_NAME" src/
git log --oneline -10
git diff HEAD~3 -- src/module/
Stack trace when lost:
import traceback; traceback.print_stack()
Phase 2: Pattern Analysis
- Find working examples in codebase:
grep -rn "working_pattern" src/
- Read reference implementation completely
- Identify ALL differences between working and broken
- Understand dependencies and assumptions
Phase 3: Hypothesis
- State: "I think X is root cause because Y"
- Make SMALLEST possible change
- Test ONE variable at a time
- If 3+ fixes failed → question architecture
Phase 4: Implement + Defense-in-Depth
- Create failing test case
- Implement single fix (no "while I'm here" changes)
- Verify fix works using
verification skill
- Add validation at every layer:
| Layer | Purpose |
|---|
| Entry | Reject invalid input at boundary |
| Business Logic | Ensure data makes sense for operation |
| Environment | Prevent dangerous operations in context |
| Debug | Capture context for forensics |
Red Flags — STOP
- "Quick fix for now"
- "Just try changing X"
- "Add multiple changes at once"
- "I don't fully understand but this might work"
- One more fix (when 2+ already failed)
All mean: Return to Phase 1. If 3+ failed → question architecture.