From Superpowers
This skill should be used when the user reports a bug, error, test failure, or unexpected behavior, or invokes /superpowers:systematic-debugging. Provides a 4-phase root cause analysis process, ensuring thorough investigation precedes any code changes.
How this skill is triggered — by the user, by Claude, or both
Slash command
/superpowers:systematic-debugging <bug description or symptom><bug description or symptom>This skill is limited to the following tools:
The summary Claude sees in its skill listing — used to decide when to auto-load this skill
Invoked via `/superpowers:systematic-debugging "<symptom>"` or auto-loaded by other skills (BDD, brainstorming) when bug-fix language is detected.
Invoked via /superpowers:systematic-debugging "<symptom>" or auto-loaded by other skills (BDD, brainstorming) when bug-fix language is detected.
When invoked as a slash command: capture $ARGUMENTS as the symptom statement, then start at Phase 1 (Root Cause Investigation) immediately. Debugging is iterative within a single session, not phase-driven. Do NOT write design documents or task files; the deliverable is the fix + a test that catches the regression, not a docs/plans/ folder.
Output discipline: Report findings inline as you complete each phase. End with: (a) root cause one-liner, (b) fix diff summary, (c) regression test path.
Inspect $ARGUMENTS for "named root cause + named fix" signals. Bail out — skip the 4-phase pipeline, apply the fix and write a regression test directly — when ALL of these match:
$ARGUMENTS names a specific root cause (file:line, config key, or specific value), AND$ARGUMENTS names a specific corrective change ("change X to Y", "add the missing flag", "fix the typo"), ANDExamples that bail out:
.foo.com, should be foo.com — fix it"await at api.ts:42, add it"DB_HOST should be DATABASE_HOST in deploy.yaml"Examples that DO NOT bail out (proceed to Phase 1):
Bail-out response (output verbatim, then proceed with direct edit + write a regression test that catches the bug):
Detected named root cause and named fix. Skipping the 4-phase pipeline (calibrated for unknown root causes). Applying the fix and writing a regression test directly. To force the full pipeline, re-invoke as
/superpowers:systematic-debugging --force "<symptom>".
When the user passes --force (literal token in $ARGUMENTS), skip this bail-out and proceed to Phase 1 unconditionally.
Iron Law remains for non-bail-out paths: NO FIXES WITHOUT ROOT CAUSE INVESTIGATION FIRST. The bail-out only fires when the user has already done the root cause work and is handing the conclusion to Claude.
Random fixes waste time and create new bugs. Quick patches mask underlying issues.
Core principle: Root cause investigation must precede any fix attempt. Symptom fixes represent process failure.
Violating the letter of this process is violating the spirit of debugging.
NO FIXES WITHOUT ROOT CAUSE INVESTIGATION FIRST
Fixes cannot be proposed without completing Phase 1. Each phase MUST finish before the next begins. Violating this rule produces fix-attempts that mask root causes — the failure mode this skill exists to prevent. If at any point you find yourself proposing a fix without completed Phase 1 evidence, stop and return to Phase 1.
Systematic debugging applies to ANY technical issue:
Especially valuable when:
Process should not be skipped even when:
Each phase must be completed before proceeding to the next.
Before attempting any fix:
Read Error Messages Carefully
Reproduce Consistently
Check Recent Changes
Gather Evidence in Multi-Component Systems
For systems with multiple components (CI -> build -> signing, API -> service -> database):
Diagnostic instrumentation should be added before proposing fixes:
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
Multi-layer system example:
# 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.
Trace Data Flow
When error is deep in call stack:
See ./references/root-cause-tracing.md for the complete backward tracing technique.
Quick approach:
Pattern identification should precede any fix:
Find Working Examples
Compare Against References
Identify Differences
Understand Dependencies
Scientific method application:
Form Single Hypothesis
Test Minimally
Verify Before Continuing
When Understanding is Missing
Fix the root cause, not the symptom:
Create Failing Test Case
Implement Single Fix
Verify Fix
If Fix Doesn't Work
Architecture Questioning After 3+ Failed Fixes
Patterns indicating architectural problem:
Stop and question fundamentals:
Discuss with human partner before attempting more fixes
This is not a failed hypothesis - this is wrong architecture.
For complex bugs, record a compact plan inline before any code change. This section is consistent with the Slash-command Usage rule at the top of this skill: do NOT create docs/plans/ folders or BUGFIX_PLAN.md files — the deliverable is still the fix + a regression test, never a planning document. The inline plan is the contract the skill holds itself to during Phase 2-4 and the audit surface the user reviews post-fix.
A bug requires the inline-plan step before edits when ANY of these apply:
After Phase 1 (Root Cause Investigation), record the plan inline in your turn output (not in a file) using this six-line shape, then proceed directly to Phase 2 with this plan as the contract:
ROOT CAUSE: <one-line summary from Phase 1 evidence>
FIX STRATEGY: <what change resolves the cause, in one sentence>
FILES: <comma-separated paths that will be modified>
TESTS: <regression test path(s) + scenario name>
RISKS: <one line — side effects, blast radius, or "low: localized to <subsystem>">
ALTERNATIVES: <one line — rejected approaches + why>
Do NOT pause for approval. The plan stays the contract through Phase 2-4; deviation requires re-running Phase 1 and re-recording a new six-line shape (do not silently mutate the fix mid-stream). If Phase 1 evidence is too thin to fill any of the six lines confidently, loop back to Phase 1 step 4 (Multi-component layered tracing) before recording the plan — never paper over weak evidence by writing a vague line.
For simple bugs: Continue with Phase 2-4 directly — no inline plan needed.
These mental patterns indicate process violation and require returning to Phase 1:
If 3+ fixes failed: Question the architecture.
Watch for these redirections:
When encountering these signals: Return to Phase 1.
| 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. |
| 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 |
If systematic investigation reveals issue is environmental, timing-dependent, or external:
Note: 95% of "no root cause" cases represent incomplete investigation.
./references/root-cause-tracing.md - Trace bugs backward through call stack to find original trigger./references/defense-in-depth.md - Add validation at multiple layers after finding root cause./references/condition-based-waiting.md - Replace arbitrary timeouts with condition polling./references/condition-based-waiting-example.ts - Example implementation of condition-based waiting./find-polluter.sh - Bisect test suite to identify which test pollutes shared stateRelated skills:
superpowers:behavior-driven-development - BDD principles including Gherkin scenarios for test designFrom debugging sessions:
npx claudepluginhub est7/dotclaude --plugin superpowersCreates structured, bite-sized implementation plans from specs or requirements before writing code. Useful for breaking down multi-step tasks into testable steps with file structure and task boundaries.