A research briefing on recurring agent loops — the single highest-leverage Claude Code technique — built from Boris Cherny's own posts and interviews, Geoffrey Huntley's Ralph loop, Anthropic's engineering blog, and the official 2026 scheduled-task docs. Every quote and link below is sourced.
Claude Code is not a chatbot — it is a while-loop around a model. Anthropic's own definition of an agent is "an LLM autonomously using tools in a loop." Every trick in this collection is really one decision: where do you put the loop boundary, and which side of it are you standing on?
Prompting puts you inside the loop — you read output, decide, type again. Looping moves you outside it — you design the cycle, the stop condition, and the feedback signal, then let the machine spin. The creator of Claude Code no longer prompts his own tool. He writes loops that prompt it for him.
Before any trick, understand the engine. Anthropic's Claude Agent SDK engineering post describes the core agentic cycle that powers Claude Code itself:
gather context → take action → verify work → repeat
That's it. A simple question may only need the first step. A bug fix might cycle through it a dozen times. The model decides each pass: do I need more context? Should I act? Did my action actually work? The loop terminates when the goal is met — or when the harness says stop.
Three consequences follow, and they drive everything else on this page:
Boris Cherny is the creator and head of Claude Code at Anthropic. He opened his now-famous setup thread on X with: "I'm Boris and I created Claude Code" — then revealed a workflow so aggressive that Slashdot and most of the dev internet spent a week dissecting it (the original thread).
The headline numbers, pulled from his thread, the Pragmatic Engineer deep-dive, and the community site howborisusesclaudecode.com:
Why his opinion outranks the thousand other "Claude Code workflow" posts: he sees the telemetry, builds the features, and dogfoods the tool harder than anyone alive. When his workflow changed from prompting to looping, it previewed where the product itself went — /loop, Routines, and scheduled tasks all shipped after he was already living that way internally. Interviews in Platformer and on Lenny's Podcast cover what he thinks comes after coding itself is "solved."
The quote that named this whole technique, via Product Market Fit's writeup of his remarks:
"I don't prompt Claude anymore. I have loops running. They're the ones prompting Claude and figuring out what to do. My job is to write loops." — Boris Cherny, creator of Claude Code
Unpack that. His loops autonomously read GitHub issues, scan feedback in Slack and on X, decide what's worth doing, do it, and surface only the results worth a human look. The shift is architectural, not cosmetic:
Your job description changes with it. As the coverage of his workflow puts it: you stop typing prompts and start designing loop logic, memory, error handling, parallelism, and evaluation. That is exactly the skill stack of a systems engineer — applied to cognition instead of CPUs. Boris runs multiple /loop instances simultaneously for different jobs: babysitting PRs, watching Slack feedback, post-merge cleanup, and pruning stale PRs — each at its own cadence (source).
And his single most repeated piece of advice is the verify step:
"Give Claude a way to verify its work. If Claude has that feedback loop, it will 2-3x the quality of the end result." — Boris Cherny, setup thread / howborisusesclaudecode.com
A loop without verification is a treadmill. A loop with verification is a ratchet — every cycle locks in progress.
Loops fail when the agent repeats the same mistake every cycle. Boris's supporting habits are all about making each cycle smarter than the last:
Notice the theme: every habit either feeds the loop better signal (verification, minimal context) or persists what the loop learned (CLAUDE.md, agents, commands). That's the whole game.
Before Anthropic shipped official loop features, the community discovered the idea with three lines of bash. Geoffrey Huntley named it the Ralph Wiggum loop — after the Simpsons kid who eats glue and keeps showing up anyway (original post, The Register's coverage):
while :; do cat PROMPT.md | claude-code ; done
"Ralph is a technique. In its purest form, Ralph is a Bash loop." — Geoffrey Huntley, ghuntley.com/ralph
The agent runs, exits (success, failure, or context exhaustion — doesn't matter), and is immediately reborn with a fresh context window, re-reading the prompt file and the repo state. State lives in files and git, not in the conversation. Huntley's framing: the LLM is "deterministically bad in an undeterministic world" — failures follow patterns, so you fix them by editing PROMPT.md between runs. "Tune Ralph like a guitar."
The rules that make Ralph work (all from the source and the codecentric analysis):
fix_plan.md / todo.md; each cycle picks the top item, does it, marks it done. (The snarktank/ralph repo packages exactly this: loop until all PRD items are complete.)git reset --hard and re-tune. Broken states are data, not disasters.Receipts: Huntley reports a $50k-contract MVP built in 7 days for ~$297 in tokens, and a Y Combinator hackathon team shipped six repos overnight on the pattern. His follow-up essay "everything is a ralph loop" generalizes it: "Software is now clay on the pottery wheel and if something isn't right then I just throw it back on the wheel." Caveats are real too: best on greenfield work, requires senior judgment to tune, and you must expect to occasionally wake up to wreckage. The full origin story is on the Dev Interrupted podcast and HumanLayer's history.
What Ralph did with bash, Claude Code now does natively. As of v2.1.72+ there are three official ways to run recurring agent work, per the official scheduled-tasks docs:
| Cloud Routines | Desktop Tasks | /loop (in-session) | |
|---|---|---|---|
| Runs on | Anthropic cloud | Your machine | Your machine, open session |
| Machine on? | No — runs while you sleep | Yes | Yes + session open |
| Survives restarts | Yes | Yes | Restored on --resume if unexpired |
| Local files | No (fresh clone each run) | Yes | Yes — inherits session |
| Min interval | 1 hour | 1 minute | 1 minute |
| Best for | Nightly reviews, triage, unattended research | Local-file jobs on a schedule | Polling, babysitting, in-session reminders |
The quickest loop. Three modes depending on what you give it:
/loop 5m check the deploy → fixed cron cadence (units: s/m/h/d)./loop check whether CI passed → Claude picks the interval itself after each iteration (1 min to 1 hr), waiting briefly while things are hot and longer when quiet, printing its reasoning each time. This self-pacing mode is the newest and most underrated feature — the agent manages its own attention./loop runs a built-in maintenance prompt: continue unfinished work, tend the current PR (review comments, failed CI, merge conflicts), then do cleanup passes. Drop a loop.md in .claude/ to replace that default with your own standing orders — edits take effect on the very next iteration.Guardrails worth knowing: tasks are session-scoped, capped at 50 per session, get deterministic jitter so the world doesn't stampede the API at :00, and every recurring task self-destructs after 7 days — a forgotten loop can't run forever. Esc kills a pending iteration. Under the hood it's three tools: CronCreate, CronList, CronDelete, with standard 5-field cron expressions in your local timezone.
The docs point at two siblings worth knowing: /goal keeps a session working turn after turn until a condition is met (condition-driven rather than clock-driven), and Channels push events (like a CI failure) into the session so you don't poll at all. In self-paced mode Claude may also use the Monitor tool — streaming a background script's output instead of re-running a prompt — which is cheaper and faster than polling. Comparisons across all the options: Routines vs Scheduled Tasks vs /loop and Better Stack's guide. Note Routines have daily run caps by plan (Pro 5 / Max 15 / Team 25).
/loop 5m check if the deployment finished and tell me what happened
/loop check whether CI passed and address any review comments
# .claude/loop.md
Check the `release/next` PR. If CI is red, pull the failing job log,
diagnose, and push a minimal fix. If new review comments have arrived,
address each one and resolve the thread. If everything is green and
quiet, say so in one line.
# PROMPT.md holds the mission + "pick ONE item from fix_plan.md"
while :; do cat PROMPT.md | claude -p --dangerously-skip-permissions; done
# Safer modern variant: bounded iterations, commit-gated
for i in $(seq 1 25); do
cat PROMPT.md | claude -p || break
git diff --quiet || git commit -am "ralph iteration $i"
done
remind me at 3pm to push the release branch
in 45 minutes, check whether the integration tests passed
# Give every loop a way to check itself. Examples of "verify" steps:
bun test # backend truth
tsc --noEmit # type-system backpressure
interceptor open localhost:5500 # real-browser screenshot for UI
curl -i localhost:8080/health # live endpoint probe
Translating the theory into the stuff already on your machine:
/loop 10m on anything you're waiting on: a Cloudflare Pages deploy, an inbox check during the first-profit campaign window, a long build.