Claude Code Scheduled Tasks & Routines: The Complete Guide (2026)
AI Infrastructure Lead
⚡ Key Takeaways
- Claude Code now has three scheduling tiers: CLI
/loop(session-scoped), Desktop Scheduled Tasks (local persistence), and Cloud Routines (Anthropic-managed infrastructure) - Routines launched April 14, 2026 as a research preview — they run even when your laptop is closed
- Three trigger types: scheduled (hourly/daily/weekly), API (HTTP POST), and GitHub webhooks (PR, push, issues)
- Daily limits: Pro gets 5 runs, Max gets 15, Team/Enterprise gets 25
- These aren't cron jobs — they're fully agentic, meaning they reason through problems, self-heal errors, and adapt to context
- Why Scheduling Changes Everything
- The Three Scheduling Tiers, Explained
- CLI /loop: Session-Scoped Polling
- Desktop Scheduled Tasks: Local Persistence
- Cloud Routines: The Game-Changing Addition
- How to Set Up Your First Routine
- 7 Gotchas That Will Bite You
- 10 Practical Automations Worth Setting Up
- Routines vs GitHub Actions vs n8n vs Cron
- Plan Limits and Pricing
- FAQ
Claude Code started as a coding assistant you talked to when you needed help. You'd open a session, ask it to fix a bug or refactor a function, and close it when done. The problem? Every morning you'd type the same prompts — "check yesterday's PRs," "run the test suite," "summarize what changed overnight." Repetitive, manual, and exactly the kind of work AI should be handling on its own.
That changed with scheduled tasks. And then Anthropic went further with Routines — cloud-based automations that run even when your laptop is closed. We spent the past week setting up 8 different scheduled automations across all three tiers, testing the limits, hitting the gotchas, and figuring out what actually works in production. Here's what we found.
Why Scheduling Changes Everything
The difference between a coding assistant and a coding agent is autonomy. An assistant waits for you to ask. An agent acts on its own, at the right time, without being prompted.
Traditional cron jobs and GitHub Actions can automate tasks too — but they execute static scripts. When a script hits an unexpected error, it stops dead and waits for human intervention. Claude Code's scheduled tasks are fundamentally different: they're fully agentic. When something goes wrong mid-execution, the AI reasons through the problem, tries alternative approaches, and adapts. As Nate Herk explains in his walkthrough, this makes them "10x more powerful" than deterministic automation.
The practical impact: a scheduled PR review doesn't just check for linting errors — it reads the code changes, understands the intent, checks for security vulnerabilities, and writes contextual review comments. A morning briefing doesn't just list Slack messages — it prioritizes by urgency, flags blockers, and suggests actions.
The Three Scheduling Tiers, Explained
Claude Code doesn't have one scheduling system — it has three, each designed for a different level of commitment and infrastructure. Understanding which to use when is the key to getting value from automation.
Here's the quick comparison before we go deep on each:
| Feature | /loop (CLI) | Desktop Tasks | Cloud Routines |
|---|---|---|---|
| Runs on | Your terminal session | Your local machine | Anthropic cloud |
| Machine must be on? | Yes | Yes | No |
| Persists across restarts? | No | Yes | Yes |
| Triggers | Timer/polling | Schedule only | Schedule + API + GitHub |
| Minimum interval | 1 minute | 1 minute | 1 hour |
| Access to local files? | Yes | Yes | No (fresh clone) |
| Auto-expiry | 7 days | Never | Never |
| Best for | Quick monitoring during a session | Daily local workflows | Always-on production automation |
Detailed Tier Comparison
| Feature | /loop | Desktop Tasks | Cloud Routines |
|---|---|---|---|
| Runs on | Local terminal session | Local machine | Anthropic cloud |
| Machine must be on | Yes | Yes | No |
| Persists across restarts | No | Yes | Yes |
| Trigger types | Timer or polling | Schedule only | Schedule, API, or GitHub |
| Minimum interval | 1 minute | 1 minute | 1 hour |
| Local file access | Yes | Yes | No (fresh clone) |
| Auto-expiry | 7 days | Never | Never |
| Daily run limits | Uses regular usage quota | Uses regular usage quota | 5 (Pro), 15 (Max), 25 (Team/Enterprise) |
| Setup method | CLI command (/loop) | Desktop app (Schedule > + New task) | Web UI, CLI (/schedule), or Desktop App |
| Cost model | Included in regular usage quota | Included in regular usage quota | Plan-based (included with daily caps) |
| Best use case | Quick monitoring during a session | Daily local workflows | Always-on production automation |
CLI /loop: Session-Scoped Polling
The /loop command is the simplest entry point to scheduling. Think of it as "keep doing this thing until I tell you to stop." It runs inside your current terminal session and dies when you close it.
Three ways to use it:
/loop 5m check the deploy status — Fixed interval + prompt
/loop check the deploy status — Dynamic self-pacing (Claude picks the interval)
/loop — Built-in maintenance mode (continues unfinished work, tends PRs)
The dynamic self-pacing mode is surprisingly clever. Claude adjusts its polling interval based on what it finds: checking every 60 seconds when a build is running, stretching to 20-30 minutes when nothing is happening. There's even a prompt cache optimization — the 5-minute cache TTL means sleeping exactly 300 seconds is the worst choice (you pay the cache miss without benefit). Stay under 270 seconds for warm cache, or commit to 1,200+ seconds for idle checks.
Limitations to know: Maximum 50 tasks per session. Recurring tasks auto-expire after 7 days. No catch-up for missed runs. And closing your terminal kills everything — there's no persistence. For anything you want to survive a restart, you need Desktop Tasks or Routines.
For deeper coverage of loops and the autonomous execution model, see our Claude Code Loops & Skills.md guide.
Quick-Reference Flashcards: Scheduling Tiers
What are the three distinct scheduling tiers available in Claude Code?
CLI /loop, Desktop Scheduled Tasks, and Cloud Routines.
What is the operational scope of the CLI /loop command?
It is session-scoped and runs only within an active terminal session.
Does the CLI /loop tier persist across system restarts?
No, it dies when the terminal session is closed.
Which scheduling tier provides local persistence across restarts but requires the machine to be on?
Desktop Scheduled Tasks
What is the minimum interval for a CLI /loop task?
1 minute
What is the minimum interval for a Cloud Routine?
1 hour
Desktop Scheduled Tasks: Local Persistence
Desktop Scheduled Tasks are the middle ground — they persist across restarts but still run on your local machine. Set them up in the Claude Code Desktop app via Schedule > + New task.
Configuration is straightforward: give it a name, a prompt, pick a frequency (hourly, daily, weekdays, or weekly), and optionally choose the model and permission mode. The prompts are stored as SKILL.md files at ~/.claude/scheduled-tasks/<task-name>/SKILL.md, which means you can edit them directly in your text editor and version control them.
The catch-up behavior is worth understanding: when you open the desktop app, it checks the last 7 days for missed runs and executes one catch-up for the most recent missed time. This means a daily 9am task could fire at 11pm if your computer slept all day. Smart prompts include time guards: "Only review today's commits. If after 5pm, skip and post a summary instead."
Every task has full access to your local files, MCP servers, skills, and connectors. Each task gets its own permission mode — so you can have a "review-only" task that can't push code alongside a "deploy" task that can.
Platform note: Desktop tasks are macOS and Windows only. Linux users need CLI /loop, Cloud Routines, or cron jobs running claude -p in headless mode.
Cloud Routines: The New Addition Everyone's Talking About
Routines launched on April 14, 2026 as a research preview, and they're the most significant addition to Claude Code's automation capabilities. Anthropic defines a routine as "a saved Claude Code configuration: a prompt, one or more repositories, and a set of connectors, packaged once and run automatically."
The critical difference from everything else: routines run on Anthropic's cloud infrastructure. Close your laptop, go to sleep, take a vacation — your routines keep running. No server to manage, no Docker containers to maintain, no infrastructure overhead.
Three Trigger Types
1. Scheduled: Hourly, daily, weekday, or weekly intervals. Minimum interval is 1 hour (unlike Desktop Tasks which can go down to 1 minute). Set them up with /schedule daily PR review at 9am.
2. API: Each routine gets a dedicated HTTP endpoint with bearer token auth. POST to the endpoint to trigger immediate execution. This opens up integration with any external system — webhooks from Sentry, PagerDuty, Slack, or your own services. One critical gotcha: the API token is shown exactly once at creation. Store it immediately or you'll need to recreate the routine.
3. GitHub Webhooks: Subscribe to repository events — PR opened, push to main, new issue, release published. Each matching event spawns an independent session. You can filter by PR author, branch, labels, draft state, and more. This requires installing the Claude GitHub App on your target repos (separate from the clone access you get with /web-setup).
What Runs in the Cloud?
Each routine execution gets a fresh clone of your selected repositories. It has access to cloud-hosted connectors (Slack, Linear, Google Drive) but not your local MCP servers. Skills committed to your repository are available. By default, routines can only push to branches prefixed with claude/ — a safety mechanism you can override per repository.
For a deeper understanding of how hooks and agents interact with scheduled execution, check our dedicated guides.
How to Set Up Your First Routine
Three ways to create a routine, from easiest to most flexible:
Method 1: Web UI (recommended for first routine)
- Go to
claude.ai/code/routines - Click "New routine"
- Write your prompt, select repositories, configure connectors
- Pick a trigger type and schedule
- Save and activate
Method 2: CLI
/schedule daily PR review at 9am
Claude parses this naturally, creates the routine, and confirms the schedule
Method 3: Desktop App
Schedule sidebar > "New remote task" — creates a cloud routine from the desktop interface.
Quick-Reference Flashcards: Setup & Commands
To maximize prompt cache benefits in CLI /loop, what is the recommended maximum sleep interval?
270 seconds
Where are the prompts for Desktop Scheduled Tasks stored on a local machine?
At ~/.claude/scheduled-tasks/
What is the purpose of adding 'time guards' to a scheduled prompt?
They prevent tasks from executing at inappropriate times, such as after business hours.
What are the three trigger types supported by Cloud Routines?
Scheduled, API, and GitHub webhooks.
Which GitHub events can trigger a Cloud Routine through webhooks?
PR opened, push to main, new issue, and release published.
What specific component must be installed to use GitHub webhooks with Cloud Routines?
The Claude GitHub App.
Management commands:
/schedule list— View all routines/schedule update— Modify an existing routine/schedule run— Trigger immediately
7 Gotchas That Will Bite You
We learned these the hard way so you don't have to:
1. Environment variables don't transfer. Your local .env file doesn't exist in the cloud environment. API keys, tokens, and secrets need to be configured separately in the routine's cloud environment settings. This caught us on our first routine when it silently failed to connect to our database.
2. API tokens are shown once. When you create an API-triggered routine, the bearer token is displayed exactly once. There's no "show token" button later. Copy it immediately and store it in your secrets manager. If you lose it, you'll need to delete and recreate the entire routine.
3. Network access defaults to "trusted" mode. Some APIs (notably ClickUp and certain internal services) are blocked under "trusted" network access. Switch to "full" access in the routine settings to resolve mysterious connection failures.
4. CLAUDE.md files eat your token budget. Every routine run loads your CLAUDE.md instructions, consuming session tokens. A 5,000-word CLAUDE.md wastes context on every single run. Nate Herk recommends dedicated repositories per routine with lean, focused instructions.
5. No browser automation in the cloud. Routines don't have local cookies, persistent browser state, or GUI access. If your workflow involves Playwright, Puppeteer, or any browser-based automation, it won't transfer to cloud routines without significant rearchitecting.
6. Desktop catch-up can fire at weird times. A daily 9am task will fire at 11pm if your laptop was sleeping all day. Add time guards to your prompts: "If the current time is after 5pm, skip execution and log 'missed window'."
7. Branch restrictions are strict by default. Cloud routines can only push to branches prefixed with claude/. If your routine creates PRs or pushes code, you'll get silent failures until you enable "Allow unrestricted branch pushes" per repository.
Quick-Reference Flashcards: Gotchas & Pitfalls
What is the purpose of adding 'time guards' to a scheduled prompt?
They prevent tasks from executing at inappropriate times, such as after business hours.
What is the critical rule regarding the API bearer token for a new Cloud Routine?
It is displayed exactly once at creation and cannot be retrieved later.
By default, Cloud Routines are restricted to pushing code only to branches with what prefix?
claude/
Why is it necessary to configure environment variables separately for Cloud Routines?
Local .env files do not transfer to the cloud environment.
Under what condition should a user switch a Cloud Routine to 'full' network access?
When the routine needs to access APIs or internal services blocked by 'trusted' mode.
What is the disadvantage of using a very large CLAUDE.md file in a Cloud Routine?
It consumes a significant portion of the session token budget on every run.
10 Practical Automations Worth Setting Up
Sorted by impact and ease of setup:
| Automation | Best Tier | Schedule |
|---|---|---|
| Morning briefing — summarize Slack, email, PRs | Desktop daily | Weekdays 8:30am |
| PR code review — review on PR opened | Routine (GitHub) | On PR opened |
| Build monitoring — watch deploy status | /loop (dynamic) | Self-pacing |
| Error log triage — check Sentry/logs, create fix PRs | Routine (scheduled) | Every 4 hours |
| Dependency audit — run npm audit, create fix PR | Desktop weekly | Monday 9am |
| Weekly metrics report — compile trends, post to Slack | Routine (scheduled) | Friday 5pm |
| Documentation sync — flag outdated docs after merges | Routine (GitHub) | On PR merged |
| Alert triage — investigate PagerDuty/Sentry alerts | Routine (API) | On alert webhook |
| Competitor research — scan news and changes | Routine (scheduled) | Weekly Monday |
| Library porting — port changes between SDK repos | Routine (GitHub) | On PR closed |
For ready-to-use automation blueprints you can adapt, check our blueprint pack guide. And if you're building more complex agent workflows, our AI coding agent blueprints cover the architectural patterns.
Routines vs GitHub Actions vs n8n vs Cron
The question everyone asks: should I replace my GitHub Actions with Routines? The answer is nuanced.
| Aspect | Routines | GitHub Actions | n8n | Cron |
|---|---|---|---|---|
| Execution | AI reasoning | Static scripts | Visual workflows | Shell commands |
| Error handling | Self-healing | Predefined retries | Visual debugging | Manual scripting |
| Setup | Natural language | YAML files | Drag-and-drop | Crontab syntax |
| Context-aware | Yes — reads code | No | Limited | No |
| Cost model | Plan-based (5-25/day) | Per-minute billing | $0-50/month | Server costs |
Our take: Routines are best for tasks that benefit from intelligence — code review, bug triage, documentation updates. GitHub Actions is still better for deterministic CI/CD pipelines (build, test, deploy). Many production teams will combine both: Routines for the thinking work, Actions for the mechanical work. A head-to-head test of 40+ workflows found Claude Code produces roughly 40-50% production-ready automation outputs — good enough for many use cases, but n8n still wins for complex data routing.
For more context on where Claude Code fits in the best AI coding tools landscape, and how it compares as an AI coding assistant, see our dedicated comparison articles.
Plan Limits and Pricing
Routines are included in existing Claude Code plans at no extra cost — but with daily run limits:
| Plan | Price | Daily Routine Runs | Overage |
|---|---|---|---|
| Pro | $20/mo | 5 | No |
| Max | $100/mo | 15 | No |
| Team | $30/user/mo | 25 | Metered |
| Enterprise | Custom | 25 | Metered |
Important note: These limits may change during the research preview. Monitor your usage at claude.ai/settings/usage. Desktop Scheduled Tasks and CLI /loop commands are not subject to these daily run limits — they use your regular Claude Code usage quota.
For most individual developers, the Pro plan's 5 daily runs covers the essentials: a morning briefing, PR reviews via webhook, and a couple of ad-hoc API triggers. Power users and teams will want Max or Team for the higher limits.
Writing Better Prompts for Scheduled Tasks
Scheduled tasks are stateless — each run starts fresh with no memory of previous executions. This changes how you need to write prompts compared to interactive sessions.
Must-haves for every scheduled prompt:
- Explicit success/failure criteria: "Review for SQL injection and missing input validation" beats "review the code"
- Clear boundaries: "Create draft PRs only. Never merge. Never push to main."
- Edge case handling: "If no new issues were opened since the last run, post a summary and exit"
- Output instructions: "Post the summary to #releases in Slack" — don't assume where output goes
- Time guards: "Only process commits from the last 24 hours. If after 5pm, skip and log."
Test prompts in normal Claude Code sessions first before scheduling them. Start with one routine and one webhook, monitor the output consistency, and adjust based on results. As Adam Holter noted in his hands-on review: this feature "does not create autonomous engineers but handles repetitive work slices previously requiring constant oversight."
The Claude Code Power User Kit includes CLAUDE.md templates and hook configurations that work well as a starting point for scheduled task prompts. And our 43+ slash commands guide covers the full command vocabulary available within scheduled sessions.
Frequently Asked Questions
What are Claude Code Routines?
Routines are cloud-based scheduled automations that run on Anthropic's infrastructure. A routine is a saved configuration — a prompt, repositories, and connectors — that executes automatically on a schedule, via API call, or in response to GitHub events. They run even when your computer is off.
How many routines can I run per day?
Pro plan: 5 runs/day. Max: 15. Team/Enterprise: 25. Organizations can exceed caps via metered overage. These limits are for cloud routines only — Desktop Tasks and /loop use your regular usage quota.
What's the difference between /loop, Scheduled Tasks, and Routines?
/loop is session-scoped CLI polling that dies when you close the terminal. Desktop Scheduled Tasks run locally and persist across restarts but require the app to be open. Cloud Routines run on Anthropic's infrastructure and work even when your laptop is closed.
Can Routines replace GitHub Actions?
Not entirely. Routines excel at tasks requiring reasoning — code review, bug triage, documentation updates. GitHub Actions is still better for deterministic CI/CD pipelines. Most production teams will use both.
Do Routines have access to my local files?
No. Each routine run clones your repository fresh from GitHub. They don't access local files, local MCP servers, or local environment variables. Configure cloud connectors and environment variables separately in the routine settings.
Are Desktop Scheduled Tasks available on Linux?
No. Desktop Tasks are macOS and Windows only. Linux users can use CLI /loop, Cloud Routines, or traditional cron jobs running claude -p in headless mode.
This guide is also available as a video walkthrough and podcast episode.
Recommended AI Tools
HeyGen
AI avatar video creation platform with 700+ avatars, 175+ languages, and Avatar IV full-body motion.
View Review →Kimi Code CLI
Open-source AI coding agent by Moonshot AI. Powered by K2.6 trillion-parameter MoE model with 256K context, 100 tok/s output, 100 parallel agents, MCP support. 5-6x cheaper than Claude Code.
View Review →Undetectr
The world's first AI artifact removal engine for music. Remove spectral fingerprints, timing patterns, and metadata that distributors use to flag AI-generated tracks. Distribute on DistroKid, Spotify, Apple Music, and 150+ platforms.
View Review →Anijam ✓ Verified
PopularAiTools Verified — the most complete AI animation tool we have tested in 2026. Story, characters, voice, lip-sync, and timeline editing in one canvas.
View Review →