# Claude Code Routines and /loop scheduling

> Claude Code: Cloud routines, /schedule, /loop, Cron tools, Desktop tasks, GitHub/API triggers, network permissions and cache strategy.

URL: https://docs.passion8.cc/en/docs/claude-code/routines-scheduling
Language: en
Publisher: Passion8

Claude Code offers local-session scheduling and hosted scheduling:

| Method | Runs in | Suitable for |
| --- | --- | --- |
| `/loop` and Cron tools | Current local session | Waiting for CI, polling deployments and temporary reminders |
| Routines and `/schedule` | Anthropic cloud | Schedules while your computer is off, API/GitHub triggers |
| Desktop scheduled tasks | Local Desktop | Local files/tools without an open CLI session |
| GitHub Actions | CI | Repository events, standardized auditing and team workflows |




Local `/loop` is the straightforward choice with Passion8. Routines and `/schedule` are claude.ai cloud features, generally requiring subscription authentication and the official cloud environment.




## `/loop`

Each trigger is an ordinary prompt turn, inheriting the session's context, permissions, MCP, model and Passion8 configuration.

```text
/loop 5m check whether the deployment finished
```

```text
/loop check CI and address any review comments
```

| Syntax | Behavior |
| --- | --- |
| `/loop 5m <prompt>` | Fixed interval |
| `/loop <prompt>` | Claude chooses the next interval based on findings |
| `/loop` | Built-in maintenance prompt or `.claude/loop.md` |
| `/loop 20m /review-pr 1234` | Periodically invokes an automatically callable skill |

Units include `s`, `m`, `h` and `d`. Cron rounds seconds up to minutes and adjusts intervals that do not divide evenly to an approximate cadence.

## `loop.md`

Customize the prompt for bare `/loop`:

| Path | Scope |
| --- | --- |
| `.claude/loop.md` | Project, higher priority |
| `~/.claude/loop.md` | User default |

```markdown title=".claude/loop.md"
Check the current PR. If CI failed, retrieve the failure logs and fix the issue.
Address and reply to review comments. If everything is quiet, output one status line.
```

Keep it short. Overlong content may be truncated, and adding it every turn increases fixed context cost.

## Cron tools

Ask for session-scoped scheduled tasks:

```text
in 45 minutes, check whether the integration tests passed
```

```text
remind me at 3pm to push the release branch
```

| Tool | Purpose |
| --- | --- |
| `CronCreate` | Create one-shot or recurring tasks |
| `CronList` | List this session's scheduled tasks |
| `CronDelete` | Cancel by task ID |

| Limit | Details |
| --- | --- |
| Current session required | Closing the terminal or starting another session stops execution |
| Resume | Unexpired recurring tasks or future one-shots can resume |
| Seven-day expiry | Recurring tasks are deleted seven days after creation |
| No catch-up runs | Multiple missed triggers are not all replayed |
| Per-session cap | Official documentation specifies at most 50 scheduled tasks |

## Cache strategy

| Interval | Five-minute TTL | One-hour TTL |
| --- | --- | --- |
| 1–4 minutes | Likely warm | Warm |
| 5–10 minutes | Borderline or cold | Usually warm |
| 15–60 minutes | Usually cold | Usually warm |
| Over one hour | Cold | Cold |

1. Each `/loop` trigger is a normal turn and can refresh the cache.
2. Waiting beyond TTL requires reading history again.
3. Dynamic loops choosing long waits should not assume a continuously warm five-minute cache.
4. Background sessions remain the same session, but paused time does not refresh TTL.
5. Cloud routines use separate sessions and do not share local Passion8 caches.

## Routines

A routine saves its prompt, repository, environment, connectors and triggers. It runs in Anthropic's cloud, even when your computer is off.

| Trigger | Use |
| --- | --- |
| Schedule | Hourly, daily, weekly or at a future time |
| API | POST to a routine endpoint |
| GitHub event | PR or release events |

| Scenario | Example |
| --- | --- |
| Backlog maintenance | Organize issues, label them and synchronize Slack |
| Alert triage | Analyze logs and draft a PR after an alert |
| Custom review | Comment on new PRs using a team checklist |
| Deployment verification | Run smoke checks and report after deployment |
| Documentation drift | Scan changes weekly and draft documentation PRs |

## `/schedule`

Create/manage routines conversationally from the CLI:

```text
/schedule daily PR review at 9am
```

```text
/schedule tomorrow at 9am, summarize yesterday's merged PRs
```

| Command | Purpose |
| --- | --- |
| `/schedule list` | List routines |
| `/schedule update` | Modify a routine |
| `/schedule run` | Trigger immediately |
| `/schedule <description>` | Create a scheduled routine |

CLI creation primarily uses schedule triggers. Configure API/GitHub triggers at [claude.ai/code/routines](https://claude.ai/code/routines).

## Routine permissions and networking

Cloud routines run autonomously rather than requesting approval for every tool call. Limit their access:

| Item | Control |
| --- | --- |
| Repositories | Select only required repositories |
| Branch pushes | Default `claude/` prefix; avoid unrestricted access without need |
| Connectors | Remove unrelated connected services |
| Variables | Supply only necessary secrets |
| Network | Trusted allowlist by default; explicitly add required domains |
| Setup script | Installs dependencies/tools with environment caching |

MCP connector traffic uses Anthropic-hosted connections; this does not guarantee the cloud VM can access the same domain. Use local `/loop` or Desktop tasks for local databases, LAN services or files.

## API triggers

An API trigger provides a dedicated URL and bearer token. POST to `/fire` starts a new session and returns its ID/URL. An optional `text` field carries alert, log or deployment details.

```bash
curl -X POST https://api.anthropic.com/v1/claude_code/routines/trig_xxx/fire \
  -H "Authorization: Bearer sk-ant-oat01-xxxxx" \
  -H "anthropic-beta: experimental-cc-routine-2026-04-01" \
  -H "anthropic-version: 2023-06-01" \
  -H "Content-Type: application/json" \
  -d '{"text": "prod deploy failed, check alert SEN-4521"}'
```

This research-preview API may change headers, limits and response shape. Keep tokens out of repositories.

## Choosing with Passion8

| Need | Recommendation |
| --- | --- |
| Periodic local checks using Passion8 | Local `/loop` |
| Interval over five minutes but under one hour | Supported one-hour TTL, or accept cold starts |
| Run while the computer is off | Official routines or GitHub Actions |
| Local files, databases or LAN | Local `/loop` or Desktop tasks |
| API-triggered Claude work | Official Routine API, or your own CI wrapper around `claude -p` |
| Fewer tokens | Short prompts, stable rules in CLAUDE.md, no large repeated logs |

## Troubleshooting

| Problem | Common cause |
| --- | --- |
| `/schedule` unknown | No subscription login, old version, nonessential traffic disabled, or invocation inside a web session |
| Routine does not run | Organization disabled it, daily cap reached, or insufficient usage credits |
| Cloud private-service 403 | Domain missing from environment network permissions |
| GitHub trigger does not fire | Missing GitHub App or unmatched filter |
| `/loop` does not continue | Session closed, task expired, or Esc stopped waiting |

## Official references

- [Scheduled tasks](https://code.claude.com/docs/en/scheduled-tasks.md)
- [Routines](https://code.claude.com/docs/en/routines.md)
- [Claude Code on the web](https://code.claude.com/docs/en/claude-code-on-the-web.md)
- [Commands](https://code.claude.com/docs/en/commands.md)
- [Prompt caching](https://code.claude.com/docs/en/prompt-caching.md)
