Blog
4 min read

Claude Code /loop: Run a Prompt on Repeat (and Let Claude Pick the Interval)

/loop re-runs a prompt inside your Claude Code session — every 5 minutes, at an interval Claude chooses, or with a built-in maintenance prompt that babysits your PR. Syntax, self-paced loops, loop.md, one-time reminders, the 7-day expiry, jitter, and when to use routines instead.

/loop turns a prompt into a repeating job inside your current Claude Code session. Use it to poll a deploy, keep a pull request green, check a long build, or remind yourself to do something.

Details as of October 2026, from Anthropic's scheduled tasks docs.

Three ways to call it

You type What happens
/loop 5m check the deploy Runs your prompt every 5 minutes
/loop check the deploy Runs your prompt at an interval Claude chooses each time
/loop Runs a built-in maintenance prompt (or your loop.md)

Fixed intervals

/loop 5m check if the deployment finished and tell me what happened
/loop check CI every 2 hours

Units are s, m, h and d. Claude turns the interval into a cron expression and tells you the job ID. Seconds round up to a minute (cron's smallest step), and awkward intervals like 7m are rounded to the nearest clean step.

You can loop a skill too: /loop 20m /review-pr 1234. Built-in commands like /model can't be looped.

Self-paced loops

Leave out the interval and Claude decides how long to wait after each iteration — anywhere from one minute to an hour — and prints why:

/loop check whether CI passed and address any review comments

It waits a minute or two while a build is running, and longer once things go quiet. When the task is done, Claude can end the loop itself. Press Esc while it's waiting to stop it.

The maintenance prompt and loop.md

A bare /loop works through, in order: unfinished work from the conversation, the current branch's PR (review comments, failed CI, merge conflicts), then cleanup passes like bug hunts. It won't start new initiatives, and it only pushes or deletes when continuing something already authorised in the conversation.

To replace it, write .claude/loop.md (project) or ~/.claude/loop.md (personal):

Check the `release/next` PR. If CI is red, read the failing job log,
diagnose, and push a minimal fix. Address new review comments.
If everything is green and quiet, say so in one line.

Edits take effect on the next iteration.

One-time reminders

You don't need /loop for these — just ask:

remind me at 3pm to push the release branch
in 45 minutes, check whether the integration tests passed

Managing tasks

Ask in plain English ("what scheduled tasks do I have?", "cancel the deploy check"). Under the hood these are the CronCreate, CronList and CronDelete tools. A session holds up to 50 tasks.

Rules worth knowing

  • Session-scoped. Tasks only fire while Claude Code is running and idle. Close the terminal and they stop (unless you background the session). --resume restores cron tasks that haven't expired, but not self-paced loops.
  • Fires between turns. If Claude is mid-response, the task waits. Missed fires don't stack up.
  • Jitter. Recurring tasks can fire up to 30 minutes late (or half the interval) so everyone's sessions don't hit the API at once. Pick an odd minute like :07 if timing matters.
  • Seven-day expiry. Recurring tasks delete themselves after a week, so a forgotten loop can't run forever.
  • Usage. Every iteration uses your plan's usage. A 1-minute loop all day adds up. (Claude Code Usage Limits)
  • Disable it entirely with CLAUDE_CODE_DISABLE_CRON=1.

/loop vs /goal vs routines

  • /loop — repeat on a time interval while your session is open.
  • /goal — keep working turn after turn until a condition is met. (Claude Code /goal)
  • Routines — run in the cloud on a schedule, without your machine. (Claude Code Routines)

The summary

  • /loop 5m <prompt> for a fixed interval; /loop <prompt> for self-paced; /loop for maintenance.
  • Tasks live in your session, fire between turns, and expire after 7 days.
  • Use routines for anything that must run without your machine.

EasySpawn keeps Claude Code sessions running on a persistent server, so a /loop babysitting your PR keeps going after you close your laptop. See how it works or join the waitlist.

Related: Cron Expressions Explained · Running Claude Code Headless · Claude Code Skills · Run Claude Code on a Remote Server

Keep reading