| name | debugging-and-error-recovery |
| description | Guides systematic root-cause debugging. Use when tests fail, builds break, behavior doesn't match expectations, or you encounter any unexpected error. Use when you need a systematic approach to finding and fixing the root cause rather than guessing. |
| zh_description | ็จไบ่ฐ่ฏใ้่ฏฏใrecovery๏ผๆฏๆไปปๅก่งๅใๆง่กใ่ฏๅฎกๅ้ช่ฏใ |
| version | 1.0.0 |
| author | addyosmani |
| source | github:addyosmani/agent-skills |
| source_url | https://github.com/addyosmani/agent-skills/blob/main/skills/debugging-and-error-recovery/SKILL.md |
| license | MIT |
| tags | ["agent", "ai", "debugging-and-error-recovery", "engineering", "workflow"] |
| created_at | 2026-07-27 |
| updated_at | 2026-07-27 |
| quality | 5 |
| complexity | advanced |
| upstream_slug | debugging-and-error-recovery |
Debugging and Error Recovery
Overview
Systematic debugging with structured triage. When something breaks, stop adding features, preserve evidence, and follow a structured process to find and fix the root cause. Guessing wastes time. The triage checklist works for test failures, build errors, runtime bugs, and production incidents.
When to Use
- Tests fail after a code change
- The build breaks
- Runtime behavior doesn't match expectations
- A bug report arrives
- An error appears in logs or console
- Something worked before and stopped working
The Stop-the-Line Rule
When anything unexpected happens:
1. STOP adding features or making changes
2. PRESERVE evidence (error output, logs, repro steps)
3. DIAGNOSE using the triage checklist
4. FIX the root cause
5. GUARD against recurrence
6. RESUME only after verification passes
Don't push past a failing test or broken build to work on the next feature. Errors compound. A bug in Step 3 that goes unfixed makes Steps 4-6 wrong.
The Triage Checklist
Work through these steps in order. Do not skip steps.
Step 1: Reproduce
Make the failure happen reliably. If you can't reproduce it, you can't fix it with confidence.
Can you reproduce the failure?
โโโ YES โ Proceed to Step 2
โโโ NO
โโโ Gather more context (logs, environment details)
โโโ Try reproducing in a minimal environment
โโโ If truly non-reproducible, document conditions and monitor
When a bug is non-reproducible:
Cannot reproduce on demand:
โโโ Timing-dependent?
โ โโโ Add timestamps to logs around the suspected area
โ โโโ Try with artificial delays (setTimeout, sleep) to widen race windows
โ โโโ Run under load or concurrency to increase collision probability
โโโ Environment-dependent?
โ โโโ Compare Node/browser versions, OS, environment variables
โ โโโ Check for differences in data (empty vs populated database)
โ โโโ Try reproducing in CI where the environment is clean
โโโ State-dependent?
โ โโโ Check for leaked state between tests or requests
โ โโโ Look for global variables, singletons, or shared caches
โ โโโ Run the failing scenario in isolation vs after other operations
โโโ Truly random?
โโโ Add defensive logging at the suspected location
โโโ Set up an alert for the specific error signature
โโโ Document the conditions observed and revisit when it recurs
For test failures (npm shown โ substitute the repository's own test command, per the test-driven-development skill's Discover the Stack First section):
npm -- --grep
npm -- --verbose
npm -- --testPathPattern= --runInBand