Skip to content
,

Claude Code Scheduled Tasks: /loop, Desktop and Cloud Routines Guide

10–15 minutes
Woman in a bright co-working space with plants holding a tablet with a SCHEDULED TASKS card, hook put Claude on a timer

Claude Code can now run work for you on a timer.

You can poll a deploy every five minutes inside a session, have the desktop app review your commits every morning, or run a nightly backlog sweep in the cloud while your laptop is switched off.

There are three ways to do it, and picking the wrong one is the most common reason a “scheduled” job quietly never runs.

This guide explains all three: /loop and one-time reminders inside a session, local scheduled tasks in the desktop app, and cloud scheduled tasks (formerly called routines) with schedule, API and GitHub triggers. It follows Anthropic’s official Claude Code documentation as of December 2026.

TL;DR

  • Quick polling in a session: /loop 5m check the deploy. Stops when the session closes.
  • Let Claude pick the pace: /loop check CI and fix failures (1 minute to 1 hour between runs).
  • One-off reminder: type “remind me at 3pm to push the release branch”.
  • Needs local files, no open session: Desktop app, Scheduled, New task, turn on Only on this computer.
  • Runs with your PC off: /schedule daily PR review at 9am or claude.ai/code/routines (cloud, 1 hour minimum).
  • Gotcha: session loops expire after 30 days, and cloud cron hours are UTC.

Which Scheduling Option Should You Use?

The three options differ mainly in where they run and what has to stay switched on. This table is condensed from the official comparison:

/loop (session) Desktop task Cloud task
Runs on Your machine Your machine Anthropic cloud
Machine must be on Yes Yes No
Session must be open Yes No No
Survives restarts Restored on --resume, with exceptions Yes Yes
Local files Yes Yes No (fresh clone)
MCP servers Inherits from session Config files and connectors Connectors per task
Permission prompts Inherits from session Set per task Auto mode by default
Minimum interval 1 minute 1 minute if Claude sets it, 1 hour in the forms 1 hour

Rule of thumb from the docs: use cloud tasks for work that must run reliably without your machine, desktop tasks when you need local files and tools, and /loop for quick polling while you work.

Run a Prompt on Repeat With /loop

/loop is a bundled skill that re-runs a prompt while your session stays open. How you write it decides the schedule:

You type What happens
/loop 5m check if the deploy finished Fixed schedule every 5 minutes
/loop check CI and fix failures Claude picks each gap, from 1 minute to 1 hour
/loop or /loop 15m Runs the built-in maintenance prompt, or your loop.md
  1. Pick an interval unit: s, m, h or d. Seconds are rounded up to the nearest minute because the scheduler works in whole minutes.
  2. Write the prompt as a full instruction. “Check the staging deploy; if it failed, read the logs and tell me why” works better than “deploy?”.
  3. Loop another command if you like: /loop 20m /review-pr 1234 re-runs a skill or slash command each time.
  4. Read the confirmation row under Claude’s CronCreate call. It shows the next run time.

Customize the default prompt with loop.md

A bare /loop runs a built-in maintenance prompt. To replace it with your own, create a loop.md file:

Path Scope
.claude/loop.md Project, wins when both exist
~/.claude/loop.md User, any project without its own file
Check the release/next branch. If CI is red, find the failing test,
fix it on a new branch and open a PR. If CI is green, do nothing.

Edits take effect on the next run, so you can tune it while the loop is live. Content beyond 25,000 bytes is cut off, so keep it short. It works like a small CLAUDE.md just for loops.

Stop a loop

  • Self-paced loop: press Esc. Claude can also end it itself once the job is done.
  • Fixed loop such as /loop 5m: Esc and Ctrl+C do not stop it. Ask Claude, for example “cancel the deploy check loop”.
  • Forgotten loops end on their own 30 days after you start them.

One-Time Reminders and Managing Tasks

You do not need /loop for a single future run. Just ask in plain language:

remind me at 3pm to push the release branch
in 45 minutes, check whether the integration tests passed

Claude turns this into a one-shot task that fires once and deletes itself. Behind the scenes it uses three tools:

Tool Purpose
CronCreate Schedule a task with a 5-field cron expression, a prompt and whether it repeats
CronList List tasks with IDs, schedules, prompts and next run
CronDelete Cancel a task by its ID

Ask “what scheduled tasks do I have?” or “cancel task abc12345”. Each task gets an 8-character ID, and one session can hold up to 50 tasks.

Tasks fire between your turns, never in the middle of a response. If Claude is busy when a task is due, it runs once when Claude goes idle. Missed runs are not replayed one by one.

