/loop Command - Claude Code
Run a prompt repeatedly on a fixed interval or self-paced.
/loop is the simplest way to make Claude do the same thing over and over - poll for status, re-run a check, keep monitoring an endpoint.
What it does
Run /loop <interval> <prompt> and Claude re-executes the prompt on that cadence. Omit the interval and Claude picks a sensible pace based on the task. You can stop the loop at any time. Common patterns: watch a deploy, re-run tests, check for new emails.
When to use it
- Polling status pages, health endpoints, or CI jobs.
- Recurring checks on a long-running process.
- Keeping a dashboard-like view running in a terminal.
- Dev workflows where "keep checking until X" is the shape of the work.
Gotchas
- Loops burn tokens on every iteration. Set a sensible interval and a stop condition.
- One-off tasks don't benefit from loops - use them only for genuinely recurring work.
- Loops stop when the session ends. For durable scheduling, use routines or scheduled tasks.
Official docs: https://code.claude.com/docs/en/scheduled-tasks.md#run-a-prompt-repeatedly-with-loop
Technical content at the intersection of AI and development. Building with AI agents, Claude Code, and modern dev tools - then showing you exactly how it works.
Get the weekly deep dive
Tutorials on Claude Code, AI agents, and dev tools - delivered free every week.
Was this helpful?






