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.
Update — July 17, 2026: Boris Cherny published Steps of AI Adoption — a 0–4 maturity ladder (Gated → AI-native) where Step 3 requires routines, /loop, /goal, and subagents — this loops guide is the primitive reference for that step.
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.
For long Sonnet execution + Fable direction on those loops, pair with Fable advisor + Sonnet executor setup and @ClaudeDevs advisor benchmarks.
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.
TL;DR — Loop types at a glance
| Loop type | You hand off | Trigger | Stop when | Best for | Reach for |
|---|---|---|---|---|---|
| Turn-based | The check (verification) | User prompt | Claude judges done or needs context | Exploration, short tasks | Custom skills |
Goal-based (/goal) | The stop condition | Manual prompt | Goal met OR max turns | Verifiable exit criteria | /goal |
Time-based (/loop, /schedule) | The trigger (interval) | Fixed interval | You cancel or work completes | Recurring / external systems | /loop, /schedule |
| Proactive | The prompt (routine) | Event or schedule, no human live | Per-task goal; routine until off | Bug triage, upgrades, migrations | All above + dynamic workflows |
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:
- How they are triggered
- How they are stopped
- Which Claude Code primitive is used
- What task type fits
That framing maps directly to context vs prompt vs loop vs harness engineering: the loop is the execution cycle; harness and skills are what make cycles safe.
Turn-based loops — every prompt is a manual loop
Triggered by: a user prompt.
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):
---
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.
explainx.ai ships skills under /skills; the pattern matches steering Claude Code with CLAUDE.md, skills, and hooks.
Goal-based loops — /goal owns the stop condition
Triggered by: manual prompt in real time.
Stop criteria: goal achieved OR maximum turns reached.
Best for: tasks with verifiable exit criteria.
Manage usage: explicit completion criteria + turn caps ("stop after 5 tries").
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:
/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.
/loop 5m check my PR, address review comments, and fix failing CI
This is the primitive Boris Cherny popularized with "babysit all my PRs" and what top 10 coding loop patterns document for CI and review workflows.
/schedule — cloud routine (research preview)
Same idea, but moves to the cloud so the routine persists without your session. Pairs with proactive compositions below.
Docs: Claude Code scheduled tasks, loop command, schedule.
Proactive loops — no human in real time
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:
/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.
That single line is loop engineering at production depth: schedule + goal + multi-agent exploration + review gate.
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
If you are learning loops in order:
- What Is Loop Engineering? — paradigm shift from prompts
- Context vs Prompt vs Loop vs Harness — four stack layers
- Build your first agent loop — step-by-step cycle
- Agentic loop: stop_reason and tool_use — API-level control flow
- This official guide — Claude Code primitives named by the team
- Loop Engineering with Claude Code — community discourse +
/looppatterns - Top 10 agent loops for coding — production recipes
- Dynamic workflows — parallel proactive orchestration
Andrew Ng's three loops for 0-to-1 products adds the product clock — user feedback on a slower interval than your CI /loop.
Getting started — which piece do you hand off?
The guide's closing exercise:
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.
Related reading
explainx.ai guides
- Claude Code desktop in-app browser (July 2026)
- What Is Loop Engineering?
- Loop Engineering with Claude Code: Practical Guide
- Anthropic Engineer on Loops and Harness Engineering
- Claude Code /goal Command
- Claude Code Dynamic Workflows
- Top 10 AI Agent Loops for Coding
- Loop Engineering Goes Mainstream
- Fable 5 Loop Design
- Fable 5 Advisor & Orchestrator Patterns — when to call Fable inside a Sonnet loop (July 8)
Official Claude Code documentation
- Getting started with loops — source article (July 2026)
- Running agents in parallel
/loopcommand/schedulecommand/goalcommand- Dynamic workflows
Primary source
- @ClaudeDevs: Getting started with loops — July 7, 2026; @delba_oliveira
Summary
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.
Related reading: Graphs vs. Loops: The Agentic AI Orchestration Debate — how Linear's competing "Loops" feature and Andrew Ng's knowledge-graph course reopened the question of when a simple loop beats structured graph orchestration.
Command names, research-preview flags, and doc URLs reflect the July 7, 2026 @ClaudeDevs publication; verify against current Claude Code docs before production rollout.
