/loop
Updated 2026-07-11
Questions this answers
- How do I get my agent to keep working without me prompting every step?
- Can my AI watch my PRs and fix build issues on its own?
- I want a task to run on repeat in the background, how?
- What's the difference between /loop and /goal?
The Fix
Type /loop in Claude Code and describe a repeating job you want handled. The agent then works in rounds, prompting itself each tick, until the work is done or you stop it. You didn't write the steps. You wrote the intent and the stopping behavior.
Boris Cherny's own starter example is the one to copy and change the nouns on: "/loop babysit all my PRs. Auto-fix build issues, and when comments come in, use a worktree agent to fix them." That's it, one line, and it keeps running.
The catch that the hype skips is the same one practitioners obsess over: a loop is only as trustworthy as its ability to check its own work. So give it a way to verify itself end to end, otherwise it can happily loop on something broken.
Quick contrast with its cousins. /goal drives toward a finish line and stops when done. /loop is for ongoing, repeating work that doesn't have a single finish line, like watching PRs or grinding a queue.
When to Use It
Reach for /loop when there's a repetitive background job you'd otherwise keep nudging: monitoring PRs, fixing build breaks, working through a batch. Pair it with auto mode for permissions so it doesn't stop to ask, and make sure it can self-verify. Skip it for a one-shot task, where a plain prompt or /goal fits better.
In the Wild
Best Practices
Simon Willison on Boris Cherny's tips
simonwillison.net
Boris's five tips for running an agent autonomously for hours, including using /loop and making the agent self-verify.
Geoffrey Huntley: the Ralph technique
ghuntley.com
The origin of the "just loop the agent" idea, and an honest look at where it works and where it doesn't.