Products·6 min read·Anthropic

How to Use Claude Code Routines: Schedule an AI Agent to Run in the Cloud

A practical, illustrated walkthrough of Claude Code routines — saved prompts that run themselves in Anthropic’s cloud on a schedule, an API call, or a GitHub event. How to create one with /schedule or the web UI, write a prompt that behaves, pick a cadence, and worked examples you can copy.

GUIDE · CLAUDE CODE ROUTINES Put your AI agent on a schedule A saved prompt that runs itself in the cloud — on a timer, an API call, or a GitHub event. TRIGGERS Schedule (cron) API call GitHub event ROUTINE A saved prompt + repositories + allowed tools CLOUD RUN Full Claude Code session, then posts output Create it with /schedule in the CLI, or at claude.ai/code/routines. BITSMINDS.COM Source: Anthropic
Share:

If you have ever wished Claude Code could keep working after you close the laptop, that is exactly what routines are for. A routine is a saved task — a prompt, the repositories it can touch, and the tools it is allowed to use — that runs by itself in Anthropic's managed cloud. Think of it as cron for agents: you describe the job once, choose when it should fire, and every trigger spins up a complete Claude Code session that reasons through the work and reports back.

This guide walks through the whole loop — what a routine is, the three ways to trigger one, how to create one from the CLI or the web, how to pick a schedule, how to write a prompt that behaves itself, and a few worked examples you can adapt today.

What a routine actually is

Locally, Claude Code runs in your terminal and stops when you do. A routine lifts that same workflow into Anthropic's cloud and gives it a trigger. Each run is a fresh, full-capability Claude Code session: it can read the repos you connected, call the tools you granted, hit external services, and — crucially — recover when something goes wrong, trying a different approach instead of silently failing the way a shell script would. The hero above shows the shape of it: a trigger fires, the routine (prompt + repos + tools) wakes up, and a cloud session does the work and posts its output.

The three ways to trigger a routine

A single routine can be wired to one trigger or several at once:

  • Schedule (cron): run on a timer — hourly, daily, on weekdays, or weekly.
  • API call: kick it off from your own systems with an HTTP request, handy for "run after deploy" style automation.
  • GitHub event: fire in response to repository webhooks — a new issue, a pushed branch, an opened pull request.

Create one from the CLI with /schedule

The fastest way to make a routine is the /schedule slash command inside Claude Code. Describe the job in plain language and it walks you through naming, the prompt, which repositories to attach, and the trigger:

/schedule daily PR review at 9am

The new routine shows up immediately at claude.ai/code/routines. A handful of sub-commands manage the rest:

/schedule          # start the guided setup
/schedule list     # see every routine you own
/schedule update   # change the prompt, schedule, or tools
/schedule run      # trigger one now, to test it

Create one in the web UI

Prefer clicking? Head to claude.ai/code/routines and:

  1. Click New routine and give it a name.
  2. Write the prompt — this is the most important step, because the routine runs it autonomously.
  3. Select the GitHub repositories the routine should clone.
  4. Choose the cloud environment it runs in.
  5. Add one or more triggers (schedule, API, GitHub events, or a combination).
  6. Review the connected tools and remove anything it does not need.
  7. Click Create, then hit Run now to test it once.

Pick a schedule

Scheduled routines come with four presets, with times entered in your local timezone and converted for you:

Built-in schedules Hourly every hour Daily your local time Weekdays Mon–Fri Weekly pick a day Need every two hours? Set a cron expression with /schedule update — the minimum interval is one hour.

For a custom cadence like "every two hours," pick the closest preset in the web UI and then run /schedule update to set an explicit cron expression — for example 0 9 * * 1-5 for 9am on weekdays. The minimum interval is one hour. Runs may start a few minutes after the scheduled time because of staggering, but the offset is consistent, so a 9am routine always fires at the same 9-ish each day.

Write a prompt that behaves

A routine has no human watching it mid-run, so the prompt has to carry all the judgment up front. Four habits make the difference between a routine you trust and one you babysit:

Anatomy of a routine prompt 1 Define success “Review open PRs in /auth for SQL-injection and missing validation.” 2 Set boundaries “Open draft PRs only. Never merge. Never push to main.” 3 Handle edge cases “If nothing changed since the last run, post ‘nothing to do’ and exit.” 4 Say where output goes “Post the summary to #releases in Slack.”

The pattern is always the same: say precisely what "done" looks like, fence off what it must never do, describe the boring "nothing to do" path, and tell it exactly where the result should land.

Worked examples

1. Nightly dependency updates. A daily routine that keeps your lockfile fresh without anyone lifting a finger:

Scan package.json and the lockfile for outdated dependencies.
Open one draft PR per update with the changelog summarized in the
description. Never bump a major version of React or Next.js without
flagging it for review. If everything is current, post "deps are
clean" to #eng and exit.

2. Morning issue triage. A weekday routine (optionally also wired to the GitHub "issue opened" event) that grooms the backlog before standup:

Read issues opened since the last run. Apply area labels, set
priority from the template's severity field, and assign an owner
based on the code paths the issue touches. Post a grooming summary
to #triage. Never close or comment on issues older than 30 days.

3. Weekly release notes. A Monday-morning routine (0 9 * * 1) that turns merged work into a changelog PR:

List the PRs merged to main since last Monday. Group them into
features, fixes, and chores, draft human-readable release notes, and
open a PR adding them to CHANGELOG.md. Flag any merged PR that
changed a public API but did not touch the docs.

Manage and test your routines

Everything you create lives in the routines dashboard. Use Run now (or /schedule run) to fire one on demand while you are still tuning the prompt, /schedule update to change its behaviour, and /schedule list to see them all. The dashboard's Calendar tab gives you a visual timeline of upcoming runs so two routines do not pile onto the same hour.

Limits and plans

Daily run caps scale with your plan: roughly five routine runs a day on Pro, fifteen on Max, and twenty-five on Team and Enterprise, with additional runs available through paid usage. Start with one or two high-value jobs, watch what they produce for a week, and tighten the prompts before you add more.

Comments

Share your thoughts. Be kind.

0/2000

Loading comments…

Related Articles