Skip to content

The /loop Command: Recurring and Self-Paced Prompts

The deploy takes about eight minutes. So you wait, type “is it done yet?”, read “still building,” wait, ask again. Or the PR is in review and you keep checking back for CI results and new comments. None of this is hard — it’s just a prompt you’d run on repeat if you could, and being the thing that runs it on repeat is a waste of a developer.

/loop is that repeater. You give it a prompt and, optionally, a cadence, and it re-runs the prompt for you — on a fixed interval, on an interval it chooses based on what it sees, or as a standing maintenance routine. It’s the cadence-based half of autonomous operation; its sibling, /goal, is the condition-based half.

  • The three modes of Claude Code’s /loop — fixed interval, self-paced, and maintenance — and when to use each
  • The exact syntax, including how intervals map to cron and how to stop a loop
  • How to replace the default maintenance prompt with your own loop.md
  • What to use instead in Codex and Cursor
  • How /loop differs from /goal

/loop is a bundled skill (requires Claude Code v2.1.72 or later). Both the interval and the prompt are optional, and what you supply decides the behavior:

What you provideExampleWhat happens
Interval and prompt/loop 5m check the deployPrompt runs on a fixed schedule
Prompt only/loop check the deployPrompt runs at an interval Claude picks each round
Interval only, or nothing/loopThe built-in maintenance prompt runs (or your loop.md)

Supply an interval and Claude converts it to a cron expression, schedules the job, and confirms the cadence and a job ID:

/loop 5m check if the deployment finished and tell me what happened

The interval can lead as a bare token (30m) or trail as a clause (every 2 hours). Units are s, m, h, d. Seconds round up to the nearest minute (cron’s granularity), and odd intervals like 7m or 90m round to the nearest clean cron step — Claude tells you what it picked. You can pass another command as the prompt, too: /loop 20m /review-pr 1234 re-runs a saved skill each iteration.

Omit the interval and Claude chooses the delay itself after each round — anywhere from one minute to an hour — based on what it observed, and prints the reason for each wait:

/loop check whether CI passed and address any review comments

Short waits while a build is finishing, longer waits once things go quiet. For this mode Claude may use the Monitor tool to stream a background script’s output instead of re-running the prompt — often more responsive and more token-efficient than polling.

A bare /loop (no prompt) runs a built-in maintenance routine at a self-chosen interval. Each round it works through, in order: continue unfinished work from the conversation, tend the current branch’s PR (review comments, failed CI, merge conflicts), then run cleanup passes like bug hunts or simplification when nothing else is pending. It won’t start new initiatives outside that scope, and irreversible actions only proceed when they continue something the transcript already authorized.

Press Esc while a loop waits for its next iteration to clear the pending wakeup. In self-paced mode, Claude can also end the loop itself by not scheduling the next wakeup once the task is provably complete. Every loop carries a seven-day expiry — it fires one last time seven days after creation, then deletes itself, so a forgotten loop can’t run forever. Loops are session-scoped; claude --resume or --continue restores any that haven’t expired.

Native, as described above. For scheduling that outlives the session, Claude Code also offers Routines (Anthropic-managed cloud, 1-hour minimum), Desktop scheduled tasks (your machine), and GitHub Actions — /loop itself is the in-session, quick-polling option. Set CLAUDE_CODE_DISABLE_CRON=1 to disable the scheduler (and /loop) entirely.

The two autonomous commands answer different questions:

  • /loop answers “how often?” — it re-runs a prompt on a cadence and may never terminate on its own (the seven-day expiry is a backstop, not a finish line).
  • /goal answers “until when?” — it runs flat-out until a verifiable stopping condition is true, then stops.

Use /loop for monitoring and standing maintenance; use /goal for convergent work with a clear definition of done. They pair well: /goal drives a feature to green, then /loop watches the PR it produced.