Anthropic just launched Routines for Claude Code — and it changes how developers automate repetitive work. Instead of managing cron jobs, GitHub Actions, and monitoring scripts across different tools, you define a prompt once and let Claude execute it on a schedule, on API call, or on GitHub events. Your laptop does not even need to be open.

Here is the complete setup guide with real use cases.

What You Will Learn

  • Set up Claude Code Routines that run autonomously on Anthropic cloud infrastructure — no local machine required
  • Configure all 3 trigger types: scheduled (hourly/daily/weekly), API webhooks, and GitHub event-driven
  • Build practical automations: nightly code review, deploy verification, and alert triage that respond in minutes, not hours

What You Will Need

  • Claude Pro, Max, Team, or Enterprise subscription ($20+/month)
  • Claude Code on the web enabled in your account settings
  • GitHub repository connected to Claude Code (for GitHub triggers)
  • 5 minutes for your first routine

Daily limits by plan: Pro gets 5 routines/day, Max gets 15, Team and Enterprise get 25.

What Routines Actually Are (And Are Not)

A routine is a saved Claude Code configuration: a prompt, one or more repositories, and a set of connectors, packaged once and run automatically. Think of it as a smart cron job — it has the repeatability of a cron job, but the intelligence of a Claude Code session.

Key difference from cron jobs: A cron job runs a fixed script. A routine runs a prompt — meaning Claude adapts to what it finds. If your nightly bug triage routine finds 3 critical issues instead of the usual 0, it adjusts its response accordingly.

Key difference from AI agents: Agents maintain ongoing state and run continuously. Routines are short-lived, trigger-driven sessions. They start, do their job, and end. No persistent state between runs.

Routines run on Anthropic infrastructure. Your laptop can be closed, your CI server can be down — the routine still fires. Each run creates a full Claude Code session you can review at claude.ai/code.

The 3 Trigger Types

1. Schedule Triggers — Run This Every Night at 2 AM

Best for: recurring maintenance, weekly reports, daily triage. Options: hourly, daily, nightly, weekdays, or weekly. Times use your local timezone. For custom intervals, use the CLI: /schedule update accepts cron expressions (minimum interval: 1 hour).

2. API Triggers — Run This When My Monitoring Fires

Best for: alert response, deploy verification, on-demand automation. Each routine gets a unique HTTP endpoint. POST to it with a bearer token and an optional text payload. Claude receives the payload alongside the routine prompt.

3. GitHub Triggers — Run This on Every New PR

Best for: code review, docs updates, library ports, release automation. Supports: pull requests, pushes, releases, issues, discussions, check runs, workflow events, and more. PR triggers support filters by author, title, branch, labels, and draft state.

A single routine can combine all three triggers. Your PR review bot can also run nightly and accept manual API calls.

Step-by-Step: Create Your First Routine

Method 1: Web Interface (Recommended for First Time)

Step 1. Go to claude.ai/code/routines and click New routine.

Step 2. Name it something descriptive: Nightly Bug Triage or PR Security Review.

Step 3. Write the prompt. This is the most critical part — the routine runs autonomously, so the prompt must be self-contained. Be explicit about what to do and what success looks like.

Example prompt for nightly bug triage:

Review all GitHub issues opened in the last 24 hours.
For each issue:
1. Apply appropriate labels (bug, feature, documentation, question)
2. Assign to the team member who owns that area of code
3. If it is a bug with a stack trace, correlate with recent commits
4. Post a summary to the #engineering Slack channel

Step 4. Select your GitHub repositories. Claude clones them at the start of each run. By default, it can only push to claude/-prefixed branches.

Step 5. Choose an environment. The Default environment works for most cases. For routines that need API keys or custom dependencies, create a custom environment.

Step 6. Add your trigger (schedule, API, GitHub, or multiple).

Step 7. Review connectors. All your MCP connectors (Slack, Linear, Google Drive) are included by default. Remove any the routine does not need.

Step 8. Click Create. The routine runs at the next trigger match. Click Run now to test immediately.

Method 2: CLI (Faster for Scheduled Routines)

In any Claude Code session, run:

/schedule daily PR review at 9am

Claude walks through the configuration conversationally. Other CLI commands: /schedule list to see all routines, /schedule update to modify one, /schedule run to trigger immediately.

Note: The CLI creates scheduled routines only. For API or GitHub triggers, use the web interface.

5 Practical Routines Worth Setting Up

1. Nightly Bug Triage (Schedule: daily)

Claude reads new issues, applies labels, assigns owners based on code area, and posts a Slack summary. Your team starts each morning with a groomed backlog instead of a chaotic inbox.

2. Automated Code Review (GitHub: pull_request.opened)

On every new PR, Claude applies your team review checklist, leaves inline comments on security, performance, and style issues, and adds a summary comment. Human reviewers focus on architecture and design instead of mechanical checks.

3. Deploy Verification (API: called from CI/CD)

Your deploy pipeline POSTs to the routine after each production deploy. Claude runs smoke checks, scans error logs for regressions, and posts go/no-go to your release channel — all before the deploy window closes.

4. Documentation Drift Detection (Schedule: weekly)

Every week, Claude scans merged PRs, identifies documentation that references changed APIs, and opens update PRs against your docs repository. No more stale docs that reference deprecated endpoints.

5. Alert Triage (API: called from monitoring)

When Sentry or Datadog crosses an error threshold, it calls the routine with the alert body. Claude pulls the stack trace, correlates with recent commits, and opens a draft PR with a proposed fix. On-call engineers review a solution instead of starting from scratch.

Setting Up an API Trigger (Step by Step)

This is the most powerful trigger type and the least documented.

Step 1. Create a routine via the web interface with any trigger.

Step 2. Edit the routine, scroll to triggers, click Add another trigger, choose API.

Step 3. Copy the URL and click Generate token. Save the token immediately — it is shown once and cannot be retrieved later.

Step 4. Call it from your system:

curl -X POST https://api.anthropic.com/v1/claude_code/routines/trig_YOURID/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."}"

The response includes a session URL where you can watch the run in real time.

What to Watch Out For

Routines run as you. Commits carry your GitHub identity. Slack messages use your account. Do not set up a routine that does something you would not do manually.

Branch restrictions exist by default. Claude can only push to claude/-prefixed branches. Disable this only if you have robust downstream review.

The prompt is everything. Unlike interactive sessions where you can course-correct, routines run autonomously. Be specific about success criteria and what to do when something unexpected happens.

Usage counts against your plan limits. Each routine run consumes tokens from your subscription. Monitor your usage, especially on Pro with only 5 runs/day.

The Bottom Line

Claude Code Routines solve a real problem: the gap between I could automate this and I actually automated this. Before Routines, automation meant writing scripts, managing infrastructure, and debugging failures at 3 AM. Now it means writing a clear prompt and choosing a trigger.

The most impactful use case is not the flashiest. It is the boring automation you have been meaning to set up for months — the nightly triage, the deploy check, the docs review — that now takes 5 minutes instead of a weekend project.

Start with one routine. Run it for a week. Then build the next one based on what you learn.