← All tutorials
Loop Engineering

Loop engineering β€” getting started with loops

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.

triggerβ†’ gather β†’ act β†’ verifyβ†Ί repeat until…→ stop
Why loops. Single turns need you between every step. Loops move you out of the inner cycle β€” handing off the triggering, the verification, and the stopping β€” so the agent iterates on complex or recurring work without you as the bottleneck.

Framing  Anatomy of a loop

Every loop is defined by three choices. Nail these and you've designed the loop:

▢️ Trigger

What starts a cycle β€” a manual prompt, a schedule, an event, or a goal being defined.

πŸ›‘ Stop criteria

What ends it β€” a user action, a goal achieved, a turn limit, or external completion.

🧩 Primitive

Which Claude Code capability powers it β€” skills, auto mode, or dynamic workflows.

Design tip. Prefer deterministic stop criteria β€” "tests pass," "score β‰₯ 0.9," "no new items" β€” over subjective judgments. They're what make a loop safe to run unattended.

The taxonomy  The four loop types

Loops fall into four kinds, along a ladder of increasing autonomy:

The four loop types by autonomy From least to most autonomous: turn-based (manual prompt, you direct each turn), goal-based (/goal, stops when criteria met), time-based (/loop and /schedule, runs on a schedule), and proactive (fully autonomous routines combining schedule, goals and workflows). Turn-based manual prompt you direct each turn Goal-based /goal stops when criteria met Time-based /loop Β· /schedule runs on a schedule Proactive autonomous routine schedule + goal + flows less autonomy Β· more control more autonomy

β‘  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.

β‘‘ Goal-based /goal β€” iterate to a target

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

β‘’ Time-based /loop Β· /schedule β€” recurring

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.

β‘£ Proactive fully autonomous routines

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.

The toolbox  The primitives that power loops

πŸ“‹ Skills

Verification standards encoded as SKILL.md files, so the agent can self-check its work against your criteria.

βš™οΈ Dynamic workflows

Orchestrate multiple agents in parallel to decompose and cover a task (a research-preview capability).

⚑ Auto mode

Execute steps without pausing for permission β€” removes approval delays inside the loop.

πŸ§‘β€πŸ”§ Subagents

Specialized agents for focused sub-tasks (e.g. an independent reviewer) within a larger loop.

loops as slash commands (illustrative)
# 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)

In practice  A worked example β€” proactive bug triage

A single proactive loop can own a recurring chore end to end by combining the primitives:

⏱ /schedule 1hβ†’ check for new bug reportsβ†’ βš™οΈ workflow: triage Β· fix Β· review (parallel)β†’ πŸ“‹ goal + skills verifyβ†’ open PR

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.

How to begin  Getting started

#Step
1Identify a task where you are the bottleneck.
2Decide what you could hand off β€” the verification, the stop condition, the triggering.
3Pick the loop type that matches (turn / goal / time / proactive).
4Run it and observe where it stalls or over-reaches.
5Iterate on the design β€” tighten criteria, adjust cadence, add a review subagent.
Start small. Not every task needs a complex loop β€” begin with the simplest type that removes you from the cycle, and climb toward proactive only as trust and criteria firm up.

Guardrails  Best practices & limits

Keep loops trustworthy

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.

Manage cost & runaway

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.

The mindset shift. Loop engineering is less about writing a clever prompt and more about designing a system: what triggers it, how it verifies itself, and when it stops. Get those right and the agent does the loop; you do the review.

Cheat sheet

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

Knowledge check

Six questions on loop engineering. Pick an answer for each, then check your score.

1. What is a "loop"?

2. Which three choices define a loop?

3. A loop that iterates until an evaluator confirms success criteria are met is…

4. "Summarize the team Slack every morning" is which type of loop?

5. What kind of stop criteria are recommended for unattended loops?

6. What's the recommended way to start with loops?

Next steps

πŸ“„ The blog post

Getting started with loops β€” the original Claude Code write-up this guide is based on.

πŸ” Anthropic architectures

Workflows & the agent loop β€” the inner cycle a loop repeats.

🧭 Google agent patterns

Multi-agent topologies β€” how dynamic workflows coordinate agents.

πŸ› οΈ Harness vs Loop vs Graph

The bigger picture β€” where loops sit on the control-vs-autonomy spectrum.

🧡 Concurrency Design

Run agents at scale β€” per-run context isolation, budgets, and queue-and-worker architecture.

πŸ““ All tutorials

The hub β€” LLMs, agents, protocols, cloud & more.