Appearance
Routines & Scheduled Tasks
Claude Code can run on a schedule, morning PR reviews, overnight CI failure analysis, weekly dependency audits. Routines run on Anthropic-managed infrastructure so they keep running even when your computer is off. Desktop scheduled tasks run on your machine with direct file access. /loop repeats a prompt within a session for quick polling.

What you'll learn
- Routines run on Anthropic infrastructure, they keep running when your computer is off, and can trigger on API calls or GitHub events
- Desktop scheduled tasks run on your machine with direct access to local files and tools
/looprepeats a prompt within a CLI session for quick polling
The problem
You want Claude Code to review every new PR at 9 AM, check for dependency updates every Monday, and sync documentation after every merge. You could run these manually, but scheduled automation is the whole point of having an agent, it should work while you don't.
Options & when to use each
| Scheduling method | Where it runs | When it works | When to use |
|---|---|---|---|
| Routines | Anthropic infrastructure | Even when your computer is off | Production-grade recurring tasks, API/webhook triggers |
| Desktop scheduled tasks | Your machine | Only when your machine is on | Tasks that need local file access, development workflows |
/loop | Your CLI session | Only while session is active | Quick polling, watching for changes |
Cron (via claude -p) | Your server | While server is running | Self-managed infrastructure |
Build it
Step 1: Create a routine
From the web, Desktop app, or CLI:
bash
/scheduleFollow the interactive prompt to set the schedule and task. Routines can trigger on:
- Time schedules (cron-style)
- API calls (webhook triggers)
- GitHub events (PR opened, issue created)
Step 2: Desktop scheduled task
In the Desktop app, create a scheduled task that runs Claude Code on your local machine:
Every weekday at 9 AM: Review all open PRs in this repo and summarize themStep 3: Use /loop for quick polling
/loop 30s: Check if the build server is responding on port 8080. If not, report the error./loop keeps running within the session. Press Ctrl+C to stop.
Step 4: Script a cron job
For environments with self-managed scheduling, you can trigger Claude Code directly via cron using the -p (print) mode. This runs the agent synchronously and exits once the task completes or hits the turn limit.
bash
# Crontab entry
0 9 * * 1 claude -p "Check for outdated dependencies and create a PR for any updates" --max-turns 10What goes wrong
| Mistake | How you notice it | The fix |
|---|---|---|
| Routine doesn't fire | No output at the scheduled time | Check routine status in the web dashboard. Verify the schedule syntax |
| Desktop task fails when laptop is asleep | Task shows as "missed" | Desktop tasks need the machine awake. Use Routines for critical tasks that can't miss a window |
/loop floods API | Rate limit errors after many iterations | Set a longer interval. /loop is for quick polling, not long-running monitoring |
Confirm it worked
Schedule a one-time routine to execute in a couple of minutes and write a test string to a temporary file. Check the file system afterward to confirm the routine triggered correctly and then clean up the file.
bash
# 1. Create a one-time routine for 2 minutes from now
/schedule "in 2 minutes: Write 'hello world' to /tmp/claude-routine-test.txt"
# 2. Wait 2 minutes, then check
cat /tmp/claude-routine-test.txt
# 3. Clean up
rm /tmp/claude-routine-test.txt