GuideAgentic ways of working · Intermediate

Routines: scheduled agents that open pull requests

Claude Code routines run a saved prompt in the cloud on a schedule, an API call or a GitHub event. Setup, environments, connectors, prompts that run unattended, three real routines, and local options: /loop, cron with claude -p, and GitHub Actions.

Checked 13 Oct 202621 min read1 prompt5 routines

On this page
  1. What it is
  2. When to use it
  3. How it works
  4. Members only: Set it up step by step
  5. Members only: Write prompts that run unattended
  6. Members only: Recipes
  7. Members only: Local and CI alternatives
  8. Members only: Scheduled tasks in Claude apps and ChatGPT
  9. Members only: Review the runs
  10. Members only: Limits and costs
  11. Members only: Patterns that work
  12. Members only: Mistakes to avoid
  13. Members only: Exercises

Some agent work should happen while nobody is watching: the CI digest that is waiting when you start the day, the dependency fixes that arrive as a pull request three times a week, the docs refresh every Monday. A routine is a saved prompt that Claude Code runs on its own, in the cloud, and ends with something a person reviews.

What it is#

A Claude Code routine packages a prompt, one or more GitHub repositories, a cloud environment and a set of connectors, then runs it automatically. Each run is a full Claude Code session on Anthropic-managed infrastructure, so it keeps working when your laptop is closed. Routines are a research preview, available on the Pro, Max, Team and Enterprise plans.

A routine starts from one or more triggers:

  • Schedule. Hourly, daily, on weekdays, weekly, a custom cron expression, or once at a set time. The minimum interval is one hour.
  • API. An HTTP POST to the routine's own endpoint with a bearer token, for example from your alerting tool or deploy script.
  • GitHub event. A pull request or release event on a repository, narrowed by filters such as base branch, labels or draft state.

One routine can combine all three. A review routine can run nightly, fire from a deploy script, and react to every new pull request.

1. The cron schedule 0 5 * * 1 fires at Monday 05:00 UTC. 2. A cloud session starts with a fresh checkout of the repository. 3. The agent researches and edits files. 4. Lint, tests and the build run, and they pass. 5. The agent opens a pull request. 6. Later that morning a person reviews the pull request and merges it. 7. The site deploys.Mon 04:58 UTCcron 0 5 * * 1Fresh checkoutcloud sessionResearch + editagent reads, editsChecks runlint, tests, buildPull requestopens for reviewYou reviewand mergeSite deploysships to productionlive

Every run starts from a fresh clone. Claude reads the repository's CLAUDE.md and committed skills, does the work without stopping for permission prompts, pushes changes to a branch named claude/..., and leaves its output where the prompt says: a pull request, a comment, a Slack message through a connector. You open the run's session later to see exactly what it did.

When to use it#

Routines suit work that is unattended, repeatable and tied to a clear outcome.

  • Digests. A daily CI health report, a Monday review-queue summary, a weekly list of stale feature flags.
  • Maintenance with a check. Dependency and CVE sweeps, lint debt, docs that reference changed APIs. Each ends in a pull request with test output.
  • Event-driven review. A team checklist applied to every new pull request, or a port of each merged change to a sister SDK.
  • Alert triage. Your monitoring tool calls the API trigger with the alert text, and the routine correlates it with recent commits and opens a draft fix.

Choose something else when the job does not fit:

You needUse instead
Local files, local tools or your machine's networkA Desktop scheduled task, which runs on your computer
Polling every few minutes while you work/loop inside an open session
A step inside your existing CI, gated like other jobsGitHub Actions with the Claude Code action
Approval in the middle of a runA normal session. Routines never pause for permission
Runs more often than hourly/loop, a Desktop task, or cron with claude -p
A pure version bump with no judgmentDependabot security updates already open those pull requests

Do not schedule anything irreversible. A routine proposes. A person merges, deploys and sends.

How it works#

Five things decide what a run can do.

  1. The prompt. The trigger delivers your saved prompt as the session's task. Nobody is there to answer questions, so it must say what to do, where the output goes and what done looks like.
  2. The repositories. Each one is cloned at the start of every run, starting from its default branch. A pull request trigger starts the first repository from the pull request's head commit.
  3. The environment. It sets network access, environment variables and a setup script whose result is cached for later runs. The default environment allows package registries, GitHub, cloud SDKs and Anthropic's own sites, and blocks everything else.
  4. The connectors. Every claude.ai connector you include is available with all of its tools, writes included, and no approval step. Remove the ones a routine does not need.
  5. Your identity. A routine belongs to your claude.ai account. Its commits, pull requests and connector actions appear as you, and its runs count against your plan's usage.

Schedules are stored in UTC. The web form takes times in your local zone and converts them, and a custom cron expression goes in with /schedule update in the CLI. A run scheduled exactly on the hour can start several minutes late, so pick a few minutes past, such as 06:07. A one-off run fires once and then disables itself.

A green status in the run list means the session started and exited without an infrastructure error. It does not mean the task succeeded. Read the run.

Set it up step by step

1. Prepare the repository Commit what every run needs: a CLAUDE.md with build and test commands, and any skills under .claude/skills/ . Cloud sessions do not read anything from your machine, including ~/.claude/skills/ , ~/.claude/CLAUDE.md and MCP servers you added with claude mcp add at ...

Members only below this line

Get the rest of this guide free

What you get on this page:

  • 1 prompt
  • 5 routines

Free. You also get Stratiflux Weekly: one email a week, unsubscribe anytime.

Also in the members part

  1. Write prompts that run unattended
  2. Recipes
  3. Local and CI alternatives
  4. Scheduled tasks in Claude apps and ChatGPT
  5. Review the runs
  6. Limits and costs
  7. Patterns that work
  8. Mistakes to avoid
  9. Exercises

Sources

Checked against these on 13 Oct 2026.

  1. Automate work with routines (Claude Code docs) (opens in a new tab)code.claude.com
  2. Configure cloud environments (Claude Code docs) (opens in a new tab)code.claude.com
  3. Run prompts on a schedule with /loop (Claude Code docs) (opens in a new tab)code.claude.com
  4. Schedule recurring tasks in Claude Code Desktop (opens in a new tab)code.claude.com
  5. Run Claude Code programmatically (claude -p) (opens in a new tab)code.claude.com
  6. Claude Code GitHub Actions (opens in a new tab)code.claude.com
  7. anthropics/claude-code-action (opens in a new tab)github.com
  8. Schedule recurring tasks in Claude Cowork (Claude Help Center) (opens in a new tab)support.claude.com
  9. Scheduled tasks in ChatGPT (opens in a new tab)learn.chatgpt.com
  10. About Dependabot security updates (opens in a new tab)docs.github.com