Claude Code Loops Official Guide: Turn-Based, /goal, /loop, and /schedule (July 2026)
Anthropic's Claude Code team published the official "Getting started with loops" guide on July 7, 2026 — turn-based agentic loops, /goal stop conditions, /loop and /schedule intervals, proactive routines, skills for verification, and token usage. Full breakdown with examples.
On July 7, 2026, @ClaudeDevs published "Getting started with loops" — the official Claude Code team definition of what a loop is, when to use each primitive, and how to keep code quality high while managing token spend. The article by @delba_oliveira passed 1.2M views on X within a day, arriving in the same news cycle as Peter Steinberger's "design loops, not prompts" discourse and Boris Cherny's public loop examples.
If you have been trying to pin down what a loop actually is from scattered tweets, this post is the canonical answer from the people who ship /goal, /loop, and /schedule in the CLI.
explainx.ai has covered loop engineering since June 2026. This article aligns our corpus with Anthropic's taxonomy so you can pick the right primitive instead of over-building orchestration for a task that only needed a sharper verification skill.
Team definition:"Loops are agents repeating cycles of work until a stop condition is met."
Not every task needs a complex loop. The guide's first advice: start with the simplest solution and add primitives selectively.
Why "loops" confused everyone (and how Anthropic fixes it)
June 2026 social discourse treated "loop" as one thing — cron for agents, ralph bash while-loops, Gas Town orchestration, Steinberger's reminder to stop hand-prompting. Multiple correct answers existed because trigger, stop, and verification were conflated.
Anthropic's July 2026 guide splits loops on four axes:
Stop criteria: Claude judges the task complete or needs more context.
Best for: shorter tasks outside a regular schedule.
Manage usage: specific prompts + verification skills to reduce turns.
Every prompt you send starts what Claude Code calls the agentic loop: gather context → act → check → repeat if needed → respond. You are the scheduler; you manually approve the next turn.
Example from the guide — ask Claude to create a like button:
Read your code
Make the edit
Run tests
Hand back something it believes works
You manually verify and write the next prompt
Improving verification with skills
The guide's key upgrade: encode your manual QA as a SKILL.md so Claude checks its own work end-to-end. More quantitative checks → easier self-verification.
Official example skeleton (abridged):
markdown
---
name: verify-frontend-change
description: Verify any UI change end-to-end before declaring it done.
---# Verifying frontend changes
Never report a UI change as complete based on a successful edit alone.
1. Start the dev server and open the edited page in the browser.
2. Interact with the change directly. Screenshot before/after.
3. Check the browser console: zero new errors or warnings.
4. Use the Chrome Devtools MCP, run a performance trace and audit Core Web Vitals.
If any step fails, fix the issue and rerun from step 1 — do not hand back partially verified work.
This is harness engineering in one file: the model is not trusted on "edit succeeded" alone.
When Claude tries to stop early, an evaluator model checks your condition and sends it back to work until the goal is met or the turn budget expires. Deterministic criteria — tests passed, Lighthouse score, empty queue — work best.
Example from the guide:
bash
/goal get the homepage Lighthouse score to 90 or above, stop after 5 tries.
We covered /goal at launch in Claude Code 2.1.139; the official guide now positions it as the middle layer between manual turns and scheduled routines.
When to choose /goal over turn-based: you can write done as a boolean or numeric check. When not to: exploratory refactors where "good enough" is subjective — you will fight the evaluator or burn turns.
Time-based loops — /loop and /schedule
Triggered by: specified time interval.
Stop criteria: you cancel, or the work completes (PR merges, queue empty).
Best for: recurring work or interfacing with external systems that change on their own clock.
Manage usage: longer intervals; prefer event-driven triggers when possible.
/loop — local interval
Runs on your computer. Close the laptop → loop stops.
bash
/loop 5m check my PR, address review comments, and fix failing CI
Triggered by: event or schedule, without you watching.
Stop criteria: each task exits on its goal; the routine runs until disabled.
Best for: recurring streams of well-defined work — bug reports, issue triage, migrations, dependency upgrades.
Manage usage: route routines to smaller, faster models; reserve the most capable model for judgment calls.
The guide composes primitives that explainx.ai has treated separately:
/schedule — fire the routine
/goal — define done per report
Dynamic workflows — orchestrate parallel agents (our deep dive)
Auto mode — run without permission prompts on safe actions
Composite example from the official post:
bash
/schedule every hour: check the project-feedback channel for bug reports. /goal: don't stop until every report found this run is triaged, actioned, and responded to. When fixing a bug, use a workflow to explore three solutions in parallel worktrees and have a judge adversarially review them.
Pilot on a small slice before unleashing hundreds of dynamic workflow agents — the guide warns dynamic workflows can spawn agents at scale and spike token usage.
Maintaining code quality around loops
The official guide argues loop output quality is mostly system design, not model IQ:
1. Keep the codebase clean
Claude follows existing patterns. Messy repos → messy loop diffs. See agent harness engineering for why scaffolding beat raw model upgrades on TerminalBench.
2. Give Claude verification
Skills with measurable checks (tests, Lighthouse, MCP browser tools). Loops without pushback are agents agreeing with themselves — same lesson as fixing local LLM looping with samplers.
3. Make docs easy to reach
Framework docs in context or via MCP reduce re-derivation each turn.
4. Second agent for code review
Fresh-context reviewer reduces bias. Use built-in /code-review or GitHub Code Review integrations.
5. Encode failures into the system
When one iteration fails QA, update the skill or harness — do not only fix the single bug.
Managing token usage
Loops without boundaries are billing incidents. Anthropic's checklist:
Lever
Action
Right primitive
Do not spawn dynamic workflows for a one-file typo
Right model
Smaller models for bulk; capable model for judgment
Clear stop
Specific done + turn caps on /goal
Pilot first
Small slice before full proactive routine
Scripts
Deterministic steps (PDF fill, codegen) as scripts not re-reasoning
Poll interval
Match /loop frequency to how often state changes
Review usage
/usage, /goal (no args), /workflows per-agent spend
Context window management and prompt caching compound with loop design — a 5-minute /loop that re-reads the entire monorepo every tick is a different cost profile than one that calls a focused skill.
How this maps to explainx.ai's loop engineering pathway
Pick one task where you're the bottleneck and ask which piece you could hand off: can you write the verification check? Is the goal clear enough? Does the work arrive on a schedule?
If your bottleneck is…
Hand off…
Start with
Manually clicking through QA
Verification
verify-* skill
Stopping Claude too early / too late
Stop condition
/goal + turn cap
Checking GitHub every hour
Trigger
/loop 60m or /schedule
Triage queue every morning
Full routine
proactive /schedule + /goal
Run the loop, observe where it stalls or over-reaches, iterate on the harness — not just the prompt.
Anthropic's July 7, 2026 loops guide gives developers a shared vocabulary: turn-based agentic loops for manual work, /goal for verifiable stop conditions, /loop and /schedule for time-triggered work, and proactive routines that compose skills, goals, dynamic workflows, and auto mode for always-on tasks.
Quality comes from verification skills and clean repos; cost control comes from right-sized primitives, turn caps, and usage dashboards. Start simple — hand off the check, the stop condition, the trigger, or the full prompt — then iterate the harness when the loop stalls.
Command names, research-preview flags, and doc URLs reflect the July 7, 2026 @ClaudeDevs publication; verify against current Claude Code docs before production rollout.