Timing Rules: Jitter, Expiry and Time Zones

Session tasks are deliberately not exact, so thousands of sessions do not hit the API at the same second:

  • Recurring tasks run late by up to half the gap to the next run, capped at 30 minutes. An hourly task can start up to 30 minutes past the hour.
  • Every five minutes (*/5 * * * *) is not delayed.
  • One-shot tasks at :00 or :30 can fire up to 90 seconds early. For exact timing, pick an odd minute like 3:07.
  • Expiry: recurring tasks expire 30 days after creation, fire one final time and delete themselves. Tasks created on versions before v2.1.330 keep the old 7-day limit.
  • Time zone: session cron uses your local time, so 0 9 * * * means 9am where you run Claude Code.

Cron syntax is the standard five fields: minute, hour, day of month, month, day of week.

Expression Meaning
*/5 * * * * Every 5 minutes
0 * * * * Every hour on the hour
0 9 * * 1-5 Weekdays at 9am
30 14 15 3 * March 15 at 2:30pm

To switch session scheduling off completely, set CLAUDE_CODE_DISABLE_CRON=1. /loop and CronCreate then disappear and existing tasks stop firing.

Local Scheduled Tasks in the Desktop App

Desktop tasks start a fresh session on your machine at the time you choose, with no session left open. They need Claude Desktop 1.1.5368 or later. If your app is new to you, start with our Claude Code desktop app guide.

  1. Open the page: in the Code tab, click Scheduled in the sidebar (or under More). Some accounts still show Routines and New routine.
  2. Click New task. If a menu offers Create with Claude or Set up manually, pick manual.
  3. Name it. The name becomes a kebab-case folder on disk, so it must be unique.
  4. Write the instructions Claude should follow on each run.
  5. Turn on Only on this computer under Advanced settings, General. If the switch is greyed out, remove any repository, API or GitHub trigger, since those make it a cloud task.
  6. Pick the local folder the task runs in. Create stays disabled until you do.
  7. Set the schedule in the Trigger card: Hourly, Daily, Weekdays or Weekly.
  8. Choose permission mode and model in the instructions toolbar, then click Create. Trust the folder if asked.

After creating it, the pencil icon opens the Edit form, where you can switch to Manual (run only on demand) or Custom cron, and tick Worktree to give each run its own isolated git worktree instead of your current working state. Our worktrees guide explains why that matters.

Shortcut: in any local Desktop session, say “set up a daily code review that runs every morning at 9am”. Claude can even set gaps shorter than an hour this way, which the forms reject.

Missed runs and sleep

  • Desktop checks every minute while the app is open, and adds a fixed delay of a few minutes per task.
  • Tasks only run while the app is running and the computer is awake. Turn on Keep computer awake in settings. Closing the lid still sleeps the laptop.
  • On wake, Desktop runs one catch-up for the most recent missed time in the last seven days. A 9am task can therefore run at 11pm, so add guardrails like “only review today’s commits”.

Avoid permission stalls

A run that hits a permission prompt just waits. Click Run now after creating the task, approve each prompt with “always allow”, and later runs skip most of them. Allow rules in ~/.claude/settings.json also apply. Our permissions guide shows how to write those rules.

Cloud Scheduled Tasks (Formerly Routines)

Cloud tasks run on Anthropic-managed infrastructure against a fresh clone of your repos, so they keep working with your laptop closed. They are in research preview on Pro, Max, Ultra, Team and Enterprise plans, and each task belongs to your own account. They are built on Claude Code on the web.

Create from the CLI

  1. Sign in with your claude.ai account in the CLI (not an API key).
  2. Run /schedule daily PR review at 9am, or /schedule clean up feature flag in one week for a one-off.
  3. Answer Claude’s follow-up questions about schedule, repositories and prompt. It then saves the task to your account.
  4. Manage it later with /schedule update or on the web. /routines is an alias.

Create from the web

Go to claude.ai/code/routines, create a task, then set its prompt, repositories, cloud environment, connectors and triggers. The same list appears on the desktop app’s Scheduled page.

Schedule trigger tips

  • Presets (hourly, daily, weekly) take your local time.
  • A plain 5-field custom cron is read as UTC, so 0 9 * * 1-5 is 9:00 UTC. Keep or add a CRON_TZ= prefix to use another zone.
  • Runs set exactly on the hour can start several minutes late; pick 9:07 instead of 9:00.
  • Expressions more frequent than once an hour are rejected.
  • One-off runs turn themselves off afterwards and show as Completed.

