Systematic Debugging
When to Use Me
Use me when:
- fix bug
- debug
- test failing
- error
- unexpected behavior
- not working
- investigate
- why is this broken
- what's wrong
- trace this
- find the cause
Do not use me for:
- write test first
- TDD
- already investigated
- clear solution
- quick fix
- just try this
- I know the fix
- general programming questions
- installation or troubleshooting
- framework-agnostic code help
Workflow
- Phase 1: Root Cause Investigation - Read errors, reproduce, check changes, gather evidence, trace data flow
- Phase 2: Pattern Analysis - Find working examples, compare against references, identify differences
- Phase 3: Hypothesis and Testing - Form single hypothesis, test minimally, verify before continuing
- Phase 4: Implementation - Create failing test case, implement single fix for root cause, verify
- If 3+ fixes failed: STOP and question architecture
Error Handling
- Quick fix for now: STOP, return to Phase 1
- Multiple changes at once: STOP, require single hypothesis
- Skip the test: STOP, require failing test first
- One more fix attempt (after 2+): STOP, question architecture
- I see the problem: STOP, seeing symptom != understanding root cause
- Pattern says X but I'll adapt: STOP, read reference completely
Tools
The following tools are available to assist with systematic debugging:
wait-for - Wait for conditions instead of using arbitrary delays
find-flaky-tests - Detect tests that pollute global state
trace-root-cause - Analyze stack traces to identify root cause
debug-session - Track debugging progress through 4 phases
These tools integrate with the systematic-debugging skill to automate error analysis and root cause detection.
Quick Tests
Should trigger:
- Fix this bug
- Tests are failing
- Getting this error
- Debug why login fails
- Why isn't this working
- Trace this issue
Should not trigger:
- Write a test for this feature
- Refactor this code
- Add documentation
- I already found the root cause
- Just change X and see
Functional:
- Debug a failing test systematically
- Find root cause of error
References
references/workflow-playbook.mdx - Complete 4-phase debugging process
references/root-cause-tracing.mdx - Trace bugs backward through call stack
references/defense-in-depth.mdx - Multi-layer validation
references/condition-based-waiting.mdx - Wait for conditions, not timing
references/visual-web-debugging.mdx - Visual debugging with Playwright for webapps
scripts/find-polluter.sh - Find tests that pollute global state
scripts/condition-based-waiting-example.ts - TypeScript implementation
The Iron Law
NO FIXES WITHOUT ROOT CAUSE INVESTIGATION FIRST
If you haven't completed Phase 1, you cannot propose fixes.
Red Flags - STOP and Follow Process
- "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"
- Proposing solutions before tracing data flow
- "One more fix attempt" (when already tried 2+)
ALL of these mean: STOP. Return to Phase 1.
Quick Reference
| Phase |
Key Activities |
Success Criteria |
| 1. Investigation |
Read errors, reproduce, check changes |
Understand WHAT and WHY |
| 2. Pattern Analysis |
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 |
1---2name: systematic-debugging3description: Enforce systematic debugging to find root causes. Always investigate before fixing. Prevents symptom fixes and random changes. Use when debugging errors or investigating failures. Do not use when already investigated or for TDD/test-first development.4license: MIT5---67# Systematic Debugging89## When to Use Me1011Use me when:1213- fix bug14- debug15- test failing16- error17- unexpected behavior18- not working19- investigate20- why is this broken21- what's wrong22- trace this23- find the cause2425Do not use me for:2627- write test first28- TDD29- already investigated30- clear solution31- quick fix32- just try this33- I know the fix34- general programming questions35- installation or troubleshooting36- framework-agnostic code help3738## Workflow39401. Phase 1: Root Cause Investigation - Read errors, reproduce, check changes, gather evidence, trace data flow412. Phase 2: Pattern Analysis - Find working examples, compare against references, identify differences423. Phase 3: Hypothesis and Testing - Form single hypothesis, test minimally, verify before continuing434. Phase 4: Implementation - Create failing test case, implement single fix for root cause, verify445. If 3+ fixes failed: STOP and question architecture4546## Error Handling4748- Quick fix for now: STOP, return to Phase 149- Multiple changes at once: STOP, require single hypothesis50- Skip the test: STOP, require failing test first51- One more fix attempt (after 2+): STOP, question architecture52- I see the problem: STOP, seeing symptom != understanding root cause53- Pattern says X but I'll adapt: STOP, read reference completely5455## Tools5657The following tools are available to assist with systematic debugging:5859- `wait-for` - Wait for conditions instead of using arbitrary delays60- `find-flaky-tests` - Detect tests that pollute global state61- `trace-root-cause` - Analyze stack traces to identify root cause62- `debug-session` - Track debugging progress through 4 phases6364These tools integrate with the systematic-debugging skill to automate error analysis and root cause detection.6566## Quick Tests6768Should trigger:6970- Fix this bug71- Tests are failing72- Getting this error73- Debug why login fails74- Why isn't this working75- Trace this issue7677Should not trigger:7879- Write a test for this feature80- Refactor this code81- Add documentation82- I already found the root cause83- Just change X and see8485Functional:8687- Debug a failing test systematically88- Find root cause of error8990## References9192- `references/workflow-playbook.mdx` - Complete 4-phase debugging process93- `references/root-cause-tracing.mdx` - Trace bugs backward through call stack94- `references/defense-in-depth.mdx` - Multi-layer validation95- `references/condition-based-waiting.mdx` - Wait for conditions, not timing96- `references/visual-web-debugging.mdx` - Visual debugging with Playwright for webapps97- `scripts/find-polluter.sh` - Find tests that pollute global state98- `scripts/condition-based-waiting-example.ts` - TypeScript implementation99100## The Iron Law101102```103NO FIXES WITHOUT ROOT CAUSE INVESTIGATION FIRST104```105106If you haven't completed Phase 1, you cannot propose fixes.107108## Red Flags - STOP and Follow Process109110- "Quick fix for now, investigate later"111- "Just try changing X and see if it works"112- "Add multiple changes, run tests"113- "Skip the test, I'll manually verify"114- "It's probably X, let me fix that"115- "I don't fully understand but this might work"116- Proposing solutions before tracing data flow117- "One more fix attempt" (when already tried 2+)118119**ALL of these mean: STOP. Return to Phase 1.**120121## Quick Reference122123| Phase | Key Activities | Success Criteria |124| ----------------------- | ------------------------------------- | --------------------------- |125| **1. Investigation** | Read errors, reproduce, check changes | Understand WHAT and WHY |126| **2. Pattern Analysis** | Find working examples, compare | Identify differences |127| **3. Hypothesis** | Form theory, test minimally | Confirmed or new hypothesis |128| **4. Implementation** | Create test, fix, verify | Bug resolved, tests pass |