--- name: autoloop description: 'Use when a trusted QRSPI spec and plan should run unattended for one phase or all remaining phases.' when_to_use: 'Use when a `./qrspi//` workspace has an approved spec and plan and you want unattended execution. For human-gated execution, use `qrspi-x:workflow` or `qrspi-x:implement`.' disable-model-invocation: false compatibility: Node 22+ --- # QRSPI Autoloop ## Core Philosophy - Spawn and track; never implement or review in this conversation - One repair attempt per phase, then a human Runtime contract: read `../workflow/references/runtime.md` before each role dispatch. It defines the fresh-context, capability, fallback, and on-disk evidence requirements; this skill adds only Autoloop's unattended sequencing and helper lifecycle. At entry, state that the human approves the scope and owns final review; autoloop implements, reviews, repairs once, and advances or stops between those gates. Interim reviews use the implementing context, so they are a fast filter, not an independent check. ## The helper Command examples below are helper subcommands; invoke them as `qrspi-x ...`. All loop state goes through the helper; never edit `loop-state.json` directly. Check findings on every command, including `status`, `log`, and `loop`, before using any payload. Exit codes are `0` clean, `1` hard block, `3` success with a finding, and `127` not found; `status`/`start` print payloads, while successful `log` and lifecycle actions print `{}`. If `qrspi-x` is not found (exit 127), tell the human to run `npm i -g @ebullient/qrspi-x`. Autoloop cannot run unattended without it — this is a hard stop, not a degrade-and-continue case. When a command or flag is unclear, use `qrspi-x --help` or the command's `--help`; do not guess. ## Entry gate Run `status`. If `loop` is present and `next.action` is not `done`, a loop already exists: go to **Resuming** instead. Agree the run with the human: choose one phase or all remaining phases (default to one; selectors are `all`, `3`, `2..4`, or `1,3`), confirm it will implement and commit one commit per step, review each phase, and repair once on failure, and confirm it will not run final review. Then run `loop start --feature --project `. It runs the helper's entry checks and resolves the scope, adding any incomplete phases the selection depends on. If it refuses, it wrote nothing: each finding's message says what is wrong and usually how to fix it, so work through them with the human and run it again. Once it succeeds, nothing has been spawned. Show the resolved `phaseIds` and wait for the only approval. If rejected, run `loop abandon "" --feature --project ` and start over with a different selector. ## Loop state The helper owns `loop-state.json` while a loop runs; `status` reports the current scope, phase, checkpoint, conditions, and stop reason under `loop`, which disappears when the loop ends. Full review history survives in `history.jsonl`; read it with `history read --kind review` when handing back. Each spawn is bracketed: `start --loop` **before** spawning, `log ` after the agent returns. `start ... --loop` writes the pre-spawn intent to `loop-state.json` before anything runs, so a session that dies mid-spawn leaves that behind rather than what it last finished — a retried `start ... --loop` reads it back instead of starting over. `log ` reads the agent's output from disk — phase markers, commits, the review artifact — and records the outcome; it does not trust the agent's report. ## The loop Before each implementation, review, repair, or re-review spawn: - If the named `qrspi-x:implementer` or `qrspi-x:reviewer` agent is registered, spawn it directly so the runtime applies its settings. - Otherwise, read the matching `../../agents/implementer.md` or `../../agents/reviewer.md` relative to this skill, then spawn a fresh general-purpose subagent with that file's full contents as its role instructions. Drive the loop from the helper: run `status`, act on `next.action`, and repeat until the action is `done`, `stop`, or `acknowledge-required`. If `start implement --loop`/`start review --loop` reports the phase's base as stale or missing (e.g. a human fixed a FAIL by hand mid-run), determine the correct base — current HEAD is a reasonable default — and retry the same call with `--base `. Ask the human if you aren't sure. ### `implement` Run `start implement --phase --loop --feature --project `. The result carries `phaseId`. ``` Spawn qrspi-x:implementer agent for feature: Mode: phase Phase: ``` When it returns: - If completed, run `log implement --phase --feature --project `. - If STOPPED, run `loop stop "" --feature --project ` (see **`stop`, `acknowledge-required`, or `done`**, below) — one call records the stop in both `loop-state.json` and `history.jsonl`, so the reason stays durable even after the loop ends. Do not retry a stopped implementer. ### `review` or `re-review` Run `start review --phase --loop --feature --project `. The result carries the checkpoint `label` and the phase `diff` command. Use them exactly; never compose a label — the reviewer stops rather than overwrite a finished review, which would strand the loop. If `./qrspi//reviews/