loop-failure-triage
Skill2 starsChanged 4 months agoMITView on GitHub
Structured triage after a tool call fails. Distinguishes test failure from environment, permission, not-found, and rate-limit failure, and avoids blind retry.
In this repository3 other files it gives its agents.
- AGENTS.mdAGENTS.md
- read-before-editSkill
- verify-before-doneSkill
The file
We split this skill into the rules it gives an agent
7 rules. About 0 are common, 6 are distinctive, and 1 is very specific to this project.
≈0
Common · estimate
Many files like this have a rule of this kind.
≈6
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 14
When a tool call fails, before retrying, answer these four questions:
- Distinctive: line 25
What is the file:line citation?: If the error mentions one, name it.
- Very specific: line 27
What was the exact command?: If you are about to retry, can you make it more narrowly scoped?
- Distinctive: line 29
What changed since the last success?: If you just edited code, the failure is probably yours.
- Distinctive: line 40
Test failures: read the test, read the code under test, read the failure citation, propose one minimal hypothesis, then verify.
- Distinctive: line 41
Environment failures: check the prereq (binary, env var, port, lock file), fix the environment, then retry the same command unchanged.
- Distinctive: line 42
Permission failures: stop. Permission errors waste tool calls if you keep going.
≈ “Common” is an estimate: at least 1 in 5 of the 350,495 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
Loop Failure Triage
The article's fifth lesson: errors are not edge cases, they are the work. The best loops are not the ones with no errors; they are the ones where errors become high-quality steering signals. This skill keeps you from doing the dumb thing after a failure.
The rule
When a tool call fails, before retrying, answer these four questions:
What kind of failure?
- Test failure: a real defect in the code under test
- Environment failure: missing dep, wrong PATH, port in use, expired token
- Permission failure: 401, 403, sudo, file mode
- Not-found failure: 404, missing file, wrong path
- Rate or timeout failure: 429, network slowness, CI throttle
Different categories need different responses. Do not retry a 401 the same way you retry a flaky test.
- What is the file:line citation? If the error mentions one, name it. That is where to look first.
- What was the exact command? If you are about to retry, can you make it more narrowly scoped? A failing
pnpm testshould usually becomepnpm test path/to/specific.test.tson the next attempt. A failingpytestshould becomepytest tests/test_thing.py::test_case. - What changed since the last success? If you just edited code, the failure is probably yours. If you have not edited code, suspect environment.
What not to do
- Do not blind-retry. Identical command, identical inputs, expecting different output. That burns tool calls and proves nothing.
- Do not paper over. Wrapping a failure in try/except and pretending it succeeded is a violation of the "done" rule.
- Do not change unrelated code to "fix" a failure whose cause you have not located. That replaces one bug with two.
- Do not loop on auth failures. A 401 will keep being a 401 until credentials change. Surface it.
What to do
- Test failures: read the test, read the code under test, read the failure citation, propose one minimal hypothesis, then verify.
- Environment failures: check the prereq (binary, env var, port, lock file), fix the environment, then retry the same command unchanged.
- Permission failures: stop. Permission errors waste tool calls if you keep going. Surface the auth issue to the user.
- Not-found: confirm the path is right and the cwd is right before assuming the resource is missing.
- Rate or timeout: back off, do not retry immediately, and consider whether the call needs to be smaller.
When to invoke
Trigger this skill whenever:
- A tool call returned
is_error: trueor a non-zero exit code - A test, build, lint, or typecheck failed
- An HTTP call returned 4xx or 5xx
- A subprocess produced "error", "exception", "failed", "timeout", or "rate limit" in its output
- A
Bashcall exited with anything other than 0
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.

