The four types of agent loops
A loop is an agent repeating cycles of work until a stop condition is met — not a skill you install. Loops are categorized by how they're triggered, how they're stopped, and which Claude Code primitive they use. Start with the simplest that fits; use these patterns selectively.
Turn-based loop
the agentic loop (every prompt)Every prompt starts one: Claude gathers context, acts, checks its work, repeats if needed, and responds — then you verify and write the next prompt. Improve the verification step by encoding your manual checks as a SKILL.md (e.g. verify-frontend-change) so Claude can self-verify end-to-end. The more quantitative the checks, the fewer turns it takes.
- triggered by
- A user prompt
- stops when
- Claude judges the task done or needs more context
- best for
- Shorter, one-off tasks that aren't part of a schedule
Goal-based loop
/goalDefine what done looks like and Claude keeps iterating instead of stopping early on 'good enough.' Each time Claude tries to stop, an evaluator model checks your condition and sends it back to work until the goal is met or your turn cap is hit. Deterministic criteria — tests passed, a score threshold — work best.
- triggered by
- A manual prompt in real time
- stops when
- The goal is achieved OR a max number of turns is reached
- best for
- Tasks with verifiable exit criteria
/goal get the homepage Lighthouse score to 90 or above, stop after 5 tries.
Time-based loop
/loop and /scheduleSome work is recurring — the task stays the same and only the inputs change. Other work depends on an external system you check on an interval and react to. /loop re-runs a prompt on your machine (stop it by turning it off); move it to the cloud as a routine with /schedule. Manage usage with longer intervals or event-driven reactions.
- triggered by
- A specified time interval
- stops when
- You cancel it, or the work completes (PR merges, queue empties)
- best for
- Recurring work, or interfacing with external systems
/loop 5m check my PR, address review comments, and fix failing CI
Proactive loop
/schedule + /goal + skills + dynamic workflows + auto modeCompose the primitives for long-running work: /schedule runs a routine that checks for new work, /goal defines done and skills document how to verify it, dynamic workflows orchestrate agents that triage and fix each item, and auto mode runs it without stopping for permission. Route routines to smaller, faster models and reserve the most capable model for judgment calls.
- triggered by
- An event or schedule, with no human in real time
- stops when
- Each task exits when its goal is met; the routine runs until you turn it off
- best for
- Recurring streams of well-defined work: bug reports, triage, migrations, upgrades
/schedule every hour: check the project-feedback channel for bug reports. /goal: don't stop until every report found this run is triaged, actioned, and responded to. When fixing a bug, use a workflow to explore three solutions in parallel worktrees and have a judge adversarially review them.
Loop tooling & patterns
Installable skills and community patterns that make loops reliable — methodologies, autonomous-loop frameworks, and self-audit prompts.