Claude Code Routines: Easy Scheduling Guide

Routines put Claude Code on autopilot. A routine is a saved configuration—prompt, repositories, and connectors—packaged once and run automatically on Anthropic-managed cloud infrastructure. This guide covers routines, the /schedule command, the /loop command, and Desktop scheduled tasks, so you can pick the right scheduling tool for recurring work.

Claude Code Routines: Easy Scheduling Guide — title card

routines: What You’ll Learn

Routines let Claude Code run unattended on a schedule, on an API call, or on a GitHub event. You’ll learn how each trigger type works, how to create routines from the web, CLI, and Desktop app, and how /loop fits in for session-scoped polling. By the end, you’ll know exactly which scheduling tool to reach for.

What Are Routines?

A routine is a saved Claude Code configuration: a prompt, one or more repositories, and a set of connectors, packaged once and run automatically. Routines execute on Anthropic-managed cloud infrastructure, so they keep working when your laptop is closed.

Each routine can have one or more triggers attached to it:

  • Scheduled: run on a recurring cadence like hourly, nightly, or weekly, or once at a specific future time
  • API: trigger on demand by sending an HTTP POST to a per-routine endpoint with a bearer token
  • GitHub: run automatically in response to repository events such as pull requests or releases

A single routine can combine triggers. A PR review routine can run nightly, trigger from a deploy script, and also react to every new pull request. Routines are available on Pro, Max, Team, and Enterprise plans with Claude Code on the web enabled. Create and manage them at claude.ai/code/routines, or from the CLI with /schedule.

Routines run autonomously as full Claude Code cloud sessions. There is no permission-mode picker and no approval prompts during a run. The session can run shell commands, use skills committed to the cloned repository, and call any connectors you include. What a routine can reach is determined by the repositories you select, the environment’s network access, and the connectors you include.

Routines belong to your individual claude.ai account. They are not shared with teammates, and they count against your account’s daily run allowance. Anything a routine does through your connected GitHub identity or connectors appears as you: commits and pull requests carry your GitHub user.

Routines vs Headless Mode vs Workflows

Routines are often confused with two related features, but they solve different problems. Headless Mode (post 1274) is a one-shot, non-interactive invocation—you run claude -p "fix the bug" once and get a result. It does not recur. Routines, by contrast, fire repeatedly on a schedule, on API calls, or on GitHub events, and they run in the cloud rather than on your machine.

Workflows (post 32) are single-session automation: a sequence of steps that run once within one session. Workflows don’t persist across restarts or fire on external events. If you need work to happen repeatedly without you present, routines are the right tool.

Think of it this way: headless mode is a one-off command, workflows are a one-off script, and routines are a recurring job. Each has its place, but only routines keep working when you walk away from the keyboard.

Three Ways to Schedule Claude Code

Claude Code offers three scheduling mechanisms. Each runs in a different place with different tradeoffs. The comparison table below summarizes the key differences:

FeatureCloud RoutinesDesktop Tasks/loop
Runs onAnthropic cloudYour machineYour machine
Requires machine onNoYesYes
Requires open sessionNoNoYes
Persistent across restartsYesYesRestored on –resume
Access to local filesNo (fresh clone)YesYes
Permission promptsNo (autonomous)ConfigurableInherits from session
Minimum interval1 hour1 minute1 minute

Use cloud routines for work that should run reliably without your machine. Use Desktop tasks when you need access to local files and tools. Use /loop for quick polling during a session that doesn’t need to survive a restart.

Creating a Routine

You can create routines from three surfaces, all writing to the same cloud account. A routine you create in one shows up in the others immediately:

  • Web: visit claude.ai/code/routines and click “New routine”
  • CLI: run /schedule in any session
  • Desktop app: click “Routines” in the sidebar, then “New routine” and choose “Remote”

The creation form sets up the routine’s prompt, repositories, environment, connectors, and triggers. The prompt is the most important part—routines run autonomously, so the prompt must be self-contained and explicit about what to do and what success looks like. The prompt input includes a model selector, and Claude uses the selected model on every run.

