Repeat

Run a task in an event-driven loop, re-triggering when specified criteria are met rather than on a timer.

seandonn-boston 1 updated 23d ago
Claude CodeGeneric
View source ↗
# /repeat

Run a task in an event-driven loop, re-triggering when specified criteria are met rather than on a timer.

> **Prerequisites:** See [`_primer.md`](_primer.md) for operational definitions (Admiral, Work Hierarchy, Decision Authority, Recovery Ladder, etc.)

## Mission

Execute a task chain repeatedly. Each iteration runs until a condition (repeatFlag) is satisfied, then executes transition logic (exitStrategy), then starts again. The loop is event-driven — for timer-based repetition, use `/loop`.

## Entry State

- A valid `/repeat` invocation with all required parameters.
- Git state is recoverable (branches, PRs, TODOs) for session continuity.

## Exit State

- `endRepeat` condition satisfied, OR user interruption, OR unrecoverable error.
- Current iteration's work is committed and checkpoint is produced.
- Git working tree is clean.

## Syntax

/repeat {task: <commands>, exitStrategy: "", repeatFlag: , conditions: [...], endRepeat: ""}


## Parameters

### Required

- **task**: The command chain to execute each iteration. See **Task Syntax** below.
- **repeatFlag**: The condition that signals iteration completion.
  - Slash command reference (e.g., `/phase-closeout`): fires when that command completes successfully.
  - Plain-language condition: evaluated honestly after each major step.
- **exitStrategy**: What to do between iterations — branch creation, state reset, context advancement. See **Exit Strategy Contract** below.

### Optional

- **conditions**: Standing rules enforced throughout every iteration. See **Condition Categories** below. Violation is immediate and unrecoverable — no Recovery Ladder.
- **endRepeat**: Termination condition that ends the loop gracefully. Evaluated after each major step alongside repeatFlag. When satisfied, the current step completes, then the loop exits without starting a new iteration.

## Task Syntax

Three composition patterns, freely combinable:

### 1. Slash command chaining

Semicolon-separated, sequential, left to right. Each must complete before the next begins.

task: /next-todo; /simplify; /phase-closeout


### 2. Sub-command arguments

Flags and directive arrays that scope a slash command's behavior for this invocation only.

/plan --auto-approve ["Build in correct order", "Use slush branch conventions"]


- **Flags** (`--flag-name`): Boolean on/off switches. Unrecognized flags are logged as warnings and ignored.
- **Directive arrays** (`["...", "..."]`): Plain-language instructions appended to the sub-command's mission for this invocation. Do not persist across iterations or carry to subsequent commands.

Positional: flags and directives attach to the slash command immediately preceding them.

### 3. Inline prose directives

Double-quoted strings between commands. Executed as standalone evaluation steps.

task: /plan; "Verify the phase objective is genuinely met"; /phase-closeout


- Must be evaluated honestly — not rubber-stamped.
- Treated as verification gates: if fail, do not proceed. Assess what needs to change.
- Logged with pass/fail, evidence, and reasoning in the Output Contract.

## Condition Categories

### Constraints

Absolute restrictions. Violations stop the loop immediately.

"Do not write to aiStrat/" "No compound commands in bash (no &&)"


### Permissions

Explicit grants that override default caution — elevating certain actions from Propose to Autonomous.

"Full read/write access in /technomancy-codex" "May merge task PRs without human approval"


Permissions cannot override safety constraints or Standing Orders.

### Behavioral directives

Approach and priority guidance. Lowest precedence — they shape judgment, not mandate.

"Prefer small commits over large ones" "Use existing patterns from the codebase"


### When conditions conflict

Highest to lowest precedence: Standing Orders (safety) → constraints → sub-command contracts → permissions → behavioral directives. If unresolvable, escalate.

## Exit Strategy Contract

The exitStrategy must:

1. **Execute fully** between every iteration. Skipping is a hard violation (unless `endRepeat` terminates the loop).
2. **Leave a clean entry state** for the next iteration:
   - Branches from the completed iteration are merged or cleaned up.
   - Working tree is clean.
   - Next iteration's starting branch exists and is checked out.
3. **Follow branch policy** from `/next-todo` if creating branches.

If the exitStrategy fails: follow the Recovery Ladder. Do not start the next iteration with a dirty transition.

## endRepeat Evaluation

### Plain-language conditions

Evaluated honestly using available information. "All phases complete" → check `plan/todo/*.md` and `plan/ROADMAP.md`. "User says stop" → only by explicit interruption.

### Token/context conditions

For conditions like "less than 100000 tokens remain":
- Use conservative estimates — err toward graceful termination.
- Message compression is evidence that context is constrained.
- If `token_budget_tracker` reports ≥80% utilization, context-limit conditions are likely satisfied.

### Interaction with repeatFlag

- If `endRepeat` fires before repeatFlag: complete the current step, then exit. Do not force the repeatFlag.
- If both fire simultaneously: execute exitStrategy only if the next iteration is viable.
- If neither fires and the task chain completes: the repeatFlag should have fired but didn't. Investigate — did a sub-command fail silently?

## Iteration State

### Carries forward

- Iteration counter (N).
- `conditions` (immutable for the loop's lifetime).
- `endRepeat` (re-evaluated fresh each iteration).
- Git state (branches, commits, PRs).

### Resets each iteration

- Directive arrays and inline prose results.
- Sub-command internal state (each runs its own Session Continuity Protocol).
- Recovery Ladder position.

## Context Window Management

Long-running 

Maintain Repeat?

Let people know it's listed here — add the badge (live metrics, light/dark aware) or a plain link to your README or docs.

[Repeat on getagentictools](https://getagentictools.com/loops/seandonn-boston-repeat?ref=badge)