Claude Code Routines Automation GitHub Actions CI/CD developer tools

Claude Code Routines: Schedule, API Triggers, and GitHub Automation (2026)

The Prompt Shelf ·

Most teams set up Claude Code as an interactive tool — you describe a task, Claude does it. That’s the obvious use case. The less obvious one, and often more valuable, is autonomous scheduled work: overnight PR reviews, morning backlog triage, automated responses to CI failures, library ports triggered by merged PRs.

Claude Code Routines are how you build that. A Routine is a saved configuration — prompt, repositories, connectors, triggers — that runs on Anthropic’s cloud infrastructure. Your laptop being closed is irrelevant. The PR that gets opened at 2 AM runs through a Routine that was waiting for it.


What Routines Are (and Aren’t)

A Routine is three things combined:

  1. A prompt — the instructions Claude runs each time
  2. One or more repositories — cloned fresh for each run
  3. One or more triggers — when to start a run

Each run is a full Claude Code cloud session. Claude has the same tools it has in interactive use: file reads, Bash execution, git operations, and any connectors you’ve included. There are no approval prompts during a run. The Routine runs autonomously.

What Routines aren’t: they’re not GitHub Actions replacements. GitHub Actions runs in your repository’s CI environment with access to your full CI tooling and caching. Routines run in a cloud environment that gets a fresh repo clone. Use GitHub Actions for build/test/deploy pipelines. Use Routines for AI-driven tasks that need full Claude Code capabilities — analysis, code generation, review, cross-repository work.

Available on Pro, Max, Team, and Enterprise plans with Claude Code on the web enabled. Create and manage at claude.ai/code/routines or from the CLI with /schedule.


Trigger Types

Schedule Triggers

Cron-style scheduling with presets (hourly, daily, weekdays, weekly) plus one-off runs.

Key behaviors:

  • Times you enter are converted from your local timezone automatically
  • Runs may start a few minutes after the scheduled time due to stagger
  • The stagger offset is consistent per Routine — if it’s 3 minutes late, it’s consistently 3 minutes late
  • Minimum interval for recurring schedules: 1 hour

One-off runs fire once at a specific timestamp, then auto-disable. They don’t count against the daily Routine cap.

/schedule tomorrow at 9am, summarize yesterday's merged PRs
/schedule in 2 weeks, open a cleanup PR removing the ENABLE_NEW_CHECKOUT flag
/schedule next Monday morning, triage all issues labeled "needs-review"

For custom cron expressions beyond the presets, set the preset closest to what you want in the form, then update with the CLI:

/schedule update

API Triggers

Every Routine can have a dedicated HTTP endpoint. POST to it to start a run on demand.

curl -X POST https://api.anthropic.com/v1/claude_code/routines/trig_01ABCDEF.../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 at 14:32 UTC. Error: TypeError in auth.handleCallback()"}'

The text field is optional run-specific context that Claude receives alongside the Routine’s saved prompt. Use it to pass the triggering event’s details — the alert body, failing log lines, the PR that was just opened.

Response:

{
  "type": "routine_fire",
  "claude_code_session_id": "session_01HJKL...",
  "claude_code_session_url": "https://claude.ai/code/session_01HJKL..."
}

Open the session URL to watch the run in real time.

Token management: Each Routine gets its own bearer token scoped to triggering that Routine only. Tokens are shown once when generated. Rotate or revoke from the Routine’s edit form.

GitHub Event Triggers

Routines can subscribe to repository events. Each matching event starts a new session.

Supported events:

  • Pull request: opened, closed, assigned, labeled, synchronized, and more. Each action is selectable individually or subscribe to all.
  • Release: created, published, edited, deleted.

Pull request filters: Narrow which PRs trigger a run by combining any of these conditions:

  • Author (GitHub username)
  • Title (contains, starts with, matches regex)
  • Body (contains, starts with, matches regex)
  • Base branch (the PR targets main)
  • Head branch (the branch name starts with hotfix/)
  • Labels (includes needs-review, security)
  • Is draft (filter to ready-for-review only)
  • Is merged (trigger only after merge)

All conditions in a filter must match. Multiple filters are OR’d.

Regex notes: matches regex tests the full field value. To match a title containing “hotfix” anywhere, use .*hotfix.*. For simple substring matching, use contains instead.

GitHub App requirement: Install the Claude GitHub App on the repository before GitHub triggers work. Different from the GitHub MCP server — the App delivers webhooks to Routines.


Creating a Routine

