Learn Claude Code: Autonomous Workflows Routines: Cloud-Managed Autonomous Agents

Routines: Cloud-Managed Autonomous Agents

Intermediate 🕐 14 min Lesson 8 of 13
What you'll learn
  • Create a cloud Routine with schedule, API, and GitHub event triggers from the CLI and web interface
  • Configure connectors, branch permissions, and cloud environments for autonomous runs that access external services
  • Trigger a Routine programmatically via the /fire API endpoint with run-specific context passed as the text field

What a Routine Is

A Routine is a saved Claude Code configuration — a prompt, one or more repositories, a cloud environment, and a set of MCP connectors — packaged once and run automatically by Anthropic-managed infrastructure. Each run creates a new autonomous Claude Code session that clones your repositories, runs your prompt, uses your connectors, and can push branches and open PRs on your behalf.

The defining characteristic of a Routine is independence. Unlike /loop or Desktop tasks, Routines don't need your machine on or a session open. They run on Anthropic's servers. Close your laptop, disconnect from the internet, fly across the world — your Routine fires at the scheduled time and works through its task without you.

Because Routines run autonomously without permission prompts, there is no permission mode picker. Claude can run shell commands, call connectors, and push branches according to the permissions you configure at setup time. What it can reach is determined by the repositories you select, the network access level of the environment, and the connectors you include.

Three Ways to Trigger a Routine

A Routine can have one or more triggers, and you can combine them:

Schedule trigger: Run on a recurring cadence. The minimum interval for cloud Routines is one hour — for more frequent automation, use Desktop tasks. Presets include hourly, daily, weekdays, and weekly. For custom schedules, run /schedule update in the CLI to set a cron expression directly. Runs may start a few minutes after the scheduled time due to stagger.

API trigger: Trigger the Routine programmatically by sending a POST request to a per-Routine endpoint. Useful for wiring Claude Code into alerting systems, deploy pipelines, and internal tools. Each Routine gets its own bearer token, scoped only to triggering that Routine.

GitHub event trigger: React automatically to repository events — pull request opened, closed, synchronized; release created or published. Configure filters on PR author, title, base branch, head branch, labels, and draft status to narrow which events fire the Routine.

Creating a Routine from the CLI

Run /schedule in any session to create a scheduled Routine conversationally. You can describe it in plain language:

/schedule daily PR review at 9am
/schedule clean up feature flags in one week

Claude walks through the same information the web form collects — prompt, repositories, environment, connectors — and saves the Routine to your account. The Routine appears immediately at claude.ai/code/routines and in any session with /schedule list.

To add API or GitHub event triggers, edit the Routine on the web. The CLI currently creates scheduled Routines only.

One important requirement: /schedule requires a claude.ai subscription login. It is not available when authenticating via an API key or on Amazon Bedrock, Google Cloud's Agent Platform, or Microsoft Foundry.

Connectors and Branch Permissions

Connectors are the MCP servers attached to your claude.ai account. By default, all of your connected connectors are included in every new Routine. Remove any the Routine doesn't need — Claude can use every tool from an included connector during a run without permission prompts.

MCP servers you added locally with claude mcp add are stored on your machine, not your account, so they don't appear in the connector list. To use them in a Routine, add them at claude.ai/customize/connectors or declare them in a committed .mcp.json in the repository.

By default, Routines can only push to branches prefixed with claude/. This prevents accidental modification of protected branches. To allow pushing to existing branches — for example, to let a Routine push fixes to a release/next branch — enable Allow unrestricted branch pushes per repository in the Routine's settings.

The /fire API Endpoint

API-triggered Routines have a per-Routine endpoint you can call from any system that can make an HTTP request:

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 in prod. Stack trace attached."}'

The text field is optional but powerful — it passes run-specific context alongside the Routine's saved prompt. An alert body, a PR description, a list of issue numbers, or a structured JSON payload all work as text. Claude receives it as a literal string alongside the saved prompt.

A successful call returns the new session ID and URL:

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

Open the URL to watch the run in real time. Each triggered run is its own session you can review, comment on, or continue manually.

Managing Runs and Limits

Routines draw down subscription usage the same way interactive sessions do, plus they have a daily cap on how many runs can start per account. One-off runs via Run now or the API do not count against the daily cap. On the Routine's detail page you can pause the schedule, run it immediately, review past runs, and manage API tokens.

Each run's session status indicates whether the session started without infrastructure errors — it does not indicate whether the task in your prompt succeeded. Open each run to read the transcript and confirm what Claude actually did. Network blocks, missing connectors, and task-level failures all surface in the transcript rather than the status indicator.

Key takeaways
  • Routines run on Anthropic infrastructure, not your machine — they keep running even when your laptop is closed, making them right for overnight jobs, PR review automation, and alert-driven workflows
  • Three trigger types compose on one Routine — combine schedule, API endpoint, and GitHub events so a PR review Routine fires automatically on every new PR, runs nightly, and can also be called from your deploy script
  • The /fire text field is freeform run-specific context — pass alert bodies, PR descriptions, or structured payloads as a string alongside the Routine's saved prompt for per-trigger customization
  • Branch permissions default to claude/ prefix only — enable unrestricted branch pushes per repository when a Routine needs to push fixes to existing branches like release/next or hotfix/*
  • One-off runs via Run now or the API don't count against the daily cap — scheduled runs use the daily allowance, but on-demand invocations are metered separately as regular subscription usage