Claude Code Routines
Saved prompts that run on Anthropic's cloud, triggered by a schedule, an API call, or a GitHub event, with zero local dependencies.
Problem: Your laptop has to stay open for Claude Code to do anything. Desktop scheduled tasks and /loop run locally, which means a closed lid kills every automation you set up. You also have no way to react to external events like a GitHub PR or a monitoring alert without polling.
Quick Win: Create your first cloud routine from the CLI and test it on demand:
/schedule daily PR review at 9am/schedule runThe first command creates a routine that clones your repo on Anthropic's cloud every morning and runs the prompt. The second fires it right now so you can verify the output before trusting the schedule.
What Routines Are
A routine is three things packaged together: a prompt, one or more GitHub repositories, and a set of connectors (MCP servers like Slack, Linear, or Datadog). You configure it once. Anthropic's cloud runs it whenever a trigger fires.
Each run clones a fresh copy of your repo, spins up a full Claude Code session, and executes autonomously. No permission prompts. No approval clicks. The session can run shell commands, use any skills committed to the repo, and call every connector you attached.
Routines shipped on April 14, 2026 as a research preview. The behavior and API surface may change before GA.
Where Routines Live
Three surfaces create and manage routines. All write to the same cloud account.
Web UI at claude.ai/code/routines. Full control over every setting: prompt, model, repos, environment, triggers, and connectors.
CLI using /schedule. Creates scheduled routines only. Subcommands:
| Command | What It Does |
|---|---|
/schedule daily PR review at 9am | Creates a new routine with that cadence |
/schedule list | Shows all routines on your account |
/schedule update | Opens the editor for an existing routine |
/schedule run | Fires a routine immediately for testing |
Desktop app via Schedule > New task > New remote task. Choosing "New local task" creates a Desktop scheduled task instead, which runs on your machine.
API triggers and GitHub triggers can only be configured from the web UI. The CLI does not support them yet.
Three Trigger Types
A single routine can combine all three. A PR review routine could run nightly on a schedule, react instantly when a PR opens, and accept ad-hoc calls from a deploy script.
Schedule triggers fire on a cadence. Presets include hourly, daily, weekdays, and weekly. Custom cron expressions work too (set them with /schedule update). Minimum interval is one hour. Times use your local timezone.
API triggers give each routine a dedicated HTTP endpoint. POST to it from any system. The optional text field in the request body gets appended to the routine's prompt as extra context:
curl -X POST \
https://api.anthropic.com/v1/claude_code/routines/trig_01ABCDEFGHJKLMNOPQRSTUVW/fire \
-H "Authorization: Bearer sk-ant-oat01-xxxxx" \
-H "anthropic-beta: experimental-cc-routine-2026-04-01" \
-H "anthropic-version: 2023-06-01" \
-H "Content-Type: application/json" \
-d '{"text": "Sentry alert SEN-4521 fired in prod. Stack trace attached."}'The response hands back a session ID and a URL. Click the URL to watch Claude work in real time:
{
"type": "routine_fire",
"claude_code_session_id": "session_01HJKLMNOPQRSTUVWXYZ",
"claude_code_session_url": "https://claude.ai/code/session_01HJKLMNOPQRSTUVWXYZ"
}GitHub triggers subscribe to repository events. 18 event categories are supported:
| Event | Fires When |
|---|---|
| Pull request | Opened, closed, assigned, labeled, synchronized |
| Pull request review | Submitted, edited, dismissed |
| PR review comment | Diff comment created, edited, deleted |
| Push | Commits land on a branch |
| Release | Created, published, edited, deleted |
| Issues | Opened, edited, closed, labeled |
| Issue comment | Comment on issue or PR created, edited, deleted |
| Check run | Created, requested, completed |
| Check suite | Completed or requested |
| Workflow run | GitHub Actions workflow starts or completes |
| Workflow job | Job queued or completes |
| Workflow dispatch | Workflow manually triggered |
| Repository dispatch | Custom repository_dispatch event sent |
| Discussion | Created, edited, answered |
| Discussion comment | Created, edited, deleted |
| Sub issues | Sub-issue or parent added/removed |
| Commit comment | Commit commented on |
| Merge queue entry | PR enters or leaves merge queue |
Pull request triggers support filters. Every filter must match for the routine to fire:
| Filter | Example |
|---|---|
| Author | @dependabot |
| Title contains | auth-provider |
| Base branch | main |
| Head branch contains | feature/ |
| Labels include | needs-review |
| Is draft | false |
| Is merged | true |
| From fork | true |
Each matching GitHub event starts its own independent session. No session reuse across events.
How Routines Differ from Everything Else
Claude Code now has four ways to run work in the background. They solve different problems.
| Routines (cloud) | Desktop Scheduled Tasks | /loop | Monitor | |
|---|---|---|---|---|
| Runs on | Anthropic cloud | Your machine | Your machine | Your machine |
| Machine must be on | No | Yes | Yes | Yes |
| Session must be open | No | No | Yes | Yes |
| Local file access | No (fresh clone) | Yes | Yes | Yes |
| Minimum interval | 1 hour | 1 minute | 1 minute | Real-time |
| API/webhook trigger | Yes | No | No | No |
| Survives restart | Yes | Yes | No | No |
| Permission prompts | None (autonomous) | Configurable | Inherited | Inherited |
Routines are the right choice when the work should happen regardless of whether your machine is on, or when an external system needs to trigger it.
Desktop scheduled tasks are better when you need local file access or sub-hourly intervals.
/loop fits quick, session-scoped polling that should die when you close the terminal.
Monitor is for event-driven reactions to a running process (watching logs, tailing a dev server).
What You Can Automate
Six patterns cover most use cases. Each maps to a trigger type and a concrete workflow.
Nightly issue triage (schedule). The routine reads new issues from Linear or GitHub via connector, applies labels based on code area, assigns owners, and posts a summary to Slack. Runs every night at 2am.
Alert triage (API). Your monitoring tool (Datadog, PagerDuty, Sentry) POSTs the alert body to the routine's endpoint. Claude pulls the stack trace, correlates it with recent commits, and opens a draft PR with a proposed fix. By the time on-call opens the page, context is already assembled.
Code review on every PR (GitHub). Triggers on pull_request.opened with is_draft: false. Claude applies your team's review checklist, leaves inline comments for security and performance patterns, and adds a summary comment. Filter by base branch or labels to scope it to sensitive modules only.
Deploy verification (API). Your CD pipeline calls the endpoint after every deploy. Claude runs smoke checks against the live environment, scans error logs for regressions introduced in the last 30 minutes, and posts a go/no-go message to the release channel.
Docs drift detection (schedule). Runs weekly. Scans merged PRs from the past 7 days, identifies docs pages that reference changed API endpoints or function signatures, and opens update PRs for each one.
Cross-SDK porting (GitHub). Triggers on pull_request.closed filtered to is_merged: true. When a change lands in the Python SDK, the routine clones the Go SDK repo, ports the change, and opens a matching PR.
15 More Ideas Worth Automating
These came from real users sharing what they built within the first hours of the launch.
- Morning standup prep. Digest GitHub activity, Slack threads, and Linear updates into a single briefing posted to your channel before standup.
- Dependency audit. Weekly scan for outdated packages. Open a PR that bumps safe updates and flags breaking ones.
- TODO scanner. Nightly sweep of the codebase for new TODO comments. Post them to a tracking channel.
- Release notes. Trigger on release publish. Compile merged PRs into formatted changelog and update CHANGELOG.md.
- Security review gate. Trigger on PRs touching auth or payments directories. Run a focused security audit and flag risky patterns.
- Error log auto-fix. Every 2 hours, scan application logs for FATAL entries. If the fix is obvious, open a draft PR.
- Stale branch cleanup. Weekly routine that lists branches with no commits in 30 days and posts a cleanup summary.
- API contract check. After a PR merges in the backend repo, verify the frontend still matches the API types.
- Performance regression catch. GitHub trigger on push to main. Run the benchmark suite and comment on the commit if anything regressed.
- Competitor monitoring. Daily routine that checks competitor changelog pages and posts a diff summary.
- Customer feedback triage. API trigger from your support tool. Claude reads the ticket, classifies it, and routes it to the right team.
- Onboarding doc freshness. Monthly check that setup guides still match the actual install steps.
- PR babysitting. GitHub trigger on check failures. Claude reads the CI output, attempts a fix, and pushes to the same branch.
- HN and Reddit monitoring. Daily routine that searches for mentions of your product and posts a digest.
- Database migration review. GitHub trigger on PRs that touch migration files. Claude reviews for safe rollback, data loss risk, and lock duration.
Plan Limits
Routines count against your daily run allowance and your subscription's token budget. Both limits apply independently.
| Plan | Daily Routine Runs |
|---|---|
| Pro ($20/mo) | 5 |
| Max ($100-200/mo) | 15 |
| Team | 25 |
| Enterprise | 25 |
Organizations with extra usage billing enabled can exceed these caps at metered overage rates. Check consumption at claude.ai/settings/usage.
Writing Good Prompts for Routines
A routine prompt runs with no human in the loop. The prompt has to carry all the context that a conversation normally provides through back-and-forth.
Be explicit about the goal. "Review PRs" is too vague. "Read every open PR on this repo. For each one, check for missing error handling in async functions, SQL queries without parameterized inputs, and React components that call hooks conditionally. Leave an inline comment on each finding. Post a summary comment at the end." That version runs autonomously without guessing.
Define what success looks like. "If no issues are found, post a single comment: 'Reviewed, no issues.' Do not open a PR. Do not post to Slack."
Scope the output. "Create a draft PR, not a ready-for-review PR. Push to a claude/ prefixed branch. Do not merge anything."
Include failure instructions. "If the build fails after your changes, revert the commit and leave a comment explaining what went wrong."
Security and Access Control
Routines act as you. Commits carry your GitHub username. Slack messages use your linked account. Treat routine access the same way you would treat handing someone your credentials for an hour.
Branch restrictions. By default, routines can only push to branches prefixed with claude/. This prevents a bad prompt from pushing directly to main. Only disable this restriction when the routine specifically needs to push to other branches and you have branch protection rules as a safety net.
Connector scoping. Every connector you have linked is included by default. Remove the ones the routine does not need. A PR review routine does not need Slack write access. A Slack digest routine does not need GitHub push access.
Environment variables. Secrets (API keys, tokens) live in the environment configuration, not in the prompt. Set them up at claude.ai/code/environments before attaching the environment to a routine.
Token storage. API trigger tokens are shown exactly once when generated. Store them in your secret manager immediately. You cannot retrieve them later.
Current Limitations
Routines are in research preview. A few boundaries are worth knowing before you build around them.
The minimum schedule interval is one hour. For anything faster, use Desktop scheduled tasks (1 minute minimum) or /loop.
Each run clones the repo fresh. There is no local file access and no state carried between runs. If a routine needs to remember something across runs, it has to write that state to the repo (a JSON file, a comment, or an issue).
GitHub webhook events have per-routine and per-account hourly caps during the preview. A high-traffic repo with broad trigger filters can exhaust the cap fast.
Routines belong to your individual account. They are not shared with teammates. Each team member who wants the same automation creates their own copy.
The /fire API endpoint requires the beta header anthropic-beta: experimental-cc-routine-2026-04-01. This will change before GA.
Getting Started
Three steps get a useful routine running today.
Pick something low-stakes. A morning digest, a weekly TODO scan, or a nightly issue label pass. Nothing that pushes to main or messages customers.
Create it from the CLI with /schedule or from the web at claude.ai/code/routines. Write the prompt as if briefing a contractor who has never seen your codebase. Test with /schedule run.
Watch the first three runs. Click into the session URL, read what Claude did, check the output. Tighten the prompt based on what you see. Then leave it running.
Routines close the gap between "Claude does what you tell it" and "Claude does what needs doing, on its own." The laptop stays closed. The work gets done. The session is there to review when you open it back up.
Stop configuring. Start building.