# Automate work with routines - Claude Code Docs

> Claude Code Routines are cloud-hosted Claude sessions triggered by schedule, HTTP API, or GitHub events, replacing Claude-in-CI and cron-plus-scripts patterns.

Published: 2026-04-16
URL: https://daniliants.com/insights/automate-work-with-routines-claude-code-docs/
Tags: claude-code, routines, automation, github-actions, mcp-connectors, scheduled-tasks, api-triggers

---

## Summary

Claude Code Routines (research preview) are cloud-hosted autonomous Claude sessions triggered by schedule, HTTP API, or GitHub events. Each routine runs as a full Claude Code session on Anthropic infrastructure with access to selected repos, MCP connectors, and cloud environment variables, acting on the connected identity. They replace "Claude-in-CI" and "cron + scripts" patterns with one prompt-driven abstraction.

## Key Insight

- **Three trigger types on one routine.** Schedule, API (per-routine `/fire` endpoint + bearer token), and GitHub events (pull_request, release) can be combined on the same routine.
- **Runs as the creator.** Commits, PRs, Slack messages, Linear tickets all appear under the creator's identity, no service account abstraction. Routines are per-individual, not shared with teammates.
- **Default branch safety.** Claude can only push to `claude/`-prefixed branches unless "Allow unrestricted branch pushes" is explicitly enabled per repo.
- **Minimum schedule interval is 1 hour.** Cron expressions below that are rejected. Presets: hourly, daily, weekdays, weekly. Custom crons editable via `/schedule update` CLI.
- **API payload is freeform text only.** The `text` field is passed as a literal string, JSON payloads arrive as raw strings, so structure inside the prompt, not the POST body.
- **API tokens are one-time shown.** No retrieval after generation, regenerate or revoke, no read-back. Treat like OAuth client secrets.
- **GitHub PR filter gotcha.** The `matches regex` operator tests the **entire** field, not a substring, use `.*hotfix.*` not `hotfix`, or use `contains` for literal substring matching.
- **GitHub triggers need the Claude GitHub App installed**, `/web-setup` grants clone access but NOT webhook delivery.
- **Events to sessions is 1:1.** Two PR updates = two independent sessions. No session reuse.
- **Daily run cap exists** in addition to standard subscription limits. Overage requires "extra usage" enabled on the org.
- **Concrete patterns worth copying:** backlog grooming at night, alert triage from monitoring webhooks (with auto-draft PR of proposed fix), PR checklist reviewer, post-deploy smoke test runner, docs drift detector, cross-SDK code port.
- **Not a routine:** Desktop "New local task" creates a local scheduled task on the user's machine, different surface, different runtime.