Skip to main content
  1. Articles/

Claude Code Routines: The AI Cron Job That Actually Understands Your Codebase

·1601 words·8 mins·

Most people use Claude Code reactively. You open a terminal, describe a task, and watch it go. The session ends when the work is done, and Claude Code goes silent until you invoke it again.

Routines change the orientation entirely. Launched April 14, 2026 as a research preview, routines let you configure Claude Code once — a prompt, a repository, a set of connectors — and then have it run automatically on a schedule, in response to an HTTP call, or whenever something happens in your GitHub repo. It runs on Anthropic’s cloud infrastructure. Your laptop doesn’t need to be on.

This is not a convenience feature. It is a different model of how an AI coding agent fits into a software team’s workflow.

What a Routine Is
#

A routine is a saved Claude Code configuration: a prompt that defines what to do, one or more GitHub repositories to work in, environment variables and setup scripts, and MCP connectors (Slack, Linear, Google Drive, or anything else you have connected). You configure it once. The triggers determine when it runs.

Each run creates a new Claude Code cloud session. Claude starts from the repository’s default branch, works in a claude/-prefixed branch by default, and can push changes, open pull requests, or call external services through connectors. Everything it does appears in your session list — reviewable, continuable, and auditable.

Crucially, routines run autonomously. There is no permission-mode picker and no approval prompt mid-run. What Claude can reach is bounded at setup time by which repositories you select, which connectors you include, and what your environment allows. Tighten those constraints before you deploy anything that touches production.

Three Ways to Trigger a Routine
#

Scheduled Triggers
#

Pick a cadence — hourly, daily, weekdays, or weekly — and Claude Code will start a session at that interval. You enter the time in your local timezone and Anthropic handles the conversion. Runs may start a few minutes late due to stagger, and that offset is consistent per routine.

For custom intervals (every two hours, first of the month), configure the closest preset in the UI and then run /schedule update from the CLI to set a specific cron expression. The minimum interval is one hour.

The canonical use case: a nightly backlog triage routine that pulls unprocessed issues from Linear, applies labels and owner assignments based on the area of code referenced, and posts a summary to Slack at 7am so the team starts the day with a groomed queue rather than an inbox. The engineer who used to do this on Monday mornings no longer does.

API Triggers
#

Every routine can be given a dedicated HTTP endpoint and a bearer token. POST to it with the token in the Authorization header and Claude Code starts a new session. An optional text field in the request body passes run-specific context — an alert body, a log snippet, a failing test output — alongside the routine’s saved prompt.

The call looks like this:

curl -X POST https://api.anthropic.com/v1/claude_code/routines/trig_01ABCDEFGHJKLMNOPQRSTUVW/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 response returns a session ID and a URL you can open to watch the run in real time:

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

The /fire endpoint ships under the experimental-cc-routine-2026-04-01 beta header. It is explicitly experimental: shapes, rate limits, and token semantics may change. Anthropic has committed to keeping the two most recent previous header versions active so callers have time to migrate when it evolves.

The use case here is alert-to-PR pipelines. Your monitoring system fires an alert. The routine receives the stack trace, correlates it with recent commits in the repo, and opens a draft pull request with a proposed fix and a link back to the alert. Your on-call engineer reviews a PR rather than starting from a blank terminal at 2am. That is a meaningful difference.

GitHub Event Triggers
#

This is where routines get genuinely powerful. A GitHub trigger fires a new Claude Code session whenever a matching event occurs in a connected repository. The list of supported events is comprehensive: pull requests (opened, closed, assigned, labeled, synchronized), PR reviews, push events, releases, issues, issue comments, check runs, check suites, workflow runs, workflow jobs, and more.

You can filter pull request triggers by author, title, body, base branch, head branch, labels, draft status, and whether the PR comes from a fork. Practical examples:

  • Auth module review: triggers on PRs targeting main from branches containing auth-provider, running a security-focused review checklist.
  • External contributor triage: triggers on all fork-based PRs, routing them through an extra review before a maintainer looks.
  • Automatic SDK porting: triggers on merged PRs in one SDK repository and opens a parallel PR in a second SDK with the equivalent change — keeping two language implementations in sync without a human re-implementing each change.
  • CI failure triage: triggers on check_suite.completed with a failure status, pulling the failing test output and proposing a fix before the developer even opens the notification.

Each matching event creates its own independent session. There is no cross-event session reuse, so two pushes produce two separate Claude Code runs — each with full context from the new event.

The CLI Interface
#

From inside any Claude Code session, /schedule creates a scheduled routine conversationally. You can also pass a description directly: /schedule daily PR review at 9am. The CLI walks through prompt, repository, environment, and saves the routine to your account.

  • /schedule list — see all routines
  • /schedule update — modify an existing routine, including setting custom cron expressions
  • /schedule run — trigger a run immediately

API and GitHub triggers can only be configured from the web UI at claude.ai/code/routines. The /schedule CLI currently handles scheduled routines only.

Plan Limits and Usage
#

Routines draw down subscription usage the same way interactive sessions do. There is also a separate daily cap on routine runs per account:

PlanDaily routine runs
Pro5
Max15
Team / Enterprise25

Organizations with extra usage enabled can continue running routines on metered overage when the daily cap is hit. Without it, additional runs are rejected until the window resets.

Five daily routines on Pro sounds limiting, but consider what those five can cover: a nightly backlog triage, a deploy verification hook, a PR review gate, a documentation drift check, and one alert-response pipeline. That is a meaningful set of async coverage for an individual developer. Max’s fifteen is the tier where routines start to become a team-level infrastructure decision.

Why This Is More Than Convenient Cron
#

The standard objection to describing this as significant is that developers already have cron, GitHub Actions, and a dozen CI/CD integrations. What does adding Claude Code to the scheduler actually change?

The answer is the difference between executing a script and completing a task. GitHub Actions runs your defined workflow. A Claude Code routine reads the state of your codebase, applies judgment about what needs to happen given that state, and produces an output — a PR, a comment, a Slack message, a proposed fix — tailored to the specific context of this run.

A GitHub Action that runs on PR open applies a static checklist. A routine that runs on PR open reads the changed files, understands what the change is trying to accomplish, applies your team’s documented review standards, and leaves inline comments that are specific to this PR. These are different things.

This is also distinct from Claude Code’s existing GitHub Actions integration (which runs Claude in your CI pipeline) and from desktop scheduled tasks (which run on your machine). Routines are cloud-native, event-responsive, and persistent — the session URL is always accessible, even after the run finishes.

The Catch
#

Routines are in research preview. Anthropic is explicit: behavior, limits, and the API surface may change. The /fire endpoint’s beta header signals this is experimental infrastructure, not a stable API commitment.

The more operational concern is autonomy without oversight. A routine runs without approval prompts. If your prompt is underspecified, if the connectors it has access to are too broad, or if the Claude GitHub App has write access to branches you care about, a routine can do more than you intended. The default branch protection (Claude only pushes to claude/-prefixed branches) is there for a reason. Trust it until you have a specific reason to widen the permission.

The correct approach is to start narrow: one trigger, one well-scoped prompt, one repository, minimum connector access. Watch the first ten runs. Then expand.

What It Signals
#

Routines are the first Claude Code feature that does not require a human to initiate anything. You set it up once and it runs. The agent operates on its own cadence, responding to the state of your codebase and the events your infrastructure generates.

That is a different mental model than “AI assistant.” It is closer to “AI colleague who works the overnight shift, triages what they can, and leaves a queue of reviewed drafts for the morning.” Whether routines fulfill that promise will depend on how well they handle the inevitable edge cases — but the architecture is right, and the direction is clear.


Sources

Related