agentleFS
MPIsaac-PerMPIsaac-Per/claude-code-loop-patterns/skills/loop-failure-triage/SKILL.md

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.

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
  1. Distinctive:

    When a tool call fails, before retrying, answer these four questions:

    line 14
  2. Distinctive:

    What is the file:line citation?: If the error mentions one, name it.

    line 25
  3. Very specific:

    What was the exact command?: If you are about to retry, can you make it more narrowly scoped?

    line 27
  4. Distinctive:

    What changed since the last success?: If you just edited code, the failure is probably yours.

    line 29
  5. Distinctive:

    Test failures: read the test, read the code under test, read the failure citation, propose one minimal hypothesis, then verify.

    line 40
  6. Distinctive:

    Environment failures: check the prereq (binary, env var, port, lock file), fix the environment, then retry the same command unchanged.

    line 41
  7. Distinctive:

    Permission failures: stop. Permission errors waste tool calls if you keep going.

    line 42

≈ “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.

Keep what fits and drop the rest. Your version, ready for your agents.
Files
SKILL.md

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:

  1. 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.

  2. What is the file:line citation? If the error mentions one, name it. That is where to look first.
  3. What was the exact command? If you are about to retry, can you make it more narrowly scoped? A failing pnpm test should usually become pnpm test path/to/specific.test.ts on the next attempt. A failing pytest should become pytest tests/test_thing.py::test_case.
  4. 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: true or 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 Bash call exited with anything other than 0

Download now (ZIP)

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
What did you use it for? e.g. Reviewing pull requests in a Rails app

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.