debugging-and-error-recovery
What it does
This guide helps you systematically find and fix errors in your code. It teaches you to stop, investigate, and resolve problems instead of guessing.
When to use it
- βWhen a test fails after a change.
- βWhen the program doesn't work as expected.
- βWhen you encounter an unexpected error.
Skill link
https://github.com/addyosmani/agent-skills/blob/main/skills/debugging-and-error-recovery/SKILL.mdCopy it and paste it into your AI (Claude, ChatGPT or Cursor), asking it to follow the instructions.
How to use
The easiest way: copy the message and paste it into your AI. It reads the skill and follows the instructions.
Ready-to-paste message
For Claude Code, Codex or Cursor: run it in your project folder and the skill gets installed.
Download the SKILL.md and drop it into your agentβs skills folder.
Example of what to ask your AI
βMy code is giving a weird error when I try to save a user, can you help me figure out why?β
5 new skills a week. 1 minute to read.
debugging-and-error-recovery: full guide
When something breaks, the natural move is to guess. You change a line, run the code again, and hope. Sometimes it works, and you never learn why. Sometimes it makes things worse. This skill gives your agent a fixed order of work instead: make the failure happen on demand, find where it happens, shrink it to the smallest case, fix the real cause, add a test, and check the result.
It is for anyone who works with an AI agent on code and sees a test fail, a build stop, or a feature that worked yesterday stop working. You do not need to read stack traces yourself. The skill tells the agent to name the cause, make the smallest fix, and say how to confirm it. It also asks the agent to stop adding features while something is broken, so one bug does not turn into three.
Use cases
A test fails after a small change
You renamed a field and now 12 tests fail. The agent first checks whether the code or the test is wrong. It looks for side effects in shared state or imports, then fixes the cause instead of skipping or deleting the failing test.
The build breaks after updating packages
After you update a dependency, the build stops with an import error. The agent works through the build checklist: the missing module, mismatched exports, wrong paths, the config file, then your Node version. It names the cause before it changes anything.
It worked last week and now it does not
A checkout page that was fine is now broken, and nobody knows which commit did it. The agent uses git bisect, which tests older versions of the code in turn, to find the exact change that introduced the bug, then fixes that.
Step by step
- 1Install the skill by placing its folder in ~/.claude/skills/debugging-and-error-recovery/, or in your project's .claude/skills/ folder, so your agent can find it.
- 2When something breaks, stop asking for new features. Paste the exact error text, the failing test name, or a description of what you expected and what you got.
- 3Let the agent reproduce the failure first. Give it the steps you took or the command that fails, so it can make the problem happen again.
- 4Ask for the cause in plain words before the fix. The agent narrows down the layer (interface, server, database, build) and shrinks the problem to a minimal case.
- 5Check that the agent adds a regression test that fails without the fix, then runs the full test suite and the build to confirm nothing else broke.
Example
What to ask
βThe search page returns no results when a task title contains quotes. It worked last week. Find the root cause, fix it, and add a test so it cannot come back.β
What you get
The agent reproduces the empty search with a title like Fix "quotes" & <brackets>, traces it to the query step, and explains why the quotes break matching. It makes a small fix, adds a test that fails without it, then runs the full suite and the build and reports both passing.
Tips
- βPaste the real error output and the command you ran. The skill tells the agent to treat error text as data, so it will not run commands found inside an error message without asking you.
- βDo not ask for several changes at once while debugging. Multiple edits mix together, and you can no longer tell which one fixed the problem or which one caused a new one.
- βA fix that makes the error disappear is not always a root-cause fix. If the agent only hides the symptom, for example by removing duplicates in the interface, ask it why the duplicates exist.
- βBugs that appear only sometimes are harder. The skill suggests extra logging, timing checks and environment comparisons. Expect it to ask you for more context rather than promise a quick fix.
Alternatives
- test-driven-development
Pick this when you are building a new feature or fix and want the failing test written first, instead of investigating a bug that already exists.
- webapp-testing
Pick this when the bug lives in a local web app's interface and you need the agent to drive a browser, read its logs and take screenshots.
- verify-and-stop
Pick this when the work is done and you only want a clear pass or fail check against your requirements, without a debugging investigation.
Questions and answers
Does this skill fix bugs automatically?
No. It gives your agent a fixed process: reproduce, localize, reduce, fix, guard and verify. The agent still does the work, but it explains the cause and how to confirm the fix instead of guessing.
Can I use it if I cannot reproduce the bug?
Yes. The skill has a separate path for bugs that appear only sometimes. It checks timing, environment differences and leaked state, adds logging, and records the conditions so you can revisit the problem when it happens again.
Does it only work with JavaScript projects?
The examples use npm and JavaScript, but the skill says to use the repository's own test and build commands. The steps themselves apply to any language.
How it works
It works by asking you to reproduce the error, then find where it's happening, simplify the problem, and finally fix the real cause.
Technical content (original SKILL.md)
Original text by the author, straight from GitHub.
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):
# Run the specific failing test
npm test -- --grep "test name"
# Run with verbose output
npm test -- --verbose
# Run in isolation (rules out test pollution)
npm test -- --testPathPattern="specific-file" --runInBand
Step 2: Localize
Narrow down WHERE the failure happens:
Which layer is failing?
βββ UI/Frontend β Check console, DOM, network tab
βββ API/Backend β Check server logs, request/response
βββ Database β Check queries, schema, data integrity
βββ Build tooling β Check config, dependencies, environment
βββ External service β Check connectivity, API changes, rate limits
βββ Test itself β Check if the test is correct (false negative)
Use bisection for regression bugs:
# Find which commit introduced the bug
git bisect start
git bisect bad # Current commit is broken
git bisect good <known-good-sha> # This commit worked
# Git will checkout midpoint commits; run your test at each
git bisect run npm test -- --grep "failing test" # substitute the repository's focused-test command
Step 3: Reduce
Create the minimal failing case:
- Remove unrelated code/config until only the bug remains
- Simplify the input to the smallest example that triggers the failure
- Strip the test to the bare minimum that reproduces the issue
A minimal reproduction makes the root cause obvious and prevents fixing symptoms instead of causes.
Step 4: Fix the Root Cause
Fix the underlying issue, not the symptom:
Symptom: "The user list shows duplicate entries"
Symptom fix (bad):
β Deduplicate in the UI component: [...new Set(users)]
Root cause fix (good):
β The API endpoint has a JOIN that produces duplicates
β Fix the query, add a DISTINCT, or fix the data model
Ask: "Why does this happen?" until you reach the actual cause, not just where it manifests.
Step 5: Guard Against Recurrence
β¦
FAQ
What does 'preserve evidence' mean?
It means saving important information about the error, like error messages, logs, or the steps you took to make it happen.
Why shouldn't I add new features when something breaks?
Because adding more code can worsen the problem or hide the original cause, making it harder to fix.
What is 'bisection'?
It's a technique to find which specific change caused a problem by testing older versions of the code until you find one that worked.
Details
Original description by the author
Guides 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.
repo: addyosmani/agent-skills
Popularity
- GitHub stars
- 107k
- Ranking position
- #768
- License
- MIT
- Updated
- 10/13/2026
Comments
- β¦
More skills from this repository
api-and-interface-design
107kHelps create well-defined APIs and interfaces. It's useful when designing how different parts of software will communicate.
browser-testing-with-devtools
107kHelps your agent test code directly in real browsers. It's useful for checking how something works in the environment where it will be used, finding errors and performance issues.
ci-cd-and-automation
107kTeaches your AI agent to automate repetitive tasks and ship projects and manage infrastructure.
code-review-and-quality
107kPerforms detailed code reviews on multiple fronts. It's useful before merging new changes to ensure quality and prevent future problems.
Similar skills
test-driven-development
311kTeaches your agent to write a failing test first, watch it fail, then write the smallest code that passes, before building any feature or fix.
verification-before-completion
311kTeaches your agent to run real checks and read their output before claiming that a task, fix, or build is complete or passing.
migrate-to-shoehorn
310kReplaces risky type casts in your test files with the shoehorn library, so tests can use partial data and still pass type checks.