Contents
"Tell me when the build finishes." "If CI goes red, fix it." "Watch the deploy every 5 minutes." What if you could hand these stay-glued chores entirely to AI? The /loop command added to Claude Code in 2026 does exactly that. It runs a prompt or slash command repeatedly on an interval you set — or one the AI decides for itself — a "watcher" and "repeater" within your session.
Here's the bottom line. /loop fills the gap between "I want to check right now" and "I want it automated 24/7." Type /loop 5m check the deploy status and it runs automatically every five minutes. Omit the interval and Claude looks at the situation and picks the best wait time itself (self-pacing). This article explains, for beginners, the four ways to use it, how self-pacing works, practical recipes, how to stop it and what to watch out for, and how it differs from related features (Desktop tasks, cloud Routines). Note that /loop is a new feature whose behavior may change, so check the official docs for the latest (this article reflects 2026 information).
On your interval, AI runs again and again
— Hand the stay-glued watching to a loop
prompt/command
interval or AI-chosen
auto-stops when finished
"Run → wait → run again," driven by AI. In self-pacing mode, the loop stops once the AI judges the task complete.
* The /loop behavior in this article is based on the Claude Code official docs (as of 2026). As a new feature it may change by version. Check `claude --version` and the official docs for the latest before use.
1. What is /loop? — in one sentence
/loop is a built-in Claude Code feature that "runs a prompt or slash command repeatedly on an interval." Technically it's a "session-scoped task scheduler," and under the hood it uses cron (a time scheduler).
/loop = a command to "have the same instruction run automatically, again and again, on an interval you set (or one the AI chooses)." You can hand off stay-glued chores — watching CI/deploys, babysitting PRs, checking long builds — while keeping the session open.
In everyday terms, /loop is "a thoughtful assistant you can ask to go check on things every five minutes." While you work on something else, the AI periodically checks in the background and responds when something changes. And if you omit the interval, the AI gauges the timing itself — "things are moving, so one minute; it's quiet now, so thirty". That's the decisive difference from plain cron. The "decides and acts on its own" nature of an underlying AI agent is exactly what pays off here.
2. Four ways to use it (interval × prompt)
The basic form is /loop [interval] [prompt]. Both interval and prompt are optional, and what you pass changes the behavior. There are four combinations.
| Example input | Behavior |
|---|---|
/loop 5m check the deploy status | Fixed interval: auto-runs this prompt every 5 minutes (cron-based) |
/loop check the deploy status | Self-pacing: Claude judges the interval each time, by the situation |
/loop 15m | Interval only: runs the built-in "maintenance prompt" every 15 minutes |
/loop | Both omitted: maintenance on an AI-chosen interval (continue unfinished work → PR/CI → cleanup) |
Intervals are written as a number + a unit (s=seconds, m=minutes, h=hours, d=days). The minimum is one minute, and seconds are rounded up to match cron's granularity. You can also write it in natural language, like every 2 hours. And crucially — you can pass a slash command instead of a prompt. For example, this loops the review of a specific PR every 20 minutes:
# Example of looping a slash command
/loop 20m /review-pr 1234
# Example of specifying the interval in natural language
/loop check the test results every 30m
In other words, you can automate "the command you used to type by hand" just by adding an interval. If you care about AI coding cost, the knack is to avoid pointless loops and run them only when needed.
3. The power of self-pacing (AI picks the interval)
Of the four usages, the one that lifts /loop above "plain cron" is self-pacing (auto-judged intervals). Omit the interval and Claude, after each run, decides for itself "when should I come back next?"
Fixed interval (cron)
- Runs mechanically at the same interval
- Keeps running even when nothing changes
- Continues until you stop it (or 7 days)
- Best when you need an exact time
Self-pacing (AI judgment)
- Waits shorter when active, longer when quiet
- The AI picks a wait between 1 minute and 1 hour
- Shows the chosen interval and reasoning each time
- Auto-ends the loop when it judges the task done
This is where it shines. Ask, in self-pacing mode, "watch until the tests pass," and it checks at short intervals while tests run, increases the frequency as the finish nears, and stops the loop and reports once they pass — behaving much like a human watcher. With a fixed interval you get "it keeps running pointlessly though it's already done" or, conversely, "the interval is too long and it misses things"; self-pacing avoids that. Personally, I'd use self-pacing for monitoring that doesn't need an exact time, and a fixed interval for things where time matters, like a scheduled report.
4. Practical recipes
Concrete examples beat abstractions. Here's where /loop genuinely helps, in ready-to-use form.
Watch CI/deploys
"If CI goes red, read the log and fix the cause," in self-pacing mode. It tends the issue automatically until it's green.
Babysit a PR
/loop 20m to periodically address PR review comments, resolve conflicts, and fix CI.
Check long builds
Hand off "check whether the build finished, and if so move on to the next step."
Reminders & timed checks
Also for one-time bookings like "in 45 minutes, check whether the integration tests passed."
Auto-maintain a branch
A prompt-less /loop periodically continues unfinished work and runs cleanup.
The point is to target "work a person used to check periodically." Especially jobs that repeat "wait → check → respond," like CI and deploys, are /loop's home turf. Routine monitoring like a PR status check, looped, frees you from staying glued.
5. Stopping it, and cautions
For all its convenience, /loop has constraints that come from "running within a session." Not knowing them leads to "huh, it's not running?"
- Stop with Esc: press Esc while it waits for the next run, and the pending wakeup is cleared and the loop stops. In self-pacing, Claude may also stop on its own when it judges the task "done."
- Runs only while the session is open: /loop is tied to that session (conversation). Starting a new conversation clears the tasks. Closing the terminal stops it too (resume within 7 days with `claude --resume`).
- Fixed intervals last up to 7 days: they keep running until you stop them or 7 days pass.
- Up to 50 tasks per session: you can't register more.
- Fires between turns (responses): it doesn't interrupt mid-action; it fires at the gap between turns. When things are busy it can drift a bit (there's also intentional jitter to avoid hammering the API). Times are in your local timezone.
Honestly, the biggest pitfall is forgetting that "it stops when you close the session." /loop isn't suited to running 24/7 unattended. For that, use a different feature, covered next.
6. Choosing among three scheduling features
Claude Code actually has three layers of scheduling. /loop handles the "within a session" one. They're easy to confuse, so let's sort them out.
| Feature | Runs on | Always on | Best for |
|---|---|---|---|
| /loop | Your PC (within a session) | ✗ (only while open) | Monitoring/polling during work (CI watching, PR babysitting) |
| Desktop scheduled tasks | Your PC (independent) | ✅ (resident) | Recurring local work that outlives a session (audits, syncs) |
| Routines (cloud) | Anthropic's cloud | ✅ (runs unattended) | Fully automatic ops like nightly builds and scheduled reports |
* Feature names and specs are as of 2026. They may change by version or availability, so check the official source.
The choice is simple. Just want to watch a bit during work? /loop. Want it to continue after you close the session? Desktop tasks. Want it to run unattended even with your PC closed? Cloud Routines. Is it "monitoring as an extension of what I'm doing," or "running even when I'm not here"? That single question decides it. If you run AI agents seriously, understanding these three layers pays off.
7. Customization (loop.md) and disabling
Finally, two more advanced touches.
- Make the "default behavior" your own with loop.md: the default action for a prompt-less
/loopcan be replaced by writing your own Markdown in `.claude/loop.md` (project-level) or `~/.claude/loop.md` (user-level). For instance, you can make "your watching routine" the default — like "check the release/next PR; if CI is red, push a minimal fix; if green, report in one line." Edits take effect on the next run. - Disable it entirely: to stop the scheduler itself, set the environment variable
CLAUDE_CODE_DISABLE_CRON=1.
loop.md follows the same idea as guidance files like CLAUDE.md. Write down once "what you want done periodically," and your personal watching loop runs without you typing a prompt every time.
Summary
Here's Claude Code's /loop, sorted out.
- What /loop is: a session-scoped scheduler that runs a prompt/slash command repeatedly on an interval you set (or the AI sets).
- Four usages: fixed interval / self-pacing / interval-only (maintenance) / both omitted (auto-maintenance).
- Self-pacing is the key: it varies the interval by activity and auto-stops when done. The difference from plain cron.
- Practical use is monitoring: CI/deploy watching, PR babysitting, build checks, reminders.
- Constraints: within a session only, up to 50 tasks, fixed intervals last 7 days, stop with Esc.
- Choosing: /loop during work, Desktop tasks for resident, cloud Routines for unattended.
In the end, what /loop changes is the "time axis" of work you can hand to AI. Until now you could only ask for jobs that finish in a single conversation; /loop makes it possible, for the first time, to hand AI "continuing work — wait, look again, respond." While you focus on something else, the loop keeps quietly turning. Get your stay-glued time back from the AI.
FAQ
Q. What is /loop?
A. It's a built-in Claude Code feature that runs a prompt or slash command repeatedly on an interval. Specify an interval like /loop 5m do X and it auto-runs every 5 minutes; omit the interval and Claude decides the best interval itself based on the situation (self-pacing). You can hand off stay-glued chores like watching CI and deploys.
Q. How do I specify the interval? What's the minimum?
A. With a number + unit (s=seconds, m=minutes, h=hours, d=days). For example, /loop 30m for every 30 minutes. Because it uses cron under the hood, the minimum is one minute, and seconds round up to minutes. You can also write it in natural language, like every 2 hours.
Q. What happens if I omit the interval?
A. After each run, Claude decides for itself "when to check next" (self-pacing). The wait is roughly between 1 minute and 1 hour — shorter when active, longer when quiet. And when Claude judges the task complete, it ends the loop automatically.
Q. How do I stop a running loop?
A. Press Esc while it's waiting for the next run, and the pending wakeup is cleared and it stops. Also, starting a new conversation clears that session's tasks. A fixed-interval loop continues until you stop it or 7 days pass.
Q. Does it keep running if I close my PC or terminal?
A. No. /loop is tied to the session (conversation), so closing the terminal stops it (you can resume within 7 days with `claude --resume`). If you want it to run unattended even with your PC closed, use locally-resident Desktop scheduled tasks or cloud-based Routines.
Q. Can I loop a slash command too?
A. Yes. Pass a slash command instead of a prompt and it runs on the schedule. For example, /loop 20m /review-pr 1234 loops the review of a specific PR every 20 minutes.
Q. What's the difference between /loop and Routines (cloud)?
A. /loop runs on your PC and only while a Claude Code session is open — lightweight, for monitoring. Routines run in Anthropic's cloud and keep going unattended even with your PC closed — for serious automated operations. Use /loop for "watching during work," and Routines for "recurring jobs you want to run even when you're not there."