From the CLI

/schedule daily PR review at 9am

Claude walks through the required information:

  • Routine name
  • Prompt
  • Repository selection
  • Environment selection
  • Trigger type

For API and GitHub triggers, edit at claude.ai/code/routines after creation.

From the Web

claude.ai/code/routinesNew routine → fill in the form.

The form covers:

  1. Name and prompt
  2. Repository selection (one or more GitHub repos)
  3. Environment (network access, environment variables, setup script)
  4. Trigger selection
  5. Connector inclusion and repository branch permissions

Writing Effective Routine Prompts

Routines run autonomously. The prompt must be self-contained. Unlike an interactive session where you can clarify, no one will answer questions during a run.

Bad prompt:

Review today's PRs.

What counts as “today”? Which PRs? What kind of review? What should happen with findings?

Better prompt:

Review all pull requests opened in the last 24 hours against our coding standards.

For each PR:
1. Check that it has a description explaining the change
2. Verify that new API endpoints include input validation
3. Check that database queries go through the service layer, not directly in handlers
4. Look for hardcoded credentials or API keys

For each PR that has issues:
- Leave a review comment summarizing findings
- Label the PR "needs-changes"

For clean PRs:
- Approve the PR
- Label it "ready-to-merge"

If there are no PRs in the last 24 hours, post a summary to the daily-review Slack channel saying no PRs were opened.

This is explicit about scope, criteria, actions, and the fallback case.

What Success Looks Like

Describe what a successful run produces:

  • A PR opened to claude/fix-123
  • A comment posted on the PR
  • A label added to issues
  • A Slack message sent
  • A test file created and passing

Claude uses this as a completion condition.


Example Routines

Daily PR Review (Schedule Trigger)

Prompt:

Review all pull requests opened or updated in the last 24 hours.

Criteria from CLAUDE.md:
- TypeScript files must have explicit return types on public functions
- All new API endpoints require Zod input validation
- No console.log — use the logger from src/utils/logger.ts
- Integration tests required for new endpoints

For each PR:
- Post a detailed review comment with specific findings and line references
- Add label "approved" if clean, "needs-changes" if issues found
- Never merge the PR

If no PRs were updated in the last 24 hours, skip and exit cleanly.

Trigger: Weekdays at 9:00 AM

Alert Triage (API Trigger)

Prompt:

You've received a production alert. The alert details are in the text passed with this trigger.

1. Read the alert body to understand the error type and affected service
2. Find the relevant source code in the repository
3. Trace the error through the call stack
4. Check git log for recent changes to the affected files
5. Propose a fix

Create a branch named claude/fix-<error-id> with the proposed fix applied.
Open a draft PR with:
- Summary of the root cause
- Explanation of the fix
- Any tests that need to be updated
- Reference to the alert

Do not merge the PR. Tag it "from-routine" and "needs-human-review".

Trigger: API endpoint, called by your monitoring system when error threshold is crossed.

Caller script:

#!/bin/bash
# Called by PagerDuty/Alertmanager webhook
ALERT_BODY=$1
SESSION=$(curl -sX POST "https://api.anthropic.com/v1/claude_code/routines/${ROUTINE_ID}/fire" \
  -H "Authorization: Bearer $ROUTINE_TOKEN" \
  -H "anthropic-beta: experimental-cc-routine-2026-04-01" \
  -H "anthropic-version: 2023-06-01" \
  -H "Content-Type: application/json" \
  -d "{\"text\": \"${ALERT_BODY}\"}")
echo "Session: $(echo $SESSION | jq -r .claude_code_session_url)"

PR Code Review (GitHub Trigger)

Prompt:

A new pull request has been opened. Review it according to our standards.

Checklist:
- [ ] Description explains what changed and why
- [ ] No hardcoded secrets or credentials
- [ ] Test coverage for new functionality
- [ ] No TODOs left uncommitted
- [ ] Breaking changes documented

Post a review comment with the checklist results.
Request changes if any checklist item fails.
Approve if all pass.

Trigger: Pull request opened, with filter: is draft = false (skip draft PRs)

Library Port (GitHub Trigger — Merged PR)

Prompt:

A pull request was just merged in the Python SDK repository.
The details are available through the GitHub connector.

Port this change to the TypeScript SDK:
1. Understand what changed in the Python SDK
2. Find the equivalent TypeScript code
3. Implement the same change in TypeScript
4. Run the TypeScript test suite
5. Open a PR with the port

