Claude Code's /loop reruns a prompt in your current session on an interval: /loop 5m check whether the deploy finished runs every five minutes for as long as the session stays open. When the work has to happen without an open session, Claude Code has three other options: routines that run in Anthropic's cloud, scheduled tasks in the desktop app, and claude -p called from cron or GitHub Actions. Here is how each works and when to use it, as of October 2026.
/loop | Desktop scheduled task | Routine | Cron or GitHub Actions | |
|---|---|---|---|---|
| Runs on | Your machine, in the session | Your machine, from the app | Anthropic's cloud | Any machine or CI runner |
| Needs your computer on | Yes | Yes, app open and awake | No | Only for local cron |
| Needs an open session | Yes | No | No | No |
| Shortest interval | 1 minute | 1 minute | 1 hour | 1 minute, or 5 on GitHub |
| Local files | Yes | Yes | No, fresh clone | Yes, or a checkout |
| Permission prompts | Same as the session | Set per task | None, runs on its own | Pre-approve with flags |
/loop: repeat a prompt while you work
/loop is a bundled skill, and what you pass decides how it behaves:
| You type | What happens |
|---|---|
/loop 5m check the deploy | Runs on a fixed schedule. Units are s, m, h and d; seconds round up to a minute |
/loop check the deploy | Claude picks the next delay after each run, between one minute and one hour, and says why |
/loop | Runs a built-in maintenance prompt: continue unfinished work, tend the branch's pull request, then clean up |
The prompt can also be a skill, such as /loop 30m /my-skill, as long as Claude is allowed to invoke that skill itself. To replace the maintenance prompt with your own default, write it in .claude/loop.md (one project) or ~/.claude/loop.md (everywhere). Edits take effect on the next run.
For a one-off, skip /loop and ask in plain words:
remind me at 3pm to push the release branch in 45 minutes, check whether the integration tests passed
To see or cancel tasks, ask "what scheduled tasks do I have?" or "cancel the deploy check job". Press Esc to stop a self-paced loop while it waits.
The limits matter for anything longer than an afternoon:
- Tasks fire only while Claude Code is running and idle, between your turns. Close the terminal and they stop.
- Missed runs aren't caught up: a run that came due during a long request fires once, afterwards.
- Recurring tasks expire after seven days, and a session holds at most 50.
- Times are in your local timezone, and Claude Code shifts runs to spread load: an hourly or daily task can start up to 30 minutes late.
CLAUDE_CODE_DISABLE_CRON=1turns the scheduler off.
Routines: scheduled runs in the cloud
A routine is a saved prompt plus one or more GitHub repositories, an environment and connectors, run on Anthropic's infrastructure so it keeps going with your laptop closed. Routines are a research preview on Pro, Max, Team and Enterprise plans.
Create one at claude.ai/code/routines, from the Routines page in the desktop app, or from any session:
/schedule daily PR review at 9am
/schedule (also /routines) asks follow-up questions about the repositories and prompt, then saves the routine to your account. A routine can have several triggers:
- Schedule: hourly, daily, weekdays or weekly presets, or a one-off time. For a custom cron expression, pick the closest preset and run
/schedule update. The minimum interval is one hour. A run set for exactly 9:00 can start several minutes late, so pick 9:07 if timing matters. - API: a per-routine URL you POST to with a bearer token, for example from an alerting tool. Optional
textin the body passes context such as the alert. - GitHub: pull request or release events, with filters.
Three things to know before you rely on one. Routines run fully autonomously, with no permission prompts. They act as you: commits, pull requests and connector actions carry your identity. And every connected connector is included by default, with write access, so remove the ones the routine doesn't need. Runs draw on your plan's usage like any session, and scheduled runs are capped at 100 per hour per account.
Desktop scheduled tasks: local, without a terminal
In the desktop app's Code tab, open Routines, click New routine and choose Local. You give it a name, instructions, a working folder, a permission mode, a model and a schedule (Manual, Hourly, Daily, Weekdays or Weekly; ask Claude for anything else, such as every 15 minutes). Turn on the worktree toggle so each run gets its own checkout instead of your uncommitted changes.
Each run starts a fresh session under Scheduled in the sidebar and sends a desktop notification. Runs need the app open and the computer awake; after sleep, the app runs one catch-up for the most recent missed time. A task in Manual mode that hits a permission prompt waits until you approve it.
Cron and claude -p: any machine you control
On a server or a machine that is always on, plain cron and non-interactive mode do the job. Find the binary with which claude, create a token with claude setup-token (a one-year OAuth token for your subscription), then add lines like these with crontab -e:
CLAUDE_CODE_OAUTH_TOKEN=your-token 30 9 * * 1-5 cd /home/me/app && /usr/local/bin/claude -p "Summarize yesterday's failed CI runs on main" --permission-mode dontAsk --allowedTools "Bash(gh run list *),Bash(gh run view *)" >> /home/me/logs/ci-digest.log 2>&1
--permission-mode dontAsk denies anything the allow list doesn't cover instead of waiting for an answer, so a cron job never hangs on a prompt. Pre-approve only what the job needs; the space before * makes each rule a prefix match. If you add --bare to skip local hooks, skills and CLAUDE.md, authenticate with ANTHROPIC_API_KEY instead, since bare mode doesn't read the OAuth token.
GitHub Actions: schedules in CI
The official action runs a prompt on any workflow trigger, including schedule:
name: Morning digest
on:
schedule:
- cron: "7 8 * * 1-5"
workflow_dispatch:
jobs:
digest:
runs-on: ubuntu-latest
permissions:
contents: read
issues: read
id-token: write
steps:
- uses: anthropics/claude-code-action@v1
with:
claude_code_oauth_token: ${{ secrets.CLAUDE_CODE_OAUTH_TOKEN }}
prompt: "Summarize yesterday's commits and the open issues labeled bug"
claude_args: |
--allowedTools "mcp__github__list_commits,mcp__github__list_issues"Use anthropic_api_key instead for an API key; for a secret shared across repositories, Anthropic recommends an API key over a personal OAuth token. With a plain prompt, Claude gets no shell or GitHub access until you allow the tools it needs. GitHub schedules run in UTC from the default branch, and public repositories disable them after 60 days without activity.
Which one to use
- Babysitting a deploy or a pull request this afternoon:
/loop. - A daily job that needs your local files and tools: a desktop scheduled task, or cron on a machine that stays on.
- Work that must run with your laptop closed, or react to an alert or a new PR: a routine.
- Team-owned jobs that live next to the code: GitHub Actions.
Skills worth scheduling
A scheduled run is only as good as its prompt. The skills directory has step-by-step skills with the exact commands and API calls, and Claude scheduled task examples groups the ones that run on a schedule by cadence, each with its cron line. Install one, run it once by hand to check its access, then schedule claude -p "Run the github-actions-failed-runs skill" with any of the methods above.
The output of a scheduled run lands in a log, a routine session or a workflow page, which nobody reads at 9am. With a BRIEFKIN_TOKEN set, each skill run posts one card to your Briefkin board and updates the same card next time, so a week of runs reads as one card with a trend. See the docs, and the hooks guide if you want a Stop hook to tell you when a scheduled session finishes.
Questions
What does /loop do in Claude Code?
It reruns a prompt inside your open session. /loop 5m check the deploy runs every five minutes; /loop check the deploy lets Claude pick a delay between one minute and one hour after each run; a bare /loop runs a built-in maintenance prompt, or your own loop.md. Recurring loops expire after seven days.
Does /loop keep running when I close the terminal?
No. Loop tasks fire only while Claude Code is running and idle, and missed runs aren't caught up. Backgrounding the session carries them over to a background session. For anything that must run without an open session, use a routine, a desktop scheduled task, cron or GitHub Actions.
What is the difference between Claude Code routines and /loop?
A routine runs in Anthropic's cloud on a fresh clone of your repositories, on a schedule, an API call or a GitHub event, even with your laptop closed. /loop runs in your current session on your machine, with your files and tools, and stops when the session ends.
Can a routine run more often than once an hour?
No. As of October 2026 the minimum interval for a scheduled routine is one hour, and more frequent cron expressions are rejected. For shorter intervals, use /loop, a desktop scheduled task or system cron, which all go down to one minute.
How do I run Claude Code from cron?
Call claude -p with the absolute path to the binary, a prompt, and pre-approved tools, for example --permission-mode dontAsk --allowedTools "Bash(gh run list *)". Cron has no browser login, so set CLAUDE_CODE_OAUTH_TOKEN (from claude setup-token) or ANTHROPIC_API_KEY in the crontab.