From officialunofficial-skills
Reference for designing agent loops — goal-based, time-based, and proactive shapes with stop conditions, state management, and unattended operation guidance.
How this skill is triggered — by the user, by Claude, or both
Slash command
/officialunofficial-skills:designing-loopsThe summary Claude sees in its skill listing — used to decide when to auto-load this skill
A **loop** is an agent repeating cycles of work until a **stop condition** is met. Every loop is a choice along two axes: what **triggers** the next cycle, and what **stops** it. Get both right and the loop runs unattended; get either wrong and it either stalls waiting on you or burns turns past the point of being useful.
A loop is an agent repeating cycles of work until a stop condition is met. Every loop is a choice along two axes: what triggers the next cycle, and what stops it. Get both right and the loop runs unattended; get either wrong and it either stalls waiting on you or burns turns past the point of being useful.
Not all tasks need a loop. Start with a single turn — write the prompt, look at the result, write the next prompt — and reach for the shapes below only once that manual cycle itself becomes the bottleneck.
| Shape | Triggered by | Stops when | Fits |
|---|---|---|---|
| Turn-based | You, each prompt | The agent judges the task done, or needs more from you | Short, one-off tasks outside any regular process |
| Goal-based | You, once, in real time | The goal is met, or a turn cap is hit | Tasks with a verifiable exit condition |
| Time-based | A schedule (local interval or cloud cron) | You cancel it, or the underlying work runs out (queue empties, PR merges) | Recurring work, or watching an external system that changes on its own clock |
| Proactive | An event or schedule, no human watching | Each cycle's goal is met; the loop itself runs until switched off | A recurring stream of well-defined work — triage, migrations, upgrades |
Turn-based is the default — it's just talking to the agent. The other three trade a bit of setup for running unattended; pick the cheapest shape that still gets you a real stop condition.
Goal-based turns "keep going until this is good enough" into a bounded loop: define what done looks like, and an evaluator checks that condition each time the agent tries to stop, sending it back to work until the goal is met or the turn cap is reached. The turn cap is what keeps a fuzzy goal from running forever — always set one.
Time-based is for work that either recurs on a fixed schedule (summarize overnight activity every morning) or watches something whose state changes on its own — a build, a review queue, a deploy. Reacting to an external system on an interval is usually simpler than wiring a webhook, provided the interval isn't tighter than the thing you're watching actually changes.
Proactive loops compose the other primitives: a recurring trigger picks up a stream of same-shaped work (bug reports, dependency bumps, migration units), a goal defines done for each item, and the agent runs without stopping to ask permission on each one. This is where /triage and /implement-style skills earn their keep — the loop's job is routing items to them, not reinventing the procedure each cycle. A proactive loop also needs a way to act on the outside world — open a PR, move a tracker card, post a notification — so wire up those integrations before you wire up the schedule; a loop that can only read is a report generator, not a loop.
A loop is only as good as its stop condition. Rank criteria by how directly they're checkable:
Whatever the criterion, make it specific enough that the agent reaches it, not so loose it stops early and not so vague it never stops. "Tests pass" beats "the code looks right"; "zero P0/P1 findings" beats "no major issues."
A time-based or proactive loop's cycles are largely independent — each firing may start from a clean slate, with no memory of what the last cycle found. If the loop's job is "report only what changed" or "don't redo settled work," that comparison needs something to compare against, and the loop itself won't remember it: the agent forgets, the record doesn't. Give the loop an external place to write down what it did and what's still open — a state file, a tracker board, a running doc in the repo — and have every cycle read it before acting and update it before stopping. Without this, a delta-reporting loop either re-announces the same status forever or silently loses track of what it already handled.
The moment a loop runs more than one agent against the same repo at the same time — a fan-out over several items, or a cycle overlapping with the next one — they can collide on the same working copy: one agent's uncommitted edit clobbers another's, or a build artifact from one poisons the other's run. Give each concurrent agent its own working directory on its own branch, sharing the repo's history rather than its live checkout. Reach for this whenever "at the same time" and "same repo" are both true; a loop that only ever runs one agent at a time doesn't need it.
Loops multiply cost by however many cycles they run, so bound them deliberately:
A loop's output quality depends on the system around it, not the loop itself:
A loop takes the prompting off your plate. It doesn't take verification off your plate — a loop running unattended is also a loop making mistakes unattended, just at whatever cadence you set it. Three things to actively guard against once a loop is running well enough that you stop watching it closely:
Design a loop like you intend to stay the engineer responsible for what it ships, not like you're handing off the job.
npx claudepluginhub officialunofficial/skills --plugin officialunofficial-skillsGuides collaborative design exploration before implementation: explores context, asks clarifying questions, proposes approaches, and writes a design doc for user approval.
Creates structured, bite-sized implementation plans from specs or requirements before writing code. Useful for breaking down multi-step tasks into testable steps with file structure and task boundaries.
Resolves in-progress git merge or rebase conflicts by analyzing history, understanding intent, and preserving both changes where possible. Runs automated checks after resolution.