Scheduled Claude Code tasks: recurring routines on autopilot
Four ways to run Claude Code on a schedule: /loop, cloud scheduled tasks (routines), Desktop tasks and plain cron. What each needs, and which to pick.
You can make Claude Code run on a schedule in four ways: /loop inside an open session, cloud scheduled tasks (called routines until recently) that run on Anthropic's infrastructure, Desktop scheduled tasks that run on your machine, or your own cron job calling claude -p. They differ in one question that decides everything: does the job need your computer, your files, or a session left open?
#Which scheduling option should you choose?
Anthropic's own comparison, condensed:
| Cloud | Desktop | /loop | |
|---|---|---|---|
| Runs on | Anthropic's cloud | Your machine | Your machine |
| Needs your machine on | No | Yes | Yes |
| Needs an open session | No | No | Yes |
| Local files | No, a fresh clone of your repo | Yes | Yes |
| Shortest interval | 1 hour | 1 minute when Claude sets it, 1 hour in the forms | 1 minute |
Rule of thumb: cloud for work that must run reliably while your laptop is shut, Desktop or cron when the job needs local files, and /loop for quick polling while you work. Reach for headless mode with cron if you want the least moving parts.
#How does /loop work?
/loop re-runs a prompt on an interval while the session stays open. You can give it an interval, a prompt, both or neither.
/loop 5m check if the deployment finished and tell me what happened
/loop check whether CI passed and address any review comments
/loop 20m /review-pr 1234
With an interval (s, m, h or d), Claude turns it into a cron expression and schedules it. Intervals that do not map to a clean cron step, such as 7m or 90m, are rounded and Claude tells you what it picked. Without an interval, Claude picks a delay between one minute and one hour after each iteration, shorter while something is changing, longer when nothing is pending. A bare /loop runs a built-in maintenance prompt: continue unfinished work, tend to the branch's pull request, then do cleanup passes. Put your own default in .claude/loop.md (or ~/.claude/loop.md) to replace it.
Limits to know before you rely on it:
- Tasks fire only while Claude Code is running and idle. A prompt that comes due mid-response waits for the turn to end.
- Recurring tasks expire seven days after creation. They fire once more and delete themselves.
- A session holds up to 50 scheduled tasks.
- Runs are not exact: a recurring task can start late by up to half the gap to its next run, capped at 30 minutes. Missed runs are not replayed; one fires when Claude is idle again.
- To stop a fixed-interval loop, ask Claude: "cancel the deploy check loop". A self-paced one stops with
Esc.
One-off reminders work in plain language: remind me at 3pm to push the release branch. Claude pins a cron time and the task deletes itself after running.
#What are cloud scheduled tasks (routines)?
A cloud scheduled task is a saved configuration: a prompt, one or more repositories and a set of connectors. It runs as a full Claude Code session in the cloud, with no need for your laptop. Each can have one or more triggers: a schedule (hourly, nightly, weekly, or once), an API call to its own endpoint with a bearer token, or a GitHub event such as a pull request opening. They are in research preview and available on paid Claude plans.
Create one at claude.ai/code/routines, from the Desktop app, or in a session:
/schedule daily PR review at 9am
/routines is an alias. Good fits from the docs: backlog grooming each weeknight, triaging an alert sent to the API trigger, a custom review checklist on every new pull request, a weekly check for documentation that has drifted from the code.
Keep in mind:
- The run starts from a fresh clone of the repository you pick, so it cannot see uncommitted local files. It works on
claude/-prefixed branches. - The prompt must be self-contained: the task runs autonomously, so say what to do and what success looks like.
- Connectors you add can write, and everything is done as you (your GitHub identity, your Slack). Remove the ones the task does not need.
- Runs count against your plan's usage limits; see Claude Code usage limits.
#How do you schedule with plain cron?
When you want a local run with full control, combine cron with claude -p:
# crontab -e (weekdays at 08:00)
0 8 * * 1-5 cd ~/code/app && claude -p "Run the test suite and summarize any failure in 5 lines" --allowedTools "Bash(npm test *),Read" >> ~/test-report.md 2>&1
Decide permissions explicitly, because nobody is there to approve. --permission-prompts none denies anything that would prompt, and --max-budget-usd caps spend. Cron starts with a bare environment, so use absolute paths and set up authentication for that user. The details are in the headless mode article. If the machine is asleep at the time, the run simply does not happen: cron does not catch up.
#How do you write a prompt that is safe to run unattended?
A scheduled run has no one to ask. A few habits:
- Make it read-only first. Start with "report, don't change", read the output for a week, then grant edits.
- Give it a definition of done and an output place. "Write the summary to
reports/2026-W47.md" beats "look into it". - Bound it. One repository, one branch, a turn or budget cap.
- Make it idempotent. If a run is missed or doubled, nothing should break.
- Ask for evidence, such as the command and its output, so the report is verifiable.
Treat anything the job fetches (web pages, issue text) as untrusted input, and hooks as the place for rules that cannot have exceptions.
#In Relais
Relais has scheduling built in. "Repeat…" resends a prompt at set times, or every so many minutes, hours or days, in the same session or in a fresh one each time. A session that repeats shows "next in 3h 12m" in the sidebar, and the Daily dashboard lists coming runs. It runs while Relais is open: a run waits if Claude is busy, and one missed while the computer slept runs once when it is back, or is offered to you. Agents get routines of their own too, each run a fresh session (reply to mentions every hour, say), and with Keep awake on, Relais holds off idle sleep while an agent has a routine due within the hour. See features and agents.