> ## Documentation Index
> Fetch the complete documentation index at: https://docs.qoder.com/llms.txt
> Use this file to discover all available pages before exploring further.

# Loop Task (/loop)

<div id="overview">
  # Overview
</div>

`/loop` enables Qoder CLI to repeatedly run the same prompt or slash command at fixed time intervals. It is ideal for scenarios such as polling status, continuous checking, and periodic repetitive actions, for example, "check deployments every 5 minutes" or "check the PR queue every half hour".

`/loop` is a simplified entry point for scheduled tasks: you only need to provide a time interval, and Qoder will convert it into the corresponding periodic schedule and create the task. If you need a more precise calendar schedule (e.g., "every Monday at 9 AM"), please use scheduled tasks. See [Scheduled Execution Task](/en/cli/03-using-qoder-cli/02-task-automation/scheduled).

<div id="usage">
  # Command Format
</div>

```text theme={null}
/loop [interval] <prompt>
```

* `interval`: Optional time interval. If not specified, it defaults to **10 minutes (`10m`)**.
* `prompt`: The prompt or slash command to run repeatedly.

Example:

```shell theme={null}
/loop 5m /babysit-prs
/loop 30m check the deploy
/loop 1h /standup 1
/loop check the deploy          # No interval specified, defaults to 10m
/loop check the deploy every 20m
```

Once created, Qoder will **execute the prompt immediately** rather than waiting for the first interval to begin.

<div id="interval">
  # Interval Syntax
</div>

An interval consists of a number followed by a unit. Four units are supported:

| Unit | Meaning | Example |
| :--- | :------ | :------ |
| `s`  | Seconds | `30s`   |
| `m`  | Minutes | `5m`    |
| `h`  | Hours   | `2h`    |
| `d`  | Days    | `1d`    |

**The minimum granularity is 1 minute.** Since the underlying scheduler does not support second-level fields, seconds are rounded up to the nearest whole minute. For example, `30s` is treated as `1m`, and Qoder will inform you of the actual rounded interval.

Interval to Cron conversion rules:

| Interval      | Corresponding Schedule             | Description                 |
| :------------ | :--------------------------------- | :-------------------------- |
| `Nm` (N ≤ 59) | Every N minutes                    |                             |
| `Nm` (N ≥ 60) | Rounded to hours                   | Must evenly divide 24 hours |
| `Nh` (N ≤ 23) | Every N hours                      |                             |
| `Nd`          | Midnight every N days (local time) |                             |
| `Ns`          | Rounded up to minutes              | Minimum 1 minute            |

> If the interval does not evenly divide its unit (e.g., `7m` would result in uneven intervals from `:56` to `:00`, and `90m` cannot be expressed in whole hours), Qoder will select the nearest clean interval and inform you of the rounded value before creation.

<div id="two-forms">
  # Two Formats
</div>

The interval can be placed at the beginning or expressed using an `every` clause at the end:

* **Interval at the beginning**: `/loop 5m check the deploy` → interval `5m`, prompt `check the deploy`.
* **every clause at the end**: `/loop check the deploy every 20m` → interval `20m`, prompt `check the deploy`. Natural expressions like `every 5 minutes` and `every 2 hours` are also supported.

Note that `every` is treated as an interval only when followed by a time expression. For example, in `/loop check every PR`, `every` is not a time expression and will be treated as part of the prompt, with the interval defaulting to `10m`.

<div id="expiry-cancel">
  # Automatic Expiration and Cancellation
</div>

Tasks created with `/loop` are periodic tasks and will automatically expire **7 days** after creation. If long-term execution is required, simply recreate the task upon expiration.

Upon successful creation, Qoder will display the scheduled content, the corresponding cycle, the automatic expiration time, and the task ID for cancellation. To stop it early, simply ask Qoder to cancel the corresponding loop task using this ID.

For complete parameters, default values, and expiration rules, see the /loop Command Reference.
