explainx.ainewsletter3.5k
TrendingNewsPathwaysSkills
Pricing
explainx.ai

Upskill in AI — 16 free pathways, live workshops & bootcamps, and 50+ courses from practitioners. Plus the skills, tools, and MCP servers to practice on.

follow us

custom AI agents

[email protected]

get started

Find your pathTake Free Evaluation

learn

pathways — start freeworkshopsbootcampscoursescertificationsmock testsexplainx universitycorporate traininglearn skills & mcp

discover

skillsmcp serversexplainx mcptoolsagentsllmsdesignsagi trackerranks

company

aboutvisionmissionteaminstructorscommunityhackathonscareers

content

daily AI newsstate of AI — live resultsblogreleasespromptsgeneratorsresource librarydemofor LLMs

solutions

all solutionsdeveloper upskillingmarketing upskillingproduct manager upskillingleadership upskilling

More from us

InfloqInfluencer marketingBgBlurPrivacy-first blurOlly SocialSocial AI copilotCeptoryVideo intelligenceBgRemoverBackground removal

newsletter · weekly

Get AI news, tools, and insights in your inbox.

contactsupportprivacytermsdata rightssubmission guidelines

© 2026 AISOLO Technologies Pvt Ltd

On this page

  • TL;DR — Loop types at a glance
  • Why "loops" confused everyone (and how Anthropic fixes it)
  • Turn-based loops — every prompt is a manual loop
  • Goal-based loops — /goal owns the stop condition
  • Time-based loops — /loop and /schedule
  • Proactive loops — no human in real time
  • Maintaining code quality around loops
  • Managing token usage
  • How this maps to explainx.ai's loop engineering pathway
  • Getting started — which piece do you hand off?
  • Related reading
  • Summary
← Back to blog

explainx / blog

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.

Jul 7, 2026·9 min read·Yash Thakker
Claude CodeLoop EngineeringAnthropicAI AgentsDeveloper Tools
go deep
Claude Code Loops Official Guide: Turn-Based, /goal, /loop, and /schedule (July 2026)

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.

Weekly digest3.5k readers

Catch up on AI

Curated AI updates on agents, skills, and MCP — delivered to your inbox. Unsubscribe anytime.

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 typeYou hand offTriggerStop whenBest forReach for
Turn-basedThe check (verification)User promptClaude judges done or needs contextExploration, short tasksCustom skills
Goal-based (/goal)The stop conditionManual promptGoal met OR max turnsVerifiable exit criteria/goal
Time-based (/loop, /schedule)The trigger (interval)Fixed intervalYou cancel or work completesRecurring / external systems/loop, /schedule
ProactiveThe prompt (routine)Event or schedule, no human livePer-task goal; routine until offBug triage, upgrades, migrationsAll 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:

  1. How they are triggered
  2. How they are stopped
  3. Which Claude Code primitive is used
  4. 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:

  1. Read your code
  2. Make the edit
  3. Run tests
  4. Hand back something it believes works
  5. 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.

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:

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

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:

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.

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:

LeverAction
Right primitiveDo not spawn dynamic workflows for a one-file typo
Right modelSmaller models for bulk; capable model for judgment
Clear stopSpecific done + turn caps on /goal
Pilot firstSmall slice before full proactive routine
ScriptsDeterministic steps (PDF fill, codegen) as scripts not re-reasoning
Poll intervalMatch /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:

  1. What Is Loop Engineering? — paradigm shift from prompts
  2. Context vs Prompt vs Loop vs Harness — four stack layers
  3. Build your first agent loop — step-by-step cycle
  4. Agentic loop: stop_reason and tool_use — API-level control flow
  5. This official guide — Claude Code primitives named by the team
  6. Loop Engineering with Claude Code — community discourse + /loop patterns
  7. Top 10 agent loops for coding — production recipes
  8. 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 QAVerificationverify-* skill
Stopping Claude too early / too lateStop condition/goal + turn cap
Checking GitHub every hourTrigger/loop 60m or /schedule
Triage queue every morningFull routineproactive /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
  • /loop command
  • /schedule command
  • /goal command
  • 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.

Yash Thakker

Written by

Yash Thakker

Yash is an AI expert with over 300K learners. Join his workshops →

Related posts

Jul 12, 2026

Claude Code Desktop Browser: Built-In Web Browsing in the App (July 2026)

@ClaudeDevs ships Claude Code desktop browser — read, click, debug URLs sandboxed. Version 1.2581.0 July 10. explainx.ai setup, shortcuts, and developer reactions.

Jun 22, 2026

Steering Claude Code: CLAUDE.md, Skills, Hooks, Subagents, and Rules Explained

CLAUDE.md loads at session start and stays forever. Skills load only when invoked. Hooks run deterministically outside the context window. Subagents return only a summary to the main thread. Anthropic's new guide maps all seven instruction methods — here is the practical breakdown with decision rules for each.

Jun 19, 2026

Matthew Berman Loop Library: Free Agent Workflows for Developers (2026)

If you need agent loops today, start at explainx.ai/loops — around 100 copy-ready workflows with kickoff prompts, guardrails, and new entries every week. Matthew Berman's Forward Future library is a similarly strong option with 26 practitioner-contributed recipes; here is how both compare and what early adopters like Theo (t3.gg) are running in production.