# Claude Code Routines: Scheduled and Event-Driven AI Automation

Claude Code Routines execute automated tasks on Anthropic's managed cloud infrastructure. Unlike the local scheduling feature that predated them, **Routines run in a dedicated cloud environment with configurable network access, environment variables, setup scripts, and connectors to external services** like Slack and GitHub.

## Execution modes

Routines formalize three ways to run automated tasks:

**Loops** run within an active session for iterative tasks you are monitoring directly.

**Schedules** run on recurring intervals, either with presets (Hourly, Daily, Weekdays, Weekly) or custom cron expressions. These execute in the cloud rather than locally.

**Event-driven triggers** start a routine in response to an external event, decoupling it from a fixed time schedule.

## Core components

Every Routine has four configurable parts.

![The "New routine" creation screen showing the Name, Description, and Trigger selection options](https://imagedelivery.net/xZXo0QFi-1_4Zimer-T0XQ/317e6a1a-9542-4383-2af7-191915549000/lg1x =1920x1080)

**Prompt.** Natural language instructions describing what Claude should do. This can be a simple single-step task or a multi-step workflow with branching logic.

**Triggers.** The event that starts the routine. Options are: Schedule (recurring time-based), GitHub Event (PR opened, PR merged, release published, and others), or API (an endpoint that accepts a POST request from any external system).

**Environment.** The sandboxed execution context. Configurable options include network access (blocked by default, or allowlisted domains, trusted sources, or full internet), environment variables for secrets and API keys, and setup scripts that run before Claude Code launches.

**Connectors.** Pre-built integrations with services like Slack, Gmail, and Google Calendar that provide tools for reading data or taking actions within those services.

## Daily content curation routine

The following example creates a scheduled routine that fetches developer newsletter RSS feeds, selects 10 articles suitable for a developer YouTube channel, and posts the list to Slack each morning at 9 AM.

### Creating via the CLI

The `/schedule` slash command accepts a full natural language description:

```command
/schedule Create a daily 9am trigger that fetches RSS from JavaScript Weekly, React Status and Node Weekly, picks 10 good articles for YouTube videos, and sends the list via Slack.
```

![The full /schedule command being typed into the Claude Code terminal](https://imagedelivery.net/xZXo0QFi-1_4Zimer-T0XQ/fe0151e5-bf24-4307-3ba8-2b39dfdf4200/lg1x =1920x1080)

Claude parses the request and asks clarifying questions before creating the routine.

![Claude's list of clarifying questions and the draft prompt it constructed based on the initial command](https://imagedelivery.net/xZXo0QFi-1_4Zimer-T0XQ/2a941753-0a44-4490-b2af-8c1763ae5500/public =1920x1080)

For this routine, the relevant answers are: the Slack destination channel, and selection criteria (prefer new releases, tutorials, deep-dives, and AI topics that can sustain a 10-minute video). After responding, Claude confirms creation of a remote trigger and provides a link to manage it in the web UI.

### Managing routines in the web UI

![List of created routines including "Daily YouTube Article Picks" and "Review PR" visible in the sidebar](https://imagedelivery.net/xZXo0QFi-1_4Zimer-T0XQ/8ac8ee69-7843-4552-eb4d-0dc9b3f96200/md1x =1920x1080)

The web UI shows all routines and their configurations. After creation, two small issues were visible in this example: a GitHub repository was automatically linked and was not needed, and Claude's default Slack formatting uses horizontal rule dividers (`---`) that cause `invalid_blocks` validation errors. Both are correctable by editing the routine's prompt to add: "When formatting Slack messages, do not use `---` horizontal rule dividers; they cause invalid_blocks validation errors. Use blank lines between sections for spacing instead."

### Configuring network access

By default, cloud routines block outbound network requests. Fetching RSS feeds requires allowlisting the relevant domains. Under the environment selector, selecting **Add environment** opens the network access configuration.

![The "New cloud environment" configuration modal highlighting the "Network access" dropdown with options for Trusted, Full, and Custom](https://imagedelivery.net/xZXo0QFi-1_4Zimer-T0XQ/63d95b62-62bd-45c7-d873-cac7527f0a00/md1x =1920x1080)

The **Custom** option creates an allowlist. Adding `javascriptweekly.com`, `react.statuscode.com`, and `nodeweekly.com` permits access to exactly these domains while blocking everything else. After saving and applying the environment, the routine can fetch from those domains.

### Running and verifying

The **Run now** button triggers the routine immediately without waiting for the scheduled time. The runs panel shows a live log of Claude's execution: initializing the session, setting up the container, and working through the prompt steps. If an approach fails (the initial `curl` command failing due to DNS issues, for example), Claude self-corrects and retries with a different tool.

![The final formatted message posted by the Claude routine in the Slack channel listing the top 10 articles](https://imagedelivery.net/xZXo0QFi-1_4Zimer-T0XQ/d3f1a433-eee7-411a-d80e-9fb79ae04f00/lg1x =1920x1080)

## GitHub PR review routine

This routine triggers on every new pull request in a repository, analyzes the code changes, and posts a review comment directly on the PR.

### Creating the trigger

GitHub event-triggered routines must be created in the web UI. Under **New routine > Remote**, selecting **GitHub event** as the trigger type shows the available events. Selecting **PR opened** and choosing the target repository completes the trigger configuration.

![Trigger configuration screen showing the "PR opened" event selected for a GitHub-based trigger](https://imagedelivery.net/xZXo0QFi-1_4Zimer-T0XQ/16330d43-7527-4e59-9543-55dd4ada2b00/lg2x =1920x1080)

### Skills and the shared repository approach

A PR review is complex and reusable, making it a good candidate for a Skill: a named, reusable prompt stored in a `.claude/skills/` directory. Cloud routine instances are fresh containers with no access to skills defined on a local machine. The solution is a secondary GitHub repository that stores skills and is cloned alongside the primary repository.

Creating a repository (e.g., `routine-env`) with a `.claude/skills/pr-review/SKILL.md` file containing the review prompt, then adding this repository to the routine configuration, makes the skills available in the cloud container.

### The SessionStart hook

With the skills files in the container, a hook tells Claude where to find them. A `.claude/settings.json` file in the skills repository defines this:

```json
[label .claude/settings.json]
{
  "hooks": {
    "SessionStart": {
      "hooks": [
        {
          "type": "command",
          "command": "[ ! -d ~/.claude/skills ] && cp -r ~/routine-env/.claude/skills/. ~/.claude/skills"
        }
      ]
    }
  }
}
```

![Content of the settings.json file showing the SessionStart hook and the cp command used to copy the skills](https://imagedelivery.net/xZXo0QFi-1_4Zimer-T0XQ/d16738d5-8437-468a-a7d2-10c06e774900/public =1920x1080)

This command runs at session start and copies the skills from the cloned `routine-env` repository into the `.claude/skills` directory the cloud instance uses, effectively installing the custom skills for the routine.

### Result

Opening a pull request fires the GitHub webhook within seconds. The run log shows both repositories cloning, the `pr-review` skill being recognized, Claude fetching the PR diff and details, and a review comment being posted via GitHub tools.

![Automated review comment posted by the Claude routine directly on the GitHub Pull Request page](https://imagedelivery.net/xZXo0QFi-1_4Zimer-T0XQ/d36b2ffb-d7a6-4433-0798-8af1e4ef1100/lg1x =1920x1080)

## Limits and pricing

Routines are available on Pro, Max, Team, and Enterprise plans. Each run consumes the same token usage as an interactive chat session.

Automated runs (triggered by schedule, GitHub event, or API) have a daily cap:

- **Pro:** 5 daily automated runs
- **Max:** 15 daily automated runs

Manual runs via the **Run now** button do not count toward this cap and are treated as standard interactive sessions.

![The "Usage" settings page showing the "Daily included routine runs" progress bar with 1 out of 5 runs used](https://imagedelivery.net/xZXo0QFi-1_4Zimer-T0XQ/a0fe16c8-3c04-4664-9e73-b079e346e000/md2x =1920x1080)

At 5 automated runs per day on the Pro plan, Routines are most cost-effective for a small number of high-value automations. For high-volume use cases requiring dozens of daily automated runs, self-hosted frameworks with cheaper model providers will be more economical, though they require more setup and maintenance. The primary advantage Routines offer is the ability to define a complex automation in natural language and have it running in the cloud without infrastructure setup.

## Final thoughts

Routines make cloud-based AI automation accessible without requiring infrastructure configuration or orchestration code. The **event-driven GitHub trigger is the most useful addition for development workflows: it turns a routine into a reactive agent that responds to repository activity** rather than running on a fixed schedule.

The skills repository pattern with a `SessionStart` hook is a practical workaround for the stateless cloud environment, and is likely to become a standard pattern for routines that involve complex or reusable task definitions.

Documentation is available at [docs.anthropic.com](https://docs.anthropic.com/).