Anthropic's Guide to "Loop Engineering" — 4 Loop Types for Claude Code, Straight From the Source

Anthropic just published a field guide on what they're calling "loop engineering" — designing Claude Code to repeat cycles of work until a stop condition is met, instead of just answering one prompt at a time. It lays out four loop types, when to use each, and how to keep the token bill…

Anthropic just published a field guide on what they're calling "loop engineering" — designing Claude Code to repeat cycles of work until a stop condition is met, instead of just answering one prompt at a time. It lays out four loop types, when to use each, and how to keep the token bill from running away on you.

The Four Loop Types

  • Turn-based — you prompt, Claude works until it thinks it's done or needs you. Good for one-off asks like "build this UI component."
  • Goal-based (`/goal`) — you give explicit success criteria and Claude keeps iterating until it hits them or maxes out turns. Example from Anthropic: "get the homepage Lighthouse score to 90 or above, stop after 5 tries." An evaluator model checks whether the condition is met each round.
  • Time-based (`/loop` and `/schedule`) — runs on an interval. `/loop` runs locally and stops when you turn it off; `/schedule` moves the same idea to the cloud. Example: check a PR and fix failing CI every 5 minutes.
  • Proactive — triggered by events or a schedule with no human in the loop at all, runs until you disable it. Meant for recurring work like triaging bug reports — combines `/schedule`, `/goal`, skills, and "dynamic workflows" (a research-preview feature that can spawn hundreds of parallel agents).

What Makes a Loop Actually Work

  • Skills as verification — Anthropic's example is a "verify-frontend-change" skill that starts a dev server, clicks through the UI, checks the browser console for errors, and runs a performance audit. The point: give Claude a quantitative check (tests passed, score threshold), not a vibe check.
  • Fresh-context code review — use a second agent (the built-in `/code-review` skill) so review isn't biased by the same context that wrote the code.
  • Model routing — cheap/fast models for small repetitive steps, save the expensive model for actual judgment calls.

Watching the Cost

  • `/usage` — tracks cost by skill, subagent, and MCP
  • `/goal` — shows turn and token counts for a running goal-loop
  • `/workflows` — shows per-agent token usage in a dynamic workflow

Anthropic's own framing: model and effort-level choice are "among the biggest levers" on what a loop costs you.

Watch Out

  • Not every task needs a loop — Anthropic's own advice is to start with the simplest thing that works and only reach for `/goal` or `/schedule` when there's a real recurring or verifiable-exit-criteria task.
  • Goal criteria that are too strict stop the loop early (wasted setup, no result); too loose and it burns tokens chasing a fuzzy target. Deterministic checks (test counts, score thresholds) work best.
  • Dynamic workflows can spawn hundreds of agents — pilot on a small slice of work before letting one rip on something big.
  • Loop quality is only as good as your codebase, docs, and skill definitions underneath it — a messy repo makes a messy loop.

Key Takeaways

  • Four loop types now have names: turn-based, goal-based (`/goal`), time-based (`/loop`/`/schedule`), and proactive.
  • If you're already running a Ralph-style loop in CCP, this is Anthropic's own vocabulary for the same idea — `/goal` is the built-in version of "keep going until the test passes."
  • Check cost with `/usage`, `/goal`, and `/workflows` before you scale any loop up.

Source

claude.com/blog/getting-started-with-loops


Source: claude.com

We break down Claude Code news like this every day in the free community. Join the crew on Skool.