When you add a repository, it is cloned at the start of each run, starting from the default branch. Claude creates claude/-prefixed branches for its changes. By default, Claude can only push to branches prefixed with claude/, which prevents routines from accidentally modifying protected branches.

Creating from the CLI with /schedule

Run /schedule in any session to create a scheduled routine conversationally. You can pass a description directly, for a recurring routine or a one-off:

/schedule daily PR review at 9am
/schedule clean up feature flag in one week

Claude walks through the same information the web form collects, then saves the routine to your account. /schedule creates scheduled routines only. To add an API or GitHub trigger, edit the routine on the web at claude.ai/code/routines.

The CLI also supports managing existing routines. Run /schedule list to see all routines, /schedule update to change one, or /schedule run to trigger it immediately. For custom cron intervals, pick the closest preset in the form, then run /schedule update to set a specific cron expression. The minimum interval is one hour.

Note that /schedule requires a claude.ai subscription login. If you are authenticated with a Console API key or a cloud provider like Amazon Bedrock, the command is hidden. The CLI must be v2.1.81 or later.

Schedule Triggers

A schedule trigger runs the routine on a recurring cadence, or once at a specific future time. Pick a preset frequency in the trigger section: hourly, daily, weekdays, or weekly. Times are entered in your local zone and converted automatically, so the routine runs at that wall-clock time regardless of where the cloud infrastructure is located.

Runs may start a few minutes after the scheduled time due to stagger. The offset is consistent for each routine, so the same routine always fires at the same offset from its scheduled time.

One-Off Runs

A one-off schedule fires the routine a single time at a specific timestamp. Use it to remind yourself later in the week, to open a cleanup PR after a rollout finishes, or to kick off a follow-up task when an upstream change lands. After the routine fires, it auto-disables and the web UI marks it as “Ran.” To run it again, edit the routine and set a new one-off time.

Create a one-off run from the CLI by describing the time in natural language. Claude resolves the phrase against the current time and confirms the absolute timestamp before saving:

/schedule tomorrow at 9am, summarize yesterday's merged PRs
/schedule in 2 weeks, open a cleanup PR that removes the feature flag

One-off runs do not count against the daily routine run cap. They consume your plan’s regular subscription usage like any other session. This makes them ideal for testing a new prompt before committing to a recurring schedule.

API Triggers

An API trigger gives a routine a dedicated HTTP endpoint. POSTing to the endpoint with the routine’s bearer token starts a new session and returns a session URL. Use this to wire Claude Code into alerting systems, deploy pipelines, internal tools, or anywhere you can make an authenticated HTTP request.

API triggers are added to an existing routine from the web. The CLI cannot currently create or revoke tokens. After saving the routine with an API trigger, the modal shows the URL and a sample curl command. Copy the URL, then click “Generate token” and copy the token immediately—it is shown once and cannot be retrieved later.

Send the token in the Authorization: Bearer header when you POST to the URL:

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."}'

A successful request returns a JSON body with the new session ID and URL:

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

The request body accepts an optional text field for run-specific context such as an alert body or a failing log. The value is freeform text and is not parsed: if you send JSON, the routine receives it as a literal string. Each routine has its own token, scoped to triggering that routine only. To rotate or revoke it, return to the same modal and click “Regenerate” or “Revoke.”

The /fire endpoint ships under the experimental-cc-routine-2026-04-01 beta header, since routines are in research preview. For the full API reference, see the Trigger a routine via API documentation on the Claude Platform.

GitHub Triggers

A GitHub trigger starts a new session automatically when a matching event occurs on a connected repository. Each matching event starts its own session—session reuse across events is not available, so two PR updates produce two independent sessions. GitHub triggers are configured from the web UI only.

The Claude GitHub App must be installed on the repository you want to subscribe to. The trigger setup prompts you to install it if it isn’t already. Running /web-setup in the CLI grants repository access for cloning, but it does not install the Claude GitHub App and does not enable webhook delivery.

Supported Events

GitHub triggers can subscribe to either of the following event categories. Within each, you can pick a specific action like pull_request.opened, or react to all actions:

