Anthropic’s official guide groups repeatable agent execution into four loop patterns based on what triggers a run, when it stops, and which tasks fit best. Short one-off tasks rarely need heavy loop automation up front.

Stopping by Turn vs. Stopping by Goal

Turn-based loops start from a direct user prompt. The agent reads context, runs tool calls, and stops once it judges the task complete or needs clarification. Encoding manual verification steps inside a reusable skill makes turn-based checks repeatable.

Goal-based loops take an explicit completion condition from the user and keep iterating until that check passes. They work best when success can be verified programmatically - such as a test suite turning green or a build succeeding.

Triggering by Clock vs. Triggering Proactively

Time-based loops rerun the same job on a fixed interval. Local /loop runs stop when your machine sleeps or shuts down, whereas cloud /schedule jobs run independently on remote infrastructure - useful for polling external state changes like open PR reviews or CI runs.

Proactive loops kick off automatically from schedules or external events without waiting for a live human prompt, combining schedules, explicit goals, and dynamic workflows for well-bounded chores like recurring bug triage or dependency cleanup.

Controlling Quality and Token Spend

Before scaling loop counts, Anthropic recommends tidying existing codebase patterns, saving verification steps as skills, and having a separate reviewer pass inspect changes. Teams keep token spend predictable by routing smaller tasks to lighter models, setting explicit stop conditions, piloting loops on a small sample before batch rollouts, and tuning schedule intervals so polling jobs do not fire more often than needed.

Summary

  • Turn-based loops run per user request, while goal-based loops iterate until an explicit completion check passes.
  • Time-based loops (/loop, /schedule) run on fixed intervals, while proactive loops trigger automatically from events or schedules.
  • Define verification skills, clear stopping rules, and model cost tiers before scaling up autonomous iteration counts.