
Claude Code Routines: how to put your AI coding agent on autopilot
Claude Code Routines let you schedule tasks, react to GitHub events, and trigger Claude via API — all running in the cloud while your laptop is closed. Here's how to set them up.
What if Claude Code could keep working after you close your laptop? That's exactly what Routines do. They let you set up tasks that Claude runs automatically — on a schedule, when something happens on GitHub, or when you hit an API endpoint.
Think of it like Bubble's backend workflows, but for your entire coding workflow. You define the task once, and Claude handles it from there.
What are Claude Code Routines?
A routine is a saved Claude Code configuration: a prompt, one or more repositories, and a set of connectors — packaged once and run automatically. They execute on Anthropic's cloud infrastructure, so they keep working whether you're at your desk or on a beach.
Right now, Routines are in research preview, so the feature is still evolving. But it's already powerful enough to handle real work.
Each routine can have one or more triggers:
- Scheduled — run on a recurring cadence (hourly, nightly, weekly)
- API — trigger on demand by sending an HTTP POST request
- GitHub — run automatically when something happens in your repo (new PR, release, etc.)
The best part? You can combine triggers. A single PR review routine could run every night, fire from a deploy script, and react to every new pull request.
You need a paid Claude plan (Pro, Max, Team, or Enterprise) with Claude Code on the web enabled.
Why should you care about this?
If you've ever thought "I wish Claude could just handle this for me every day," Routines are the answer. Here are some real examples:
Backlog grooming on autopilot. Set up a routine that runs every weeknight. It reads new issues from your tracker, applies labels, assigns owners based on the code area, and posts a Slack summary. Your team starts the day with a clean queue — no standup needed.
Alert triage that actually fixes things. Your monitoring tool calls Claude's API endpoint when errors spike. Claude pulls the stack trace, connects it to recent commits, and opens a draft PR with a proposed fix. On-call reviews a PR instead of starting from scratch.
Custom code review on every PR. A GitHub trigger fires on pull_request.opened. Claude applies your team's review checklist, leaves inline comments for security, performance, and style, and adds a summary so human reviewers can focus on design decisions.
Deploy verification. Your CI/CD pipeline calls Claude after each production deploy. Claude runs smoke checks, scans error logs, and posts a go/no-go to your release channel.
Docs that stay current. A weekly routine scans merged PRs, finds documentation that references changed APIs, and opens update PRs for an editor to review.
How to create your first routine
You can create routines from three places — the web, the Desktop app, or the CLI. All three write to the same account, so a routine created in the CLI shows up on the web immediately.
From the web (easiest to start)
- Go to claude.ai/code/routines and click New routine
- Name it and write the prompt — this is the most important part. The routine runs without you, so the prompt needs to be self-contained. Be explicit about what to do and what success looks like.
- Select repositories — add the GitHub repos Claude should work in. Each one gets cloned fresh at the start of every run.
- Pick an environment — this controls network access, environment variables (API keys, tokens), and setup scripts. A Default environment is provided, or create a custom one.
- Choose a trigger — schedule, GitHub event, or API (more on each below).
- Review connectors — your connected MCP connectors (Slack, Linear, Google Drive, etc.) are included by default. Remove any the routine doesn't need.
- Click Create — the routine is live. Click Run now to test it immediately.
From the CLI
Run /schedule in any Claude Code session. You can also pass a description directly:
/schedule daily PR review at 9am
Claude walks you through the same setup conversationally. The CLI creates scheduled routines only — to add API or GitHub triggers, edit the routine on the web afterward.
Other CLI commands:
/schedule list— see all routines/schedule update— modify an existing routine/schedule run— trigger a routine immediately
From the Desktop app
Open the Schedule page, click New task, and choose New remote task. (Choosing "New local task" creates a Desktop scheduled task that runs on your machine — that's a different feature.)
Setting up schedule triggers
Schedule triggers are the simplest: pick how often you want the routine to run. The presets are hourly, daily, weekdays, or weekly.
A few things to know:
- Times are in your local timezone — Claude converts automatically, so "9am" means 9am where you are.
- Runs may start a few minutes late — there's a small stagger, but it's consistent for each routine.
- Custom cron intervals — for something like "every 2 hours" or "first of each month," pick the closest preset in the web form, then run
/schedule updatein the CLI to set a specific cron expression. - Minimum interval is one hour — anything more frequent gets rejected.
Setting up API triggers
API triggers give your routine a dedicated HTTP endpoint. This is how you wire Claude into your existing tools — monitoring systems, deploy pipelines, internal dashboards.
To set it up:
- Open your routine on the web and click Edit
- Under triggers, click Add another trigger and choose API
- Copy the URL and click Generate token — save the token immediately, it's shown only once
- Call it from anywhere:
curl -X POST https://api.anthropic.com/v1/claude_code/routines/trig_01ABC.../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": "Production deploy completed. Run smoke tests."}'
The optional text field passes run-specific context to Claude alongside the saved prompt. You get back a session ID and URL so you can watch the run in real time.
Each routine gets its own token, scoped to that routine only. You can regenerate or revoke it anytime.
Setting up GitHub triggers
GitHub triggers are where Routines get really interesting. Claude reacts to repository events automatically — no cron job needed.
Currently supported events:
| Event | When it triggers |
|---|---|
| Pull request | PR opened, closed, assigned, labeled, synchronized, etc. |
| Release | Release created, published, edited, or deleted |
Filtering pull requests
You can narrow which PRs trigger a run using filters. All conditions must match. Available filters:
- Author — PR author's GitHub username
- Title / Body — match text in the PR title or description
- Base branch / Head branch — target and source branches
- Labels — labels applied to the PR
- Is draft / Is merged / From fork — PR state
Each filter supports operators like equals, contains, starts with, matches regex, and more.
Some practical filter combos:
- Auth module review: base branch
main, head branch containsauth-provider— sends auth PRs to a focused reviewer - External contributor triage: from fork is
true— routes fork-based PRs through extra security review - Ready-for-review only: is draft is
false— skips draft PRs - Label-gated backport: labels include
needs-backport— triggers only when a maintainer tags a PR
How sessions work
Each matching GitHub event starts a new, independent session. Two PR updates create two separate sessions. There's no session reuse across events.
Important things to know
Branch permissions
By default, Claude can only push to branches prefixed with claude/. This prevents routines from accidentally modifying protected branches. If you need unrestricted access, enable Allow unrestricted branch pushes per repository.
Routines act as you
This is important: everything a routine does through your GitHub identity or connectors appears as you. Commits carry your GitHub user, Slack messages use your linked account. Scope your routines carefully.
Connectors extend what Claude can reach
Routines can use your connected MCP connectors to interact with external services during each run. A triage routine might read from Slack and create issues in Linear. Remove connectors the routine doesn't need to limit Claude's access.
Usage limits
Routines draw from your subscription usage, plus there's a daily cap on how many runs can start per account. Check your limits at claude.ai/settings/usage. Organizations with extra usage enabled can keep running on metered overage.
Getting started: a practical first routine
Here's a good first routine to try — a nightly code review summary:
Name: "Nightly PR Summary"
Prompt:
Review all open pull requests in the repository. For each PR:
1. Summarize what it changes in 1-2 sentences
2. Flag any obvious issues (missing tests, large diffs, draft status)
3. Note how long it's been open
Post a summary as a comment on the most recent PR, or create a new issue
titled "Daily PR Summary - [today's date]" with the full report.
Trigger: Schedule — daily at 9am
Repositories: Your main project repo
That's it. Tomorrow morning, you'll have a summary waiting for you.
The bottom line
Routines turn Claude Code from a tool you use into a teammate that works while you don't. The key insight is the same one that makes Bubble's backend workflows powerful: define the task once, set the trigger, and let the system handle it.
Start with one simple routine. Once you see it work, you'll immediately think of five more things Claude should be handling for you automatically.
Routines are available now in research preview at claude.ai/code/routines.