β Turn-based manual, one cycle at a time
Trigger A manual prompt. Stops when you take the next action. Use for exploratory or high-touch work where you steer every turn.
A loop is an agent repeating cycles of work until a stop condition is met. It's a shift from one-shot prompting toward designing automated workflows that iterate on their own β gathering context, acting, verifying, and going again until they're done.
Every loop is defined by three choices. Nail these and you've designed the loop:
What starts a cycle β a manual prompt, a schedule, an event, or a goal being defined.
What ends it β a user action, a goal achieved, a turn limit, or external completion.
Which Claude Code capability powers it β skills, auto mode, or dynamic workflows.
Loops fall into four kinds, along a ladder of increasing autonomy:
Trigger A manual prompt. Stops when you take the next action. Use for exploratory or high-touch work where you steer every turn.
Trigger You define success criteria. Stops when an evaluator confirms the goal is met (with a turn cap as a backstop). Use for "make the tests pass," "get the score above X."
Trigger A schedule / interval. Stops per run (or on your cancel). Use for recurring work β "summarize the #eng Slack every morning," monitoring an external system that changes over time.
Trigger Schedule/event, combined with goals + workflows + auto mode. Stops on goal completion or external completion. Use for well-defined work: bug triage, issue handling, migrations, dependency upgrades.
Verification standards encoded as SKILL.md files, so the agent can self-check its work against your criteria.
Orchestrate multiple agents in parallel to decompose and cover a task (a research-preview capability).
Execute steps without pausing for permission β removes approval delays inside the loop.
Specialized agents for focused sub-tasks (e.g. an independent reviewer) within a larger loop.
# Time-based: recurring summary
/loop 24h summarize yesterday's #eng Slack and post the highlights
# Goal-based: iterate until a deterministic criterion is met
/goal make the failing tests in tests/ pass # evaluator checks; turn cap as backstop
# Proactive routine: schedule + goal + workflow + auto mode
/schedule 1h triage new bug reports, fix, open a PR, and request review
# Keep an eye on cost & progress
/usage Β· /workflows Β· /goal (metrics & dashboards)
A single proactive loop can own a recurring chore end to end by combining the primitives:
Here /schedule checks for new reports hourly (trigger), /goal plus a verification skill defines "done" (stop), dynamic workflows triage, fix and review in parallel, and auto mode removes approval delays. You review the PRs β not every step.
| # | Step |
|---|---|
| 1 | Identify a task where you are the bottleneck. |
| 2 | Decide what you could hand off β the verification, the stop condition, the triggering. |
| 3 | Pick the loop type that matches (turn / goal / time / proactive). |
| 4 | Run it and observe where it stalls or over-reaches. |
| 5 | Iterate on the design β tighten criteria, adjust cadence, add a review subagent. |
Do Keep the codebase clean (the agent follows existing patterns), encode verification standards in skills, keep docs accessible, and deploy a secondary agent for independent review.
Do Match primitives and models to task complexity; use deterministic scripts for routine work instead of reasoning; align schedule intervals with how often things actually change; pilot dynamic workflows before scaling; and monitor with /usage, /goal metrics and the /workflows dashboard.
Watch Token cost scales with agent complexity and frequency; turn caps prevent runaway iterations but need calibration; subjective stop criteria are unreliable β prefer measurable ones.
| Question | Short answer |
|---|---|
| What is a loop? | An agent repeating cycles of work until a stop condition is met. |
| What defines a loop? | Its trigger, its stop criteria, and the primitive that powers it. |
| The four types? | Turn-based, Goal-based (/goal), Time-based (/loop Β· /schedule), Proactive. |
| The primitives? | Skills, dynamic workflows, auto mode, subagents. |
| Best kind of stop criteria? | Deterministic (tests pass, score threshold) over subjective judgment. |
| How to start? | Find where you're the bottleneck; hand off verification & stopping; start simple. |
Six questions on loop engineering. Pick an answer for each, then check your score.
Getting started with loops β the original Claude Code write-up this guide is based on.
Workflows & the agent loop β the inner cycle a loop repeats.
Multi-agent topologies β how dynamic workflows coordinate agents.
The bigger picture β where loops sit on the control-vs-autonomy spectrum.
Run agents at scale β per-run context isolation, budgets, and queue-and-worker architecture.
The hub β LLMs, agents, protocols, cloud & more.