A 15-line skill that stops Claude Code agents from burning your quota in loops
If you let a Claude Code agent run unattended, you have probably seen it: the same failing command, retried five times, each retry eating tokens. Or a "sweep" that keeps re-checking a file that has not changed.
The expensive part is not the work, it is the work that goes nowhere. We run several Claude Code sessions every day on one project, and the cheapest fix we found was not a bigger limit. It was two habits, written down once as a skill:
Brief the agent like a colleague, not a command
Before launching a subagent or a repeating task, write four things:
- Goal and why. The agent works better when it knows the purpose, not only the task.
- What it may touch. Files or folders, nothing else.
- A budget. Turns, tokens or minutes.
- The stops (below).
Decide in advance when to stop
Stop and rethink, rather than raising the limit or retrying the same way, if:
- Two checks in a row show no measurable progress (same state, same file, same figure).
- The same error appears twice. Change the cause (a tool in a loop, an API limit) before retrying.
- The budget of the brief is exceeded.
- A git conflict or a locked file blocks progress. Do not force it.
And when the result comes back: at most three follow-up rounds, each with a reason. On the third, close it as applied or discarded. Nothing stays in limbo.
The skill
That is the whole thing. It fits in a plain-text SKILL.md you can read in thirty seconds and drop in your skills folder:
---
name: loop-stop
description: "Brief a long-running agent or loop properly and know when to stop it. Use when launching or watching a subagent, a sweep or any repeating task."
---
The full file, with a short "why it exists" note, is free to use and copy for your own work: https://github.com/happy-program-zero/loop-stop
Honest notes
- This comes from our own experience on one project. We have not measured savings across other projects, so we make no promise about results.
- It is plain text. Read it before you use it; there is nothing hidden in it.
- It is not affiliated with Anthropic. "Claude" and "Claude Code" are trademarks of Anthropic.
If you want the rest of what we use (cross-checking a "done" by another route, a quota budget before long jobs, a daily hand-off report, file-based memory between sessions), there is a paid pack of seven skills: https://plainskills.gumroad.com/l/multi-ai-pack-complete. It is optional; the free one stands on its own.
What stop rules do you use for your own agents? I would like to hear which ones we are missing.
Comments
No comments yet. Start the discussion.