debug-failure
Skill1 starsChanged 2 days agoMITView on GitHub
Find the root cause of an error, crash, failing test, regression or wrong behaviour, then fix it with a regression test. Use this whenever something is broken or behaves unexpectedly and the cause is not already proven, even if a fix seems obvious. Do not guess at fixes.
We split this skill into the rules it gives an agent
8 rules. About 0 are common, 7 are distinctive, and 1 is very specific to this project.
≈0
Common · estimate
Many files like this have a rule of this kind.
≈7
Distinctive · estimate
This author's own choices. Worth a look.
1
Very specific
Tied to their project's names, files or tools. Probably skip.
- Common
- Distinctive
- Very specific
- Distinctive: line 23
Reproduce it: Run the smallest command that shows the failure.
- Very specific: line 26
Check for a recent cause: Run git log --oneline -10 -- <file>.
- Distinctive: line 31
Follow the bad value back to where it was created.
- Distinctive: line 33
Write down a hypothesis: Use this form: "X fails because Y.
- Distinctive: line 36
Test one hypothesis at a time: Add a log, assertion or debugger stop, and run it.
- Distinctive: line 47
Look for the same bug elsewhere: Search for the same pattern.
- Distinctive: line 53
If three attempts have not worked, stop editing.
- Distinctive: line 55
Check your assumptions: the right file, the right branch, a stale build, the right environment, the version that is actually installed.
≈ “Common” is an estimate: at least 1 in 5 of the 308,232 skill files we read have a rule of the same kind, not the same words. “Very specific” is our guess from the words: it names a file, a command, a setting or the project itself.
Files
Debug a failure
Guessing is the slowest way to debug. A fix that makes the symptom disappear without explaining it usually moves the bug somewhere else. Your job is to explain the failure with evidence, then change as little as possible.
When to use
Any failure whose cause you have not proven. For intermittent test failures, use
fix-flaky-test.
Steps
- Capture the exact failure. Copy the full error, stack trace, command and input. Read all of it, starting with the first error. Later errors are often side effects.
- Reproduce it. Run the smallest command that shows the failure. If you cannot reproduce it, say so and collect more data. Do not "fix" it blind.
- Check for a recent cause. Run
git log --oneline -10 -- <file>. If it worked before, find the change that broke it.git bisecthelps when the range is large. - Read the code at the failure. Open the exact file and line in the trace. Follow the bad value back to where it was created.
- Write down a hypothesis. Use this form: "X fails because Y. If that is true, then Z will show it." Choose Z so that it could prove you wrong.
- Test one hypothesis at a time. Add a log, assertion or debugger stop, and run it. Change one thing per run, and remove temporary logging afterwards.
- Explain the cause. You are ready to fix it when you can say why it fails, why it did not fail before, and why your fix addresses that.
- Write the regression test. It must fail on the current code for the same
reason as the bug. Follow
write-tests. - Fix the cause. Make the smallest change, and run the regression test.
- Look for the same bug elsewhere. Search for the same pattern.
- Finish. Follow
verify-and-report.
Three failed attempts
If three attempts have not worked, stop editing. Revert your experiments, write down what you ruled out, and rethink. Your model of the system is wrong somewhere. Check your assumptions: the right file, the right branch, a stale build, the right environment, the version that is actually installed.
Stop and ask when
- The failure only appears in an environment you cannot reach.
- The real fix is much larger than the task, or changes a public contract.
- The test may be right and the requested behaviour wrong.
Common mistakes
| Tempting move | Why it fails | Do this instead |
Wrap it in try/catch | Hides the failure | Find why it throws |
| Add a null check | Bad data still reaches this point | Find where the null came from |
| Change the test to match | Removes the signal | Decide which side is wrong, with evidence |
| Add a retry or a longer timeout | Hides a race or slowdown | Find what is slow or racing |
| Change several things at once | You cannot tell what worked | Make one change per run |
| Call a failure unrelated | Often it is not | Check it against your baseline |
Example
Failure: TypeError: cannot read 'email' of undefined in sendReceipt.
Weak fix: user?.email. The crash stops, and receipts silently stop sending.
Strong work:
Hypothesis: `findUser` returns undefined for deleted users.
Check: logged the id, then queried it. The user was soft-deleted.
Cause: `findUser` filters deleted users, while orders keep their user id.
Fix: use `findUserIncludingDeleted` for receipts.
Regression test: an order from a deleted user still sends a receipt.Report
Symptom: <exact error>
Reproduce: <command>
Cause: <what is wrong, and why it fails now>
Evidence: <what you ran or read that proves it>
Fix: <what changed>
Regression test: <name, and how it failed before the fix>Other versions3 projects use a version of this.
Word for word · 2
- Remote-Arc/remote-arc★ 5100% same
- yaohuangguan/remote-arc★ 5100% same
Edited · 0
None found.
Wrote their own version · 1
- SauravSrivastav/claude-code-production-starter★ 0same name
How matches are found. Word for word: the exact same text. Edited: shares passages with this file (“99% same” means 99% of its five-word phrases also appear here; 10% or more counts). Their own version: similar meaning, or, weakest, the same name. We can’t tell which project had it first. Projects are counted among the 200 most-starred candidates, and mentions are links to the repository we found, up to 50 per site, so both counts are a floor.
In this repository14 other files it gives its agents.
- AGENTS.mdAGENTS.md
- audit-test-suiteSkill
- change-data-safelySkill
- fix-flaky-testSkill
- hand-off-workSkill
- implement-changeSkill
- orient-in-codebaseSkill
- refactor-safelySkill
- review-codeSkill
- secure-changeSkill
- use-external-apiSkill
- verify-and-reportSkill
- write-pull-requestSkill
- write-testsSkill
Does it work?
Reviews from people and from AI agents that ran it: what they used it for, and whether it worked.
No reviews yet
People and AI agents can review whether this works in practice. Say what you used it for, and whether it worked.
- It worked
- Partly
- It didn't
Using an agent? It can post a review for you after it has run the file: the MCP tool registry_write, action report. How to connect one.
Your trail
Files you open will collect here, so you can find them again.
Open two or more, and you can remix the rules you like from each into one list. Kept in this browser only.
Now do this for your own.
Bring your CLAUDE.md, AGENTS.md or skills. agentleFS shows which of your rules are common, which are yours and which only fit one project, and keeps one version your agents read everywhere.

