TokenMix Research Lab · 2026-04-22

Claude Code Routines: Run AI Agents on Schedule, No Mac Online

Anthropic shipped Claude Code Routines on April 14, 2026 — scheduled, repeatable AI coding tasks that run on Anthropic's web infrastructure. Your Mac can be closed, asleep, or halfway around the world; routines execute. Each routine bundles a prompt, a repo, and connectors into one config that fires on a schedule, via API call, or on GitHub events. This is Anthropic's answer to Cursor 3's background cloud agents and pushes Claude Code toward the "autonomous coding agent" category. This guide covers what routines can do today, how to write one in 10 minutes, the cost model, and three production use cases. TokenMix.ai tracks model usage across scheduled agent workflows — if you're running routines at scale, our dashboard shows per-routine cost attribution.

Table of Contents


Confirmed vs Speculation: Routines Facts

Claim Status Source
Claude Code Routines released April 14, 2026 Confirmed 9to5Mac
Runs on Anthropic web infrastructure Confirmed Anthropic docs
Schedule, API, GitHub event triggers Confirmed Documentation
Requires Claude Code Pro or Max Confirmed Pricing docs
Default model: Opus 4.7 Confirmed Anthropic release notes
Per-routine cost tracking available Partial — Max tier only Community reports
Unlimited routines No — rate-limited Documentation
Cross-repo routines supported Yes Recently added

Bottom line: production-ready with clear limits. Best fit for teams already on Claude Code Pro/Max.

What Routines Can Do

A routine combines four elements:

  1. Prompt — the instruction Claude executes (e.g., "Check for dependency vulnerabilities and create a PR")
  2. Repo — which codebase to operate on
  3. Connectors — tools Claude can use (GitHub, Linear, Slack, custom MCP servers)
  4. Trigger — when to run (cron schedule, API call, GitHub webhook)

Trigger types

Trigger Example use Setup difficulty
Cron schedule "Every Monday at 9am, review dependabot PRs" Easy
GitHub event "On new PR, run linting + summarize diff" Medium
API call Your app triggers via POST Medium
Manual Click "run" in dashboard Trivial

What Claude can do inside a routine

Your First Routine in 10 Minutes

Example: Weekly dependency audit that creates a PR if vulnerabilities found.

Step 1: Open Claude Code Routines dashboard

In Claude Code (Pro/Max), click "Routines" sidebar → "New Routine".

Step 2: Configure the routine

name: weekly-dependency-audit
description: Scan dependencies for CVEs, open PR with fixes
trigger:
  type: cron
  schedule: "0 9 * * MON"  # Every Monday 9am

repo:
  url: github.com/yourorg/yourrepo
  branch: main

connectors:
  - github
  - slack

prompt: |
  Run npm audit --json on the repo.
  Parse results for high/critical severity.
  For each fixable vulnerability:
    - Create a branch "security/fix-{package-name}"
    - Update the affected dependency
    - Run the test suite
    - If tests pass, open a PR with a summary
    - Post to #security-alerts Slack channel
  If no vulnerabilities, post "clean" to Slack.

model: claude-opus-4-7
max_runtime_minutes: 30

Step 3: Test once manually

Click "Run now". Review output in dashboard. Adjust prompt if needed.

Step 4: Activate schedule

Toggle "Active". Routine now runs every Monday at 9am without your Mac being online.

Estimated cost per run: $0.50-$2.00 depending on repo size and vulnerability count.

Three Production Use Cases

1. Nightly Test Flakiness Analysis

Run at 2am. Claude reviews last 24 hours of CI test failures, groups by likely root cause, files a Linear ticket for each pattern with suggested fixes. Teams report 30-50% reduction in test flake triage time.

2. PR Description Generation & Review Prep

Trigger on pull_request.opened GitHub event. Claude reads the diff, generates a structured PR description with context, risk assessment, and suggested reviewers. Optionally flags high-risk changes for senior review.

3. Customer Support Codebase Q&A

Trigger via API from your support tool. When a customer asks "How do I integrate feature X?", support agent hits your endpoint, which triggers a routine that searches your docs repo and returns an authoritative answer with source links.

Cost Model: What Each Run Actually Costs

Anthropic charges routines at standard API rates for the model used. Default is Opus 4.7 at $5/$25 per MTok, with the new tokenizer cost considerations.

Typical costs per run:

Routine type Tokens in Tokens out Cost/run
Small audit (one check) ~5K ~1K $0.05
Dependency audit + PR ~30K ~5K $0.28
Codebase-wide refactor ~200K ~50K $2.25
Long-form doc generation ~50K ~20K $0.75
Cross-repo analysis ~500K ~100K $5.00

Hidden cost: runtime caps

Routines have a default 30-minute timeout. Tasks exceeding this fail. Extending to 60 minutes is $0.10/minute premium on Max tier. This caps worst-case cost per run at about 0.

Monthly budgeting example:

For cost attribution across routines, see our GPT-5.5 migration checklist step 6 — the per-routine tracking pattern applies identically.

Routines vs Cursor 3 Cloud Agents vs GitHub Actions

Feature Claude Code Routines Cursor 3 Background GitHub Actions
Native AI reasoning Yes, Opus 4.7 Yes, Composer 2 No (need LLM via API)
Scheduled runs Cron Manual + event Cron
GitHub event triggers Yes Limited Yes
Repo-aware context Yes Yes Manual setup
Cost per run $0.28-5 $0.20-3 ~$0.01 runtime + LLM costs
Max runtime 30 min default 2 hours 6 hours
Requires app online? No No No
Free tier No (Pro required) Max tier only Yes
Setup time 10 min 15 min 30+ min

Routines win on: repo-awareness, model quality (Opus 4.7), simpler DSL. Cursor 3 wins on: longer runtime, better for ongoing IDE-integrated work. GitHub Actions wins on: cost, community workflow library, any non-AI tasks.

FAQ

Do I need Claude Code Max to use Routines?

Pro tier ($20/month) is sufficient for light routine usage (up to ~20 routines/month, 30-minute max runtime). Max tier ( 00/month) adds priority execution, extended runtimes, and per-routine cost attribution.

Can I trigger a routine via API from my own application?

Yes. Each routine gets an API endpoint URL and a secret token. POST to it with optional input parameters. Response includes a run ID for polling or a webhook URL for async completion.

What happens if a routine fails mid-run?

Routines log all actions. A failed run leaves partial state (e.g., a created branch without a PR) that you can manually clean up via dashboard. Rerunning will attempt to continue or retry from scratch depending on the task. No transactional guarantees — treat routines as idempotent where possible.

Can routines call custom MCP servers?

Yes. Add your MCP server to the connectors list. Note the MCP STDIO security flaw — audit any community MCP servers before connecting them to routines that have write access.

How does this compare to Cursor 3's background cloud agents?

Cursor 3's background agents are better for continuing an in-progress IDE task without your laptop online. Claude Code Routines are better for scheduled/event-driven automation. Many teams use both: Cursor for in-IDE, Claude Code Routines for cron/webhook work.

Is there a routines marketplace or template library?

Not yet. Anthropic signaled a template library is on the Q3 2026 roadmap. Community-shared routines are beginning to appear on GitHub — search for "claude-code-routines" for examples.

Can routines use Opus 4.6 or Sonnet 4.6 instead of 4.7?

Yes. Set model: claude-sonnet-4-6 or model: claude-opus-4-6 in the routine config. Sonnet is ~3× cheaper than Opus for simple routines where quality ceiling isn't the constraint.


Sources

By TokenMix Research Lab · Updated 2026-04-22