/repeat - Autonomous Recurring Execution
$ARGUMENTS
Argument Parsing
Parse the user input into three components:
- Interval — duration between iterations (default:
10m)
- Accepts:
1m, 5m, 10m, 30m, 1h
- Minimum:
1m (enforced, reject anything lower)
- Command or prompt — the slash command or freeform prompt to execute each iteration
- Flags:
--iterations N — maximum number of iterations (default: 5)
Examples of parsed input:
/repeat 5m /test -> interval=5m, command=/test, iterations=5
/repeat 10m "check deploy status" -> interval=10m, command="check deploy status", iterations=5
/repeat --iterations 3 /review -> interval=10m, command=/review, iterations=3
/repeat 2m --iterations 10 /lint -> interval=2m, command=/lint, iterations=10
Safety Controls
These limits are constitutionally mandated (Article I, Section 4). Violating them is not permitted.
Max Iterations
- Default: 5 iterations
- Configurable via
--iterations N
- Hard ceiling: the loop MUST terminate after N iterations regardless of outcome
Circuit Breaker
- Track consecutive failures (non-zero exit code, error output, exceptions)
- 3 consecutive failures -> immediate hard stop
- Reset the failure counter on any successful iteration
Minimum Interval
- Never execute faster than 1 minute between iterations
- If user requests
<1m, override to 1m and warn
Exit Detection
After each iteration, inspect the output for completion signals:
- Exit code
0 combined with success markers
- Output contains:
DONE, COMPLETE, ALL PASS, ALL TESTS PASSED, SUCCESS
- Case-insensitive matching
- If detected: stop the loop early and report success
Execution Protocol
For iteration = 1 to max_iterations:
1. Log iteration start (timestamp, iteration number)
2. Execute the command or prompt
3. Capture output and exit status
4. Check exit detection:
- If completion marker found -> STOP, report success
5. Check circuit breaker:
- If failure: increment consecutive_failures
- If success: reset consecutive_failures to 0
- If consecutive_failures >= 3 -> HARD STOP, report failure
6. Log iteration result to stats
7. If not last iteration: wait for interval duration
8. Repeat
After loop ends:
- Print summary: total iterations, pass/fail counts, elapsed time
- Final status: COMPLETED | EARLY_SUCCESS | CIRCUIT_BREAKER | MAX_ITERATIONS
Stats Logging
Each iteration MUST be logged to ~/.softspark/ai-toolkit/stats.json:
{
"loop_runs": [
{
"id": "loop-<timestamp>",
"command": "/test",
"interval": "5m",
"max_iterations": 5,
"started_at": "2026-04-01T10:00:00Z",
"iterations": [
{
"number": 1,
"timestamp": "2026-04-01T10:00:00Z",
"result": "pass",
"exit_code": 0,
"summary": "All 42 tests passed"
},
{
"number": 2,
"timestamp": "2026-04-01T10:05:00Z",
"result": "fail",
"exit_code": 1,
"summary": "3 tests failed"
}
],
"final_status": "EARLY_SUCCESS",
"ended_at": "2026-04-01T10:10:00Z"
}
]
}
Ensure the stats directory and file exist before writing. Append to existing data, never overwrite.
Usage Examples
# Run tests every 5 minutes until all pass (max 5 iterations)
/repeat 5m /test
# Poll deployment status every 10 minutes
/repeat 10m "check deploy status"
# Run review max 3 times at default interval
/repeat --iterations 3 /review
# Lint every 2 minutes, up to 10 times
/repeat 2m --iterations 10 /lint
# Monitor CI pipeline every 5 minutes
/repeat 5m "check if CI pipeline passed for current branch"
When to Use
- Polling deployment or CI/CD pipeline status
- Running tests repeatedly until green
- Monitoring an external process for completion
- Retrying a flaky operation with intervals
- Watching for a condition to become true
When NOT to Use
- Anything requiring human judgment between iterations
- Tasks where each iteration depends on user feedback
- Long-running computations that should be a single background job
- Destructive operations (deletes, drops, force pushes) -- never loop these
- Intervals shorter than 1 minute -- use a proper scheduler instead
1---2name: repeat3description: Runs prompt/slash command on recurring interval until done or limit. Triggers: repeat, recurring task, poll status, run every N minutes, interval.4---56# /repeat - Autonomous Recurring Execution78$ARGUMENTS910## Argument Parsing1112Parse the user input into three components:13141. **Interval** — duration between iterations (default: `10m`)15 - Accepts: `1m`, `5m`, `10m`, `30m`, `1h`16 - Minimum: `1m` (enforced, reject anything lower)172. **Command or prompt** — the slash command or freeform prompt to execute each iteration183. **Flags**:19 - `--iterations N` — maximum number of iterations (default: `5`)2021Examples of parsed input:22- `/repeat 5m /test` -> interval=5m, command=/test, iterations=523- `/repeat 10m "check deploy status"` -> interval=10m, command="check deploy status", iterations=524- `/repeat --iterations 3 /review` -> interval=10m, command=/review, iterations=325- `/repeat 2m --iterations 10 /lint` -> interval=2m, command=/lint, iterations=102627## Safety Controls2829These limits are constitutionally mandated (Article I, Section 4). Violating them is not permitted.3031### Max Iterations32- Default: **5** iterations33- Configurable via `--iterations N`34- Hard ceiling: the loop MUST terminate after N iterations regardless of outcome3536### Circuit Breaker37- Track consecutive failures (non-zero exit code, error output, exceptions)38- **3 consecutive failures** -> immediate hard stop39- Reset the failure counter on any successful iteration4041### Minimum Interval42- **Never** execute faster than 1 minute between iterations43- If user requests `<1m`, override to `1m` and warn4445### Exit Detection46After each iteration, inspect the output for completion signals:47- Exit code `0` combined with success markers48- Output contains: `DONE`, `COMPLETE`, `ALL PASS`, `ALL TESTS PASSED`, `SUCCESS`49- Case-insensitive matching50- If detected: stop the loop early and report success5152## Execution Protocol5354```55For iteration = 1 to max_iterations:56 1. Log iteration start (timestamp, iteration number)57 2. Execute the command or prompt58 3. Capture output and exit status59 4. Check exit detection:60 - If completion marker found -> STOP, report success61 5. Check circuit breaker:62 - If failure: increment consecutive_failures63 - If success: reset consecutive_failures to 064 - If consecutive_failures >= 3 -> HARD STOP, report failure65 6. Log iteration result to stats66 7. If not last iteration: wait for interval duration67 8. Repeat6869After loop ends:70 - Print summary: total iterations, pass/fail counts, elapsed time71 - Final status: COMPLETED | EARLY_SUCCESS | CIRCUIT_BREAKER | MAX_ITERATIONS72```7374## Stats Logging7576Each iteration MUST be logged to `~/.softspark/ai-toolkit/stats.json`:7778```json79{80 "loop_runs": [81 {82 "id": "loop-<timestamp>",83 "command": "/test",84 "interval": "5m",85 "max_iterations": 5,86 "started_at": "2026-04-01T10:00:00Z",87 "iterations": [88 {89 "number": 1,90 "timestamp": "2026-04-01T10:00:00Z",91 "result": "pass",92 "exit_code": 0,93 "summary": "All 42 tests passed"94 },95 {96 "number": 2,97 "timestamp": "2026-04-01T10:05:00Z",98 "result": "fail",99 "exit_code": 1,100 "summary": "3 tests failed"101 }102 ],103 "final_status": "EARLY_SUCCESS",104 "ended_at": "2026-04-01T10:10:00Z"105 }106 ]107}108```109110Ensure the stats directory and file exist before writing. Append to existing data, never overwrite.111112## Usage Examples113114```bash115# Run tests every 5 minutes until all pass (max 5 iterations)116/repeat 5m /test117118# Poll deployment status every 10 minutes119/repeat 10m "check deploy status"120121# Run review max 3 times at default interval122/repeat --iterations 3 /review123124# Lint every 2 minutes, up to 10 times125/repeat 2m --iterations 10 /lint126127# Monitor CI pipeline every 5 minutes128/repeat 5m "check if CI pipeline passed for current branch"129```130131## When to Use132133- Polling deployment or CI/CD pipeline status134- Running tests repeatedly until green135- Monitoring an external process for completion136- Retrying a flaky operation with intervals137- Watching for a condition to become true138139## When NOT to Use140141- Anything requiring human judgment between iterations142- Tasks where each iteration depends on user feedback143- Long-running computations that should be a single background job144- Destructive operations (deletes, drops, force pushes) -- never loop these145- Intervals shorter than 1 minute -- use a proper scheduler instead