EventTriggers when
Pull requestA PR is opened, closed, assigned, labeled, synchronized, or otherwise updated
ReleaseA release is created, published, edited, or deleted

Filtering Pull Requests

Use filters to narrow which pull requests start a new session. All filter conditions must match for the routine to trigger. The available filter fields are:

  • Author: PR author’s GitHub username
  • Title: PR title text
  • Body: PR description text
  • Base branch: Branch the PR targets
  • Head branch: Branch the PR comes from
  • Labels: Labels applied to the PR
  • Is draft: Whether the PR is in draft state
  • Is merged: Whether the PR has been merged

Each filter pairs a field with an operator: equals, contains, starts with, is one of, is not one of, or matches regex. The matches regex operator tests the entire field value, not a substring. To match any title containing “hotfix,” write .*hotfix.*. For literal substring matching without regex syntax, use the contains operator instead.

During the research preview, GitHub webhook events are subject to per-routine and per-account hourly caps. Events beyond the limit are dropped until the window resets.

The /loop Command

/loop is a bundled skill for running a prompt on repeat while the session stays open. It requires Claude Code v2.1.72 or later. Tasks are session-scoped: they live in the current conversation and stop when you start a new one. Resuming with --resume or --continue brings back any task that hasn’t expired.

Both the interval and the prompt are optional, and what you provide determines how the loop behaves:

What you provideExampleWhat happens
Interval and prompt/loop 5m check the deployFixed schedule
Prompt only/loop check the deployClaude chooses interval
Interval only or nothing/loopBuilt-in maintenance prompt

The interval can lead the prompt as a bare token like 30m, or trail it as a clause like every 2 hours. Supported units are s for seconds, m for minutes, h for hours, and d for days. Seconds are rounded up to the nearest minute since cron has one-minute granularity.

When you omit the interval, Claude chooses one dynamically. After each iteration it picks a delay between one minute and one hour based on what it observed: short waits while a build is finishing, longer waits when nothing is pending. The chosen delay and the reason for it are printed at the end of each iteration.

Customizing with loop.md

A loop.md file replaces the built-in maintenance prompt with your own instructions. Claude looks for the file in two locations and uses the first one it finds. The project-level file takes precedence when both exist:

  • .claude/loop.md: project-level, takes precedence
  • ~/.claude/loop.md: user-level, applies in any project without its own

The file is plain Markdown with no required structure. Write it as if you were typing the /loop prompt directly. Edits take effect on the next iteration, so you can refine the instructions while a loop is running. Content beyond 25,000 bytes is truncated.

Managing /loop Tasks

Ask Claude in natural language to list or cancel tasks. Under the hood, Claude uses three tools to manage scheduled tasks:

  • CronCreate: schedule a new task with a 5-field cron expression, the prompt to run, and whether it recurs or fires once
  • CronList: list all scheduled tasks with their IDs, schedules, and prompts
  • CronDelete: cancel a task by its 8-character ID

A session can hold up to 50 scheduled tasks at once. Recurring tasks automatically expire 7 days after creation—the task fires one final time, then deletes itself. To stop a /loop while waiting for the next iteration, press Esc. This clears the pending wakeup so the loop does not fire again.

All times are interpreted in your local timezone. A cron expression like 0 9 * * * means 9am wherever you are running Claude Code, not UTC. The scheduler adds deterministic jitter: recurring tasks fire up to 30 minutes after the scheduled time, and one-shot tasks scheduled for the top or bottom of the hour fire up to 90 seconds early.

Desktop Scheduled Tasks

The Desktop app’s Routines page lets you create both local scheduled tasks and remote routines. A local task runs on your machine with direct access to your files and tools, but only fires while the app is open and your computer is awake. A remote routine runs on Anthropic-managed cloud infrastructure even when your computer is off.

Click “Routines” in the sidebar, then “New routine” and choose “Local.” Configure the name, description, instructions, working folder, and schedule. The instructions input includes pickers for the permission mode and model. By default, scheduled tasks run against whatever state your working directory is in, including uncommitted changes. Enable the worktree toggle to give each run its own isolated Git worktree.

Schedule Options

