Systematic Debugging: make Claude find the cause before it fixes anything

by obra · MIT license · ★ 289,792 on GitHub · updated Sep 20

Systematic debugging cover

Systematic Debugging is a free Claude skill by obra, part of the Superpowers collection. It stops Claude from guessing at bugs: Claude has to read the error, reproduce it and trace where it starts before proposing a fix, then test one change at a time. After three failed fixes it stops and asks whether the design itself is wrong.

---
name: systematic-debugging
description: Use when encountering any bug, test failure, or unexpected behavior, before proposing fixes
---

# Systematic Debugging

## Overview

**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
```

Overview

Core principle: ALWAYS find root cause before attempting fixes. Symptom fixes are failure.

Manual install (npx, ZIP)
Claude Codenpx skills add obra/superpowers --skill systematic-debugging -g -a claude-code
Claude Code (manual)mkdir -p ~/.claude/skills && curl -sL https://codeload.github.com/obra/superpowers/tar.gz/5bf4e7801107 \ | tar -xz -C ~/.claude/skills --strip-components=2 superpowers-5bf4e7801107/skills/systematic-debugging
Windows (PowerShell)New-Item -ItemType Directory -Force "$HOME\.claude\skills" | Out-Null; Invoke-WebRequest "https://m.agentalley.io/zip/6ff76f8f8f4f9b33803a/systematic-debugging.zip" -OutFile "$env:TEMP\systematic-debugging.zip"; Expand-Archive "$env:TEMP\systematic-debugging.zip" -DestinationPath "$HOME\.claude\skills" -Force
Claude.ai / desktopDownload the ZIP and upload it under Settings → Capabilities → Skills.
Codex, Cursor, other agentsPoint them at SKILL.md. The other files are plain text.

Connects with Agent Alley MCP · agentalley.io/mcp

Files included

  • SKILL.md9.2 KB
  • CREATION-LOG.md4.2 KB
  • condition-based-waiting-example.ts4.9 KB
  • condition-based-waiting.md3.4 KB
  • defense-in-depth.md3.6 KB
  • find-polluter.sh1.9 KB
  • root-cause-tracing.md5.2 KB
  • test-academic.md653 B
  • test-pressure-1.md1.9 KB
  • test-pressure-2.md2.2 KB
  • test-pressure-3.md2.6 KB
Read the files here
obra/5bf4e7811 files
SKILL.md
Show the full text284 lines

Systematic Debugging

Overview

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.

When to Use

Use for ANY technical issue:

  • Test failures
  • Bugs in production
  • Unexpected behavior
  • Performance problems
  • Build failures
  • Integration issues

Use this 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
  • You don't fully understand the issue

Don't skip when:

  • Issue seems simple (simple bugs have root causes too)
  • You're in a hurry (rushing guarantees rework)
  • Manager wants it fixed NOW (systematic is faster than thrashing)

The Four Phases

You MUST complete each phase before proceeding to the next.

Phase 1: Root Cause Investigation

BEFORE attempting ANY fix:

  1. 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
  2. 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
  3. Check Recent Changes

    • What changed that could cause this?
    • Git diff, recent commits
    • New dependencies, config changes
    • Environmental differences
  4. Gather Evidence in Multi-Component Systems

    WHEN system has multiple components (CI → build → signing, API → service → database):

    BEFORE proposing fixes, add diagnostic instrumentation:

    For EACH component boundary:
      - Log what data enters component
      - Log what data exits component
      - Verify environment/config propagation
      - Check state at each layer
    
    Run once to gather evidence showing WHERE it breaks
    THEN analyze evidence to identify failing component
    THEN investigate that specific component
    

    Example (multi-layer system):

    # Layer 1: Workflow
    echo "=== Secrets available in workflow: ==="
    echo "IDENTITY: ${IDENTITY:+SET}${IDENTITY:-UNSET}"
    
    # Layer 2: Build script
    echo "=== Env vars in build script: ==="
    env | grep IDENTITY || echo "IDENTITY not in environment"
    
    # Layer 3: Signing script
    echo "=== Keychain state: ==="
    security list-keychains
    security find-identity -v
    
    # Layer 4: Actual signing
    codesign --sign "$IDENTITY" --verbose=4 "$APP"
    

    This reveals: Which layer fails (secrets → workflow ✓, workflow → build ✗)

  5. Trace Data Flow

    WHEN error is deep in call stack:

    See root-cause-tracing.md in this directory for the complete backward tracing technique.

    Quick version:

    • Where does bad value originate?
    • What called this with bad value?
    • Keep tracing up until you find the source
    • Fix at source, not at symptom
Phase 2: Pattern Analysis

Find the pattern before fixing:

  1. Find Working Examples

    • Locate similar working code in same codebase
    • What works that's similar to what's broken?
  2. Compare Against References

    • If implementing pattern, read reference implementation COMPLETELY
    • Don't skim - read every line
    • Understand the pattern fully before applying
  3. Identify Differences

    • What's different between working and broken?
    • List every difference, however small
    • Don't assume "that can't matter"
  4. Understand Dependencies

    • What other components does this need?
    • What settings, config, environment?
    • What assumptions does it make?
Phase 3: Hypothesis and Testing

Scientific method:

  1. Form Single Hypothesis

    • State clearly: "I think X is the root cause because Y"
    • Write it down
    • Be specific, not vague
  2. Test Minimally

    • Make the SMALLEST possible change to test hypothesis
    • One variable at a time
    • Don't fix multiple things at once
  3. Verify Before Continuing

    • Did it work? Yes → Phase 4
    • Didn't work? Form NEW hypothesis
    • DON'T add more fixes on top
  4. When You Don't Know

    • Say "I don't understand X"
    • Don't pretend to know
    • Ask for help
    • Research more
Phase 4: Implementation

Fix the root cause, not the symptom:

  1. Create Failing Test Case

    • Simplest possible reproduction
    • Automated test if possible
    • One-off test script if no framework
    • MUST have before fixing
    • Use the superpowers:test-driven-development skill for writing proper failing tests
  2. Implement Single Fix

    • Address the root cause identified
    • ONE change at a time
    • No "while I'm here" improvements
    • No bundled refactoring
  3. Verify Fix

    • Test passes now?
    • No other tests broken?
    • Issue actually resolved?
    • Use the superpowers:verification-before-completion skill before claiming success
  4. If Fix Doesn't Work

    • STOP
    • Count: How many fixes have you tried?
    • If < 3: Return to Phase 1, re-analyze with new information
    • If ≥ 3: STOP and question the architecture (step 5 below)
    • DON'T attempt Fix #4 without architectural discussion
  5. If 3+ Fixes Failed: Question Architecture

    Pattern indicating architectural problem:

    • Each fix reveals new shared state/coupling/problem in different place
    • Fixes require "massive refactoring" to implement
    • Each fix creates new symptoms elsewhere

    STOP and question fundamentals:

    • 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
  • "Ultra-think 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:

  1. You've completed the process
  2. Document what you investigated
  3. Implement appropriate handling (retry, timeout, error message)
  4. 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
1---
2name: systematic-debugging
3description: Use when encountering any bug, test failure, or unexpected behavior, before proposing fixes
4---
5 
6# Systematic Debugging
7 
8## Overview
9 
10**Core principle:** ALWAYS find root cause before attempting fixes. Symptom fixes are failure.
11 
12**Violating the letter of this process is violating the spirit of debugging.**
13 
14## The Iron Law
15 
16```
17NO FIXES WITHOUT ROOT CAUSE INVESTIGATION FIRST
18```
19 
20If you haven't completed Phase 1, you cannot propose fixes.
21 
22## When to Use
23 
24Use for ANY technical issue:
25- Test failures
26- Bugs in production
27- Unexpected behavior
28- Performance problems
29- Build failures
30- Integration issues
31 
32**Use this ESPECIALLY when:**
33- Under time pressure (emergencies make guessing tempting)
34- "Just one quick fix" seems obvious
35- You've already tried multiple fixes
36- Previous fix didn't work
37- You don't fully understand the issue
38 
39**Don't skip when:**
40- Issue seems simple (simple bugs have root causes too)
41- You're in a hurry (rushing guarantees rework)
42- Manager wants it fixed NOW (systematic is faster than thrashing)
43 
44## The Four Phases
45 
46You MUST complete each phase before proceeding to the next.
47 
48### Phase 1: Root Cause Investigation
49 
50**BEFORE attempting ANY fix:**
51 
521. **Read Error Messages Carefully**
53 - Don't skip past errors or warnings
54 - They often contain the exact solution
55 - Read stack traces completely
56 - Note line numbers, file paths, error codes
57 
582. **Reproduce Consistently**
59 - Can you trigger it reliably?
60 - What are the exact steps?
61 - Does it happen every time?
62 - If not reproducible → gather more data, don't guess
63 
643. **Check Recent Changes**
65 - What changed that could cause this?
66 - Git diff, recent commits
67 - New dependencies, config changes
68 - Environmental differences
69 
704. **Gather Evidence in Multi-Component Systems**
71 
72 **WHEN system has multiple components (CI → build → signing, API → service → database):**
73 
74 **BEFORE proposing fixes, add diagnostic instrumentation:**
75 ```
76 For EACH component boundary:
77 - Log what data enters component
78 - Log what data exits component
79 - Verify environment/config propagation
80 - Check state at each layer
81 
82 Run once to gather evidence showing WHERE it breaks
83 THEN analyze evidence to identify failing component
84 THEN investigate that specific component
85 ```
86 
87 **Example (multi-layer system):**
88 ```bash
89 # Layer 1: Workflow
90 echo "=== Secrets available in workflow: ==="
91 echo "IDENTITY: ${IDENTITY:+SET}${IDENTITY:-UNSET}"
92 
93 # Layer 2: Build script
94 echo "=== Env vars in build script: ==="
95 env | grep IDENTITY || echo "IDENTITY not in environment"
96 
97 # Layer 3: Signing script
98 echo "=== Keychain state: ==="
99 security list-keychains
100 security find-identity -v
101 
102 # Layer 4: Actual signing
103 codesign --sign "$IDENTITY" --verbose=4 "$APP"
104 ```
105 
106 **This reveals:** Which layer fails (secrets → workflow ✓, workflow → build ✗)
107 
1085. **Trace Data Flow**
109 
110 **WHEN error is deep in call stack:**
111 
112 See `root-cause-tracing.md` in this directory for the complete backward tracing technique.
113 
114 **Quick version:**
115 - Where does bad value originate?
116 - What called this with bad value?
117 - Keep tracing up until you find the source
118 - Fix at source, not at symptom
119 
120### Phase 2: Pattern Analysis
121 
122**Find the pattern before fixing:**
123 
1241. **Find Working Examples**
125 - Locate similar working code in same codebase
126 - What works that's similar to what's broken?
127 
1282. **Compare Against References**
129 - If implementing pattern, read reference implementation COMPLETELY
130 - Don't skim - read every line
131 - Understand the pattern fully before applying
132 
1333. **Identify Differences**
134 - What's different between working and broken?
135 - List every difference, however small
136 - Don't assume "that can't matter"
137 
1384. **Understand Dependencies**
139 - What other components does this need?
140 - What settings, config, environment?
141 - What assumptions does it make?
142 
143### Phase 3: Hypothesis and Testing
144 
145**Scientific method:**
146 
1471. **Form Single Hypothesis**
148 - State clearly: "I think X is the root cause because Y"
149 - Write it down
150 - Be specific, not vague
151 
1522. **Test Minimally**
153 - Make the SMALLEST possible change to test hypothesis
154 - One variable at a time
155 - Don't fix multiple things at once
156 
1573. **Verify Before Continuing**
158 - Did it work? Yes → Phase 4
159 - Didn't work? Form NEW hypothesis
160 - DON'T add more fixes on top
161 
1624. **When You Don't Know**
163 - Say "I don't understand X"
164 - Don't pretend to know
165 - Ask for help
166 - Research more
167 
168### Phase 4: Implementation
169 
170**Fix the root cause, not the symptom:**
171 
1721. **Create Failing Test Case**
173 - Simplest possible reproduction
174 - Automated test if possible
175 - One-off test script if no framework
176 - MUST have before fixing
177 - Use the `superpowers:test-driven-development` skill for writing proper failing tests
178 
1792. **Implement Single Fix**
180 - Address the root cause identified
181 - ONE change at a time
182 - No "while I'm here" improvements
183 - No bundled refactoring
184 
1853. **Verify Fix**
186 - Test passes now?
187 - No other tests broken?
188 - Issue actually resolved?
189 - Use the `superpowers:verification-before-completion` skill before claiming success
190 
1914. **If Fix Doesn't Work**
192 - STOP
193 - Count: How many fixes have you tried?
194 - If < 3: Return to Phase 1, re-analyze with new information
195 - **If ≥ 3: STOP and question the architecture (step 5 below)**
196 - DON'T attempt Fix #4 without architectural discussion
197 
1985. **If 3+ Fixes Failed: Question Architecture**
199 
200 **Pattern indicating architectural problem:**
201 - Each fix reveals new shared state/coupling/problem in different place
202 - Fixes require "massive refactoring" to implement
203 - Each fix creates new symptoms elsewhere
204 
205 **STOP and question fundamentals:**
206 - Is this pattern fundamentally sound?
207 - Are we "sticking with it through sheer inertia"?
208 - Should we refactor architecture vs. continue fixing symptoms?
209 
210 **Discuss with your human partner before attempting more fixes**
211 
212 This is NOT a failed hypothesis - this is a wrong architecture.
213 
214## Red Flags - STOP and Follow Process
215 
216If you catch yourself thinking:
217- "Quick fix for now, investigate later"
218- "Just try changing X and see if it works"
219- "Add multiple changes, run tests"
220- "Skip the test, I'll manually verify"
221- "It's probably X, let me fix that"
222- "I don't fully understand but this might work"
223- "Pattern says X but I'll adapt it differently"
224- "Here are the main problems: [lists fixes without investigation]"
225- Proposing solutions before tracing data flow
226- **"One more fix attempt" (when already tried 2+)**
227- **Each fix reveals new problem in different place**
228 
229**ALL of these mean: STOP. Return to Phase 1.**
230 
231**If 3+ fixes failed:** Question the architecture (see Phase 4.5)
232 
233## your human partner's Signals You're Doing It Wrong
234 
235**Watch for these redirections:**
236- "Is that not happening?" - You assumed without verifying
237- "Will it show us...?" - You should have added evidence gathering
238- "Stop guessing" - You're proposing fixes without understanding
239- "Ultra-think this" - Question fundamentals, not just symptoms
240- "We're stuck?" (frustrated) - Your approach isn't working
241 
242**When you see these:** STOP. Return to Phase 1.
243 
244## Common Rationalizations
245 
246| Excuse | Reality |
247|--------|---------|
248| "Issue is simple, don't need process" | Simple issues have root causes too. Process is fast for simple bugs. |
249| "Emergency, no time for process" | Systematic debugging is FASTER than guess-and-check thrashing. |
250| "Just try this first, then investigate" | First fix sets the pattern. Do it right from the start. |
251| "I'll write test after confirming fix works" | Untested fixes don't stick. Test first proves it. |
252| "Multiple fixes at once saves time" | Can't isolate what worked. Causes new bugs. |
253| "Reference too long, I'll adapt the pattern" | Partial understanding guarantees bugs. Read it completely. |
254| "I see the problem, let me fix it" | Seeing symptoms ≠ understanding root cause. |
255| "One more fix attempt" (after 2+ failures) | 3+ failures = architectural problem. Question pattern, don't fix again. |
256 
257## Quick Reference
258 
259| Phase | Key Activities | Success Criteria |
260|-------|---------------|------------------|
261| **1. Root Cause** | Read errors, reproduce, check changes, gather evidence | Understand WHAT and WHY |
262| **2. Pattern** | Find working examples, compare | Identify differences |
263| **3. Hypothesis** | Form theory, test minimally | Confirmed or new hypothesis |
264| **4. Implementation** | Create test, fix, verify | Bug resolved, tests pass |
265 
266## When Process Reveals "No Root Cause"
267 
268If systematic investigation reveals issue is truly environmental, timing-dependent, or external:
269 
2701. You've completed the process
2712. Document what you investigated
2723. Implement appropriate handling (retry, timeout, error message)
2734. Add monitoring/logging for future investigation
274 
275**But:** 95% of "no root cause" cases are incomplete investigation.
276 
277## Supporting Techniques
278 
279These techniques are part of systematic debugging and available in this directory:
280 
281- **`root-cause-tracing.md`** - Trace bugs backward through call stack to find original trigger
282- **`defense-in-depth.md`** - Add validation at multiple layers after finding root cause
283- **`condition-based-waiting.md`** - Replace arbitrary timeouts with condition polling
284 
View all files on GitHub →

Details

Updated
Sep 20, 2026
License
MIT
Stars on the repo
★ 289,792
Checked
Source
obra/superpowers ↗
Creator
obra · 14 listings
View creator

Similar skills

See all →
MCPExpert debugging specialist for errors, test failuresDebugger AgentCloudAI-X/claude-workflow-v2 · by CloudAI-XExpert debugging specialist for errors, test failures, crashes, segmentation faults, memory leaks, timeouts, race conditions, deadlocks, and unexpected behavior. Use PROACTIVELY when encountering any error, exception, or failing test. Performs systematic root cause analysis.★ 1.4k GitHub starsSkillRequires running verification commands and confirming outputVerification before completionobra/superpowers · by obraUse when about to claim work is complete, fixed, or passing, before committing or creating PRs - requires running verification commands and confirming output before making any success claims; evidence before assertions always★ 290k GitHub starsSkillGuides systematic root-cause debuggingDebugging and error recoveryaddyosmani/agent-skills · by addyosmaniGuides systematic root-cause debugging. Use when tests fail, builds break, something that worked yesterday broke, behavior doesn't match expectations, or you encounter any unexpected error. Use when you need to figure out what broke and why — a systematic approach to finding and fixing the root cause rather than guessing.★ 98.7k GitHub starsSkillMaster systematic debugging techniques, profiling toolsDebugging strategieswshobson/agents · by wshobsonMaster systematic debugging techniques, profiling tools, and root cause analysis to efficiently track down bugs across any codebase or technology stack. Use when investigating bugs, performance issues, or unexpected behavior.★ 39.9k GitHub starsSkillMaster error handling patterns across languages includingwshobson/agents · by wshobsonMaster error handling patterns across languages including exceptions, Result types, error propagation, and graceful degradation to build resilient applications. Use when implementing error handling, designing APIs, or improving application reliability.★ 39.9k GitHub starsSkillCreate structured incident response runbooksIncident runbook templateswshobson/agents · by wshobsonCreate structured incident response runbooks with step-by-step procedures, escalation paths, and recovery actions. Use this skill when building a service outage runbook for a payment processing system; creating database incident procedures covering connection pool exhaustion, replication lag, and disk space alerts; onboarding new on-call engineers who need step-by-step recovery guides written for a 3 AM brain; or standardizing escalation matrices across multiple engineering teams.★ 39.9k GitHub stars

More from obra

SkillBrainstorms ideas into designs before any creative workBrainstorming Ideas Into Designsobra/superpowers · by obraYou MUST use this before any creative work - creating features, building components, adding functionality, or modifying behavior. Explores user intent, requirements and design before implementation.★ 290k GitHub starsSkillRequires technical rigor and verificationCode Review Receptionobra/superpowers · by obraUse when receiving code review feedback, before implementing suggestions, especially if feedback seems unclear or technically questionable - requires technical rigor and verification, not performative agreement or blind implementation★ 290k GitHub starsSkillDispatches parallel agentsDispatching parallel agentsobra/superpowers · by obraUse when facing 2+ independent tasks that can be worked on without shared state or sequential dependencies★ 290k GitHub starsSkillExecutes plans with review checkpointsExecuting plansobra/superpowers · by obraUse when you have a written implementation plan to execute in a separate session with review checkpoints★ 290k GitHub starsSkillFinishes a development branchFinishing a development branchobra/superpowers · by obraUse when implementation is complete, all tests pass, and you need to decide how to integrate the work★ 290k GitHub starsSkillRequests code review before mergingRequesting code reviewobra/superpowers · by obraUse when completing tasks, implementing major features, or before merging to verify work meets requirements★ 290k GitHub stars