Security·terminal·MIT
loop-guard
After the same failure twice, a hidden note tells Claude to change approach.

loop-guard catches Claude running the same failing call again. When a tool call fails twice in a row with the same arguments and the same error, it attaches a note to the second error that only the model reads: do not run it a third time, re-read the error, question the assumption behind the call, then try another approach or ask you. A toast tells you the note went out.
It never refuses a call. That is the difference from Loop Breaker, which blocks the third identical try and also catches edits that flip a file back and forth.
What counts as a repeat
- The same call: same tool, same arguments, same agent. The
descriptionfield is ignored, because Claude words it anew on each try. A subagent’s failures are counted apart from the main thread’s. - The same error: the error text must match exactly. Running
npm testagain after a fix usually fails with different output, so it is not flagged. - Once per streak: the note and the toast go out once per call. A success of that call clears its record, and a later pair of identical failures sends them again.
- Resets:
/clearand an interrupted turn (Esc) clear every record, since a call you stop fails with the same text each time.
Install
Needs Claude Code 2.1.287 or later.
claude plugin marketplace add arasovic/claude-code-mods
claude plugin install loop-guard@claude-code-mods
Restart Claude Code. There is no command: it watches every tool call from then on.
The add command registers a marketplace called claude-code-mods, the same name that karanb192/claude-code-mods and a few other repos use. If claude plugin marketplace list already shows a claude-code-mods from another author, run claude plugin marketplace remove claude-code-mods before adding this one. If it is already this author’s, skip the add.
How it works
One tool.call hook wraps every call from Claude and its subagents. It lets the call run, then reads the result. Each call is keyed on its full input, minus the call id and the description, and the hook keeps the last error text for each key. A call refused by a permission rule or another hook is skipped: it neither counts as a failure nor clears one.
When the second error matches the stored one, the note goes into the result’s context, so the model reads it next to the error. turn.complete clears everything when the turn was interrupted, and session.end clears it too.
The records live in memory only. Nothing is written to disk and nothing goes over the network. The only token cost is the note, about 45 words, once per repeated failure.
Limitations
- An error that carries a timestamp or a random id differs on every run, so it is never flagged.
- Only the last error of a call is kept. Failing with error A, then B, then A again sends no note.
- The note is advice. If the model ignores it, the third call still runs.
- The author shows the toast only in the terminal. Where mods run without drawing, such as
claude -p, the note still reaches the model but no toast appears.
Similar Claude Mods
loop-detective
Opens a case when the same Bash command keeps failing the same way, with the evidence.
cache-timer
A countdown above the prompt to the moment the prompt cache goes cold.
blast-radius
Shows what rm -rf or a force push would change and waits for Proceed or Cancel.
pii-guard
Reversible Taiwanese PII redaction for tool results, prompts and writes, all on loopback.
Popular Claude Mods
The whole directory →savvy-progress
Running, finished and planned subagents with model, context, cost and time, in one panel.
claude-latex
TeX math, TikZ diagrams and LaTeX blocks typeset in Claude's replies, in the desktop app.
agent-profiler
Model wait, tools and subagents as shares of session time, live, with OTLP export.
source-control
Git status above the prompt and a VS Code-style panel to commit, sync and resolve.