Pick a preset from the Schedule control. Manual runs only when you click “Run now.” Hourly runs every hour. Daily shows a time picker, defaulting to 9:00 AM local time. Weekdays is the same as Daily but skips Saturday and Sunday. Weekly shows both a time picker and a day picker. For intervals the picker doesn’t offer, ask Claude in any Desktop session to set the schedule in plain language.

Missed Runs and Catch-Up

When the app starts or your computer wakes, Desktop checks whether each task missed any runs in the last seven days. If it did, Desktop starts exactly one catch-up run for the most recently missed time and discards anything older. A daily task that missed six days runs once on wake. Desktop shows a notification when a catch-up run starts.

Keep this in mind when writing prompts. A task scheduled for 9am might run at 11pm if your computer was asleep all day. If timing matters, add guardrails to the prompt itself: “Only review today’s commits. If it’s after 5pm, skip the review and just post a summary.”

To prevent idle-sleep, enable “Keep computer awake” in Settings under Desktop app, General. For tasks that need to run even when your computer is off, create a remote routine instead.

Permissions for Scheduled Tasks

Each task has its own permission mode, which you set when creating or editing the task. Allow rules from ~/.claude/settings.json also apply to scheduled task sessions. If a task runs in Ask mode and needs a tool it doesn’t have permission for, the run stalls until you approve it. The session stays open in the sidebar so you can answer later.

To avoid stalls, click “Run now” after creating a task, watch for permission prompts, and select “always allow” for each one. Future runs of that task auto-approve the same tools without prompting. A scheduled task can also modify its own schedule using the update_scheduled_task MCP tool, letting a task reschedule itself based on what it finds.

To edit a task’s prompt on disk, open ~/.claude/scheduled-tasks/<task-name>/SKILL.md. The file uses YAML frontmatter for name and description, with the prompt as the body. Changes take effect on the next run.

Environments and Network Access

Each routine runs in a cloud environment that controls network access, environment variables, and setup scripts. The routine inherits the environment’s network policy on every run. The Default environment uses Trusted network access: a default allowlist of package registries, cloud provider APIs, container registries, and common development domains is reachable, but arbitrary domains are not.

Outbound requests to non-allowlisted hosts fail with 403 and x-deny-reason: host_not_allowed. MCP connector traffic is routed through Anthropic’s servers, so connectors work without adding their hosts to the allowed domains list. To allow additional domains, edit the environment’s network access and switch to Custom, then enter your domains in the Allowed domains field.

You can also set environment variables for API keys, tokens, or other secrets Claude can use, and a setup script to install dependencies and tools the routine needs. The setup script result is cached, so the script doesn’t re-run on every session.

Usage and Limits

Routines draw down subscription usage the same way interactive sessions do. In addition to the standard subscription limits, routines have a daily cap on how many runs can start per account. See your current consumption and remaining daily routine runs at claude.ai/code/routines or claude.ai/settings/usage.

When a routine hits the daily cap or your subscription usage limit, organizations with usage credits turned on can keep running routines on metered overage. Without usage credits, additional runs are rejected until the window resets. One-off runs do not count against the daily routine cap—they draw down regular subscription usage but are exempt from the per-account daily routine run allowance.

Team and Enterprise Owners can disable routines for all members with the Routines toggle at claude.ai/admin-settings/claude-code. When disabled, existing routines stop running and members cannot create new ones.

A Worked Example

Imagine your team wants nightly PR reviews that post a summary to Slack each morning. Here’s how you’d set this up with routines, step by step.

First, create a routine from the web at claude.ai/code/routines. Name it “Nightly PR Review.” Write an explicit prompt: “Review all pull requests opened in the last 24 hours on the main repository. For each, check for security issues, performance regressions, and style violations. Post a summary to the #reviews Slack channel with PR title, author, and your assessment.”

Select your GitHub repository and a cloud environment with Trusted network access. Under connectors, keep Slack and GitHub, remove everything else. Under triggers, pick the Schedule tab and choose “Daily” at 9:00 AM local time. Click “Create.” The routine appears in your list and runs every weekday at 9 AM.

