agentleFS
0-CYBERDYNE-SYSTEMS-00-CYBERDYNE-SYSTEMS-0/FFT_nano/skills/runtime/loops/SKILL.md

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

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.
  • GoogleSkill

    code-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

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

    Before building anything, answer three questions:

    line 10
  2. Distinctive:

    If you can't answer #1, fix that first — a loop without verification just burns tokens confidently.

    line 16
  3. Distinctive:

    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 …

    line 39
  4. Distinctive:

    Always set an explicit turn/attempt cap.

    line 47
  5. Distinctive:

    If the goal keeps failing at the cap, the loop design is wrong — tighten the goal or split it.

    line 48
  6. Distinctive:

    Prefer event triggers (webhook, notification) over polling whenever the system offers one.

    line 60
  7. Distinctive:

    No human in the loop: an event or schedule fires, the agent triages, acts, verifies, and responds on its own.

    line 64
  8. Distinctive:

    Only automate work you've already watched succeed in supervised runs.

    line 69
  9. Distinctive:

    Every task inside the routine needs its own exit condition.

    line 71
  10. Distinctive:

    Keep the codebase clean — the agent amplifies whatever patterns it finds.

    line 75
  11. Distinctive:

    Use a second agent for code review — self-review is biased.

    line 78
  12. Distinctive:

    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.

    line 79

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

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

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:

  1. Can success be verified mechanically? (tests pass, score ≥ N, queue empty)
  2. Is the trigger a person, a goal, a clock, or an event?
  3. 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 typeTriggered byStops whenBest forReach for
Turn-basedUser prompt each turnAgent judges task done / needs inputExploration, decisions, short non-recurring tasksVerification skills
Goal-basedOne prompt with success criteriaGoal met OR max-turn capTasks with verifiable exit criteriaGoal runner (/goal or equivalent)
Time-basedClock interval or scheduleCancelled or work completeRecurring checks, external systems (CI, PRs, inboxes)Interval runner (/loop), cloud scheduler (/schedule, cron)
ProactiveEvents/schedules, no human in the loopEach task exits at its goal; routine runs until disabledWell-defined recurring work: triage, migrations, bug intakeScheduler + 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 tries

Rules:

  • 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:

ConceptClaude CodeOther hosts
Goal runner/goalOne prompt with explicit success criteria + attempt cap, re-invoked until evaluator passes
Interval runner/loop, ScheduleWakeupcron/launchd job re-invoking the agent CLI with the same prompt
Cloud routine/scheduleHosted scheduler, gateway cron, CI scheduled workflow
Verification skillSKILL.mdSame SKILL.md format, or a checked-in verify script the loop must run
Cheap-model routingsubagent model fieldPoint routine steps at a smaller provider/model in your agent's config

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.