Skip to Content
loop.fun
Environments

Claude Code

Anthropic's agent has the widest set of loop primitives: a goal loop with a separate evaluator, interval loops, routines, Stop hooks and agent teams.

Claude Code is where many loop patterns were first tried, partly because its team uses it this way. Boris Cherny, who leads Claude Code, reportedly said in June 2026: "I don't prompt Claude anymore. I have loops prompting Claude and figuring what to do" (The New Stack, Paweł Huryn on X). secondary reporting

The primitives

/goal
Sets a completion condition. After every turn, a separate evaluator model (Haiku by default) reads the transcript and decides whether the condition is met. If not, Claude starts another turn instead of handing back control. Ends when met, when judged impossible, or on error. Also works headless: claude -p "/goal …". (docs)
/loop
Repeats a prompt on an interval, for example /loop 5m /babysit. Good for babysitting things that change over time.
Routines / scheduled tasks
Run prompts on a schedule. Per the team, the first routines were code review, PR babysitting, CI fixes and rebases.
Stop hook
A hook that runs when Claude tries to finish; exit code 2 blocks the stop. This is how the official ralph-loop plugin worked before /goal.
Background sessions
Start with claude --bg "task" or /bg; edits can be isolated in a git worktree.
Agent View
claude agents shows one screen listing every background session, its state and which ones need input. Research preview since May 2026 (Cobus Greyling).
Agent teams / subagents
Teams share a task list and message each other; subagents isolate context for side quests.

How the goal loop behaves

Claude worksTries to stopEvaluator checksNot met: continue/goal

The evaluator is the interesting design choice. Because it's a different, smaller model, it's cheap to run every turn and doesn't share the worker's optimism about its own work. But it reads the transcript, not the world, so it judges what the agent reported. That makes checkable goals that point at concrete commands (whose output appears in the transcript) much more reliable than vague ones.

Guides consistently warn about two failure modes: goals the evaluator can't check (so the loop can't stop), and impossible goals (Claude can loop indefinitely) (XDA, MindStudio).

Which primitive for which job?

You want…Use
"Keep going until the tests pass"/goal
"Check this every 10 minutes"/loop
"Every weekday at 9"Routines / scheduled tasks
"Run this in the background while I do other things"--bg plus Agent View
"Several agents on one big project"Agent teams, worktrees
"Custom logic for whether to stop"A Stop hook

MindStudio's comparison goes deeper on /goal vs. routines vs. /loop.

Limits and pricing

Loops are what pushed Anthropic to add weekly limits in 2025, aimed at continuous 24/7 use (TechCrunch). Heavy loop users have reported exhausting weekly limits in one or two days (issue #9424, #76006, The Register). In late October 2026 Max 20x was renamed Ultra, and the five-hour limit was removed for verified Ultra accounts; weekly limits remain. Sources disagree on whether that covers interactive Claude Code sessions (Developer's Digest, Requesty). contested

Further reading

loop.fun

Patterns, hints and tools for designing the loops that keep agents working, and for widening the set of loops you can think of.

© 2026 loop.fun · CC BY 4.0

On this page