Part 4 · Scale & Automation

Mastering Claude Code · ~7 min

Scheduling & Cloud Routines

Stop babysitting a terminal at 9am. Recurring work belongs on a schedule — and the only real decision is which machine runs it.

Why this, for you: you keep an open session alive just to re-run the same check — poll a deploy, sweep for docs drift, audit dependencies. The moment your laptop sleeps or you close the terminal, the schedule dies. There are two fixes, and picking the wrong one either loses your working tree or opens an unattended security hole.

Claude Code gives you two scheduling surfaces with one clean dividing line: where the run executes. Local scheduling stays inside your session; cloud routines run on Anthropic infrastructure. Everything else — cadence, file access, permission gates — follows from that one choice.

1 Local scheduling: /loop and the cron tools

Session scheduling re-runs a prompt automatically inside an active session. The interactive entry point is the /loop bundled skill — pass an optional interval and a prompt, and Claude converts it to a cron expression:

# every 5 minutes, until the loop cancels itself /loop 5m check if the deployment finished and tell me what happened # no interval → Claude picks a 1-minute–1-hour delay each iteration /loop check the build

Units are s, m, h, d; seconds round up to the nearest minute. Under the hood, agents and skills drive the same machinery with three tools: CronCreate (schedule a task), CronList (list tasks with IDs), and CronDelete (cancel by 8-character ID). Expressions are standard 5-field cron — wildcards, steps (*/15), ranges, comma lists — with a 50-task-per-session cap.

A bare /loop runs a built-in maintenance prompt; override it with a plain-Markdown .claude/loop.md (project-level wins over ~/.claude/loop.md). Edits take effect on the next iteration — no restart.

For a deferred one-off, just describe it: remind me at 3pm to push the release branch schedules a single-fire task that auto-deletes after running. A few execution facts worth holding: tasks fire between turns (never mid-response), in your local timezone, with deterministic jitter, and no catch-up — a fire missed while Claude is busy runs once when idle, not once per missed interval.

It dies with the terminal

Local scheduling is session-scoped only. Closing the terminal or restarting Claude Code cancels everything. Recurring tasks also expire 7 days after creation. This is a convenience layer, not durable infrastructure — which is exactly the gap cloud routines fill.

2 Cloud routines: durable, but a different machine

A Routine is a saved Claude Code configuration — prompt, repos, connectors, environment — that runs on Anthropic-managed cloud infrastructure on a schedule, an API call, or a GitHub event. Create one from the CLI with /schedule. It is the cloud counterpart to /loop and CronCreate, and the deployment choice is a clean trade: cloud fixes host-uptime and env-drift failures but breaks working-tree fidelity, the permission gate, and sub-hour cadence.

DimensionCloud Routine/loop
Runs onAnthropic cloudYour machine
Machine on?NoYes
Open session?NoYes
Local filesNo — fresh clone of default branchYes — working tree
Permission promptsNone — runs autonomouslyInherits from session
Minimum interval1 hour1 minute

Choose cloud when all hold: cadence is hourly or slower (sub-hour cron is rejected), work runs against the default branch (each run clones fresh from it — in-flight feature work is invisible), no mid-run human approval is needed, and every required resource is reachable from the cloud environment. Move scheduled work to the cloud when the local box is the failure point — laptops that sleep, reboots that drop cron, dev-env drift, rotated secrets.

3 The cloud trade has teeth

The same "always on, no prompts, acts as creator" posture that makes routines durable is what opens their failure surfaces. Three are worth memorizing:

When the decision lands on cloud, three settings shrink the blast radius: keep the claude/-prefixed branch-push restriction, trim the connector list (every connected connector is included by default and callable with no per-tool prompt), and keep the network policy at Trusted — widen only when a run fails on a 403.

The rule of thumb writes itself. A weekly dependency audit against main fits cloud cleanly — autonomous PR posture is the point. A hotfix loop watching CI on your current feature branch does not: it needs the live branch, 5-minute granularity, and the in-session prompt on git push.

↪ Your win: recurring work, off your machine, with eyes open

Retrieval practice — recall, don't peek

Question 1Local /loop scheduling stops working the moment you…

Question 2A cloud routine sees your repo as…

Question 3The minimum interval a cloud routine accepts is…

Question 4"Identity collapse" in a cloud routine means…

Question 5 · spaced recall from an earlier lessonTo run isolated parallel work in a monorepo without agents colliding, you reach for…

Ask me anything. Want help deciding whether a specific recurring job belongs in a /loop or a cloud routine, or how to trim a routine's connector list to close the trifecta? Next, the capstone: The Claude Code Decision Table — symptom to move, picking the right Claude Code surface for the job.
✎ Feedback