Skip to main content
Task Automation

Loop Tasks

Overview

/loop lets Qoder CLI run the same prompt or slash command over and over. It is ideal for scenarios such as polling status, continuous checking, and periodic repetitive actions, for example, "check deployments every 5 minutes" or "watch the CI pipeline until it turns green". There are two pacing modes, selected by whether you give an interval:
ModeHow to trigger itTiming
Fixed-intervalProvide an interval (/loop 5m …)Qoder converts the interval into a periodic schedule and creates a scheduled task.
Dynamic-pacingOmit the interval (/loop monitor CI)Qoder runs the task, then decides for itself when the next run is worth doing (60s–3600s). The loop ends as soon as it stops scheduling the next wake-up.
If you need a precise calendar schedule (e.g., "every Monday at 9 AM"), use scheduled tasks instead. See Scheduled Execution Task.

Command Format

/loop [interval] [flags] <prompt>
  • interval: Optional time interval. If provided, the loop runs at a fixed interval; if omitted, Qoder paces itself.
  • flags: Optional. Persistence (--durable, --permanent) and budget ceilings (--max-turns, --max-credits). Flags may appear anywhere in the input and are removed from the prompt before it is scheduled.
  • prompt: The prompt or slash command to run repeatedly. If you omit it and a .qoder/loop.md file exists, Qoder loops over that task list instead.
Example:
/loop 5m /babysit-prs
/loop 30m check the deploy
/loop 1h /standup 1
/loop check the deploy every 20m
/loop monitor CI pipeline                    # No interval, Qoder picks the timing
/loop 10m --max-turns 6 check the deploy     # Stops after 6 runs
Once created, Qoder will execute the prompt immediately rather than waiting for the first interval to begin.

Interval Syntax

An interval consists of a number followed by a unit. Four units are supported:
UnitMeaningExample
sSeconds30s
mMinutes5m
hHours2h
dDays1d
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:
IntervalCorresponding ScheduleDescription
Nm (N ≤ 59)Every N minutes
Nm (N ≥ 60)Rounded to hoursMust evenly divide 24 hours
Nh (N ≤ 23)Every N hours
NdMidnight every N days (local time)
NsRounded up to minutesMinimum 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.

Two Formats

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, so the loop runs in dynamic-pacing mode.

Budget Ceilings

A loop keeps running until it expires or you stop it, which makes it easy to spend more than you intended. Two flags put a ceiling on it:
/loop 10m --max-turns 6 check the deploy      # At most 6 runs
/loop --max-credits 20 monitor CI             # At most 20 credits
/loop 1h --max-turns=24 --max-credits=50 /standup 1
FlagMeaning
--max-turns NStop after N runs. N is a whole number.
--max-credits NStop once N credits have been spent in total. Decimals are allowed, because a single run often costs less than one credit.
Both flags also accept the = form (--max-turns=6). Only positive numbers are accepted—a ceiling of zero would retire the loop before its first run. How the ceilings behave:
  • Set both, and whichever is reached first stops the loop.
  • Runs are counted over the whole life of the task, not per session. Restarting Qoder CLI does not reset the count, so a restart cannot be used to get past the ceiling.
  • The run count is checked before each run, so --max-turns 2 fires exactly twice, never a third time.
  • Credits are metered after a run finishes, so the final run can end slightly above the ceiling (for example 3.2 against a ceiling of 3). Qoder does not cut a run off midway, because the work you already paid for would be discarded.
  • Reaching a ceiling stops the loop for good. The task is removed and you see a message such as Scheduled task a1b2c3d4 stopped: it used 2 of 2 turns. Qoder receives the same notice, so it reports the stop instead of continuing to reason as though the loop were still running. To keep going, start a new loop with a fresh ceiling.
  • In dynamic-pacing mode the ceiling sticks to the loop. You only pass it once, on the /loop that starts the loop; it stays in effect for every later wake-up. Stopping the loop clears both the ceiling and the usage, so the next /loop starts from zero.

Viewing and Changing Usage

/crontab opens the scheduled task panel, where the USAGE column shows what each loop has consumed:
USAGE
3/10 turns · 12.5/50 credits     Both ceilings set
2 turns · 8.25 credits           No ceiling
1/5 turns · —/50 credits         Spend not metered yet
On the detail page of a task you can change the ceilings without recreating the loop: press t for the run ceiling and b for the credit ceiling. Entering an empty value removes that ceiling.

Persistence, Automatic Expiration, and Cancellation

By default a /loop task lives in the current session only: it fires on schedule while Qoder CLI is running and disappears when the process exits. Recurring tasks also expire automatically 7 days after creation. Two flags change that:
FlagEffect
--durablePersist the task to disk so it survives restarts, with no automatic expiry.
--durable 30dPersist the task and expire it 30 days from now.
Both flags apply to fixed-interval loops. A dynamic-pacing loop always lives in the current session. Upon successful creation, Qoder will display the scheduled content, the corresponding cycle, whether the task is persisted, the automatic expiration time, and the task ID for cancellation. To stop it early, ask Qoder to cancel the corresponding loop task using this ID, delete it from the /crontab panel, or—in dynamic-pacing mode—simply ask Qoder to stop the loop. For complete parameters, default values, and expiration rules, see the Loop Command Reference.