DEV Community

Cover image for Claude Code Routines: Automate AI Workflows on Autopilot in 2026
Ramsis Hammadi
Ramsis Hammadi

Posted on

Claude Code Routines: Automate AI Workflows on Autopilot in 2026

Claude Code Routines: Automate AI Workflows on Autopilot in 2026

TL;DR Summary

  • Claude Code Routines run on Anthropic's cloud infrastructure — your laptop can be closed, routines keep executing
  • Three trigger types: schedule (cron, recurring or one-off), API (HTTP POST from any system), and GitHub events (PRs, releases)
  • Routines run autonomously as full Claude Code sessions — they clone repos, use MCP connectors, run shell commands, and create PRs
  • Use cases include PR review, alert triage, deploy verification, docs drift detection, backport automation, and library sync
  • Available on Pro/Max/Team/Enterprise plans with Claude Code on the web enabled. Create via web dashboard or /schedule in CLI

Direct Answer Block

A Claude Code Routine is a saved configuration — a prompt, repositories, and MCP connectors — that executes automatically on Anthropic's managed cloud infrastructure. You define it once, then it runs on schedule, when called via API, or when a GitHub event fires. Unlike CI/CD pipelines that run deterministic scripts, routines run full AI-powered coding sessions autonomously: they reason about your codebase, use tools, and produce PRs.

Introduction

Most automation tools force a tradeoff: either you write deterministic scripts that can't think, or you run AI agents that need constant supervision. Claude Code Routines split the difference. They run unattended on cloud infrastructure — scheduled, API-triggered, or GitHub-event-driven — but each run is a full Claude Code session with access to your repos, MCP connectors, and shell. The routine's prompt defines what to do; the infrastructure handles when and how. No laptop, no open terminal, no approval prompts.

What are Claude Code Routines and how do they differ from CI/CD pipelines?

Routines are not CI/CD. They are not GitHub Actions. They are autonomous AI coding sessions that run on Anthropic-managed cloud infrastructure when triggered.

The distinction matters because it changes what you automate:

  • CI/CD runs a deterministic script. It can't inspect a PR and decide whether the changes introduce a subtle security issue. It can lint, test, and build — but it can't reason.
  • Routines run a Claude Code session. It reads your codebase, applies judgment, uses tools, and produces a PR with inline comments explaining why something should change.

"A routine stores a prompt, repositories, and connectors as one configuration and runs it automatically. The system executes routines on managed cloud infrastructure, so your workflows run without a local machine." — AlphaSignal summary of Anthropic's announcement

According to Anthropic's documentation, each routine can have one or more triggers attached:

Trigger What fires it Example
Schedule Cron-based recurring or one-off time Nightly PR review at 9am
API HTTP POST with bearer token Alerting system fires routine on error threshold
GitHub Repository events (PR opened, release created) Auto-review every new PR

A single routine can combine triggers. A PR review routine can run nightly, trigger from a deploy script via API, and also react to every new PR opened.

Anthropic's documentation explicitly distinguishes routines from /loop (session-scoped, stops when terminal closes), Desktop scheduled tasks (runs on your machine), and GitHub Actions (deterministic CI). Routines are the "runs on Anthropic cloud, survives independently" tier.

How do you create a routine from the web dashboard, the CLI, and the Desktop app?

Method 1: Web dashboard (claude.ai/code/routines)

This is the most complete creation surface. All three trigger types (schedule, API, GitHub) are configurable here. The creation form walks through:

  1. Name and prompt — the prompt is the most important part. Since routines run autonomously, the prompt must be self-contained and explicit about what success looks like. Anthropic's docs note: "The prompt is the most important part: the routine runs autonomously, so the prompt must be self-contained and explicit about what to do and what success looks like."

  2. Repositories — add GitHub repos for Claude to work in. Each is cloned at run start from the default branch. Claude creates claude/-prefixed branches for changes.

  3. Environment — pick a cloud environment controlling network access (Trusted, Custom, Full), environment variables (API keys, tokens), and a setup script (dependencies install). The setup script result is cached across runs.

  4. Trigger — schedule (preset or custom cron via /schedule update), API (URL + token generated after save), or GitHub event (PR/release with filters).

  5. Connectors and permissions — all connected MCP connectors (Slack, Linear, Google Drive) are included by default. Remove unused ones. Enable "Allow unrestricted branch pushes" if the routine should push to existing branches.