Each run creates a new session you can open to review what Claude did. A green status means the session started and exited without an infrastructure error—it does not mean the task succeeded. Always open the run to read the transcript and confirm what Claude actually did. Blocked network requests, missing connector tools, and task-level failures all surface there.

Now add a GitHub trigger so the routine also fires on every new pull request. Edit the routine, scroll to the trigger section, click “Add another trigger,” and choose “GitHub event.” Select your repository, pick pull_request.opened, and add a filter: is draft is false, so drafts are skipped. Save the trigger.

The same routine now runs on a nightly schedule and reacts to every new PR. Both triggers share the same prompt, repositories, and connectors. If the daily run gets too noisy, pause the schedule toggle and keep only the GitHub trigger active. If you need to trigger it manually for a one-off review, use the API endpoint with a curl call passing the PR URL as the text field.

This example shows how routines let you combine triggers. A single routine can handle scheduled work, event-driven work, and on-demand work—all pointing at the same prompt and repositories. That’s the power of routines over running individual headless commands.

routines: Common Mistakes to Avoid

Routines run autonomously, so small configuration errors compound across every run. Watch for these common pitfalls when setting up your routines:

  • Writing vague prompts: routines have no one to ask for clarification mid-run. A prompt like “review the code” is too open-ended. Specify exactly what to check, what to ignore, and where to post results.
  • Forgetting the daily run cap: routines have a daily cap on runs per account. A GitHub trigger on a busy repository can exhaust your allowance before the day ends. Add filters to limit which events fire.
  • Leaving all connectors enabled: all connected MCP connectors are included by default. A routine with access to Slack, Linear, and Google Drive when it only needs GitHub is a security risk. Remove what you don’t need.
  • Expecting green status to mean success: a green status means the session ran without an infrastructure error, not that the task succeeded. Blocked network requests and task-level failures surface in the transcript, not the status indicator.
Claude Code Routines: Easy Scheduling Guide — key concepts card

routines: Best Practices

  • Write self-contained prompts: include the goal, the scope, the output format, and what success looks like. Routines cannot ask follow-up questions mid-run, so every detail must be in the prompt.
  • Scope connectors to what’s needed: remove every connector the routine doesn’t use. Fewer tools means fewer ways for an autonomous session to take an unexpected action during a run.
  • Use one-off runs for experiments: test a new prompt with a one-off schedule before committing to a recurring trigger. One-off runs don’t count against the daily cap, so they’re free to iterate on.
  • Keep branch pushes restricted: leave the default claude/-prefixed branch restriction in place unless you have a specific reason to allow unrestricted pushes. This prevents routines from modifying protected branches.
  • Monitor the transcript, not the status: open each run to read what Claude actually did. The green status tells you the session ran, not that the work was correct or complete.
Claude Code Routines: Easy Scheduling Guide — best practices card

routines: Frequently Asked Questions

What is a routine in Claude Code?

A routine is a saved configuration—prompt, repositories, and connectors—that runs automatically on Anthropic-managed cloud infrastructure on a schedule, API call, or GitHub event.

How is /schedule different from /loop?

/schedule creates cloud routines that persist across sessions and run even when your machine is off. /loop runs a prompt on repeat within the current session only and stops when the session ends.

Do routines run when my computer is off?

Yes. Cloud routines run on Anthropic-managed infrastructure, so they keep working when your laptop is closed. Desktop scheduled tasks, by contrast, require the app open and computer awake.

What is the minimum interval for a routine?

Cloud routines have a minimum interval of one hour. Desktop scheduled tasks and /loop support a minimum interval of one minute for finer-grained scheduling.

How do I stop a routine?

Open the routine’s detail page at claude.ai/code/routines and use the toggle in the Repeats section to pause it. Paused routines keep their configuration but don’t run until re-enabled.

These questions cover the most common points of confusion. If you’re exploring automation further, the patterns above apply across all scheduling tools.

Routines let Claude Code run unattended on schedules, API calls, and GitHub events. Pair them with /loop for session-scoped polling and Desktop tasks for local file access, and you have a complete scheduling toolkit for any recurring workload.