If the change is Python-specific and has no TypeScript equivalent, 
post a comment on the original PR explaining why no port is needed.

Trigger: Pull request merged, in the Python SDK repository


Connectors and MCP Servers in Routines

Routines use claude.ai connectors — not locally configured MCP servers.

The distinction matters:

  • claude mcp add on your machine = local only, not available in cloud Routines
  • claude.ai connectors at claude.ai/customize/connectors = available in Routines

To use an MCP server in a Routine, either:

  1. Add it as a claude.ai connector
  2. Commit a .mcp.json to the repository so it’s available in the cloned repo during the Routine run

All your connected connectors are included in Routines by default. Remove any the Routine doesn’t need to limit Claude’s access surface. Claude can use every tool from included connectors without asking during a run.


Environment and Network Access

Each Routine runs in a cloud environment controlling:

  • Network access: The Default environment uses Trusted mode — common package registries, cloud provider APIs, and development domains are reachable. Your internal services are not.
  • Environment variables: API keys, tokens, and configuration values
  • Setup script: Install dependencies (cached after first run)

To allow your internal services:

  1. Edit the Routine
  2. Open the environment selector
  3. Change Network access to Custom
  4. Add your internal domain(s)
  5. Optionally keep the default list for package registries

Full network access allows unrestricted outbound requests — use only when necessary.

MCP connector traffic routes through Anthropic’s infrastructure, so connectors work without adding their hosts to the allowlist.


Branch Permissions

By default, Routines push only to branches prefixed with claude/. This prevents accidental writes to main, master, or release branches.

To allow broader branch access for a specific repository:

In the Routine’s edit form, under the repository list, enable Allow unrestricted branch pushes for that repository.

Commits and PRs from Routines appear under your GitHub identity — your name on the commit, your username on the PR.


Monitoring Runs

Run Status

The run list on the Routine’s detail page shows a status indicator per run. Green means the session started and exited without infrastructure error — it does not mean your task succeeded. A Routine that silently failed to find any matching PRs is also green.

Always open the run to read the transcript and confirm what Claude actually did.

Session URL

The API trigger response includes claude_code_session_url. Open it in a browser to watch a run in progress, review changes, or continue the conversation manually. You can also create a PR from within the session if Claude opened a branch.

Pausing Routines

Toggle the schedule on/off from the Routine detail page without deleting the configuration.

To stop all Routines organization-wide (Enterprise/Team admins):

claude.ai/admin-settings/claude-code → Routines toggle


Comparing Routines, Desktop Scheduled Tasks, and /loop

RoutinesDesktop scheduled tasks/loop
Runs when laptop is offYesNoNo (session-based)
InfrastructureAnthropic cloudYour machineCurrent session
Trigger typesSchedule, API, GitHub eventsSchedule onlyInterval or self-paced
File accessCloned repo onlyFull local filesystemCurrent session filesystem
Connectorsclaude.ai connectorsLocal MCP serversLocal MCP servers
Use forUnattended automation, GitHub workflowsLocal scheduled scriptsRepeated tasks in a session

Troubleshooting

/schedule Returns “Unknown Command”

Check whether one of these is active:

  • ANTHROPIC_API_KEY, ANTHROPIC_AUTH_TOKEN, or apiKeyHelper in settings — these take precedence over claude.ai login, hiding /schedule
  • DISABLE_TELEMETRY, DO_NOT_TRACK, or DISABLE_GROWTHBOOK — these disable feature-flag fetching that /schedule depends on
  • CLI version older than v2.1.81 — run claude update

Routines can always be managed at claude.ai/code/routines regardless of CLI configuration.

”Routines Are Disabled by Your Organization”

An admin has disabled Routines for your Team or Enterprise organization. The setting is at claude.ai/admin-settings/claude-code. Contact your admin to request access.

Routine Ran But Task Failed

Green status means infrastructure success, not task success. Common failure patterns:

  • Blocked network request: Your internal service is outside the Default allowlist. Edit the environment to add allowed domains.
  • Missing connector tool: The connector wasn’t included or wasn’t authenticated. Check connectors in the Routine edit form.
  • Ambiguous prompt: The Routine’s prompt didn’t specify success criteria or fallback behavior. Revise the prompt.
  • Repository access: The repository isn’t accessible with your connected GitHub identity. Check the GitHub App installation.

Related Articles

Explore the collection

Browse all AI coding rules — CLAUDE.md, .cursorrules, AGENTS.md, and more.

Browse Rules