Method 2: CLI (/schedule)

Run /schedule to create a scheduled routine conversationally. You can pass a description:

/schedule daily PR review at 9am
/schedule clean up feature flag in one week
Enter fullscreen mode Exit fullscreen mode

Claude walks through the same info the web form collects. The CLI creates scheduled routines only — to add API or GitHub triggers, edit on the web.

Manage existing routines from CLI:

/schedule list        # see all routines
/schedule update      # change one
/schedule run         # trigger immediately
Enter fullscreen mode Exit fullscreen mode

Method 3: Desktop app

Click Routines in the sidebar, then New routine, and choose Remote (vs Local for Desktop scheduled tasks). All three surfaces write to the same cloud account — a routine created in one appears everywhere immediately.

How do you configure schedule triggers, API triggers, and GitHub event triggers?

Schedule triggers

Pick a preset (hourly, daily, weekdays, weekly) or a custom cron via /schedule update. Minimum interval is 1 hour. Times are entered in your local timezone and converted automatically.

For one-off runs, describe the time naturally:

/schedule tomorrow at 9am, summarize yesterday's merged PRs
/schedule in 2 weeks, open a cleanup PR that removes the feature flag
Enter fullscreen mode Exit fullscreen mode

One-off runs don't count against the daily routine run cap. After firing, they auto-disable.

API triggers

API triggers give a routine a dedicated HTTP endpoint. POST to the endpoint with a bearer token to start a new session.

Setup (web only):

  1. Edit routine → Add another trigger → API
  2. Copy the URL
  3. Click Generate token — shown once, store securely

Call:

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 "Content-Type: application/json" \
  -d '{"text": "Sentry alert SEN-4521 fired in prod. Stack trace attached."}'
Enter fullscreen mode Exit fullscreen mode

Response returns a session ID and URL for live monitoring. Note the beta header — this is research preview.

GitHub triggers

Configure from web UI only. Requires the Claude GitHub App installed on the target repo.

Supported events: Pull request (opened, closed, assigned, labeled, synchronized) and Release (created, published, edited, deleted).

Filters (all must match):

  • Author, Title, Body, Base branch, Head branch, Labels, Is draft, Is merged

Example: Base branch main + Head branch contains auth-provider → focused auth module review.

Each matching event starts a new session — no session reuse across events.

What are 6 real-world use cases for Claude Code routines — from PR review to alert triage?

A visual 2x3 grid of use case cards: Backlog maintenance, Alert triage, Bespoke code review, Deploy verification, Docs drift, Library port.

Anthropic's documentation provides six example use cases, each mapping a trigger type to unattended, repeatable work:

1. Backlog maintenance (schedule trigger)

Runs weeknights against your issue tracker via MCP connector. Reads new issues, applies labels, assigns owners based on referenced code areas, posts summary to Slack.

2. Alert triage (API trigger)

Monitoring tool calls routine's API endpoint with error threshold breach. Routine pulls stack trace, correlates with recent commits, opens draft PR with proposed fix and link to alert. On-call reviews PR instead of starting from blank terminal.

3. Bespoke code review (GitHub trigger)

Runs on pull_request.opened. Applies team's review checklist, leaves inline comments for security/performance/style, adds summary comment. Human reviewers focus on design, not mechanical checks.

4. Deploy verification (API trigger)

CD pipeline calls routine after production deploy. Routine runs smoke checks, scans error logs for regressions, posts go/no-go to release channel.

5. Docs drift (schedule trigger)

Runs weekly. Scans merged PRs, flags documentation referencing changed APIs, opens update PRs against docs repo.

6. Library port (GitHub trigger)

Runs on pull_request.closed filtered to merged PRs in one SDK repo. Ports the change to a parallel SDK in another language, opens matching PR — keeps libraries in step without human re-implementation.

These aren't hypothetical — they map to the connector ecosystem (Slack, Linear, Google Drive, GitHub) and the network access controls Anthropic provides.

How do routines handle repository access, branch permissions, and connector integrations?

Repository access

Routines need GitHub access to clone repos. When creating from CLI with /schedule, Claude checks if GitHub is connected and prompts /web-setup if not. Two authentication methods exist via the claude.ai interface — OAuth app installation or personal access token.

