Systematic Debugging
Overview
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.
Violating the letter of this process is violating the spirit of debugging.
The Iron Law
NO FIXES WITHOUT ROOT CAUSE INVESTIGATION FIRST
If you haven't completed Phase 1, you cannot propose fixes.
Anti-Rationalization Table
| Rationalization |
Reality |
| "I'll figure it out as I go" |
A structured approach saves time and reduces errors. Follow the workflow in this skill rather than improvising. |
| "I already know this topic" |
Familiarity breeds shortcuts. Use the checklist to verify you haven't missed critical steps. |
| "This doesn't apply to my situation" |
The patterns here generalize across contexts. Adapt, don't skip — the underlying principles hold. |
| "One more tool will fix it" |
Adding complexity rarely solves process gaps. Master the core workflow first. |
When to Use
Trigger phrases:
"systematic debugging"
"Any bug, test failure, or unexpected behavior"
"Performance problems"
"Build failures"
Any bug, test failure, or unexpected behavior
Performance problems
Build failures
Use especially when:
- Under time pressure
- "Quick fix" seems obvious
- Previous fix didn't work
Four Phases
- Configure before, behavior, debugging, encountering, failure settings before first use
Phase 1: Root Cause Investigation
- Read errors carefully — Don't skip warnings
- Reproduce consistently — Can you trigger reliably?
- Check recent changes — What changed recently?
- Trace data flow — Find where bad value originates
- Add diagnostics — In multi-component systems
Phase 2: Pattern Analysis
- Find working examples in codebase
- Compare against references
- Identify differences
Phase 3: Hypothesis & Testing
- Form hypothesis: "X is root cause because Y"
- Test with smallest change
- Verify before continuing
- If unknown, say "I don't know"
Phase 4: Implementation
Create failing test first
Fix ONE thing at a time
Verify fix works
If 3+ fixes failed → question architecture
- Is this pattern fundamentally sound?
- Are we "sticking with it through sheer inertia"?
- Should we refactor architecture vs. continue fixing symptoms?
Discuss with your human partner before attempting more fixes
This is NOT a failed hypothesis - this is a wrong architecture.
Red Flags - STOP and Follow Process
If you catch yourself thinking:
- "Quick fix for now, investigate later"
- "Just try changing X and see if it works"
- "Add multiple changes, run tests"
- "Skip the test, I'll manually verify"
- "It's probably X, let me fix that"
- "I don't fully understand but this might work"
- "Pattern says X but I'll adapt it differently"
- "Here are the main problems: [lists fixes without investigation]"
- Proposing solutions before tracing data flow
- "One more fix attempt" (when already tried 2+)
- Each fix reveals new problem in different place
ALL of these mean: STOP. Return to Phase 1.
If 3+ fixes failed: Question the architecture (see Phase 4.5)
your human partner's Signals You're Doing It Wrong
Watch for these redirections:
- "Is that not happening?" - You assumed without verifying
- "Will it show us...?" - You should have added evidence gathering
- "Stop guessing" - You're proposing fixes without understanding
- "Ultrathink this" - Question fundamentals, not just symptoms
- "We're stuck?" (frustrated) - Your approach isn't working
When you see these: STOP. Return to Phase 1.
Common Rationalizations
| Excuse |
Reality |
| "Issue is simple, don't need process" |
Simple issues have root causes too. Process is fast for simple bugs. |
| "Emergency, no time for process" |
Systematic debugging is FASTER than guess-and-check thrashing. |
| "Just try this first, then investigate" |
First fix sets the pattern. Do it right from the start. |
| "I'll write test after confirming fix works" |
Untested fixes don't stick. Test first proves it. |
| "Multiple fixes at once saves time" |
Can't isolate what worked. Causes new bugs. |
| "Reference too long, I'll adapt the pattern" |
Partial understanding guarantees bugs. Read it completely. |
| "I see the problem, let me fix it" |
Seeing symptoms ≠ understanding root cause. |
| "One more fix attempt" (after 2+ failures) |
3+ failures = architectural problem. Question pattern, don't fix again. |
Quick Reference
| Phase |
Key Activities |
Success Criteria |
| 1. Root Cause |
Read errors, reproduce, check changes, gather evidence |
Understand WHAT and WHY |
| 2. Pattern |
Find working examples, compare |
Identify differences |
| 3. Hypothesis |
Form theory, test minimally |
Confirmed or new hypothesis |
| 4. Implementation |
Create test, fix, verify |
Bug resolved, tests pass |
When Process Reveals "No Root Cause"
If systematic investigation reveals issue is truly environmental, timing-dependent, or external:
- You've completed the process
- Document what you investigated
- Implement appropriate handling (retry, timeout, error message)
- Add monitoring/logging for future investigation
But: 95% of "no root cause" cases are incomplete investigation.
Supporting Techniques
These techniques are part of systematic debugging and available in this directory:
root-cause-tracing.md - Trace bugs backward through call stack to find original trigger
defense-in-depth.md - Add validation at multiple layers after finding root cause
condition-based-waiting.md - Replace arbitrary timeouts with condition polling
Related skills:
- superpowers:test-driven-development - For creating failing test case (Phase 4, Step 1)
- superpowers:verification-before-completion - Verify fix worked before claiming success
Real-World Impact
From debugging sessions:
- Systematic approach: 15-30 minutes to fix
- Random fixes approach: 2-3 hours of thrashing
- First-time fix rate: 95% vs 40%
- New bugs introduced: Near zero vs common
When to Use
- Any bug, test failure, or unexpected behavior
- Before proposing any fix
- When something isn't working as expected
- Performance issues or crashes
When NOT to Use
- Quick exploratory work where root cause doesn't matter
- When you're just gathering information
- For confirming known issues (already have root cause)
Common Mistakes
- Fixing symptoms instead of root cause
- Making changes without understanding why they work
- Random trial-and-error debugging
- Not documenting what you tried
- Skipping the reproduction step
- Accepting "works now" without understanding why
Red Flags
- Agent applies fixes without understanding the root cause
- Debug output is left in production code after the fix
- Watch for shortcuts and skipped steps
Verification
After completing this skill, confirm:
Process
- Analyze the task requirements
- Apply domain expertise
- Verify output quality
1---2name: systematic-debugging3description: Use when encountering any bug, test failure, or unexpected behavior, before proposing fixes4license: Apache-2.05---6789# Systematic Debugging1011## Overview1213Random fixes waste time and create new bugs. Quick patches mask underlying issues.1415**Core principle:** ALWAYS find root cause before attempting fixes. Symptom fixes are failure.1617**Violating the letter of this process is violating the spirit of debugging.**1819## The Iron Law2021```22NO FIXES WITHOUT ROOT CAUSE INVESTIGATION FIRST23```2425If you haven't completed Phase 1, you cannot propose fixes.262728## Anti-Rationalization Table2930| Rationalization | Reality |31|---|---|32| "I'll figure it out as I go" | A structured approach saves time and reduces errors. Follow the workflow in this skill rather than improvising. |33| "I already know this topic" | Familiarity breeds shortcuts. Use the checklist to verify you haven't missed critical steps. |34| "This doesn't apply to my situation" | The patterns here generalize across contexts. Adapt, don't skip — the underlying principles hold. |35| "One more tool will fix it" | Adding complexity rarely solves process gaps. Master the core workflow first. |3637## When to Use3839**Trigger phrases:**40- "systematic debugging"41- "Any bug, test failure, or unexpected behavior"42- "Performance problems"43- "Build failures"4445- Any bug, test failure, or unexpected behavior46- Performance problems47- Build failures4849**Use especially when:**50- Under time pressure51- "Quick fix" seems obvious52- Previous fix didn't work5354## Four Phases5556- Configure before, behavior, debugging, encountering, failure settings before first use575859### Phase 1: Root Cause Investigation60611. **Read errors carefully** — Don't skip warnings622. **Reproduce consistently** — Can you trigger reliably?633. **Check recent changes** — What changed recently?644. **Trace data flow** — Find where bad value originates655. **Add diagnostics** — In multi-component systems6667### Phase 2: Pattern Analysis68- Find working examples in codebase69- Compare against references70- Identify differences7172### Phase 3: Hypothesis & Testing731. Form hypothesis: "X is root cause because Y"742. Test with smallest change753. Verify before continuing764. If unknown, say "I don't know"7778### Phase 4: Implementation791. Create failing test first802. Fix ONE thing at a time813. Verify fix works824. If 3+ fixes failed → question architecture83 - Is this pattern fundamentally sound?84 - Are we "sticking with it through sheer inertia"?85 - Should we refactor architecture vs. continue fixing symptoms?8687 **Discuss with your human partner before attempting more fixes**8889 This is NOT a failed hypothesis - this is a wrong architecture.9091## Red Flags - STOP and Follow Process9293If you catch yourself thinking:94- "Quick fix for now, investigate later"95- "Just try changing X and see if it works"96- "Add multiple changes, run tests"97- "Skip the test, I'll manually verify"98- "It's probably X, let me fix that"99- "I don't fully understand but this might work"100- "Pattern says X but I'll adapt it differently"101- "Here are the main problems: [lists fixes without investigation]"102- Proposing solutions before tracing data flow103- **"One more fix attempt" (when already tried 2+)**104- **Each fix reveals new problem in different place**105106**ALL of these mean: STOP. Return to Phase 1.**107108**If 3+ fixes failed:** Question the architecture (see Phase 4.5)109110## your human partner's Signals You're Doing It Wrong111112**Watch for these redirections:**113- "Is that not happening?" - You assumed without verifying114- "Will it show us...?" - You should have added evidence gathering115- "Stop guessing" - You're proposing fixes without understanding116- "Ultrathink this" - Question fundamentals, not just symptoms117- "We're stuck?" (frustrated) - Your approach isn't working118119**When you see these:** STOP. Return to Phase 1.120121## Common Rationalizations122123| Excuse | Reality |124|--------|---------|125| "Issue is simple, don't need process" | Simple issues have root causes too. Process is fast for simple bugs. |126| "Emergency, no time for process" | Systematic debugging is FASTER than guess-and-check thrashing. |127| "Just try this first, then investigate" | First fix sets the pattern. Do it right from the start. |128| "I'll write test after confirming fix works" | Untested fixes don't stick. Test first proves it. |129| "Multiple fixes at once saves time" | Can't isolate what worked. Causes new bugs. |130| "Reference too long, I'll adapt the pattern" | Partial understanding guarantees bugs. Read it completely. |131| "I see the problem, let me fix it" | Seeing symptoms ≠ understanding root cause. |132| "One more fix attempt" (after 2+ failures) | 3+ failures = architectural problem. Question pattern, don't fix again. |133134## Quick Reference135136| Phase | Key Activities | Success Criteria |137|-------|---------------|------------------|138| **1. Root Cause** | Read errors, reproduce, check changes, gather evidence | Understand WHAT and WHY |139| **2. Pattern** | Find working examples, compare | Identify differences |140| **3. Hypothesis** | Form theory, test minimally | Confirmed or new hypothesis |141| **4. Implementation** | Create test, fix, verify | Bug resolved, tests pass |142143## When Process Reveals "No Root Cause"144145If systematic investigation reveals issue is truly environmental, timing-dependent, or external:1461471. You've completed the process1482. Document what you investigated1493. Implement appropriate handling (retry, timeout, error message)1504. Add monitoring/logging for future investigation151152**But:** 95% of "no root cause" cases are incomplete investigation.153154## Supporting Techniques155156These techniques are part of systematic debugging and available in this directory:157158- **`root-cause-tracing.md`** - Trace bugs backward through call stack to find original trigger159- **`defense-in-depth.md`** - Add validation at multiple layers after finding root cause160- **`condition-based-waiting.md`** - Replace arbitrary timeouts with condition polling161162**Related skills:**163- **superpowers:test-driven-development** - For creating failing test case (Phase 4, Step 1)164- **superpowers:verification-before-completion** - Verify fix worked before claiming success165166## Real-World Impact167168From debugging sessions:169- Systematic approach: 15-30 minutes to fix170- Random fixes approach: 2-3 hours of thrashing171- First-time fix rate: 95% vs 40%172- New bugs introduced: Near zero vs common173174## When to Use175176- Any bug, test failure, or unexpected behavior177- Before proposing any fix178- When something isn't working as expected179- Performance issues or crashes180181## When NOT to Use182183- Quick exploratory work where root cause doesn't matter184- When you're just gathering information185- For confirming known issues (already have root cause)186187## Common Mistakes188189- Fixing symptoms instead of root cause190- Making changes without understanding why they work191- Random trial-and-error debugging192- Not documenting what you tried193- Skipping the reproduction step194- Accepting "works now" without understanding why195196## Red Flags197198- Agent applies fixes without understanding the root cause199- Debug output is left in production code after the fix200- Watch for shortcuts and skipped steps201202## Verification203204After completing this skill, confirm:205206- [ ] Root cause is identified and documented before applying fixes207- [ ] Debug output is removed from production code208- [ ] All required outputs generated209- [ ] Success criteria met210211## Process2122131. Analyze the task requirements2142. Apply domain expertise2153. Verify output quality