loops
Skill4 starsChanged 8 months agoMITView on GitHub
Design agent loops instead of prompting turn-by-turn: pick the right loop type (turn-based, goal-based, time-based, proactive), define stop conditions and verification, and control token burn. Use when the user wants recurring/autonomous agent work, asks 'make this run until done', 'check X every N minutes', 'keep iterating until tests pass', or asks which loop primitive to reach for. Based on Anthropic's 'Getting started with loops'.
12 other projects use a version of this.
Adopted by
Most recently taken up by
- sophonfinance-wq/finance-automation-portfoliotheir own version, first seen Nov 1, 2026
- anlmalabs/skillstheir own version, first seen Oct 25, 2026
- 5dive-ai/skillstheir own version, first seen Oct 5, 2026
- xmeir-dev/skillstheir own version, first seen Oct 4, 2026
- vivary-dev/vivarytheir own version, first seen Sep 27, 2026
- michielhdoteth/awesome-ai-agent-toolstheir own version, first seen Aug 24, 2026
Used with
Projects with it also use code-review.
Other files people use alongside this one.
Files found in the same public projects as a version of this one, more often than they turn up anywhere else. Each project counts once, large collections count for less, and this file's own repository is left out.
GoogleSkillcode-review
Adversarial systems, concurrency, memory-model, and architecture code review protocol. Use this skill whenever asked to review code, PRs, diffs, or branches in Filament.
Also in 3 projects that use this
Other versions12 projects use a version of this.
Word for word · 0
None found.
Edited · 0
None found.
Wrote their own version · 12
- jwangkun/loops★ 123same name
- michielhdoteth/awesome-ai-agent-tools★ 62same name
- sophonfinance-wq/finance-automation-portfolio★ 16same name
- vivary-dev/vivary-cli★ 4same name
- weselben/RooForge★ 4same name
- 5dive-ai/skills★ 2same name
- miketromba/skills★ 2same name
- thepictishbeast/claude-tools★ 1same name
- vivary-dev/vivary★ 1same name
- anlmalabs/skills★ 0same name
2 more not listed
How matches are found. Word for word: the exact same text. Edited: shares passages with this file (“99% same” means 99% of its five-word phrases also appear here; 10% or more counts). Their own version: similar meaning, or, weakest, the same name. We can’t tell which project had it first. Projects are counted among the 200 most-starred candidates, and mentions are links to the repository we found, up to 50 per site, so both counts are a floor.
In this repository23 other files it gives its agents.
- AGENTS.mdAGENTS.md
- CLAUDE.mdCLAUDE.md
- add-telegramSkill
- add-telegram-swarmSkill
- agent-browserSkill
- agent-harness-engineerSkill
- autoresearch-createSkill
- autoresearch-finalizeSkill
- fft-coder-opsSkill
- fft-dashboard-opsSkill
- fft-debugSkill
- fft-farm-bootstrapSkill
- fft-farm-onboardingSkill
- fft-farm-opsSkill
- fft-host-ipcSkill
- fft-setupSkill
- fft-telegram-opsSkill
- rapid-researchSkill
- skill-mechanicSkill
- web-searchSkill
- customizeSkill
- debugSkill
- setupSkill
The file
We split this skill into the rules it gives an agent
12 rules. 0 are common, 12 are distinctive, and 0 are very specific to this project.
0
Common
Most of the 10 edited versions we read keep these.
12
Distinctive
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 10
Before building anything, answer three questions:
- Distinctive: line 16
If you can't answer #1, fix that first — a loop without verification just burns tokens confidently.
- Distinctive: line 39
Don't let the agent decide "good enough" — you define success, an evaluator checks it, and the loop either exits or goes back for another …
- Distinctive: line 47
Always set an explicit turn/attempt cap.
- Distinctive: line 48
If the goal keeps failing at the cap, the loop design is wrong — tighten the goal or split it.
- Distinctive: line 60
Prefer event triggers (webhook, notification) over polling whenever the system offers one.
- Distinctive: line 64
No human in the loop: an event or schedule fires, the agent triages, acts, verifies, and responds on its own.
- Distinctive: line 69
Only automate work you've already watched succeed in supervised runs.
- Distinctive: line 71
Every task inside the routine needs its own exit condition.
- Distinctive: line 75
Keep the codebase clean — the agent amplifies whatever patterns it finds.
- Distinctive: line 78
Use a second agent for code review — self-review is biased.
- Distinctive: line 79
When a loop produces a bad result, don't just fix the output: encode the fix (skill, check, doc) so the next iteration can't repeat it.
“Common” is measured: kept by at least 6 in 10 of the 10 edited versions of this file we could read. “Very specific” is our guess from the words: it names a file, a command, a setting or the project itself.
Files
Loops
A loop is an agent repeating cycles of work — gather context, act, verify — until a stop condition is met. Stop being the loop yourself: encode the trigger, the work, the verification, and the exit, then let the agent run.
Before building anything, answer three questions:
- Can success be verified mechanically? (tests pass, score ≥ N, queue empty)
- Is the trigger a person, a goal, a clock, or an event?
- What is the hard stop? (goal met, max turns, cancellation)
If you can't answer #1, fix that first — a loop without verification just burns tokens confidently.
Choose the loop type
| Loop type | Triggered by | Stops when | Best for | Reach for |
| Turn-based | User prompt each turn | Agent judges task done / needs input | Exploration, decisions, short non-recurring tasks | Verification skills |
| Goal-based | One prompt with success criteria | Goal met OR max-turn cap | Tasks with verifiable exit criteria | Goal runner (/goal or equivalent) |
| Time-based | Clock interval or schedule | Cancelled or work complete | Recurring checks, external systems (CI, PRs, inboxes) | Interval runner (/loop), cloud scheduler (/schedule, cron) |
| Proactive | Events/schedules, no human in the loop | Each task exits at its goal; routine runs until disabled | Well-defined recurring work: triage, migrations, bug intake | Scheduler + goals + skills + subagent workflows combined |
Escalate only as needed: don't build a proactive routine for something a single goal-based run finishes this afternoon.
1. Turn-based loops
You direct each turn; the agent iterates within it. The lever is verification you encode once: put your quality bar in a skill so every turn self-checks before declaring done.
Example verification skill content: start the dev server, exercise the changed flow, check console for errors, run the perf/lint audit, only then report complete. Quantitative checks beat vibes.
Token control: specific prompts, and skills instead of re-explaining standards every turn.
2. Goal-based loops
Don't let the agent decide "good enough" — you define success, an evaluator checks it, and the loop either exits or goes back for another iteration.
/goal get the homepage Lighthouse score to 90 or above, stop after 5 triesRules:
- Criteria must be deterministic and checkable: test pass rate, score threshold, build green. "Make it better" is not a goal.
- Always set an explicit turn/attempt cap. The cap is your budget.
- If the goal keeps failing at the cap, the loop design is wrong — tighten the goal or split it; don't just raise the cap.
3. Time-based loops
For work that arrives on a clock or lives in external systems the agent can't be notified about.
/loop 5m check my PR, address review comments, and fix failing CI- Local interval runner (
/loop) for things tied to your machine/session; cloud scheduler (/schedule, cron, launchd) for routines that should survive without you. - Match the interval to how fast the watched thing actually changes — polling a nightly job every 5 minutes is pure waste.
- Prefer event triggers (webhook, notification) over polling whenever the system offers one.
4. Proactive loops
No human in the loop: an event or schedule fires, the agent triages, acts, verifies, and responds on its own. Compose the other primitives — scheduler + goal criteria + skills + subagent workflows.
Example routine: "Check #project-feedback hourly. Don't stop until every report is triaged, actioned, and responded to. When fixing bugs, explore three candidate solutions and have a second agent adversarially review before merging."
Rules:
- Only automate work you've already watched succeed in supervised runs.
- Route routine steps to smaller/cheaper models; reserve the capable model for judgment calls and review.
- Every task inside the routine needs its own exit condition; the routine itself runs until disabled.
Keeping quality high inside a loop
- Keep the codebase clean — the agent amplifies whatever patterns it finds.
- Encode standards and verification steps as skills so they apply on every iteration, not just when you remember to say them.
- Make framework/library docs easily reachable (local copies, links in skills) so the loop doesn't guess.
- Use a second agent for code review — self-review is biased.
- When a loop produces a bad result, don't just fix the output: encode the fix (skill, check, doc) so the next iteration can't repeat it.
Managing token burn
- Pick the simplest primitive that works; multi-agent proactive routines are the last resort, not the default.
- Specific success criteria = fewer wasted turns.
- Pilot on a small slice before scaling a dynamic workflow to the full dataset/repo.
- Push deterministic steps into scripts — a script is cheaper than reasoning through the same steps every cycle.
- Set intervals by the watched system's rate of change, not by impatience.
- Review usage regularly (
/usage, goal turn counts, per-workflow breakdowns) and tune the loop, the model mix, or the interval.
Getting started
Find the bottleneck work you keep manually shepherding, then ask: Can I write a verification check for it? Is the goal crisp? Does it arrive on a schedule or event? Pick the matching loop type, run it small, watch where it stalls or over-reaches, and iterate on the loop design — not just the prompt.
Platform mapping
The primitives above are Claude Code's names. On other hosts, map the concepts:
| Concept | Claude Code | Other hosts |
| Goal runner | /goal | One prompt with explicit success criteria + attempt cap, re-invoked until evaluator passes |
| Interval runner | /loop, ScheduleWakeup | cron/launchd job re-invoking the agent CLI with the same prompt |
| Cloud routine | /schedule | Hosted scheduler, gateway cron, CI scheduled workflow |
| Verification skill | SKILL.md | Same SKILL.md format, or a checked-in verify script the loop must run |
| Cheap-model routing | subagent model field | Point routine steps at a smaller provider/model in your agent's config |
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.

