# #16: Running Prompts on a Loop 🔁

> /loop, a quick way to have Claude Code re-run a prompt on a schedule while our session stays open. It's handy for the stuff we'd otherwise keep checking by...

Published 2026-11-16 by Jake Marsh on Little Cups of Claude. Canonical: https://littlecupsofclaude.com/16
Topics: [Workflows](https://littlecupsofclaude.com/topics/workflows), [Claude Code CLI](https://littlecupsofclaude.com/topics/claude-code-cli)

Today we'll check out `/loop`, a quick way to have **Claude Code** re-run a prompt on a schedule while our session stays open.

It's handy for the stuff we'd otherwise keep checking by hand: a deploy that's still rolling out, a PR waiting on CI, a build that takes around ~20 minutes or so. Let's dive in.

## Three Ways To Call It

`/loop` is a bundled skill, and what we pass it decides how it behaves:

```text
/loop 5m check if the deploy finished
/loop check whether CI passed
/loop
```

The first runs our prompt on a fixed schedule. The second lets **Claude** pick the wait between runs. The third runs a built-in maintenance prompt that keeps working on whatever's unfinished in the conversation.

## Fixed Intervals

Intervals can lead the prompt (`30m`) or trail it as a clause (`every 2 hours`). Units are `s`, `m`, `h`, and `d`:

```text
/loop 15m check the release PR for new review comments
/loop run the smoke tests every 2 hours
```

Under the hood this becomes a cron job, so seconds round up to the nearest minute. Intervals that don't map to a clean cron step, like `7m` or `90m`, get rounded to one that does, and **Claude** tells us what it picked.

We can also loop a skill:

```text
/loop 20m /review-pr 1234
```

Only skills **Claude** is allowed to invoke on its own will actually run. Built-in commands like `/clear` and skills with `disable-model-invocation: true` arrive as plain text instead.

## Letting Claude Pick The Pace

Leaving off the interval makes the loop self-paced. After each run, **Claude** picks a delay between one minute and one hour based on what it saw, short waits while a build is wrapping up and longer ones once things go quiet, and prints the delay and the reason at the end of each iteration.

It can also end the loop on its own once the job's done. Neat!

## Our Own Default Prompt

A bare `/loop` normally runs the built-in maintenance prompt. To swap in our own, we drop a `loop.md` in `.claude/` for the project, or in `~/.claude/` for every project:

```loop.md
Check the `release/next` PR. If CI is red,
read the failing job log and push a minimal fix.
If new review comments came in, address them.
If everything is green and quiet, say so in one line.
```

Edits take effect on the next iteration, so we can tweak it while a loop is running. The project file wins when both exist.

## One-Time Reminders

For a single run, we skip `/loop` and just ask:

```text
remind me at 3pm to push the release branch
in 45 minutes, check whether the integration tests passed
```

**Claude** schedules a one-shot task that deletes itself after it fires. Asking `what scheduled tasks do I have?` lists everything, and `cancel the deploy check job` removes one.

## Watch Out

A few things that are easy to trip over:

- Tasks only fire while **Claude Code** is running and idle. Closing the terminal stops them.
- A fixed-interval loop ignores `Esc` and `Ctrl+C`. We stop it by asking **Claude** to cancel it. A self-paced loop stops with `Esc` while it's waiting.
- Recurring tasks expire after 7 days, firing one last time before they're deleted.
- Times are in our local timezone, and runs get a bit of jitter, so an hourly task can start up to around ~30 minutes late.

For anything that has to run without our laptop open, cloud routines or **GitHub Actions** are a better fit.

More info about **scheduled tasks** can be found at [the Claude Code docs](https://code.claude.com/docs/en/scheduled-tasks).
