Sources#
- Anthropic's Boris Cherny: Why Coding Is Solved, and What Comes Next
- Full Walkthrough: Workflow for AI Coding — Matt Pocock
- How Anthropic's product team moves faster than anyone else | Cat Wu (Head of Product, Claude Code)
Summary#
A loop is an agent process that repeatedly executes a prompt until a queue is empty or a stopping condition is reached. As of mid-2026, three converging implementations point to the loop becoming a primitive on par with the single-shot session: Anthropic's /loop slash command (cron-scheduled, repeating), Anthropic's routines (server-side /loop), and Matt Pocock's Ralph Wiggum loop (bash + claude --permission-mode accept-edits in a while). Boris Cherny calls loops "the future"; Matt Pocock uses them as the AFK backbone of his end-to-end workflow.
The two loop families#
Cron-scheduled loops (/loop, routines)#
Used inside Claude Code and Cowork. Mechanism: agent calls cron (via tool) to schedule a job at a future time; the job re-enters the agent at that time with an instruction to perform the task. The schedule can repeat (every minute, every 5 minutes, every day).
Boris Cherny's reported uses:
- Babysit PRs — fix CI, auto-rebase
- Keep CI healthy — heal flaky tests
- Cluster Twitter feedback every 30 minutes
- "Dozens of loops running at any time"
- Overnight: "a few thousand agents" doing deeper work
Routines are the same primitive on the server, so they survive the laptop being closed.
Backlog-draining loops (Ralph Wiggum loop)#
Used by Matt Pocock and others. Mechanism: a shell script runs the agent on a fixed prompt, the prompt instructs it to pick the next task from a backlog and complete it, the script restarts. The backlog is a directory of markdown issue files (or GitHub issues).
Pocock's once.sh skeleton:
issues=$(cat issues/*.md)
recent_commits=$(git log -5 --oneline)
prompt=$(cat prompt.md)
claude --permission-mode accept-edits "$prompt" --context "$issues" "$recent_commits"The "loop" wrapper just re-runs once.sh until the agent emits a sentinel (no more tasks) or the harness stops it.
The prompt enforces AFK-only task selection — only tasks tagged AFK (vs human-in-loop) are eligible.
Why loops matter#
- Amortize planning over many executions. One careful planning session (e.g. via Design Concept Grilling) creates a Kanban backlog (see Vertical Slice Tracer Bullets); loops drain it without further human input.
- Hours-long tasks become tractable. Rather than one giant context window, the loop fragments work into many fresh sessions — staying in the Context Window Smart Zone each time.
- Parallelization. Independent backlog items run on separate sandboxes simultaneously. Pocock's Sandcastle library does this with per-issue git worktrees in Docker containers; merger agent reconciles afterwards.
- Idle compute. Boris's overnight setup is a thousand-agent loop on cheap idle hours — work that wouldn't be worth a human's evening but produces value at agent cost.
AFK vs human-in-loop tasks#
Matt Pocock's key distinction:
- AFK tasks — implementation, refactoring, test scaffolding, doc gardening, CI healing. The agent can succeed without per-step approval; verification is automatic (tests, types, linters).
- Human-in-loop tasks — alignment, design choices, prioritization, QA. These have no mechanical verification; they need taste and tacit context.
Loops are for the AFK class. Trying to loop human-in-loop work produces drift — the agent makes plausible-but-wrong calls and accumulates them.
Verification is the ceiling#
Pocock's stronger claim: the quality of feedback loops sets the ceiling on what loops can do. Without good tests, types, and linters, the loop is "coding blind." This is the same point made in Agent Harness Engineering about mechanical enforcement — loops just expose the cost more starkly because there's no human to catch drift.
Connection to model trajectory#
Boris Cherny reports that Opus 4.7 spontaneously starts loops without prompting:
"I'll tell it, 'Go pull this data query.' And it's like, 'Hey, I noticed that the data is changing over time. I'll start a loop and I'll give you a report every 30 minutes.'"
This fits Harness Shrinkage as Models Improve — capability the harness used to inject becomes natural model behavior. The loop primitive remains, but the user no longer has to invoke it.
Connections#
- Claude Code Best Practices — the best-practices guide treats
/loopas a core workflow primitive - Engineer PM Convergence — generalist PM-engineers fan work out across loops
- Boris Cherny — primary advocate, day-to-day driver
- Matt Pocock — Ralph loop + Sandcastle exemplar
- Harness Shrinkage as Models Improve — loops as next-generation primitive replacing per-step prompting
- Context Window Smart Zone — why fragmenting into many fresh sessions beats one long one
- Vertical Slice Tracer Bullets — what fills the backlog the loop drains
- Design Concept Grilling — the planning step that justifies the loop
- Deep Modules for Agents — modules with strong test boundaries make loops viable
- Agent Harness Engineering — generalizes the "verification is the ceiling" point
- Symphony — daemon-driven equivalent at the orchestration layer
- Claude Code Auto Mode — permission classifier that lets
accept-editsmode be safe in AFK loops - Agentic Misalignment (AM) — loops + weak per-action oversight is exactly the AM threat surface; loop reviewers depend on model-side alignment holding up unattended
- AI Brain Fry — the human-side limit on output multipliers: more loop output → more review → more cognitive fatigue → more missed errors
- Human-AI Accountability Redesign — loops force the redesign question; span-of-control redesign is the missing partner for unattended loop deployments
- AI-Driven Formal Proof Search — DeepMind's basic proof-search agent is literally a "Ralph loop" (huntley2025ralph): episodes of generate→compile→learn-lessons, run as parallel independent subagents
- AlphaProof Nexus — the framework whose basic agent (A) is a Ralph-loop fleet; it matched the bespoke system on most problems
- Agent-Native Infrastructure — always-on loops acting via sensors/actuators are the runtime of Karpathy's agent-native world
- Stopping Under a Noisy Verifier — the measured case against this primitive's two default stop conditions. A round cap ("repair up to K times") is the worst deployable arm in Wu et al.'s stress setting — 0.116 true validity against 0.700 for committing the first draft, degrading monotonically with the budget — and a sentinel the agent emits is only as good as the verifier behind it, whose discrimination bounds how fine a stopping decision it can support. The transferable rule: the stop boundary belongs to whatever rewrites the work, not to whatever checks it, so it is
α/(α+β)and ports between loops no better than those two rates do - Loop Engineering — the system-design discipline one floor above this primitive (Osmani / Steinberger): automations are the loop's scheduled heartbeat, and
/goal(keep going until a written condition holds, with a separate small model checking "done" after each turn) is the maker/checker split applied to the stop condition itself - The Three Loops of AI-Native Building — Andrew Ng's taxonomy places this primitive: it closes the innermost of three nested loops, and the developer-feedback and external-feedback loops outside it run 1–2 orders of magnitude slower
- Dynamic Workflows: An Algebra for Agents — the sibling primitive for one large task rather than a repeating one: a workflow structures a single run across staged agents, where this page's loop asks "when does it run again?"
Open Questions#
- When the model schedules its own loops (4.7 behavior), who owns the budget? Boris answered "the model just decides" — but that pushes cost discipline into the model's training, not the harness.
- Does a loop with a smart enough model still need a Kanban backlog, or does the model choose its own next task from raw goals?
- Loop output review is now Matt Pocock's confessed bottleneck — "we just need to be ready to be doing more code review."
Sources#
- Anthropic's Boris Cherny: Why Coding Is Solved, and What Comes Next —
/loopand routines as primary primitive - Full Walkthrough: Workflow for AI Coding — Matt Pocock — Ralph loop + Sandcastle architecture
- How Anthropic's product team moves faster than anyone else | Cat Wu (Head of Product, Claude Code) — loops at the feature level (CI healing, code review)
Cited by 31
- Learning to Co-Work with AI: A Software Engineer's Field Guide×6
Adopt the AFK vs human-in-loop split (Agent Loop Pattern). AFK tasks (implementation, refactoring,…
- Agent Control Plane Patterns: Tickets, Loops, Specs, and Memory Files×4
Agent Loop Pattern is necessary but not sufficient. A loop is an execution pattern: repeat a prompt…
- Harness Shrinkage as Models Improve×4
Ai Brain Fry — partially mitigated by harness shrinkage (less to oversee), reintroduced by output…
- Claude Code Best Practices×3
Loops and routines: /loop (cron-scheduled repeat job, in-CLI) and routines (server-side variant).…
- Loop Engineering×3
Automations — scheduled discovery + triage that run by themselves. The heartbeat that makes a loop…
- Open Questions Backlog×3
Agent Loop Pattern: Loop output review is now Matt Pocock's confessed bottleneck — "we just need to…
- The Three Loops of AI-Native Building×3
"This is an active area of invention!" — which is Loop Engineering and Agent Loop Pattern in their…
- Agentic Misalignment (AM)×2
This describes Cowork, Claude Code in agent mode (especially --dangerously-skip-permissions),…
- AI Brain Fry×2
Agent Loop Pattern — loops are an aggressive output multiplier; brain fry is the human-side limit…
- Opinions on Using AI Tools & the Future of the Software Engineering Role×2
Capabilities migrate inward. The /loop primitive (see Agent Loop Pattern) went from harness feature…
- Boris Cherny×2
Loops as the future. Heavy user of /loop (Claude-scheduled cron jobs) for PR babysitting, CI…
- Claude Code×2
/loop — Claude-scheduled cron job; primary primitive of Agent Loop Pattern
- Context Window Smart Zone×2
Fragment work into many sessions. Loops (see Agent Loop Pattern) and vertical slices (see Vertical…
- Human-AI Accountability Redesign×2
Agent Loop Pattern — loops increase agent output volume per human; the span-of-control redesign in…
- Vertical Slice Tracer Bullets×2
The Kanban is materialized as markdown files in issues/ (or GitHub issues) with explicit…
- Agent Harness Engineering
Agent Loop Pattern — the natural session-level primitive once the per-session harness works: drain…
- Agent-Native Infrastructure
Agent Loop Pattern — always-on agents acting via sensors/actuators are the runtime of an…
- Agentic Loops Overtake Bespoke Systems
Agent Loop Pattern — the "Ralph loop" basic agent is an instance of the loop-as-primitive
- AI-Driven Formal Proof Search
Agent Loop Pattern — the basic prover subagent is literally a "Ralph loop" (huntley2025ralph)
- AlphaProof Nexus
Agent Loop Pattern — the basic prover subagent is a "Ralph loop" (huntley2025ralph)
- Claude Code Auto Mode
Agent Loop Pattern — auto mode is a precondition for AFK loops; without it, every tool call would…
- Claude Opus 4.7
Agent Loop Pattern — /loop becomes natural model behavior at 4.7 per Boris Cherny's report
- Deep Modules for Agents
Agent Loop Pattern — review-in-fresh-context fits the loop's clear-then-restart rhythm
- Design Concept Grilling
Agent Loop Pattern — grilling sits at the human-in-loop top of the funnel; loop drains the AFK…
- Dynamic Workflows: An Algebra for Agents
The split is the loop primitive's question ("when does it run again?") versus this page's question…
- Engineer PM Convergence
Agent Loop Pattern — at the limit, individual contributors run dozens of agents and ship like teams…
- Matt Pocock
Independent AI-coding educator; built Sandcastle library; smart-zone/grill-me/tracer-bullets pedagogical framing; "bad…
- Agent Systems & Harness Engineering
Agent Loop Pattern — /loop (cron-scheduled) and Ralph Wiggum (backlog-draining) loops as…
- Peter Steinberger
Founder of PSPDFKit turned prolific independent AI-coding experimenter (@steipete); originated the framing that loop en…
- Stopping Under a Noisy Verifier
Agent Loop Pattern — the loop primitive whose stopping condition is a sentinel or a round cap; the…
- Symphony
Agent Loop Pattern — the daemon-driven equivalent at the orchestration layer; Symphony is…
Related articles
- Agent Harness Engineering
Patterns for scaffolding long-running LLM agents: environment design, progressive context disclosure, mechanical archit…
- Harness Shrinkage as Models Improve
Prompt scaffolding shrinks each model release; Cat Wu's pruning discipline; Boris Cherny "100 lines of code a year from…
- Claude Code
Anthropic's agentic coding product; created by Boris Cherny late 2024; TypeScript/React on Bun (itself Claude-rewritten…
- Loop Engineering
Replacing yourself as the agent's prompter by designing the system that prompts it: a recursive-goal loop built from fi…
- Verification as the New Bottleneck
Fiona Fung: coding is no longer the bottleneck — verification, review, maintenance are; shift-left; TDD loses its tax;…
