---
name: loop
description: Run a prompt or slash command on a recurring interval.
---

# Loop — Session-Scoped Recurring Tasks

Set up a recurring task that runs automatically within this session. Each tick injects the prompt into the conversation and you respond with full context.

## How It Works

Loops use two meta-tools: `get_tool_info` and `execute_tool`. You MUST call them in this order:

1. Call `get_tool_info` with `tool_name: "loop"` to get the loop tool's parameter schema
2. Call `execute_tool` with `tool_name: "loop"` and the appropriate parameters

## Parsing the User's Input

The user types `/loop <interval> <prompt>` or variations:

```
/loop 5m check staging health
/loop 30s run the test suite
/loop 1h summarize new PRs
/loop list
/loop stop <id>
/loop stop-all
```

### Interval Parsing

Convert the time shorthand to milliseconds:
- `30s` → 30000
- `1m` → 60000
- `5m` → 300000
- `10m` → 600000 (default if no interval given)
- `30m` → 1800000
- `1h` → 3600000
- `2h` → 7200000

Minimum interval is 30 seconds (30000ms).

### Starting a Loop

After parsing, call the tools:

```
get_tool_info({ tool_name: "loop" })
execute_tool({ tool_name: "loop", parameters: { action: "start", prompt: "<the prompt>", intervalMs: <ms>, name: "<short name>" } })
```

The `name` should be a short (2-4 word) description derived from the prompt.

### Stopping Loops

For `/loop stop <id>`:
```
execute_tool({ tool_name: "loop", parameters: { action: "stop", id: "<id>" } })
```

For `/loop stop-all`:
Stop each active loop. First list them, then stop each one.

### Listing Loops

For `/loop list`:
```
execute_tool({ tool_name: "loop", parameters: { action: "list" } })
```

## When a Loop Fires

You'll receive a message like:
```
[Loop "check staging" — tick #3]

check staging health
```

Respond to this naturally — you have full conversation context from previous ticks. If something changed since the last tick, note that. If nothing changed, keep the response brief.

## Constraints

- Maximum 5 concurrent loops
- Maximum 100 ticks per loop (auto-stops after)
- Minimum 30 second interval
