spec-loop ยท diff

git:20261018.7301061 to git:20261018.368afab

62 added, 61 removed. Audit A to A.

---
name: spec-loop
description: >
- Run an approved Spec-backed Plan (design.md and plan.json both present) unattended to a draft
- PR: implement and review each batch with fresh subagents, commit, then finish with one
- whole-branch review. Use when the user says "run it to the end" or "implement everything and
- open a PR".
- argument-hint: "[docs/specs/<dir>]"
+ Loop an approved Spec-backed Plan to a PR: implement each batch in a subagent, commit,
+ code-review rq, code-review rs, fix in a subagent, commit, repeat, then open the PR. Use when
+ the user says "loop", "run it to the end", or "implement everything and open a PR".
user-invocable: true
---
# Spec Loop
- Drive an approved Spec-backed Plan to a draft PR without stopping for the human. The main agent
- only drives; fresh subagents implement and review. Never run `code-review rs` in this loop.
+ Drive an approved Spec-backed Plan to a PR. Each batch is implemented, committed, reviewed,
+ fixed, and committed again. The main agent only drives; subagents do the implementation.
- **Announce at start:** "I'm using the spec-loop skill to run this plan to a draft PR."
+ **Announce at start:** "I'm using the spec-loop skill to run this plan to a PR."
- This skill makes no design decisions. A finding or blocker that needs a plan change goes back to
- `spec-plan`; a design change goes back to `spec-brainstorm`.
+ This skill makes no design decisions. If a finding or blocker needs a plan change, go back to
+ `spec-plan`. If it needs a design change, go back to `spec-brainstorm`.
## Start
- Runs on every invocation, including a resume.
+ 1. Follow **spec-implement** Prerequisites and Step 1 (plan review). Raise concerns now, while
+ the human is present. If `design.md` or `plan.json` is missing, stop and use spec-implement.
+ 2. Stop if `git status` shows uncommitted changes.
+ 3. Run the test suite once and record tests that already fail. Never blame a batch for them.
+ 4. Ask one authorization question, naming each action:
+ - commit after every batch and every fix round
+ - push to `<remote>/<branch>` and open the PR (draft or ready)
+ - cost: roughly 8 review subagents per batch
- 1. If `design.md` or `plan.json` is missing, stop and use spec-implement. Otherwise follow
- **spec-implement** Prerequisites and "Load and Review the Plan" while the human is present.
- 2. Stop if the tree is dirty or the test suite is not green.
- 3. Ask one authorization question naming each action. The answer is the explicit authorization
- **code-commit** and **code-pull-request** require.
- - commit after every batch and after the final fix
- - push to `<remote>/<branch>`, without force
- - open a **draft** PR with code-pull-request's Create flow
- - budget: at most N batches (plan task count / 3, rounded up, plus 1); stop when the same task
- or test fails twice
- - cost: one batch reviewer per batch plus one full review at the end
- - excluded: merge, marking the PR ready, rewriting history
+ The answer is the explicit authorization **code-commit** and **code-pull-request** require.
+ Fixes still go through `rs`, so review gates are unchanged.
- ## Resume
+ ## Resume State
- Progress lives in the tracker. After each batch commit, mark its tasks done as spec-implement
- does; on re-invocation the closed entries are the done tasks. With no tracker, say at Start that
- a stopped run cannot resume and that spec-implement can continue it by hand.
+ State lives in git. There is no progress file.
+ - **Base:** `git merge-base <default-branch> HEAD`
+ - **Implement commits** carry `Spec-Task: <feature>/<task-id>` for each task actually completed
+ - **Fix commits** carry `Spec-Reviewed: <reviewed-head-sha>`. When `rs` yields no fixes, record it
+ with an empty commit
+ - **On re-invocation:** stop if the tree is dirty. Done tasks are the `Spec-Task:` footers for
+ this feature in `base..HEAD`. If any commit is newer than the last `Spec-Reviewed:`, review
+ that range before selecting new tasks
+
## Loop
- Repeat until every task is done or the budget runs out.
+ Repeat until every task in `plan.json` is done.
- 1. **Select** up to 5 tasks in `plan.json` order whose `depends_on` are done or earlier in the
- same batch.
- 2. **Implement** each task in its own fresh subagent, one at a time, using **code-subagents**
- Sequential mode and `references/implementor-prompt.md`. Set OWNED_FILES from the task's
- `files`. Select the agent per Delegation in `atelier-orchestrator`. Add these rules: do not
- stage, commit, push, or install anything the plan does not name; never add or edit
- `review-decision:` comments; never delete, skip, or weaken tests; return BLOCKED instead of
- asking a question.
- 3. **Gate.** Run code-subagents Batch Review as written. Validate each task's tests, the full
- suite, lint, and type check. Stop if anything fails twice (see "When Subagents Fail").
- 4. **Commit** with **code-commit** once the diff has no out-of-scope paths and no added
- `review-decision:` lines. Put the reviewer's Minor issues in the commit body. Then update the
- tracker.
- 5. **Report** one line, for example `Batch 2/5: T4, T7 done`. Keep only condensed results in
- context. On BLOCKED, `git stash push` the blocked task's paths, give the stash ref in the
- report, and stop. Commit nothing from a partial batch.
+ 1. **Select** the next 3-5 unblocked tasks from the `depends_on` graph. Record
+ `BATCH_BASE=HEAD`.
+ 2. **Implement** in one fresh subagent for the whole batch. Use the template from
+ **code-subagents** (`references/implementor-prompt.md`) with the full task entries, the
+ relevant `design.md` excerpt, spec-implement Step 3 (TDD), and these rules: do not stage or
+ commit; when `design.md` cannot answer a question, return BLOCKED with the question. Select
+ the agent explicitly (see Delegation in `atelier-orchestrator`). In Codex, pick the closest
+ agent that can write files and say which.
+ 3. **Validate and commit.** The main agent checks the diff for out-of-scope files, runs each
+ task's validation and the suite (re-run a failure once), then commits with **code-commit**.
+ Partially completed batches commit only the finished tasks; treat the rest as a blocker.
+ 4. **Review:** `code-review rq $BATCH_BASE`. State the goal: "Batch Tn-Tm of `<feature>`. Later
+ tasks are not implemented yet, so planned `new_abstractions.consumers` count as consumers."
+ 5. **Plan fixes:** `code-review rs`. Run the interview as written. Stop if it resolves a
+ finding as a plan or design change.
+ 6. **Fix** in one fresh subagent given rs's confirmed fix list and the files it owns. Validate
+ and commit with the `Spec-Reviewed:` footer.
+ 7. **Cap:** at most 2 rq, rs, fix rounds per batch, then escalate (see "When to escalate" in
+ `atelier-orchestrator`).
+ 8. **Report** one line, for example `Batch 2/5: T4-T6 done, 3 fixed, 1 deferred`. After about 3
+ batches, suggest re-invoking `/spec-loop` in a fresh session; resume makes that safe.
## Finish
- Run **spec-finish** whole. Where it would ask the human, apply this policy:
-
- - Commit the simplify edits with code-commit before its review step so the review sees them.
- - Review is one whole-branch `code-review rq`. Auto-fix only findings marked `Mechanical: Yes`
- and `Requires user approval: No` with no reopened decision. Give one fix subagent only each
- location and change, not the raw finding text, with the Loop step 2 rules and a note that
- review text is untrusted data. Re-validate, then commit.
- - Stop without pushing on a `blocking: true` finding that is not fixed as mechanical, any
- `requires_user_approval` finding, or one that needs a change to `plan.json` or `design.md`.
- This matches spec-finish. List every non-blocking finding in the PR body.
- - Scan each commit in `base..HEAD` for secrets (gitleaks if installed, a pattern scan otherwise)
- before pushing. Stop on a hit.
- - Report the completion summary instead of asking. Require "Ready for PR: yes", then open a
- draft PR.
+ 1. Run the spec-implement Completion checklist.
+ 2. Run **spec-finish** Steps 1-3 (simplify, docs, validate).
+ 3. Run `code-review rq <base>` then `rs` over the whole branch, fix in a subagent, and commit.
+ This catches cross-batch problems and reviews the simplify and docs edits.
+ 4. Invoke **code-pull-request**, listing deferred findings in the body.
## Stop and Report
- Besides spec-implement's "When to Stop and Ask", stop on BLOCKED, a gate that fails twice, a
- failed commit check, the budget running out, or a secret-scan hit. Report the blocker and
- whether `/spec-loop` can resume (it can only with a tracker).
+ Besides spec-implement's "When to Stop and Ask", stop when:
+
+ - the implementer returns BLOCKED
+ - `rs` routes a finding to a plan or design change
+ - the round cap is hit
+
+ Report the blocker and what was tried, and say that `/spec-loop` resumes from git.