The /loop command in Claude Code re-runs a prompt on an interval for as long as your session stays open. Since v2.1.330, released on November 20, 2026, a /loop or any other recurring session task runs for up to 30 days instead of 7. As of November 22, 2026, the scheduled tasks page in the docs still says 7 days. The change is listed in the changelog under v2.1.330.
/loop runs on your machine, inside your session. For a task that has to run with your laptop shut, use cloud scheduled tasks instead.
What changed in v2.1.330?
When you create a loop, Claude Code now tells you when it will end.
A task created before the update keeps its 7-day limit. To get the 30 days, cancel it and create it again.
Since v2.1.329, released the day before, most tasks saved by earlier versions need scheduling again in a new signed-in session. A --resume of the session they belong to still runs them.
How do I start a loop with /loop?
Both the interval and the prompt are optional. What you pass decides how the loop behaves.
| Command | What happens |
|---|
/loop 5m check if the deploy finished | The prompt runs on a fixed interval |
/loop check CI and address review comments | Claude picks the delay after each run, between 1 minute and 1 hour |
/loop or /loop 15m | Claude runs the built-in maintenance prompt, or your loop.md |
Units are s, m, h and d, and seconds round up to the next minute. An interval like 7m is rounded to one that maps cleanly to cron, and Claude tells you which. A session holds up to 50 scheduled tasks.
The maintenance prompt picks up unfinished work, then tends to your branchās pull request. To replace it, write your own instructions in .claude/loop.md, or in ~/.claude/loop.md for every project. Edits to the file apply from the next run.
You can also re-run a skill on each pass, for example /loop 20m /review-pr 1234. Since v2.1.325, the loop asks before running a skill that declares allowed-tools or hooks. To let it run unattended, allow it in permissions.allow. Skill(name) matches the exact call, and Skill(name *) matches it with arguments.
{
"permissions": {
"allow": ["Skill(review-pr *)"]
}
}
How do I list and stop a loop?
Since v2.1.329, /tasks shows the sessionās scheduled tasks, /loop wakeups, the /goal and the conversationās forks. Press x to stop the selected one, after a confirmation.
Outside /tasks, how you stop a loop depends on its type.
- Self-paced loop. While it waits, press
Esc on an empty prompt. A Pending wakeup cancelled notice confirms it.
- Fixed-interval loop.
Esc and Ctrl+C donāt stop it. Ask Claude to cancel it, for example ācancel the deploy check loopā.
Claude ends a self-paced loop on its own once it judges the work done. Since v2.1.319, the loop also ends when a run finishes without Claude scheduling the next one. Before that, Claude Code added a fallback wakeup. CLAUDE_CODE_LOOP_KEEPALIVE=1 brings back one extra run, about 20 minutes later.
When you quit, choosing Exit and stop tasks ends the sessionās tasks. Since v2.1.329, they no longer come back on --resume, unless you quit while Claude is responding. Without that choice, --resume restores fixed-interval tasks that havenāt expired. A self-paced loop doesnāt come back, so run /loop again.
Which interval fits the prompt cache?
Each run sends the whole conversation to the model again. While the prompt cache is warm, that re-read is cheap. Once it has expired, the full conversation is processed again, which costs far more. How long the cache lasts depends on how you sign in.
| Sign-in | Main conversation cache, by default |
|---|
| Claude subscription, within included usage | 1 hour |
| API key, usage credits or cloud provider | 5 minutes |
In the second case, setting promptCacheTtl to 1h gives the main conversation a one-hour cache. The post on idle compaction covers that setting in more detail.
To check, run /usage. Since v2.1.251, the Prompt cache (main) line shows the cache state and its lifetime, for example warm (1h TTL, ā¦).
With a 5-minute cache, runs need to come at most 5 minutes apart to keep the cache warm. /loop 5m creates the task */5 * * * *, which Claude Code starts 4 minutes 45 seconds after the previous run. Those 15 seconds are there so the run lands before the cache expires. If you do nothing between runs, a 10 or 15-minute interval re-reads the whole conversation uncached every time.
With a one-hour cache, any interval under an hour keeps the cache warm, such as /loop 30m for a quiet pull request. In self-paced mode, Claude waits at most an hour between runs. Since v2.1.304, a wakeup set at that maximum no longer fires just after the cache expires.
To wait for CI, Claude can also use the Monitor tool in a self-paced loop. It runs a background script and streams each output line back, without re-running a prompt. The docs say this is often more token-efficient.
How much does a loop cost?
Each run is a full turn, counted against your plan or billed to your API key. It re-reads the conversation, which grows with every run, then adds Claudeās own work.
The run count climbs fast. At one run every 4 minutes 45 seconds, /loop 5m works out to about 300 runs a day. Over 30 days with the session open, a forgotten loop would reach about 9,000. The old 7-day limit would have cut it off around 2,100.
To track the spend on a Pro, Max, Ultra, Team or Enterprise plan, open /usage. Since v2.1.243, a Loops section lists the heaviest loops. Each row shows how often the loop fires, its run count, total and per-run tokens, and when it last ran. Press d or w to switch between the last 24 hours and the last 7 days.
The figures are approximate and come from local session history on this machine. A loop you stop and create again stays on the same row, because Claude Code keys each row by its prompt.
When the task has an end, prefer a self-paced loop, which Claude stops once the work is done. For what a turn costs and how much the cache weighs on the bill, read what a Claude Code task costs.
Should I use /loop, /goal or /schedule?
| /loop | /goal | /schedule |
|---|
| Next turn starts | After an interval | As soon as the previous turn ends | On a schedule, an API call or a GitHub event |
| Runs in | Your session, on your machine | Your current session | Anthropicās cloud, by default |
| Open session needed | Yes | Yes | No |
| Minimum interval | 1 minute | No interval | 1 hour |
Keep /loop for watching CI or a pull request while you work. If Claude should instead keep going until it reaches a specific state, use the /goal command.
Section 7.11 of module 7, Optimization and pro workflow covers /loop, /goal and scheduled tasks.