# Work that runs on a clock

Claude Code has three places to run something repeatedly: cloud routines, Desktop scheduled tasks and the in-session /loop. They differ in where they run, how often they can fire and what survives.

## Three places, three trade-offs

The first question is not how to schedule something. It is where it will run, because that decides everything else.

- **Cloud routines**, set up with `/schedule`, run without your machine. The minimum interval is 1 hour.
- **Desktop scheduled tasks** run on your machine. When Claude sets one, the minimum is 1 minute.
- **`/loop`** runs inside an open session.

```flow
Need it when your laptop is closed?
Yes: a cloud routine, hourly at most
No, my machine can stay on: a Desktop task
Only while you are working: /loop
```

The rule is plain. If the job must happen when you are not there, it cannot depend on your machine being awake, and that costs you a coarser clock.

**Question:** What is the shortest interval a cloud routine can use?

- 1 minute
- 10 minutes
- 1 hour
- 24 hours

**Answer:** 1 hour. Cloud routines run without your machine but have a minimum of 1 hour. The 1 minute minimum belongs to Desktop scheduled tasks.


## /loop in practice

`/loop` has three forms.

- `/loop 5m prompt` runs on a fixed interval.
- `/loop prompt` lets Claude pick the interval each time, which suits work where the right gap depends on what it sees.
- A bare `/loop` runs a built-in maintenance prompt, or your own.

Your own lives in `.claude/loop.md` in the project, which wins, or `~/.claude/loop.md` for the user. It replaces the default bare-loop prompt, and edits apply on the next iteration, so you can tune a running loop by editing a file.

```terminal
$ claude
> /loop 5m check whether the deploy finished and tell me if it failed
* Schedules the check every 5 minutes
* Runs it, reports "still building"
# Esc and Ctrl+C will not stop it. Ask Claude to cancel the loop.
```

That last point surprises people. To stop a fixed-interval loop, ask Claude to cancel it. Esc and Ctrl+C do not.

## What a scheduled fire cannot do

A scheduled run has no one to answer it, so it is restricted. It cannot run built-in commands, skills marked `disable-model-invocation`, or MCP prompts. If your loop prompt depends on a slash command, it will not work the way it does when you type it.

Limits to know:

- A session holds at most 50 scheduled tasks.
- Each has an 8-character ID that `CronDelete` takes, and `CronList` shows the next run times.
- Session tasks are restored on `--resume` unless they expired. The expiry is seven days.

> **A loop is not a promise**
Session tasks live in a session. Close it and let seven days pass, and the schedule is gone. For something you depend on, use a routine or a Desktop task, not a loop you started on Monday.


## Background work

Scheduling is not the only way to keep work going without you watching. `claude --bg` starts a background agent. `claude --bg --exec 'pytest -x'` runs a shell job in the background as a PTY job.

Two neighbours are worth knowing. For reacting to events instead of polling, use Channels. To keep working toward a condition, use `/goal`. A loop asks "is it time yet?" on a clock. These ask "did something happen?" or "are we there?", which is often what you actually meant.

> **Print mode waits for loops**
A `claude -p` run waits for pending `/loop` wakeups before exiting, with idle waiting cut at 10 minutes. If a headless script hangs at the end, a loop it started may be why.


> **Watch a loop edit itself**
Create `.claude/loop.md` with one line, such as "check git status and tell me if anything is uncommitted". Run a bare `/loop`, then change the file while it is running. The next iteration uses the new text.


**Question:** How do you stop a fixed-interval /loop?

- Press Esc
- Press Ctrl+C
- Ask Claude to cancel it
- Close the terminal tab only

**Answer:** Ask Claude to cancel it. Esc and Ctrl+C do not stop it. You ask Claude to cancel the loop, which removes the scheduled task.
