/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."4user-invocable: true5effort: medium6argument-hint: "[interval] [command or prompt] (e.g., /repeat 5m /test, defaults to 10m)"7allowed-tools: Read, Write, Edit, Grep, Glob, Bash, Agent8---910# /repeat - Autonomous Recurring Execution1112$ARGUMENTS1314## Argument Parsing1516Parse the user input into three components:17181. **Interval** — duration between iterations (default: `10m`)19 - Accepts: `1m`, `5m`, `10m`, `30m`, `1h`20 - Minimum: `1m` (enforced, reject anything lower)212. **Command or prompt** — the slash command or freeform prompt to execute each iteration223. **Flags**:23 - `--iterations N` — maximum number of iterations (default: `5`)2425Examples of parsed input:26- `/repeat 5m /test` -> interval=5m, command=/test, iterations=527- `/repeat 10m "check deploy status"` -> interval=10m, command="check deploy status", iterations=528- `/repeat --iterations 3 /review` -> interval=10m, command=/review, iterations=329- `/repeat 2m --iterations 10 /lint` -> interval=2m, command=/lint, iterations=103031## Safety Controls3233These limits are constitutionally mandated (Article I, Section 4). Violating them is not permitted.3435### Max Iterations36- Default: **5** iterations37- Configurable via `--iterations N`38- Hard ceiling: the loop MUST terminate after N iterations regardless of outcome3940### Circuit Breaker41- Track consecutive failures (non-zero exit code, error output, exceptions)42- **3 consecutive failures** -> immediate hard stop43- Reset the failure counter on any successful iteration4445### Minimum Interval46- **Never** execute faster than 1 minute between iterations47- If user requests `<1m`, override to `1m` and warn4849### Exit Detection50After each iteration, inspect the output for completion signals:51- Exit code `0` combined with success markers52- Output contains: `DONE`, `COMPLETE`, `ALL PASS`, `ALL TESTS PASSED`, `SUCCESS`53- Case-insensitive matching54- If detected: stop the loop early and report success5556## Execution Protocol5758```59For iteration = 1 to max_iterations:60 1. Log iteration start (timestamp, iteration number)61 2. Execute the command or prompt62 3. Capture output and exit status63 4. Check exit detection:64 - If completion marker found -> STOP, report success65 5. Check circuit breaker:66 - If failure: increment consecutive_failures67 - If success: reset consecutive_failures to 068 - If consecutive_failures >= 3 -> HARD STOP, report failure69 6. Log iteration result to stats70 7. If not last iteration: wait for interval duration71 8. Repeat7273After loop ends:74 - Print summary: total iterations, pass/fail counts, elapsed time75 - Final status: COMPLETED | EARLY_SUCCESS | CIRCUIT_BREAKER | MAX_ITERATIONS76```7778## Stats Logging7980Each iteration MUST be logged to `~/.softspark/ai-toolkit/stats.json`:8182```json83{84 "loop_runs": [85 {86 "id": "loop-<timestamp>",87 "command": "/test",88 "interval": "5m",89 "max_iterations": 5,90 "started_at": "2026-04-01T10:00:00Z",91 "iterations": [92 {93 "number": 1,94 "timestamp": "2026-04-01T10:00:00Z",95 "result": "pass",96 "exit_code": 0,97 "summary": "All 42 tests passed"98 },99 {100 "number": 2,101 "timestamp": "2026-04-01T10:05:00Z",102 "result": "fail",103 "exit_code": 1,104 "summary": "3 tests failed"105 }106 ],107 "final_status": "EARLY_SUCCESS",108 "ended_at": "2026-04-01T10:10:00Z"109 }110 ]111}112```113114Ensure the stats directory and file exist before writing. Append to existing data, never overwrite.115116## Usage Examples117118```bash119# Run tests every 5 minutes until all pass (max 5 iterations)120/repeat 5m /test121122# Poll deployment status every 10 minutes123/repeat 10m "check deploy status"124125# Run review max 3 times at default interval126/repeat --iterations 3 /review127128# Lint every 2 minutes, up to 10 times129/repeat 2m --iterations 10 /lint130131# Monitor CI pipeline every 5 minutes132/repeat 5m "check if CI pipeline passed for current branch"133```134135## When to Use136137- Polling deployment or CI/CD pipeline status138- Running tests repeatedly until green139- Monitoring an external process for completion140- Retrying a flaky operation with intervals141- Watching for a condition to become true142143## When NOT to Use144145- Anything requiring human judgment between iterations146- Tasks where each iteration depends on user feedback147- Long-running computations that should be a single background job148- Destructive operations (deletes, drops, force pushes) -- never loop these149- Intervals shorter than 1 minute -- use a proper scheduler instead