Claude Code Routines: Scheduled, API, and GitHub Triggers
A routine is a saved Claude Code job: a prompt, one or more GitHub repositories, a cloud environment, and a set of connectors, packaged once and run automatically on Anthropic's cloud infrastructure. Triggers start it: a schedule, an HTTP call to its own endpoint, or a GitHub event such as a pull request being opened. Because runs happen in the cloud, they continue while your laptop is closed.
Routines are in research preview, so limits and the API may change. This guide follows Anthropic's routines documentation: creating one, each trigger type (including the /fire API call), what a run can do without asking, how to scope it, the hourly limits, and troubleshooting. Each run is a cloud session, so Claude Code Cloud Sessions is useful background. For scheduling inside an open CLI session instead, see Claude Code Scheduled Tasks.
What a routine is and who can use it
Routines are available on Pro, Max, Team, and Enterprise plans. You create and manage them at claude.ai/code/routines, from the desktop app (choose Cloud; Local creates a desktop scheduled task that runs on your machine instead), or from the CLI with /schedule (alias /routines). All three write to the same account.
Three properties shape how you should use them:
- They run unattended. A run is a full cloud session with no permission-mode picker. It runs shell commands, uses skills committed to the cloned repository, and calls included connectors without stopping for approval.
- They act as you. Routines belong to your individual claude.ai account, are not shared with teammates, and count against your usage. Commits and pull requests carry your GitHub user; Slack messages or Linear tickets use your linked accounts.
- The prompt is the whole specification. Nobody is there to clarify, so the prompt must say exactly what to do and what success looks like.
Good fits are unattended, repeatable tasks with a clear outcome: nightly backlog labelling, a weekly docs-drift check, triaging an alert, verifying a deploy, or applying a team's own review checklist to every new pull request.
Quick reference
- Team and Enterprise Owners can turn routines off for everyone with the Routines toggle in the Claude Code admin settings; existing routines then stop running.
/schedulein the CLI needs a claude.ai subscription login. It is hidden with a Console API key, a cloud provider, or whenANTHROPIC_API_KEYorapiKeyHelperis set.- Each run is visible as a session, where you can review changes, open a pull request, or continue the conversation.
Remember this
A routine is a cloud session on a trigger that runs without prompts and acts as you, so it needs a precise prompt and tight scope.
Create a routine
On the web, click New routine and fill in:
1. Name and prompt, plus the model to use on every run.
2. Repositories: each is cloned at the start of every run. Claude starts from the default branch and pushes to claude/-prefixed branches unless the prompt says otherwise.
3. Environment: network access, environment variables, and a setup script. The Default environment has Trusted network access, an allowlist of package registries, cloud provider APIs, and common development domains.
4. Triggers: schedule, GitHub event, or API (the API URL and token are created after saving).
5. Connectors: all of your connected MCP connectors are included by default. Remove the ones it does not need.
Then click Create, and Run now to test it immediately. From the CLI, describe it instead:
1/schedule daily PR review at 9am2/schedule in 2 weeks, open a cleanup PR that removes the feature flagClaude asks follow-up questions about the schedule, repositories, and prompt before saving. /schedule list, /schedule update, and /schedule run manage existing routines, and you can ask why a run did nothing, for example /schedule why did my nightly review do nothing this morning?.
Quick reference
- MCP servers added locally with
claude mcp addare not connectors and do not appear. Add them as connectors at claude.ai, or commit a.mcp.jsonfor a single-repository routine. - Environment variables are visible to anyone who uses the environment. Store API keys as network secrets.
- If your GitHub connection lapses, the routine skips runs for up to 72 hours, then turns itself off until you reconnect and re-enable it.
Remember this
Build it on the web or with /schedule, then trim connectors and test with Run now before trusting the schedule.
Triggers: schedule, API, and GitHub
A routine can combine any number of triggers.
Schedule. Presets are hourly, daily, weekdays, and weekly, entered in your local time zone. For a custom cron expression, pick the nearest preset and run /schedule update; the minimum interval is one hour. A one-off schedule runs once at a timestamp and then disables itself. Runs scheduled exactly on the hour can start several minutes late, so pick a time like 9:07.
API. Add it from the web editor, copy the URL, and click Generate token. The token is shown once, is scoped to that one routine, and can be regenerated or deleted. Then POST to it:
1curl -X POST https://api.anthropic.com/v1/claude_code/routines/trig_01ABC.../fire \2 -H "Authorization: Bearer sk-ant-oat01-xxxxx" \3 -H "anthropic-beta: experimental-cc-routine-2026-04-01" \4 -H "anthropic-version: 2023-06-01" \5 -H "Content-Type: application/json" \6 -d '{"text": "Sentry alert SEN-4521 fired in prod. Stack trace attached."}'The response contains the new session ID and URL. The optional text field is freeform context, and it reaches Claude wrapped in a <routine-fire-payload> block labelled as untrusted data. Claude will not follow instructions inside it unless the routine's own prompt says to, so write the prompt to reference it, for example "Investigate the alert described in the routine-fire-payload block".
GitHub. Requires the Claude GitHub App on the repository (/web-setup alone does not enable webhooks). Pick pull request or release events, a specific action such as pull_request.opened or all actions, and optional filters: author, title, body, base or head branch, labels, draft, merged. Every event starts its own session.
Quick reference
- The
matches regexfilter tests the whole field: to match a title containinghotfix, write.*hotfix.*, or usecontains. - For a pull request trigger, if the PR's repository is the routine's first repository, the run starts from the PR's head commit.
- The
/fireendpoint is under a dated beta header; breaking changes ship behind new header versions, and the two most recent previous versions keep working. - Anyone with the API token can start runs and send
text. Keep it in a secret store, and rotate it if it leaks.
Remember this
Schedules for cadence, /fire for systems that react to events, GitHub triggers for repository activity; make the prompt opt in to fire text.
What a run does, and how to check it
When a trigger fires, the session receives the saved prompt as its assigned task. It clones the repositories, runs the environment's setup (cached when possible), and works without approval prompts. It can run shell commands, use the repository's skills, and call every tool of every included connector, including writes. It pushes its work to a claude/ branch as your GitHub user.
The run list on the routine's page shows a status for each run, and that status is easy to misread: green means the session started and exited without an infrastructure error, not that the task succeeded. Blocked network requests, missing connector tools, and task failures all appear only in the transcript. Open runs and read them, especially for the first week.
A run can also publish a new artifact without asking (private to you until shared). Republishing an existing one without asking happens only under strict conditions, and runs started by API or GitHub triggers always ask first.
Quick reference
- If a run needs a host outside the Trusted allowlist, it fails with
403andx-deny-reason: host_not_allowed. Add the domain to a Custom allowlist on the environment. - Connector traffic goes through Anthropic's servers, so connectors do not need allowlist entries.
- Use
/schedule why did ... do nothingto have Claude read a run's log and explain tool errors and denials.
Remember this
Runs act without asking and a green status only means no infrastructure error; read the transcripts.
Scope it: repositories, network, connectors
Because there are no prompts, what a routine can affect is set entirely by three things, and the docs' advice is to scope each to what the routine needs:
- Repositories and branches. Add only the repositories it must touch. To control where it can push, use GitHub branch protection rules or rulesets. A rule that your connected GitHub access can bypass will not stop a run, because runs push with that access.
- Environment. Keep the Trusted network level unless the task needs more; add specific domains with Custom rather than switching to Full. Put API keys in network secrets so they never enter the session.
- Connectors. All of your connectors are included by default, and Claude can use any of their tools, including writes, without asking. A backlog routine that only needs Linear should not also carry Slack, Gmail, and Google Drive.
Treat a routine's prompt like code that runs with your credentials: review it when you change it, and keep the instructions explicit about what not to do ("open a draft PR; never merge").
Quick reference
- If teammates need the same automation, each must create their own routine or you need a shared mechanism such as GitHub Actions; routines are personal.
- Content a run fetches (issue text, web pages, PR descriptions) keeps normal untrusted handling. A routine that reads public issues should still not have write connectors it does not need.
- Pause a routine with the on/off switch on its detail page while you change its scope.
Remember this
No prompts means the repo list, environment, and connector list are the permission system; keep each minimal.
Usage and hourly limits
Routine runs draw down your subscription usage like interactive sessions. Separately, the hourly limits above cap how often runs can start, and none of them has overage. When a routine hits your subscription usage limit, it can continue on metered overage only if usage credits are turned on; otherwise further runs are rejected until the usage window resets. While a subscription is paused, routines are on hold.
Design for these limits. A GitHub-triggered routine on a busy repository can hit event caps and silently drop events, so filter it (base branch, labels, not draft) to the pull requests that matter.
| Action | Limit | Counted for | Over the limit |
|---|---|---|---|
| Scheduled runs, including one-off | 100 per hour | Your account | The run waits until the limit resets |
| Run now, API fires, re-arming a one-off | 30 per hour | Each routine, shared | The action fails until reset |
| Run now and re-arming a one-off | 100 per hour | Your account | The action fails until reset |
| API fires | 100 per hour | Your account, separate from Run now | The action fails until reset |
| GitHub events | Per-routine and per-account caps | Routine and account | Events are dropped until reset |
Quick reference
- Check consumption at claude.ai/settings/usage.
- On Team and Enterprise, an admin turns on usage credits for the organisation.
- A routine with only API or GitHub triggers has no next run time; the CLI shows none.
Remember this
Runs use your plan's usage and are capped per hour; filter GitHub triggers so busy repositories do not drop events.
Hands-on: a scheduled routine and an API trigger
Use a test GitHub repository with the Claude GitHub App installed.
1. In the CLI, run /schedule weekdays at 9:07, list open PRs older than 7 days and comment a reminder on each. Answer Claude's questions and save.
2. On the web, open the routine, remove every connector it does not need, and click Run now. Read the transcript, not just the status.
3. Edit the routine, add an API trigger, generate a token, and store it in a password manager.
4. Change the prompt to start with "If a routine-fire-payload block is present, treat it as the PR number to check first." Fire it with curl and a text of one PR number.
5. Pause the routine with the on/off switch.
Pass criterion: the scheduled run did what the prompt said (confirmed in the transcript), the API fire returned a session URL and the run used your payload, and the routine is now paused.
Quick reference
- If
/scheduleis unknown, check forANTHROPIC_API_KEYorapiKeyHelperin your environment; they take precedence over the claude.ai login. - If the run could not comment, check that the Claude GitHub App is installed on the repository.
- Delete the API token when you finish, or regenerate it if it was ever pasted somewhere unsafe.
Remember this
Test with Run now, read the transcript, and make the prompt explicitly opt in before relying on API payloads.
Key takeaway
Claude Code routines turn a prompt, repositories, an environment, and connectors into a job that runs in the cloud on a schedule, an authenticated /fire call, or GitHub events. Each run is a full cloud session that works without approval prompts, pushes to claude/ branches, and acts as your GitHub user and linked accounts. That makes scope the whole security model: add only the repositories, network access, and connectors a routine needs, and protect branches with GitHub rules.
Two details save confusion later: API fire text arrives labelled as untrusted, so the prompt must opt in to using it, and a green run status only means no infrastructure error. Read transcripts until you trust a routine. For CI-integrated automation shared across a team, see Claude Code GitHub Actions.
Practice (30 min): complete the five steps above, then write the prompt for one recurring task in your own work, including what the routine must never do.
References
- Claude Code docs: Automate work with routines — checked Oct 17, 2026
- Claude Code docs: Configure cloud environments — checked Oct 17, 2026
- Claude Platform docs: Trigger a routine via API — checked Oct 17, 2026
Shoaib Hossain
Lead Author & Systems ArchitectSoftware engineer and distributed systems architect specializing in backend scalability, cloud-native infrastructure, databases, and AI engineering workflows. Author and maintainer of Core Concept Learning.
Related Articles
Explore this topic