skills/superpowers/systematic-debugging/SKILL.md
Use when encountering any bug, test failure, or unexpected behavior, before proposing fixes
npx skillsauth add jbro/pi-agent systematic-debuggingInstall this skill globally with one command. Works with Claude Code, Cursor, and Windsurf.
3 of 9 scanners reported clean
Some scanners were skipped, did not run, or reported a non-clean status. Review each row below.
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.
NO FIXES WITHOUT ROOT CAUSE INVESTIGATION FIRST
If you haven't completed Phase 1, you cannot propose fixes.
Use for any technical issue: test failures, bugs, unexpected behavior, performance problems, build failures, integration issues.
Never skip when: issue seems simple, you're under time pressure, or you've already tried multiple fixes. Systematic debugging is FASTER than thrashing. Emergencies make guessing tempting — resist.
You MUST complete each phase before proceeding to the next.
BEFORE attempting ANY fix:
Read Error Messages Carefully
Reproduce Consistently
Check Recent Changes
Gather Evidence in Multi-Component Systems
WHEN system has multiple components:
Add diagnostic instrumentation at each component boundary before proposing fixes:
For EACH component boundary:
- Log what data enters component
- Log what data exits component
- Verify environment/config propagation
Run once to gather evidence → identify failing component → investigate that component
Example (CI → build → signing pipeline):
echo "=== Secrets in workflow: ===" && echo "IDENTITY: ${IDENTITY:+SET}${IDENTITY:-UNSET}"
echo "=== Env vars in build: ===" && env | grep IDENTITY || echo "IDENTITY not in environment"
echo "=== Keychain state: ===" && security find-identity -v
This reveals which layer fails (workflow ✓, workflow → build ✗).
Trace Data Flow
WHEN error is deep in call stack:
Read root-cause-tracing.md in this skill's 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.
Fix the root cause, not the symptom:
Create Failing Test Case — simplest possible reproduction; use the test-driven-development skill
Implement Single Fix — one change; no "while I'm here" improvements
Verify Fix — test passes; no other tests broken
If Fix Doesn't Work — STOP; count fixes tried:
If 3+ Fixes Failed: Question Architecture
Pattern indicating architectural problem:
STOP: discuss with your human partner before attempting more fixes. This is a wrong architecture, not a failed hypothesis.
If you catch yourself thinking any of these:
ALL of these mean: STOP. Return to Phase 1.
If 3+ fixes failed: Question the architecture (Phase 4.5).
Watch for these redirections:
When you see these: STOP. Return to Phase 1.
| 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 investigation reveals the issue is truly environmental, timing-dependent, or external:
Note: 95% of "no root cause" cases are incomplete investigation.
Available in this directory:
root-cause-tracing.md — trace bugs backward through call stack to find original triggerdefense-in-depth.md — add validation at multiple layers after finding root causecondition-based-waiting.md — replace arbitrary timeouts with condition pollingRelated skills:
testing
Use when writing or editing human-facing prose that needs clearer, more concise wording.
development
Use when you have a spec or requirements for a multi-step task, before touching code
data-ai
Use 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
tools
Use when starting any conversation or task, to determine which skills apply before responding or taking any action.