Anthropic's guide to Claude agent loops
Anthropic's Claude Code team just dropped a practical guide on loop engineering, helping developers graduate from babysitting individual prompts to building autonomous agent loops. The framework breaks loops into four distinct levels—turn-based, goal-based using /goal, time-based using /loop and /schedule, and proactive routines—while offering tricks like SKILL.md self-verification to keep token costs in check. Basically, it shows how to turn open-ended coding agents into deterministic, self-healing workers.

Forget prompt engineering for a second. The Claude Code team thinks you should be designing loops instead.
Anthropic just dropped an engineering guide that breaks down how it views agentic loops. The core idea is dead simple: an AI agent keeps repeating cycles of work until an explicit stop condition is met, rather than waiting on you after every single turn.
The four stages of letting Claude work
The guide lays out four loop types based on who triggers them and what makes them stop.
First is the turn-based loop. You type a prompt, Claude does the work, and hands it back. To keep Claude from handing back broken code, the team suggests writing a SKILL.md file. This forces the agent to spin up a local server, click around, check DevTools for console errors, and verify changes before reporting back.
Second is the goal-based loop using the /goal command. Instead of letting Claude guess when something is good enough, you give it verifiable exit criteria. Think along the lines of hitting a Lighthouse score of 90 with a cap of five tries. A separate evaluator model keeps kicking Claude back to work until it actually hits the mark.
Third is time-based loops. The /loop command runs a task on your local machine every few minutes, like monitoring a pull request for fresh review comments or broken CI builds. If you want it running while your laptop is closed, /schedule moves that routine to the cloud.
Finally, proactive loops combine everything with auto mode and dynamic workflows. Anthropic showed off an autonomous setup that watches a feedback channel for bugs every hour, spins up three parallel Git worktrees to test competing fixes, and has a separate judge agent pick the best one.
Keeping token bills on a leash
Letting agents run on autopilot can empty your API wallet fast, especially since dynamic workflows can spawn hundreds of subagents. Anthropic recommends running small pilot batches before letting a loop loose on an entire codebase.
They also emphasize using deterministic scripts whenever possible. If you need to fill out a PDF, do not let Claude re-derive the logic every time. Ship a Python script inside a skill and let Claude run it instead.
To check your damage in real time, you can run /usage to inspect token breakdowns across subagents and MCPs, or type /goal without arguments to see your turn count and current burn rate.
Why it matters
We think this guide signals where AI coding is actually heading. The bottleneck is no longer how eloquently you ask the model to build a feature. It is whether you can define verifiable criteria that allow the model to grade its own homework without human intervention.
For engineers, this makes Claude Code significantly more useful for well-scoped chores like fixing test suites, migrating dependencies, or bumping performance scores. If you have clear pass/fail metrics, setting up a loop is worth trying right now.
The clever part here is Anthropic's honesty. Instead of pretending LLMs never make mistakes, they bake in adversarial second-opinion agents and tell you to replace expensive reasoning with cheap scripts. The risk, however, is that autonomous worktree loops can easily trigger nasty merge conflicts or spiral into expensive retry loops if your verification steps have edge cases.
Sources (1)
- claude.com(opens in a new tab)Originalclaude.com