Each repo is cloned fresh on every run, starting from the default branch unless the prompt specifies otherwise.

Branch permissions

By default, Claude can only push to branches prefixed with claude/. This prevents routines from accidentally modifying protected or long-lived branches. To remove this restriction, enable "Allow unrestricted branch pushes" per repository.

Connectors

Routines use your connected MCP connectors (Slack, Linear, Google Drive, etc.) to read/write to external services. All currently connected connectors are included by default on routine creation. Remove any the routine doesn't need.

Important: MCP servers added locally with claude mcp add are stored on your machine, not your claude.ai account. To use them in routines, add them as connectors at claude.ai/customize/connectors, or declare them in a committed .mcp.json so they're part of the cloned repository.

Network access

Each routine runs in a cloud environment with controlled network access. The Default environment uses Trusted access: package registries, cloud provider APIs, and common dev domains are reachable, but arbitrary domains are blocked (returns 403). MCP connector traffic routes through Anthropic's servers, bypassing network restrictions.

Environment and secrets

Environment variables (API keys, tokens) are set in the cloud environment, not in the prompt. A setup script installs dependencies — the result is cached so it doesn't re-run every session.

How do usage limits, daily run caps, and extra-usage billing work for routines?

Routines draw down your subscription usage like interactive sessions, with additional constraints:

Constraint Detail
Daily run cap Per-account limit on routine starts. View at claude.ai/code/routines
One-off runs Exempt from daily cap — consume regular subscription usage
GitHub webhook caps Per-routine and per-account hourly caps during research preview
Extra usage Organizations with extra usage enabled can exceed caps on metered overage
Without extra usage Additional runs rejected until window resets

The daily cap is visible in the routines dashboard and billing settings. Enable extra usage from Settings > Billing to handle overflow.

Important caveat from Anthropic's docs: "A green status in the run list means the session started and exited without an infrastructure error. It does not mean the task in your prompt succeeded. Open the run to read the transcript and confirm what Claude actually did."

Admins can disable routines organization-wide via the toggle at claude.ai/admin-settings/claude-code. When disabled, existing routines stop and new ones can't be created.

Frequently Asked Questions

Q: Do routines run when my laptop is closed?

Yes. Routines execute on Anthropic-managed cloud infrastructure. This is the key difference from /loop (needs open terminal) and Desktop scheduled tasks (needs machine on).

Q: Can I use routines with repos not on GitHub?

Routines require GitHub-connected repositories for cloning. GitLab, Bitbucket, and self-hosted repos are not currently supported for routine cloning.

Q: What happens if a routine run fails?

The session exits with an error visible in the run transcript. Green status means no infrastructure error — not that the task succeeded. Always review the transcript. Routines don't retry automatically; configure a schedule trigger for recurring attempts.

Q: Can multiple people share a routine?

Routines belong to your individual claude.ai account and are not shared with teammates. Anything the routine does through your connected GitHub or connectors appears as you (commits, PRs, Slack messages use your identity).

Q: What's the minimum schedule interval?

1 hour. Expressions running more frequently are rejected. For sub-hour polling, use /loop in an open session or Desktop scheduled tasks.

Q: How do routines differ from GitHub Actions?

GitHub Actions run deterministic workflows in CI. Routines run AI-powered coding sessions that reason about your codebase and produce intelligent output (PR comments, summaries, analysis). They complement each other — Actions for deterministic CI, routines for intelligent automation.

Glossary

  • Routine: A saved Claude Code configuration (prompt + repos + connectors) that executes autonomously on Anthropic cloud infrastructure
  • Cloud environment: The runtime configuration for cloud sessions, controlling network access, environment variables, and setup scripts
  • MCP connector: An integrated MCP server connected to your claude.ai account that routines can use to read/write external services
  • Trusted network access: The default network policy allowing package registries and cloud APIs while blocking arbitrary domains
  • Daily run cap: Per-account limit on how many routine runs can start per day, visible in the routines dashboard
  • /schedule: The CLI command to create, list, update, or run routines conversationally

Author

Ramsis Hammadi — AI/ML engineer specializing in GenAI, LLM engineering, and automation. Full bio →

Top comments (0)