Scheduled agents with Claude Code routines
Routines are cloud-hosted scheduled agents. Here is how to build a daily brief, an inbox triage, or a deploy watcher as a routine without your own server.
Routines have been part of Claude Code since April 2026. You give an agent a cron schedule and a prompt, and it runs autonomously at the chosen time without you having to be in the session. For many operators that replaces their own crontab with shell scripts or an n8n workflow.
The point: routines run on Anthropic infrastructure, not on your machine. Meaning: they run while you sleep, they survive reboots, and they see your repositories via the GitHub connection plus the connectors you picked when creating the routine.
State of April 2026, tested with Claude Code v2.1.118+, official docs. Available on Pro, Max, Team, Enterprise with Claude Code on the web enabled.
What you have at the end
Three running routines you have built from this playbook:
- A daily morning brief at 06:00 that summarizes sprint, MCP health and inbox status and sends it to you via Slack or email.
- An inbox triage at noon that labels new mails and archives unimportant ones.
- A deploy watcher that fires after every push to
mainand checks whether the production containers are healthy.
All three use connectors you pick during routine setup. No new code, only configuration.
Step 1: Create a routine
In Claude Code, type:
/schedule
Claude opens a conversation that asks for a name, a schedule (cron or natural language), a prompt, repositories, and connectors. You can also pass the description directly:
/schedule daily 06:00, run the morning-brief skill and post to Slack
For a one-off run in the future:
/schedule in 2 weeks, open a cleanup PR for the feature flag we just shipped
The routine is stored in your claude.ai account, not in a local file. It is account-scoped, not project-scoped, so it shows up in all your sessions and in the web UI at claude.ai/code/routines.
Through the CLI you only set up schedule triggers. API triggers and GitHub event triggers are added afterwards in the web UI.
Four subcommands you will use day to day:
/schedule list # show all your routines
/schedule update # edit a routine
/schedule run # fire a routine immediately, without waiting for the next slot
/schedule # create a new routine conversationally
Step 2: Morning brief
Routine morning-brief, schedule 0 6 * * 1-5 (Mon-Fri 06:00):
You are the morning brief bot. Task:
1. Read current sprint state via the memory connector
2. Check MCP fleet health
3. Read inbox status via the mail connector
4. Check today's follow-ups via the CRM connector
Write a 200-word brief in Reddit tone. What needs to happen today,
what stays open, what are the two most important decisions I need
to push on.
Send the brief via Slack (Slack connector, channel "morning-brief").
When creating the routine, pick the Slack connector plus the memory and CRM connectors in the connector picker. You do not need to add repositories because the bot is not working on code.
Mind the minimum cron interval: 1 hour. More frequent is not allowed via /schedule.
Step 3: Inbox triage
Routine inbox-triage, schedule 0 12 * * * (daily 12:00):
You are the inbox triage bot. Task:
1. Read new mails from the last 6 hours via the mail connector
2. Per mail: is this a lead, a vendor mail, a newsletter,
or a bot bounce?
3. Lead → label "lead" + automatic acknowledgement reply
4. Newsletter → archive
5. Bot bounce → archive
6. Vendor mail → label "vendor", leave for human review
7. Send a summary via Slack: "X mails triaged, Y archived, Z leads"
Important: do not let the bot archive important mails on its own. If it is unsure, it should leave the mail with label "review-needed".
Step 4: Deploy watcher
The deploy watcher works as a routine with an API trigger instead of a schedule. You first create the routine via /schedule (just prompt + repos + connectors), then go to claude.ai/code/routines, open the routine, and add an API trigger via "Add another trigger → API". You get an HTTP URL and a bearer token back.
Routine prompt:
You are the deploy watcher. You are triggered after a production deploy.
Task:
1. SSH connector to prod, read docker ps status
2. Curl the /health route of the app
3. If all green: short Slack confirmation "Deploy healthy"
4. If a container is unhealthy or /health failed:
- Pull the last 5 minutes of logs
- Slack alert with container name, status, logs
In your deploy script at the end, trigger the routine via HTTP POST:
curl -X POST https://api.anthropic.com/v1/claude_code/routines/trig_01ABC.../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": "Production deploy of commit abc123 just finished, please verify"}'
The routine starts a new session and returns the session ID plus URL. Store the token securely. It is shown once and cannot be retrieved later. To rotate it, open the same modal in the web UI and click "Regenerate" or "Revoke".
If you really need to wait 15 minutes after the deploy before the watcher checks, do not bake that into the routine itself. Instead, schedule the trigger from your deploy script with a delay (e.g. at now + 15 minutes or a separate cron line). Routines are not meant for long internal sleeps.
Limit: What routines CAN'T do
- No direct access to your local filesystem state. Routines run in Anthropic cloud sessions. They see your repos via clone (on the default branch at the start of each run) plus the connectors you picked.
- Minimum cron interval is 1 hour. More frequent is not possible via
/schedule. If you need minute-level triggers, that's a job for local crontab or a systemd timer. - Daily cap per account. Each account has a per-day routine run allowance. One-off runs (e.g.
/schedule in 2 weeks, ...) do not count against the cap, they draw from your regular subscription usage. - Routines can write only to
claude/-prefixed branches by default. To let a routine push tomainor other existing branches, enable "Allow unrestricted branch pushes" per repository in the routine editor.
Logs and debugging
Run logs live in the web UI at claude.ai/code/routines. Click on a routine, then on a single run. You see a full session, can review what Claude did, inspect changes, or open a pull request.
When a run failed silently, the most common causes are:
- A connector was removed after routine setup and the prompt still needs it
- Tool name in the prompt is outdated (e.g. because you updated the MCP server)
- Daily cap reached, status visible at claude.ai/settings/usage
What feels different from cron
With cron you write a bash script that calls another tool. With routines the routine itself is the agent: it has a prompt, it can think, it can decide based on what it finds what to do.
Example: your normal cron for "health check" is if curl -f / failed → send mail. A routine can instead "if health failed, look at logs why, classify whether it is a known pattern, and decide whether to alert or first try restart". More intelligence, less brittleness.
Next steps
Once you have the setup from this playbook running with three routines, look at the crews we build in Level 5. That is the step from "one agent does one task" to "multiple agents work together".
Plus: routines are flat-rate on Max Plan, on Pro only with limited capacity. If you have many routines running in parallel, Max Plan is cheaper.
Source
The mechanics described here come from the official Anthropic docs at code.claude.com/docs/en/routines. If a flag, file path, or subcommand is not described there, it does not exist.