Good fits listed in the docs: backlog grooming, alert triage, PR review, deploy verification, docs drift checks and porting changes between libraries.

API and GitHub Triggers

API trigger

  1. Edit the task at claude.ai/code/routines, click + in the Trigger row and choose API.
  2. Copy the Fire URL, click Generate token and store the token in a secret store at once. It is shown only once.
  3. POST to the URL with the token as a bearer header:
curl -X POST https://api.anthropic.com/v1/claude_code/routines/trig_YOUR_ID/fire \
  -H "Authorization: Bearer YOUR_TOKEN" \
  -H "anthropic-beta: experimental-cc-routine-2026-04-01" \
  -H "anthropic-version: 2023-06-01" \
  -H "Content-Type: application/json" \
  -d '{"text": "Alert fired in prod. Stack trace attached."}'

The response includes a session URL you can open to watch the run. The optional text arrives wrapped as untrusted data, so your saved prompt must say to act on it (for example “investigate the alert in the routine-fire-payload block”).

Use Regenerate to rotate the token, or Delete token to turn the API trigger off. The endpoint is a beta, so its shape may change.

GitHub trigger

Install the Claude GitHub App on the repo, then add a GitHub event trigger. Supported events are pull requests, releases and issues. Pull request filters cover author, title, body, base and head branch, labels, draft and merged state.

Note that matches regex tests the whole value, so use .*hotfix.* or the contains operator. Every event starts its own session. For CI-based automation instead, see our Claude Code GitHub Actions guide.

Usage and Limits

Action Hourly limit
Scheduled runs incl. one-offs 100 per account (extra runs wait)
Run now + API fires per task 30 per task
Run now per account 100
API fires per account 100

Cloud runs draw from your normal subscription usage, just like interactive sessions. Check it at claude.ai/settings/usage, and see our Claude Code pricing guide for plan limits. A paused subscription puts tasks on hold until you turn them back on.

Troubleshooting

/schedule says “Unknown command”

It needs a claude.ai subscription login. Remove ANTHROPIC_API_KEY, ANTHROPIC_AUTH_TOKEN or apiKeyHelper, which override that login, then run /login. It is also unavailable inside a cloud session and when your organization disables cloud sessions. You can still use claude.ai/code/routines.

Scheduled tasks are off for my organization

A Team or Enterprise Owner must turn on the Scheduled tasks (Was Routines) toggle under Organization settings, Capabilities, Remote sessions.

My /loop stopped overnight

Session tasks only fire while Claude Code is running and idle. Closing the terminal stops them. Use a desktop or cloud task for anything that must survive that.

Esc does not stop my loop

Fixed-interval loops ignore Esc. Ask Claude to cancel it, or to list tasks and delete by ID.

A desktop task never ran

The computer was asleep or the app was closed. Check Keep computer awake, and look for a catch-up run after wake.

A cloud task ran at the wrong hour

Your custom cron is in UTC. Convert the hours or add a CRON_TZ= prefix.

“The last run didn’t start because its environment couldn’t be found”

Edit the task and pick a valid cloud environment; the old one was archived.

Still stuck? Our Claude Code not working fixes cover login and network problems.

FAQ

What is the difference between /loop and /schedule?

/loop runs inside your open session on your machine. /schedule creates a cloud task that runs on Anthropic’s servers whether or not your computer is on.

Are routines and cloud scheduled tasks the same thing?

Yes. Routines were renamed to scheduled tasks. The old name remains in the URL claude.ai/code/routines, the /routines alias and the API.

Can a scheduled task edit my local files?

Session loops and desktop tasks can. Cloud tasks work on a fresh clone of your GitHub repos and push changes there instead.

What is the shortest interval?

One minute for /loop and for desktop tasks Claude sets for you. One hour for cloud tasks and desktop forms.

Do loops survive closing Claude Code?

Unexpired tasks are restored when you resume with claude --resume or --continue, but missed runs are not replayed.

Do scheduled tasks cost extra?

No separate fee is listed. They use your subscription usage the same way interactive sessions do.

Can I run scheduled jobs with an API key instead?

For headless jobs on your own cron or CI, use claude -p headless mode or GitHub Actions instead of /schedule.

Sources

Free weekly email

Get new AI guides every week

One short weekly email with our newest local AI, ComfyUI and AI tool guides. No spam, no pop-ups, just the good stuff.

Free. Unsubscribe anytime in one click. We only use your email to send this newsletter. See our privacy policy.

Woman in a bright co-working space with plants holding a tablet with a SCHEDULED TASKS card, hook put Claude on a timer