loop-recovery
Skill146 starsChanged 3 months agoMITView on GitHub
Structured recovery and escalation when an agent hits a retry loop.
In this repository22 other files it gives its agents.
- AGENTS.mdAGENTS.md
- agent-decisionSkill
- agent-memorySkill
- architect-design-treeSkill
- architect-impl-groundingSkill
- bootSkill
- browser-inspectSkill
- code-coherence-reviewSkill
- code-quality-reviewSkill
- coder-self-reviewSkill
- code-sec-reviewSkill
- context-maintenanceSkill
- contextualizer-self-reviewSkill
- dispatchSkill
- grillSkill
- plan-managementSkill
- reviewer-architect-adversarialSkill
- reviewer-handoffSkill
- reviewer-self-reviewSkill
- review-loopSkill
- task-trackingSkill
- web-searchSkill
The file
We split this skill into the rules it gives an agent
5 rules. About 0 are common, 5 are distinctive, and 0 are very specific to this project.
≈0
Common · estimate
Many files like this have a rule of this kind.
≈5
Distinctive · estimate
This author's own choices. Worth a look.
0
Very specific
Tied to their project's names, files or tools. Probably skip.
- Common
- Distinctive
- Very specific
- Distinctive: line 19
Check for drift: If recent actions touched files unrelated to the stated goal, the agent is flailing.
- Distinctive: line 34
Never attempt a third approach.
- Distinctive: line 35
Never retry with debug commands, additional logging, or exploratory reads unless the new information would change the approach — not merely …
- Distinctive: line 36
Never continue after detecting oscillation twice.
- Distinctive: line 37
Never treat drift (touching unrelated files) as progress.
≈ “Common” is an estimate: at least 1 in 5 of the 213,895 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
Purpose
When an agent has repeated the same failing action three times, it needs a concrete recovery procedure — not just the instruction to "reassess." This skill defines the recovery steps, the escalation path when the second approach also fails, and the detection patterns that catch loops before they waste effort.
Procedure
- Stop and report. State what was attempted and what failed. Do not retry.
- Check for oscillation. Before diagnosing, review the last several actions. If the agent has been alternating between two states — modifying file A, then file B, then file A again, or toggling between two error messages — the loop is structural, not incidental. Skip straight to step 5 on second detection.
- Check for drift. If recent actions touched files unrelated to the stated goal, the agent is flailing. Acknowledge the drift, discard the unrelated changes, and refocus on the original objective before diagnosing.
- Diagnose. Identify why the approach is not working. The answer must be a root cause, not a symptom — "the API rejects the payload because field X is required" is a diagnosis; "it returns 400" is a symptom.
- Pivot. Propose a fundamentally different approach. Trivial variations (different whitespace, reordered arguments, minor rewording) do not count as a different approach. If no alternative exists, skip to step 7.
- Execute the pivot. Attempt the new approach. If it succeeds, resume normal work. If it fails twice with the same result, proceed to step 7.
- Abandon and hand off. Return a handoff explaining:
- The original approach and why it failed.
- The alternative approach and why it also failed (or why no alternative existed).
- What is needed to unblock (different tooling, human intervention, missing information).
Guardrails
- Never attempt a third approach. Two failed approaches show the problem needs human judgment or context the agent lacks.
- Never retry with debug commands, additional logging, or exploratory reads unless the new information would change the approach — not merely confirm the same failure.
- Never continue after detecting oscillation twice. An A→B→A→B cycle means the two approaches are undoing each other — a third attempt will repeat the pattern.
- Never treat drift (touching unrelated files) as progress. If the last action modified files outside the task scope, revert it before proceeding.
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.

