Syntax
/loop [interval] <prompt or slash command>
The interval is optional. Without it, the loop runs in dynamic mode. The body can be a plain-English instruction or another slash command.
Interval formats
Accepted shorthand:
30s— every 30 seconds (subject to floor clamp).5m— every 5 minutes.2h— every 2 hours.1h30m— combination.
The runtime enforces a minimum interval (typically 60s) to prevent runaway loops. Anything below the floor is clamped up.
Fixed-interval mode
Pass an interval to get exact, predictable cadence.
/loop 10m /code-review
Behavior:
- Task runs immediately.
- Next run is scheduled exactly N units after the previous one starts.
- If a run takes longer than the interval, the next run starts as soon as the previous finishes.
Dynamic mode
Omit the interval. Claude self-paces by calling ScheduleWakeup at the end of each run.
/loop poll the deploy and end the loop when it is live
Use dynamic mode when:
- The polling rate should change based on observed state.
- You are waiting on external work that has variable duration.
- You want Claude to choose to stop on its own.
ScheduleWakeup
The tool Claude uses to schedule the next iteration in dynamic mode. Parameters:
delaySeconds— wait time, clamped to [60, 3600].prompt— the prompt to re-fire on wake-up. Pass the original verbatim.reason— short telemetry string shown to you. Be specific.
Special prompt sentinels:
<<autonomous-loop-dynamic>>— resumes an autonomous loop with no user prompt.
Stopping a loop
Four ways:
/loop stop— explicit halt in the active session.- Close the Claude Code session.
- The model omits
ScheduleWakeupin dynamic mode. - The runtime cancels on certain unrecoverable errors.
Autonomous loops
Loops can run without a user-supplied prompt by using the sentinel <<autonomous-loop-dynamic>> in the prompt field. The runtime resolves it to a built-in autonomous-loop instruction at fire time.
There is a sister sentinel <<autonomous-loop>> for CronCreate-based autonomous loops. Do not mix them up — ScheduleWakeup always uses the -dynamic variant.
/schedule vs /loop
| Aspect | /loop | /schedule |
|---|---|---|
| Where it runs | Active local session | Cloud routine, cron-driven |
| Survives session close | No | Yes |
| Best for | Attended monitoring | Unattended automation |
| Pacing | Fixed or dynamic | Cron expression |
| Cost model | Per iteration in your session | Cloud agent runtime |
Skills and slash commands inside loops
Any installed skill or slash command can be wrapped in a loop:
/loop 1h /security-review /loop 15m /verify /loop 30m /code-review
This gives you scheduled execution of complex skill behavior with zero glue code.
Context management
Loops are designed to ride out context-window pressure. The runtime:
- Summarizes prior iterations once they are no longer load-bearing.
- Preserves the original loop prompt across iterations.
- Keeps tool results from the current iteration intact until the iteration ends.
If your loop needs to remember state across iterations, write it to a scratch file or skill memory rather than relying on conversation history.
Common errors and fixes
"Interval too short"
You passed an interval below the runtime floor. Increase to 60s or longer.
"Loop already running"
Only one loop runs per session. Stop the existing one first with /loop stop.
"ScheduleWakeup not available"
Dynamic mode requires the deferred ScheduleWakeup tool to be loaded. The runtime loads it automatically when you invoke /loop without an interval.
Loop runs forever
Add an explicit stop condition to your prompt: "end the loop when X happens." Or just call /loop stop.