If you have been using Claude Code interactively, you already know what it can do in a session. Routines take that further: you define a prompt once, wire up a trigger, and Claude Code runs autonomously on Anthropic-managed cloud infrastructure whenever that trigger fires. Your laptop can be off. The job still runs.
This article walks through what routines are, how to set them up, and where the rough edges are during the current research preview.
What Is a Routine?
A routine is a saved Claude Code configuration. It packages three things:
- A prompt (the instructions Claude runs each time)
- One or more GitHub repositories to work in
- A set of connectors (MCP servers for external services like Slack, Linear, etc.)
You attach one or more triggers to it. Each trigger type determines when a run starts:
- Schedule - recurring on a cron cadence, or a one-off at a specific timestamp
- API - an HTTP POST to a per-routine endpoint with a bearer token
- GitHub event - reactions to pull requests, releases, and similar repository events
A single routine can combine all three. A PR review routine could run nightly, also fire when your CD pipeline calls the endpoint, and also react to every new pull request.
Routines are available on Pro, Max, Team, and Enterprise plans with Claude Code on the web enabled. You manage them at claude.ai/code/routines or from the CLI using /schedule.
Why This Matters
The key property is that routines run without you present. A regular Claude Code session expects you to review, approve, and guide. A routine is designed for unattended, repeatable work tied to a clear outcome.
That changes the use cases you can build:
Backlog maintenance. A schedule trigger runs every weeknight. The routine reads issues opened since the last run, applies labels, assigns owners based on the area of code referenced, and posts a summary to Slack. Your team starts the day with a groomed queue.
Alert triage. Your monitoring tool POSTs to the routine's API endpoint when an error threshold crosses. The routine pulls the stack trace, correlates it with recent commits, and opens a draft PR with a proposed fix. On-call reviews the PR instead of starting from a blank terminal.
Bespoke code review. A GitHub trigger fires on pull_request.opened. The routine applies your team's review checklist and leaves inline comments covering security, performance, and style issues. Human reviewers focus on design decisions.
Library porting. A trigger fires on merged PRs in one SDK repository. The routine ports the change to a parallel SDK in another language and opens a matching PR. Two libraries stay in sync without a human re-implementing each change.
Creating a Routine
You can create routines from the web UI, the Claude Desktop app, or the CLI.
From the Web
- Go to
claude.ai/code/routinesand click New routine. - Name it and write the prompt. The prompt is the most important part. Since the routine runs autonomously, the prompt must be self-contained and explicit about what to do and what success looks like.
- Select one or more GitHub repositories. Each is cloned fresh at the start of every run from the default branch.
- Pick a cloud environment (controls network access, environment variables, and setup scripts). A Default environment is provided.
- Add triggers (Schedule, GitHub event, or API).
- Review connectors. All your connected MCP connectors are included by default. Remove any the routine does not need.
- Click Create.
After creation, click Run now on the detail page to start an immediate run without waiting for a trigger.
From the CLI
/schedule daily PR review at 9am
/schedule in 2 weeks, open a cleanup PR that removes the feature flag
Claude walks through the same information the web form collects and saves the routine. The CLI supports scheduled triggers only. To add API or GitHub triggers, edit the routine on the web afterward.
Useful CLI management commands:
/schedule list # see all routines
/schedule update # change a routine
/schedule run # trigger a routine immediately
Configuring Triggers
Schedule Triggers
Pick a preset: hourly, daily, weekdays, or weekly. Times are entered in your local timezone and converted automatically. Runs may start a few minutes after the scheduled time due to stagger, but the offset is consistent for each routine.
For custom intervals (every two hours, first of each month), pick the closest preset in the form and then use /schedule update in the CLI to set a specific cron expression. The minimum interval is one hour.
One-off runs fire the routine a single time at a specific timestamp, then auto-disable. Useful for cleanup after a rollout, follow-ups when an upstream change lands, or end-of-week summaries.
One-off runs do not count against the daily routine run cap. They draw down your regular subscription usage like any other session.
API Triggers
An API trigger gives the routine a dedicated HTTP endpoint. POSTing to it with the bearer token starts a new session and returns a session URL.
To set one up:
- Open the routine for editing.
- Click Add another trigger and choose API.
- Copy the URL and click Generate token. Store the token immediately - it is shown once and cannot be retrieved later.
Here is how to call the endpoint:
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 text field is optional freeform context passed alongside the saved prompt. It is not parsed - if you send JSON, the routine receives it as a literal string.
A successful response looks like this:
{
"type": "routine_fire",
"claude_code_session_id": "session_01HJKLMNOPQRSTUVWXYZ",
"claude_code_session_url": "https://claude.ai/code/session_01HJKLMNOPQRSTUVWXYZ"
}
Open the session URL to watch the run in real time, review changes, or continue the conversation manually.
Note: The /fire endpoint ships under the experimental-cc-routine-2026-04-01 beta header. Request and response shapes, rate limits, and token semantics may change. Breaking changes ship behind new dated beta header versions, with the two most recent previous versions remaining active during migration.
Each routine gets its own token scoped to that routine only. To rotate or revoke it, return to the same modal and use Regenerate or Revoke.
GitHub Triggers
GitHub triggers start a new session automatically on matching repository events. Each matching event starts its own independent session - there is no session reuse across events.
Supported events:
| Event | Triggers when |
|---|---|
| Pull request | A PR is opened, closed, assigned, labeled, synchronized, or otherwise updated |
| Release | A release is created, published, edited, or deleted |
You can subscribe to a specific action (like pull_request.opened) or to all actions in the category.
Filters let you narrow which events actually start a session:
| Filter | Matches |
|---|---|
| Author | PR author's GitHub username |
| Title | PR title text |
| Body | PR description text |
| Base branch | Branch the PR targets |
| Head branch | Branch the PR comes from |
| Labels | Labels applied to the PR |
| Is draft | Whether the PR is in draft state |
| Is merged | Whether the PR has been merged |
Operators: equals, contains, starts with, is one of, is not one of, matches regex.
One thing to watch with regex: the matches regex operator tests the entire field value, not a substring. To match any PR title containing hotfix, write .*hotfix.*. Without the surrounding .*, it only matches a title that is exactly hotfix and nothing else. For substring matching without regex syntax, use the contains operator.
Example filter combinations:
- Auth module review: base branch
main, head branch containsauth-provider - Ready-for-review only: is draft is
false - Label-gated backport: labels include
needs-backport
The Claude GitHub App must be installed on the repository. The trigger setup prompts you if it is not already. Note that running /web-setup in the CLI grants repository access for cloning but does not install the GitHub App and does not enable webhook delivery. GitHub triggers require the App specifically.
During the research preview, GitHub webhook events are subject to per-routine and per-account hourly caps. Events beyond the limit are dropped until the window resets.
Branch Behavior and Safety
By default, Claude can only push to branches prefixed with claude/. This prevents routines from accidentally modifying protected or long-lived branches.
To allow pushing to any branch (for example, if you need Claude to push directly to main or a release branch), enable Allow unrestricted branch pushes for that repository when creating or editing the routine. Scope this permission carefully.
Connectors
Routines can use your connected MCP connectors to read from and write to external services during each run. A backlog routine might read from a Slack channel and create issues in Linear. An alert triage routine might read from PagerDuty and push to GitHub.
All connectors are included by default when you create a routine. Remove any the routine does not actually need. During a run, Claude can use every tool from an included connector, including writes, without asking for permission.
Usage and Limits
Routines draw down subscription usage the same way interactive sessions do. There is also a daily cap on how many routine runs can start per account.
You can check your current consumption and remaining daily routine runs at claude.ai/code/routines or claude.ai/settings/usage.
When a routine hits the daily cap or your subscription usage limit, organizations with extra usage enabled can keep running routines on metered overage. Without extra usage, additional runs are rejected until the window resets. Enable extra usage from Settings > Billing.
One-off runs are exempt from the daily routine run allowance. They still consume your regular subscription usage.
There is no per-run token count displayed directly in the routine detail view. Usage is reflected in your overall account consumption at the settings page rather than being itemized per routine run.
Managing Runs
Click a routine in the list to open its detail page. From there you can view past runs, see what Claude did in each run, review changes, create a pull request, or continue the conversation.
You can also:
- Click Run now to start an immediate run
- Toggle the schedule on and off to pause or resume
- Edit the name, prompt, repositories, environment, connectors, or triggers
- Delete the routine (past sessions created by it remain in your session list)
Things to Know Before You Ship
Routines run as you. Anything a routine does through your connected GitHub identity or connectors appears as your account. Commits and pull requests carry your GitHub user. Slack messages and Linear tickets use your linked accounts.
Routines belong to your individual account. They are not shared with teammates and count against your account's daily run allowance.
The prompt is everything. The routine runs autonomously with no approval prompts. There is no permission-mode picker. Write prompts that are self-contained, explicit about the goal, and explicit about what success looks like.
This is research preview. Behavior, limits, and the API surface may change. The /fire endpoint ships under a dated beta header for exactly this reason.
Top comments (0)