nitm-ai-dev-toolkit 5.2.1 → 5.3.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (30) hide show
  1. package/CHANGELOG.md +13 -1
  2. package/README.md +24 -0
  3. package/bin/cli.js +1 -1
  4. package/package.json +1 -1
  5. package/src/monorepo/.agents/skills/dispatching-parallel-agents/SKILL.md +1 -1
  6. package/src/monorepo/.agents/skills/factory/SKILL.md +36 -13
  7. package/src/monorepo/.agents/skills/factory/roles/approve.md +3 -2
  8. package/src/monorepo/.agents/skills/factory/roles/review-code.md +2 -1
  9. package/src/monorepo/.agents/skills/factory/roles/spec.md +3 -1
  10. package/src/monorepo/.claude/prompt-snippets/implement-feature.md +2 -1
  11. package/src/monorepo/.claude/prompt-snippets/implement.md +15 -7
  12. package/src/monorepo/.claude/prompt-snippets/plan.md +2 -2
  13. package/src/monorepo/.claude/prompt-snippets/specify.md +9 -2
  14. package/src/monorepo/.claude/rules-snippets/fit-review.md +62 -0
  15. package/src/monorepo/.claude/rules-snippets/subagent-workflow.md +59 -28
  16. package/src/monorepo/AGENTS.md +8 -5
  17. package/src/monorepo/factory/README.md +3 -1
  18. package/src/repo/.agents/skills/dispatching-parallel-agents/SKILL.md +1 -1
  19. package/src/repo/.agents/skills/factory/SKILL.md +36 -13
  20. package/src/repo/.agents/skills/factory/roles/approve.md +3 -2
  21. package/src/repo/.agents/skills/factory/roles/review-code.md +2 -1
  22. package/src/repo/.agents/skills/factory/roles/spec.md +3 -1
  23. package/src/repo/.claude/prompt-snippets/implement-feature.md +2 -1
  24. package/src/repo/.claude/prompt-snippets/implement.md +15 -7
  25. package/src/repo/.claude/prompt-snippets/plan.md +2 -2
  26. package/src/repo/.claude/prompt-snippets/specify.md +9 -2
  27. package/src/repo/.claude/rules-snippets/fit-review.md +62 -0
  28. package/src/repo/.claude/rules-snippets/subagent-workflow.md +59 -28
  29. package/src/repo/AGENTS.md +12 -5
  30. package/src/repo/factory/README.md +3 -1
@@ -71,42 +71,73 @@ When dispatching implementation tasks, match the specialist to the domain:
71
71
 
72
72
  ## Orchestration Patterns
73
73
 
74
- ### Sequential (default)
74
+ ### Delegation Default
75
75
 
76
- Tasks with dependencies are implemented one at a time in dependency order. Each must pass review before the next begins.
76
+ - **Delegate by default.** Hand substantial, safely separable discovery, implementation, test, and review work to subagents. Use a single agent only for trivial work, as listed under "When to Use a Single Agent Directly".
77
+ - **The coordinator keeps outcome responsibility.** It defines each task's scope, reconciles every result, makes sure verification runs, and reports the final outcome. A subagent reporting success is not the outcome.
78
+ - **Work directly only** for trivial changes (one small edit, a quick answer) or when the context is too heavy to hand off cheaply, such as work that depends on large context the coordinator already holds. Say why when you skip delegation.
79
+ - **No delegation capability.** If the host offers no subagent dispatch, say so explicitly in the report. Do permitted direct work where it is safe. Never self-review in place of an independent gate: record the gate as pending and end as BLOCKED or WAITING.
77
80
 
78
- ### Parallel
81
+ ### Dependency Graph and Parallel Batches (REQUIRED before dispatching)
79
82
 
80
- Independent tasks can be dispatched to multiple specialist subagents simultaneously. Use when tasks don't share files or state.
83
+ Before dispatching any task list, the orchestrator builds the dependency graph. No `[P]` marker is required. If a task list has `[P]` markers, treat them as hints and verify them.
81
84
 
82
- ### Parallelization Analysis (REQUIRED before dispatching)
85
+ 1. **Read and write sets.** For each task, list the files, directories, or packages it reads and writes.
86
+ 2. **Exclusive writable scopes.** Each writer gets a scope no other concurrent task writes. Two tasks that share any writable path are dependent. A task whose write set is unknown or undeclared runs serially until its scope is established from the changed-file list.
87
+ 3. **Data dependencies.** A task that reads what another task writes waits for that task.
88
+ 4. **Ready batch.** Tasks whose dependencies are satisfied and whose writable scopes are disjoint form one batch. Dispatch the whole batch together. Dependent and shared-write tasks run in later batches, one at a time.
89
+ 5. **Route by domain.** Backend tasks → Backend Architect; frontend → Frontend Developer; API contracts → API Specialist; docs → Documenter; cross-cutting → Implementer.
90
+ 6. **Track handles.** Record each dispatched task's handle, agent, writable scope, and status until its result is reconciled.
91
+ 7. **Reconcile before dependents.** Inspect each result (changed files, summary, verification) before dispatching any task that depends on it. If a result changed a path the graph did not expect, stop the affected tasks and re-plan the batch.
92
+ 8. **Continue the chain.** When a batch's results are reconciled, compute the next ready batch and dispatch it. Do not wait for the user unless a mandatory gate applies or no authorized, unblocked work remains (see Autonomous Execution and Blockers).
83
93
 
84
- Before executing any task list, the orchestrator MUST run this analysis:
85
-
86
- 1. **Scan for `[P]` markers** in the task list — these are pre-identified parallel candidates
87
- - If no `[P]` markers exist, do **not** assume sequential-only work. Treat all tasks as candidates and infer parallel-safe groups via the independence test.
88
- 2. **Build a dependency graph**: For each task, list which files it reads and writes
89
- 3. **Apply the independence test**:
90
- - Tasks that write to **different files** with **no shared state** → parallel-safe
91
- - Tasks that share any writable file → sequential (dependency edge)
92
- - Tasks where one reads what another writes → sequential (data dependency)
93
- 4. **Group by domain** for specialist routing:
94
- - Backend tasks → Backend Architect
95
- - Frontend tasks → Frontend Developer
96
- - API contract tasks → API Specialist
97
- - Documentation tasks → Documenter
98
- - Cross-cutting → Implementer
99
- 5. **Dispatch decision**:
100
- - **3+ independent tasks** → Use `dispatching-parallel-agents` skill, one agent per task
101
- - **2 independent tasks** → Parallel dispatch (simpler coordination)
102
- - **All tasks dependent** → Sequential with `subagent-driven-development` skill
103
- - **Mixed** → Dispatch independent group in parallel, then continue sequential chain
94
+ **Dispatch shape:** 3+ independent tasks → `dispatching-parallel-agents`, one agent per task. 2 independent tasks → parallel dispatch. All tasks dependent → sequential with `subagent-driven-development`. Mixed → run each ready batch in parallel, then continue the sequential chain.
104
95
 
105
96
  ```
106
- Example: 5 tasks → T1 (setup) → T2 [P] (backend API) + T3 [P] (frontend UI) + T4 [P] (docs) → T5 (integration tests)
107
- Dispatch: T1 sequential → T2+T3+T4 parallel → T5 sequential
97
+ Example: 5 tasks → T1 (setup) → T2 (backend API) + T3 (frontend UI) + T4 (docs) → T5 (integration tests)
98
+ Batches: [T1] → [T2, T3, T4] → [T5]
99
+ T2, T3, and T4 run together only because their writable scopes are disjoint.
108
100
  ```
109
101
 
102
+ ## Turn Completion and Waiting
103
+
104
+ During active multi-step execution, never end a turn silently, and never treat dispatch or partial progress as completion. End each such turn in exactly one of these states. Informational answers need no status line:
105
+
106
+ - **DONE:** the requested work is complete and verified under Quality Gates. State the outcome and the validation that ran.
107
+ - **WAITING:** name each pending task (handle and agent) and its resume trigger, such as a subagent notification or a user reply at a named gate. List what completed and what remains.
108
+ - **BLOCKED / NEEDS-DECISION:** state the blocker or decision, what completed, what remains, and the exact next user action.
109
+
110
+ Resume mechanics depend on the host:
111
+
112
+ - When the host notifies on subagent completion, reconcile the notified result and continue with the next eligible batch. Check each handle once per notification.
113
+ - When the host cannot resume in the background, do not claim that it will. Either run the batch in the foreground and collect the results within the turn, or end as WAITING and say that the user must send a message to resume, naming the exact step.
114
+ - Do not busy-poll. Never loop on status checks.
115
+
116
+ ## Autonomous Execution and Blockers
117
+
118
+ During multi-step execution, work autonomously within the approved goal, scope, and permissions. Autonomy grants no extra authority.
119
+
120
+ - **A blocker pauses only the affected task and its dependents.** Independent ready work within authority continues in the next batch.
121
+ - **Record each unresolved blocker immediately** in the existing progress record or the conversation: the affected task, what is needed and why, safe options or a targeted input, and the next action. Keep it visible in progress updates and the final report. Never drop it silently.
122
+ - **Defer non-global blockers** as follow-up questions while work can safely advance.
123
+ - **Stop for user input** only when no authorized, unblocked work remains, or when a mandatory approval, security, or permission gate prevents the remaining work. Agents still running are WAITING, not blocked.
124
+ - **Ask clearly.** Present the consolidated outstanding questions through the harness's native question or clarification tool when one is available. Do not assume a tool name or support. Without one, give numbered options or a fill-in block in chat.
125
+ - **Answers can arrive early.** Do not require a blocking tool prompt while independent work continues. Report deferred questions in progress updates.
126
+ - **Never** silently choose a consequential scope or requirement change, bypass a required human approval, or mark a partially blocked task DONE.
127
+
128
+ ## Long-Session Checkpoint
129
+
130
+ For sessions that span several batches or a context reset:
131
+
132
+ - Use existing progress records only: a progress section the plan or task list already has, Factory job notes, or task records, when they exist. Keep the approved goal, current step, active task handles, blocker, and next action in those notes or in the conversation.
133
+ - Never add fields to structured files such as Factory `job.json`, never rewrite accepted requirements or spec/plan text, and never replace an authoritative source with a summary.
134
+ - If no such records exist, a short checkpoint in the conversation is enough. Do not create new files for trivial work.
135
+ - On resume, reread the accepted source (spec, plan, or task text) instead of relying on the checkpoint summary, and check the working tree before dispatching anything.
136
+
137
+ ## Factory Approvals
138
+
139
+ Spec and plan confirmations remain mandatory human steps; final approval, escalation, and merge behavior follow the job's `APPROVAL_MODE` and `MERGE_MODE`. Delegation, batching, autonomy, and subagent sign-offs never satisfy spec or plan human confirmation, or human final approval when `APPROVAL_MODE=human`. Mode-defined approver behavior is preserved. Stop at the gate and report it as WAITING or BLOCKED.
140
+
110
141
  ## Quality Gates
111
142
 
112
143
  - Every implementation must pass **Reviewer** before proceeding
@@ -122,7 +153,7 @@ When a subagent stops on a model capacity, quota, session limit, or reset-wait f
122
153
  - **Model order, one attempt each.** Try the next model in the configured fallback order for that agent. When the order is exhausted, try the harness's known available default, unless it was already tried. Then stop; do not cycle back.
123
154
  - **Never** retry the same unavailable model, and never wait blindly for a quota reset.
124
155
  - **Only supported switching.** Change the model through per-call selection the runtime supports, using only fallback models and defaults that are already configured or exposed. Do not invent model IDs, and do not edit persistent or global config, accounts, or billing.
125
- - **Blocker when nothing is left.** If no configured fallback or default is available, or per-call selection is unsupported, stop, report the blocker, and ask the user which model to use.
156
+ - **Blocker when nothing is left.** If no configured fallback or default is available, or per-call selection is unsupported, the affected task is reported BLOCKED with the question of which model to use. Its dependents stop; independent authorized work continues (see Autonomous Execution and Blockers).
126
157
  - **Inspect before resuming.** Check what the failed attempt left in the working tree, then resume from that partial work. Never run two writers on the same files at once.
127
158
  - **Keep review independent.** The reviewer stays a separate agent from the builder, even when the builder moves to a fallback model.
128
159
  - **Disclose.** The final report names the original model, each fallback attempted, and the model that finished the work.
@@ -77,7 +77,7 @@ For CLI command reference, see the matching skill: `.agents/skills/{acli,gh-cli,
77
77
 
78
78
  #### 1. Proactive Clarification
79
79
 
80
- - **Identify Ambiguity**: Stop and ask if a task lacks clear acceptance criteria, inputs, or expected outputs.
80
+ - **Identify Ambiguity**: Ask a targeted question if a task lacks clear acceptance criteria, inputs, or expected outputs. It blocks only that task and its dependents; independent work with clear requirements continues (see the "Autonomy with blockers" bullet under Operating Rules).
81
81
  - **Resolve Conflicts**: Flag conflicting instructions between the user prompt, existing code, and documentation before writing code.
82
82
  - **Expose Assumptions**: State your assumptions clearly and ask for validation before proceeding with high-impact changes.
83
83
 
@@ -268,7 +268,10 @@ Use custom agents when you want explicit coordinator and worker roles. Use workf
268
268
  - Do not make an implementation subagent read the plan file on its own; pass the relevant task directly.
269
269
  - In `subagent-driven-development`, keep the review order strict: spec compliance first, then code quality.
270
270
  - If a reviewer finds issues, fix them and re-run the same review before moving on.
271
- - Do not run multiple implementation subagents in parallel when they could touch shared packages, shared docs, or the same app surface.
271
+ - Parallel implementation subagents need exclusive writable scopes. If scopes could overlap (shared packages, shared docs, or the same app surface), or one task reads another's output, run them sequentially. See `.claude/rules-snippets/subagent-workflow.md` for the dependency graph and batch rules.
272
+ - Delegate substantial, separable work by default; the coordinator stays responsible for the outcome and reconciles each result before dispatching dependents.
273
+ - **Never end silently** — During active multi-step execution, end each turn as DONE, WAITING (pending task handle and resume trigger), or BLOCKED / NEEDS-DECISION (what completed, what remains, exact next user action). Dispatch or partial progress is not completion. Spec and plan confirmations remain mandatory human steps; final approval, escalation, and merge behavior follow the job's `APPROVAL_MODE` and `MERGE_MODE`. Delegation or autonomy alone never satisfies a gate.
274
+ - **Autonomy with blockers** — Work autonomously within the approved goal, scope, and permissions. A blocker pauses only its task and dependents: record it, defer non-global questions, and continue independent authorized work. Stop for the user only when no authorized work remains or a mandatory gate applies, and ask through the harness's native question tool when one exists.
272
275
  - For cross-app work, research boundaries first, sequence shared package changes before app-specific changes, and review downstream impact explicitly.
273
276
 
274
277
  #### Recommended Flow
@@ -343,8 +346,8 @@ Workers are dispatched by coordinators and are not directly user-invocable.
343
346
  - Admin dashboards, RBAC, reporting, monitoring → Admin Portal
344
347
  - General implementation → Implementer
345
348
 
346
- **Sequential**: Tasks with dependencies are implemented one at a time.
347
- **Parallel**: Independent tasks (e.g., changes in different apps) can be dispatched to multiple subagents simultaneously.
349
+ **Sequential**: Dependent tasks, and tasks that share a writable file or package, run one at a time in dependency order.
350
+ **Parallel**: Ready tasks with exclusive writable scopes (e.g., changes in different apps) run together as one batch. Reconcile each batch's results before dispatching the next.
348
351
 
349
352
  **Monorepo-specific**: When implementing features that span multiple apps, coordinate carefully:
350
353
 
@@ -366,7 +369,7 @@ Subagents are typically **agent-initiated** — the coordinator decides when to
366
369
 
367
370
  ### Factory (opt-in)
368
371
 
369
- An optional file-driven pipeline for feature-sized work, alongside Feature Builder and TDD. Start it with `/factory <request>` in Claude Code, Copilot, Cursor, or OpenCode. The orchestrator reads the project and asks only the glaring questions before it creates anything, then asks you to continue or change the answers. Resume a feature with `/factory start <KEY | slug | job-id>`. Codex runs the orchestrator skill directly. Each job belongs to a feature folder in `docs/features/`, stops at a spec gate and a plan gate for your confirmation before any ticket or build, builds in its own git worktree unless you ask for `--in-place`, and moves its tickets when the project tracks them. The orchestrator is [.agents/skills/factory/SKILL.md](.agents/skills/factory/SKILL.md). It runs on the native `planner` (spec and plan), `implementer` (build, repair, and rework), and `reviewer` (the code, security, ux, and ui lenses, and approval) agents. Each role's Factory rules are in its brief in `.agents/skills/factory/roles/`. Setup, placeholders, and approval modes are in [factory/README.md](factory/README.md). Jobs name the affected apps and packages in their spec, and checks run for those with the filtered commands in [Commands](#commands).
372
+ An optional file-driven pipeline for feature-sized work, alongside Feature Builder and TDD. Start it with `/factory <request>` in Claude Code, Copilot, Cursor, or OpenCode. The orchestrator reads the project and asks only the glaring questions before it creates anything, then asks you to continue or change the answers. Resume a feature with `/factory start <KEY | slug | job-id>`. Codex runs the orchestrator skill directly. Each job belongs to a feature folder in `docs/features/`, stops at a spec gate and a plan gate for your confirmation before any ticket or build, builds in its own git worktree unless you ask for `--in-place`, and moves its tickets when the project tracks them. The orchestrator is [.agents/skills/factory/SKILL.md](.agents/skills/factory/SKILL.md). It runs on the native `planner` (spec and plan), `implementer` (build, repair, and rework), and `reviewer` (the code, security, ux, and ui lenses, and approval) agents. Each role's Factory rules are in its brief in `.agents/skills/factory/roles/`. Spec and plan goal-fit must be confirmed by an independent Oracle or read-only reviewer, not the spec or plan author. Single-session role switching, including the Codex fallback, does not satisfy that and blocks these gates. Spec and plan confirmations stay mandatory human steps in every approval mode. Setup, placeholders, and approval modes are in [factory/README.md](factory/README.md). Jobs name the affected apps and packages in their spec, and checks run for those with the filtered commands in [Commands](#commands).
370
373
 
371
374
  ## Documentation Requirements
372
375
 
@@ -55,7 +55,7 @@ The orchestrator and agents are the same in every harness. Each harness has its
55
55
  | GitHub Copilot | `/factory` prompt (`.github/prompts/factory.prompt.md`) | `.github/agents/` |
56
56
  | Cursor | `/factory` (`.cursor/commands/factory.md`) | `.cursor/agents/` |
57
57
  | OpenCode | `/factory` (`.opencode/commands/factory.md`) | `.opencode/agents/` |
58
- | Codex | The factory skill (`.agents/skills/factory/SKILL.md`) | None. Runs each role brief directly, one role at a time in one session (see Harness notes in SKILL.md) |
58
+ | Codex | The factory skill (`.agents/skills/factory/SKILL.md`) | No native agent definitions. Role briefs run directly; spec and plan acceptance requires an independent review session. Single-session role switching cannot satisfy that gate (see Harness notes in SKILL.md). |
59
59
 
60
60
  In OpenCode with the Slim plugin, `oracle` and `designer` are optional alternatives to `reviewer`, if you configure them as edit-denied. The default is the native agents.
61
61
 
@@ -83,6 +83,8 @@ Sizing is decided in `plan.md`:
83
83
 
84
84
  Every job stops twice, in every approval mode, before anything is ticketed or built:
85
85
 
86
+ Before either confirmation, an independent read-only Oracle, or reviewer when Oracle is unavailable, checks goal fit. Revisions and resumed gates are reviewed again. Missing independent review blocks acceptance, including single-session Codex use; it does not block discussing unresolved decisions. If the original requirements cannot be recovered, the operator must confirm the recovered baseline rather than treating an agent-written summary as the original request.
87
+
86
88
  1. **Spec gate** (`awaiting-spec`). You read the spec summary, the acceptance criteria count, each open `[PRODUCT DECISION]` item, and open questions. Answer every open decision before you confirm: answers go in your change request, are saved as `spec-<k>.md`, and the spec writer records each one as `[DECIDED]`.
87
89
  2. **Plan gate** (`awaiting-plan`). You read the plan, the tasks, the size, the tracking proposal, and the build mode. Confirm, request changes (saved as `plan-<k>.md`), or change size, tracking, or build mode. Requests that touch the spec go back through the spec gate.
88
90
 
@@ -139,7 +139,7 @@ For full-stack or cross-cutting features, dispatch domain specialists in paralle
139
139
  | Multi-subsystem fix | Backend Architect (service A) + Backend Architect (service B) | Independent service bugs |
140
140
  | Cross-app monorepo | Specialist per app | Same feature in `apps/web` + `apps/api` (no shared packages) |
141
141
 
142
- **Safe to parallelize:** Agents touch different files/directories with no shared state.
142
+ **Safe to parallelize:** Agents have exclusive writable scopes (no shared files/directories) and no shared state. Build the dependency graph first; see `.claude/rules-snippets/subagent-workflow.md`.
143
143
  **Still sequential:** Tasks that share files, database migrations, or API contracts that one depends on.
144
144
 
145
145
  ## When NOT to Use
@@ -59,7 +59,7 @@ factory/
59
59
  jobs/ runtime state, ignored by git
60
60
  <NNN-slug>/
61
61
  job.json orchestrator only; rewrite the whole file
62
- intake.md you, from the intake questions and answers (only when asked)
62
+ intake.md you: the original request verbatim under `## Original request`, the questions and answers (when asked), and `## Baseline confirmed` (when needed)
63
63
  spec-<k>.md you, from the operator's change request at the spec gate
64
64
  plan-<k>.md you, from the operator's change request at the plan gate
65
65
  build.md builder; cumulative round log
@@ -147,7 +147,7 @@ A job is **closed** when its stage is `merged` or `abandoned`. Every other job i
147
147
  2. Make changes: the operator types them.
148
148
 
149
149
  Changes → revise the Q&A with the operator's text, show it, and ask again. Nothing is created until the operator picks 1.
150
- 4. **Continue as Start.** Treat the answers as clarifications of the request. Run Start from step 1 with the request text. Once the job folder exists (Start step 4), write `factory/jobs/<id>/intake.md` with the questions as asked and the answers, verbatim, one question and answer each. Skip the file when nothing was asked. The spec writer reads it (paths block). If Start resumes an open job instead of creating one, say the answers were not applied. Changes after the spec go through the spec gate, the plan gate, or `/factory rework`.
150
+ 4. **Continue as Start.** Treat the answers as clarifications of the request. Run Start from step 1 with the request text. Once the job folder exists (Start step 4), add the questions as asked and the answers to `factory/jobs/<id>/intake.md`, verbatim, one question and answer each. Skip this when nothing was asked. The spec writer reads it (paths block). If Start resumes an open job instead of creating one, say the answers were not applied. Changes after the spec go through the spec gate, the plan gate, or `/factory rework`.
151
151
 
152
152
  `--in-place` on the command, or the operator's answer saying so, sets `worktree` to `false` on the new job (see In-place mode).
153
153
 
@@ -188,9 +188,9 @@ Resume by stage:
188
188
  | Stage | Resume action |
189
189
  | --- | --- |
190
190
  | `spec` | Rerun `planner` in spec mode (brief `roles/spec.md`), then show the spec gate |
191
- | `awaiting-spec` | Show the spec gate |
191
+ | `awaiting-spec` | Show the spec gate (it runs the fit review first) |
192
192
  | `plan` | Rerun `planner` in plan mode (brief `roles/spec.md`), then show the plan gate |
193
- | `awaiting-plan` | Show the plan gate |
193
+ | `awaiting-plan` | Show the plan gate (it runs the fit review first) |
194
194
  | `build` | Rerun `implementer` (brief `roles/build.md`) in the mode the files call for: rework if a `rework-<k>.md` is newer than `build.md`, repair if the last review round has `CHANGES`, otherwise build |
195
195
  | `review` | Rerun the review round `round` |
196
196
  | `approve` | Rerun the approval (`reviewer` in approval mode, brief `roles/approve.md`) |
@@ -212,7 +212,7 @@ A job with no work started (stage before `build`, so no build has begun and no `
212
212
  3. Slug = the feature folder name without its key prefix (`onboarding-bootstrap` for `PROJ-1234-onboarding-bootstrap`). Stable across the key rename.
213
213
  4. `mkdir factory/jobs/<NNN-slug>` (no `-p`). If it already exists, bump `NNN` and retry. `mkdir` without `-p` is the claim.
214
214
  5. Write `job.json` with stage `spec`, `feature_dir`, `issue_key` (the key from Resolve, or `null`), `size` `unclear`, `tracking` `none`, `worktree` (`false` for `--in-place` or when the operator asked for it at intake, `true` otherwise), and `worktree_path` `null`.
215
- 6. If intake asked questions, write `intake.md` (see Intake).
215
+ 6. Write `intake.md` (see Intake): when the request text was typed, the original request verbatim under `## Original request`. For a key or slug start, write no original request section; the Fit review baseline step asks the operator for it. Add the questions and answers when intake asked.
216
216
 
217
217
  ## Spec
218
218
 
@@ -220,18 +220,19 @@ Set stage `spec`. Dispatch `planner` in spec mode (brief `roles/spec.md`) with t
220
220
 
221
221
  ## Spec gate (mandatory)
222
222
 
223
- Runs in every `APPROVAL_MODE`, before any plan is written. Show the operator in chat:
223
+ Runs in every `APPROVAL_MODE`, before any plan is written. Every time the gate is shown (first time, after each change request, and on resume), run the fit review first (see Fit review). Show the operator in chat:
224
224
 
225
225
  - The spec's Summary, the number of acceptance criteria, each open `[PRODUCT DECISION]` item, and Open Questions.
226
+ - The fit review's verdict, its blocking findings, and its decisions for the user.
226
227
 
227
228
  Then ask in chat, as a numbered choice:
228
229
 
229
- 1. Confirm the spec. Offered only when no `[PRODUCT DECISION]` item is open.
230
+ 1. Confirm the spec. Offered only when no `[PRODUCT DECISION]` item is open and the current fit review is an explicit `VERDICT: PASS`.
230
231
  2. Request changes: the operator types the change. Each open `[PRODUCT DECISION]` item needs an answer in the change text.
231
232
 
232
233
  Handle the answer:
233
234
 
234
- - **Confirm** → continue to Plan. If decision items are still open, do not continue: list them and ask again.
235
+ - **Confirm** → continue to Plan. If decision items are still open, or the current fit review is not an explicit `VERDICT: PASS`, do not continue: list them and ask again.
235
236
  - **Request changes:** write the operator's text verbatim to `spec-<k>.md` in the job folder (`k` = next free index). Set stage `spec`, rerun `planner` in spec mode (brief `roles/spec.md`) with the paths block and `spec-<k>.md`. It updates `spec.md`. Set stage `awaiting-spec` and show the gate again. The spec writer records each answered decision as `[DECIDED] <answer>`.
236
237
 
237
238
  If the session ends at this gate, `/factory start <job-id|slug|KEY>` shows it again (see Start).
@@ -247,21 +248,22 @@ Read the `**Size:**` line of `plan.md`:
247
248
 
248
249
  Proposed tracking: `tracked` only when size is `large` and the project's `AGENTS.md` Project Management section names a real tracker. Unfilled placeholders mean no tracker. Otherwise propose `none`.
249
250
 
250
- Set stage `awaiting-plan` and show the plan gate.
251
+ Set stage `awaiting-plan`. The plan gate runs the fit review before it is shown.
251
252
 
252
253
  ## Plan gate (mandatory)
253
254
 
254
- Every job stops at `awaiting-plan` before anything is ticketed or built, in every `APPROVAL_MODE`. Show the operator in chat:
255
+ Every job stops at `awaiting-plan` before anything is ticketed or built, in every `APPROVAL_MODE`. Every time the gate is shown (first time, after each change request, and on resume), run the fit review first (see Fit review), against the goal sources (see Fit review), the accepted spec, and the plan. Show the operator in chat:
255
256
 
256
257
  - The plan's approach and steps from `plan.md`.
257
258
  - The size and the reason from `plan.md`.
259
+ - The fit review's verdict, its blocking findings, and its decisions for the user.
258
260
  - For large work, the lines of `tasks.md`.
259
261
  - The tracking proposal: create tickets in the tracker under the parent (the job's key, or a new parent), or no tickets (`tasks.md` only), or no tickets at all.
260
262
  - The build mode: `worktree` (default) or `in-place`, as set in `job.json`.
261
263
 
262
264
  Then ask in chat, as a numbered choice:
263
265
 
264
- 1. Confirm the plan.
266
+ 1. Confirm the plan. Offered only when the current fit review is an explicit `VERDICT: PASS`.
265
267
  2. Request changes: the operator types the change.
266
268
  3. If size is `unclear`: answer `small` or `large`.
267
269
  4. Change tracking: `tracked` or `none`.
@@ -269,7 +271,7 @@ Then ask in chat, as a numbered choice:
269
271
 
270
272
  Handle the answer:
271
273
 
272
- - **Confirm** with size known → continue to Tracking. If size is still `unclear`, ask again.
274
+ - **Confirm** with size known → continue to Tracking. If size is still `unclear`, or the current fit review is not an explicit `VERDICT: PASS`, ask again.
273
275
  - **Request changes:** write the operator's text verbatim to `plan-<k>.md` (`k` = next free index). Set stage `plan`, rerun `planner` in plan mode (brief `roles/spec.md`) with the paths block and `plan-<k>.md`. Show the gate again. If the change touches the spec itself, send it through the spec gate instead: write it to `spec-<k>.md`, rerun spec mode, show the spec gate, then plan again.
274
276
  - **Change size only:** the operator's answer to choice 3 sets `size` in `job.json`. The plan does not change.
275
277
  - **Change tracking only:** update `tracking` in `job.json`. Do not rerun the spec writer.
@@ -277,6 +279,25 @@ Handle the answer:
277
279
 
278
280
  If the session ends at the gate, nothing is lost. `/factory start <job-id|slug|KEY>` returns to this gate (see Start).
279
281
 
282
+ ## Fit review (spec and plan gates)
283
+
284
+ Read and follow the goal-fit brief: [fit-review](../../../.claude/rules-snippets/fit-review.md). It is a read-only goal-fit review, separate from the reviewer lenses. It runs every time a spec or plan gate is shown: after each planner run, after each change request, after each repair, and on resume.
285
+
286
+ - **Baseline first.** No review runs without the original request. Check `intake.md` for an `## Original request` section or a `## Baseline confirmed` section. If neither exists (a key or slug start, a legacy job, or a sparse one), the orchestrator promotes nothing. It shows the candidate sources it found (the existing `intake.md`, the tracker description when `issue_key` is set, and the existing `spec.md`), each labelled as a candidate and not a requirement. It asks the operator, as a numbered choice: (1) confirm one candidate as the original request, or (2) paste the original request. It writes the confirmed text to `intake.md` under `## Baseline confirmed`, naming its source. Until then the gate reports `NEEDS-DECISION: baseline missing`, and Confirm is not offered.
287
+ - **Goal sources in every dispatch.** Pass them as text, not as paths alone: the verbatim original request (from `## Original request` or `## Baseline confirmed`), and every explicit amendment (the intake answers, and the operator's `spec-<k>.md`, `plan-<k>.md`, and `rework-<k>.md`). For a plan review, also pass the accepted spec. The accepted spec and plan are traced against these; they are not goal authority. A slug, a key, a tracker title, the existing spec on its own, and any reviewer finding are never goal sources.
288
+ - **Reviewer.** Dispatch `oracle` when the harness has it configured read-only. Otherwise dispatch `reviewer` in fresh context. The task line is `goal-fit review: spec` or `goal-fit review: plan`, then the paths block, the goal sources, and the brief. Give the reviewer the artifacts, never the planner's summary.
289
+ - **Independence.** The planner's own output, the orchestrator's reading, and a single session playing every role do not count. With no independent reviewer, the gate reports `BLOCKED: no independent reviewer`, shows the artifact, and does not offer Confirm. Request changes and abandon stay available.
290
+ - **Reply.** The first line decides:
291
+ - `VERDICT: PASS`: the gate may offer Confirm.
292
+ - `VERDICT: CHANGES` with a finding marked `requires user decision; do not auto-repair`: stop as `NEEDS-DECISION`. Show the marked findings with the gate. Confirm is not offered. Nothing is repaired until the user answers with an explicit amendment (a change request), and the artifact is reviewed again.
293
+ - `VERDICT: CHANGES` with only repairable findings: run the repair loop below.
294
+ - No valid first line: re-dispatch once. If it still has none, set `needs-human` with `failed_stage` `spec` or `plan`, as for any spec or plan agent that returns no output.
295
+ - **Repair loop.** On `CHANGES` with only repairable findings, pass the blocking findings to the planner as dispatch context under the heading `Fit repair findings (reviewer findings, not operator requests, not goal authority)`. Write no `spec-<k>.md`, `plan-<k>.md`, or fit file for them. Rerun the planner, then review the changed artifacts again. The loop has no round limit. It repeats until `PASS`, `NEEDS-DECISION`, or `BLOCKED`. Stop as `BLOCKED` with the reason when a repair changes nothing, when the same blocking finding returns unchanged after a repair, or when the planner reports a finding it cannot address. On `BLOCKED`, show the open findings. Confirm is not offered. Request changes and abandon stay available.
296
+ - **Timeouts.** A timed-out fit reviewer is never re-dispatched (see Harness notes). Set stage `needs-human`, `failed_stage` `spec` or `plan`, and the reason `fit reviewer timed out after <N> min; it may still be running`. Tell the operator to confirm the reviewer has stopped before `/factory start`. Confirm is not offered.
297
+ - **Confirm needs an explicit PASS.** Confirm is offered only when the reply on this gate visit starts with `VERDICT: PASS`. The absence of blocking findings is not a PASS.
298
+ - **BLOCKED at the gate versus agent failure.** A `BLOCKED` gate (baseline, independence, or an unproductive loop) leaves the stage at `awaiting-spec` or `awaiting-plan`. A failed agent or a timeout uses `needs-human`, as above.
299
+ - **Later visits.** Once a `BLOCKED` or `needs-human` outcome is resolved (the baseline confirmed, a reviewer available, or a change request given), the next gate visit runs the review again from the start.
300
+
280
301
  ## Tracking
281
302
 
282
303
  Runs once, after the operator confirms the plan and before the build location is created. Skip it when `tracking` is `none`. Keys written in earlier attempts make each step idempotent, so a rerun picks up where it stopped. A re-plan keeps the keys already written: a line with a key is never ticketed again, and tickets for lines a re-plan removes are left as they are and reported.
@@ -604,6 +625,8 @@ The age rule is the same as Archive: by default only jobs whose `updatedAt` is m
604
625
 
605
626
  Dispatch with the paths block first, then the task line, then the role brief and the files to read. The task line names the mode when the agent has one (spec or plan for the spec writer; build, repair, or rework for the builder; the lens for a reviewer; approval for the approver).
606
627
 
628
+ Every dispatch of the planner, builder, reviewers, and approver also passes the goal sources as text, not as paths alone: the confirmed original request and every explicit user amendment (see Fit review: Baseline first and Goal sources). This applies to first runs, reruns, repairs, rework, and resumes alike. If a job has no confirmed baseline, run the Baseline first procedure of Fit review before dispatching, and do not invent goals or omit these inputs. Reviewer findings passed as dispatch context are never goal sources.
629
+
607
630
  Factory adds no agents of its own. Each role runs on a native agent (`planner`, `implementer`, or `reviewer`), and the Factory rules for that role (outputs, evidence, verdict format, escalation triggers) live in its brief in this skill's `roles/` folder. Every dispatch tells the agent to read the matching brief first. The role brief overrides the dispatched agent's default output format and file-writing rules, and the first line of the reply must follow the brief.
608
631
 
609
632
  | Role | Native agent | Task line | Brief | Fresh context | Output |
@@ -641,7 +664,7 @@ The loop is the same in every harness. Use a parallel lens batch where the harne
641
664
  - **Timeout.** The default is 15 minutes per agent. The operator can set another value for one run by saying so in the request, for example `timeout 30 min`.
642
665
  - **A timed-out agent is never re-dispatched.** It may still be running, and a second run could write the same file. Stage `needs-human` with the reason "`<agent>` timed out after `<N>` min; it may still be running". For a spec or plan agent, also set `failed_stage`. Tell the operator to check the job folder and the build location, and to confirm the agent has stopped, before `/factory start` or `/factory rework`.
643
666
 
644
- **Single-session mode (Codex).** Codex has no agent files, so one session plays every role. The orchestrator switches roles one at a time. For each role it reads only that role's brief and input files, writes only that role's output (a reviewer or the approver returns its report, and you save it), and keeps the same write boundaries. The rule "never write code" applies per role: as orchestrator it writes only orchestrator files, and it writes code only as the builder, and only in the build location. Lenses run in order (stage A, then stage B). The security reviewer judges the diff, not the builder's account. A timed-out role is handled as above; a role that ends without its file is re-run once, then `needs-human`.
667
+ **Single-session mode (Codex).** Codex has no agent files, so one session plays every role. The orchestrator switches roles one at a time. For each role it reads only that role's brief and input files, writes only that role's output (a reviewer or the approver returns its report, and you save it), and keeps the same write boundaries. The rule "never write code" applies per role: as orchestrator it writes only orchestrator files, and it writes code only as the builder, and only in the build location. Lenses run in order (stage A, then stage B). The security reviewer judges the diff, not the builder's account. A timed-out role is handled as above; a role that ends without its file is re-run once, then `needs-human`. Fit review is the exception: one session is not independent, so the spec and plan gates report `BLOCKED` instead (see Fit review).
645
668
 
646
669
  ## Limits
647
670
 
@@ -4,7 +4,7 @@ You decide whether a job goes to merge or to a human. You are the approval gate
4
4
 
5
5
  ## Inputs
6
6
 
7
- - The whole job history: `spec.md` (feature folder, paths block), `build.md`, `rework-*.md` if any, every `round-*/review-*.md`, and the job's `job.json`.
7
+ - The whole job history: `spec.md` and `plan.md` (feature folder, paths block), the goal sources in your dispatch (the original request, explicit amendments, and rework decisions, verbatim), `build.md`, `rework-*.md` if any, every `round-*/review-*.md`, and the job's `job.json`.
8
8
  - The final diff: `git -C <worktree> diff {{DEFAULT_BRANCH}}...factory/<id>`.
9
9
  - The project's `AGENTS.md` for test commands.
10
10
 
@@ -12,7 +12,7 @@ You decide whether a job goes to merge or to a human. You are the approval gate
12
12
 
13
13
  1. **Read the history.** Read everything listed above. Note any rework and what it asked for.
14
14
  2. **Final-round reviews.** Confirm every review in the latest round has `VERDICT: PASS`. If any is `CHANGES` or missing, the decision is `ESCALATE`.
15
- 3. **Spot-check one acceptance criterion.** Pick at least one `AC-n` from `spec.md`. Verify it independently: run its check yourself in the build location, or read the code and the test that covers it. Do not trust the builder's evidence alone.
15
+ 3. **Spot-check one acceptance criterion.** Pick at least one `AC-n` from `spec.md`. Verify it independently: run its check yourself in the build location, or read the code and the test that covers it. Do not trust the builder's evidence alone. Also check the branch diff against `plan.md`'s steps and the goal sources: any change that hits the untraced-change trigger in step 5 is an escalation.
16
16
  4. **Dry-run merge.** Check for conflicts without changing anything:
17
17
  ```
18
18
  git -C <main checkout> merge-tree --write-tree {{DEFAULT_BRANCH}} factory/<id>
@@ -28,6 +28,7 @@ You decide whether a job goes to merge or to a human. You are the approval gate
28
28
  - Production data writes, including backfills and one-off scripts.
29
29
  - New dependencies (any added line in a manifest or lockfile).
30
30
  - Open product decisions: any `[PRODUCT DECISION]` item still in `spec.md`. Items the operator answered at the spec gate read `[DECIDED] <answer>` and do not escalate. `build.md` cannot settle a product decision.
31
+ - Untraced change: any changed file or behavior in the final diff that traces to neither an explicit user amendment or rework decision in your dispatch, nor an accepted spec requirement or plan step, and has no justified necessary implementation detail recorded in the round reviews. List each file and line. Drift is not a note: it escalates.
31
32
  6. **Decide.** `APPROVE` only if steps 2–4 pass and step 5 hits nothing. Otherwise `ESCALATE`.
32
33
 
33
34
  ## Output
@@ -4,7 +4,7 @@ You review one round of a job's branch for correctness, simplicity, reuse, conve
4
4
 
5
5
  ## Inputs
6
6
 
7
- - `spec.md` in the feature folder (paths block), and `build.md` in the job folder.
7
+ - `spec.md` and `plan.md` in the feature folder (paths block), the goal sources in your dispatch (the original request and explicit user amendments, verbatim), and `build.md` in the job folder.
8
8
  - The branch diff: `git -C <worktree> diff {{DEFAULT_BRANCH}}...factory/<id>`.
9
9
  - `qa.md` at the paths block's `qa.md (absolute, build location)` line, if it exists: the builder's suggested manual checks. Use it for context only. It never changes your verdict.
10
10
  - Round `N > 1`: your own previous review, `round-<N-1>/review-code.md`. Check whether earlier blocking items were fixed, and say so.
@@ -19,6 +19,7 @@ Run each command the project documents in `AGENTS.md` from the build location: t
19
19
  Use the [requesting code review](../../requesting-code-review/SKILL.md) checklist for process. Then cover:
20
20
 
21
21
  - **Correctness:** logic, edge cases, error handling at boundaries, every acceptance criterion in `spec.md` covered by a test or check.
22
+ - **Scope trace, both ways:** trace the branch diff to `spec.md`'s requirements and acceptance criteria, `plan.md`'s steps, and the goal sources in your dispatch. Every changed file or behavior must trace to a user-authorized goal (the original request or an explicit amendment), to an accepted requirement or planned step, or be a necessary implementation detail for a stated goal (name the goal). A requirement or planned step with no change is a gap. An untraced change with no such reason is scope drift and a blocking item.
22
23
  - **Simplicity:** use the [ponytail-review](../../ponytail-review/SKILL.md) lens. Flag reinvented standard library, speculative abstractions, and dead flexibility.
23
24
  - **Reuse:** the change should extend existing utilities rather than duplicate them.
24
25
  - **Conventions:** the project's `AGENTS.md` and `.claude/rules-snippets/` standards.
@@ -6,7 +6,7 @@ You turn a feature request into a testable spec, and then into a plan. You are o
6
6
 
7
7
  Read these, in this order:
8
8
 
9
- 1. The feature request in your prompt.
9
+ 1. The feature request in your prompt, and the goal sources the orchestrator passes in your dispatch: the original request, verbatim, and any explicit user amendments. The original request is the primary goal source. If a copy in the prompt differs from it, report the difference and follow the verbatim text.
10
10
  2. The project's `AGENTS.md` (conventions and commands).
11
11
  3. The existing code the feature touches. Inspect it. Do not write a spec or plan from the request alone.
12
12
  4. [Feature spec template](../../../../templates/feature-spec.template.md) for the section structure.
@@ -113,5 +113,7 @@ On a re-plan, keep each existing task line that still applies, with its T-number
113
113
 
114
114
  - A change note with `spec-<k>.md` or `plan-<k>.md` is the operator's request. Apply it, and keep everything else the operator already accepted.
115
115
  - When a change note answers a `[PRODUCT DECISION]` item, rewrite that item to start with `[DECIDED]` and the operator's answer, for example `[DECIDED] Free tier: 3 seats.`. Items the note does not answer stay `[PRODUCT DECISION]`. Never mark an item decided yourself.
116
+ - Goal-fit findings passed in your dispatch are reviewer findings. They are not operator requests and not goal authority. Fix only the listed findings, in their sections, and write nothing else. Do not drop or narrow a goal to satisfy a finding. If a finding would need a goal changed, leave the goal as written and add it to Open Questions as a decision for the operator.
117
+ - In plan mode, trace each step to an acceptance criterion, a requirement, or the request. A step no goal needs is out of scope. Implementation details a goal needs are fine without their own criterion.
116
118
  - Keep `spec.md` and `plan.md` free of tooling chatter. They are feature docs that merge with the code.
117
119
  - Do not modify code, tests, `build.md`, `job.json`, `qa.md`, or any file outside the feature folder. Your writes are `spec.md` (spec mode), or `plan.md` and `tasks.md` (plan mode), in the feature folder only.
@@ -32,6 +32,7 @@ Implement a feature by completing tasks sequentially with proper tracking.
32
32
  - Group tasks by domain (backend, frontend, docs, tests)
33
33
  - Tasks that touch **different files with no shared state** → run their loops in parallel
34
34
  - Tasks with dependencies or shared files → keep sequential
35
+ - Tasks with an unknown or undeclared write set → keep sequential until the scope is established
35
36
  - Use `dispatching-parallel-agents` skill when 3+ independent tasks exist
36
37
 
37
38
  3. **Create Feature Branch** (before any build):
@@ -80,7 +81,7 @@ Implement a feature by completing tasks sequentially with proper tracking.
80
81
 
81
82
  6. **Create Pull Request** (only after the feature review is accepted):
82
83
 
83
- a. **Final Validation**: the accepted verify results from step 5 (every required check ran and passed).
84
+ a. **Final Validation**: after all tasks are reconciled, run the project's full required regression checks once on the final integrated tree (implement.md step 3): the repo-defined full suite, lint, typecheck, and build, where they exist. Every required check must pass on this tree. Any edit after this run requires revalidation.
84
85
 
85
86
  b. **Commit and push**: if accepted feature-review changes are still uncommitted, commit them once, staging only the feature's paths, and skip the commit when nothing is staged. Do not create repair-only commits.
86
87
 
@@ -8,6 +8,7 @@ You are the orchestrator for this implementation. You derive the acceptance crit
8
8
  > with this loop. Do not route through a planning skill, and do not write a spec or plan first.
9
9
  > For 3+ independent `[P]` tasks that touch disjoint files, the loops may run concurrently with the
10
10
  > `dispatching-parallel-agents` skill. Each task still runs its own loop.
11
+ > Nontrivial ad-hoc code changes outside these commands follow the same loop. Context-heavy nontrivial work may be built directly, but acceptance still needs an independent reviewer; without one it is BLOCKED. Trivial changes (typos, one-line edits) stay outside this loop.
11
12
 
12
13
  ## Roles
13
14
 
@@ -31,12 +32,12 @@ build → verify → review → decide ─┬─ accept (review PASS, every re
31
32
 
32
33
  ### 1. Task, checks and baseline (orchestrator)
33
34
 
34
- - The original supplied task (request, task list entry, or fix description) is the requirement. Keep its text and give it to the builder and the reviewer unchanged. Do not require a new spec or plan first, and do not write one.
35
+ - The original supplied task (request, task list entry, or fix description) is the requirement. Keep its text and give it to the builder and the reviewer unchanged. Explicit user amendments and answers given during the loop are part of the requirement too: record each one as a dated entry beside the original text (do not rewrite it), and give the builder and the reviewer the original text plus every amendment. Do not require a new spec or plan first, and do not write one.
35
36
  - Turn every requirement in the supplied task into an acceptance criterion, `AC-1`, `AC-2`, ... There is no fixed count: one criterion per requirement, however many there are. Do not add requirements the task does not state.
36
37
  - Each AC names its check. Discover the real checks; do not assume them. Read the project's manifests (for example `package.json` scripts, `Makefile`, `pyproject.toml`, `Cargo.toml`, `go.mod`), its CI configuration (for example `.github/workflows`), its README, and `AGENTS.md`. Use the commands the project actually runs.
37
38
  - A documentation criterion may be checked by direct inspection: open the file and confirm the content, and quote what you found as evidence.
38
- - A required check that cannot be discovered, or cannot be run, is a gap. It is not a pass, and it is not a bypass. Stop and ask the user for the command (see the Blocked exit in step 5).
39
- - Ask only when the task is unclear in a way that changes what gets built: two readings lead to different code, or a needed fact is missing. Ask one targeted question, offering the options, and wait.
39
+ - A required check that cannot be discovered, or cannot be run, is a gap. It is not a pass, and it is not a bypass. It blocks acceptance of the affected task and of any aggregate run that needs it. Ask the user for the command as one targeted question and keep that question in the progress report. Independent tasks whose checks do not depend on the gap continue (see the Blocked exit in step 5).
40
+ - Ask only when a requirement is unclear in a way that changes what gets built: two readings lead to different code, or a needed fact is missing. Ask one targeted question with its options. A task-scoped question blocks only that task and its dependents: independent tasks with clear requirements continue, and the question stays in the progress report (see [subagent-workflow.md](../rules-snippets/subagent-workflow.md), Autonomous Execution and Blockers). If the whole request is unclear, stop and ask before any build.
40
41
  - Take a baseline snapshot once, before any build. It is a plain copy of the state the task starts from, kept in a temporary directory outside the repository:
41
42
  - `git rev-parse HEAD`: the base commit.
42
43
  - `git status --porcelain > <tmp>/baseline/status.txt`: which files were already changed, staged or untracked.
@@ -59,6 +60,8 @@ build → verify → review → decide ─┬─ accept (review PASS, every re
59
60
 
60
61
  Every round, run every check that covers an AC, using the commands from step 1. Treat the builder's report as a lead, not as evidence. For each AC, record `pass` with the command and result from this round, or `not verified` or `fail` with the reason. Docs criteria are recorded with the quoted content.
61
62
 
63
+ Checks are scoped: each repair and each task runs the checks for its own ACs. After all writers are reconciled, run the project's full required regression checks once: the repo-defined full suite, lint, typecheck, and build, where they exist. Use only commands the project defines; do not invent them. A failed required check is a repair. A required check that does not exist or cannot run is BLOCKED (see step 5).
64
+
62
65
  ### 4. Review (reviewer, read-only)
63
66
 
64
67
  Every round, after verify, dispatch the reviewer on the current working tree. Give it the original supplied task text, the AC list, this round's check results, the base commit, and the baseline snapshot. Its review scope covers the whole task, and it compares content, not patches:
@@ -74,6 +77,7 @@ The reviewer's rules:
74
77
  - The first line of the reply is exactly `VERDICT: PASS` or `VERDICT: CHANGES`.
75
78
  - `VERDICT: CHANGES` needs at least one blocking item, each with `file:line`, the problem, and the specific fix. Blocking means a correctness issue, a failing check, a requirement with no test or evidence, or a clear convention break. Taste goes in non-blocking notes.
76
79
  - Check each requirement of the original task, not only the diff. A requirement with no coverage is a blocking item.
80
+ - Scope drift, both ways: trace the diff against the original supplied task. A change that no requirement needs is a blocking item unless the reviewer confirms it is a necessary implementation detail for a stated goal and says why. Goals are the original supplied task plus the user amendments recorded in step 1: do not require or assume a spec or plan (supplied-task exception). Simplicity and SRP notes stay non-blocking unless they add scope the task does not ask for.
77
81
 
78
82
  ### 5. Decide (orchestrator)
79
83
 
@@ -81,11 +85,13 @@ Pick one outcome per round:
81
85
 
82
86
  - **Repair (back to step 2):** the review is `VERDICT: CHANGES`, **or** any AC is `not verified` or `fail`, **or** a required check failed or did not run. Send the open items to the builder, then run steps 3, 4 and 5 again on the current tree.
83
87
  - **Accept (exit):** all of these hold on this round's verify and review: the review is `VERDICT: PASS`; every requirement has an AC marked `pass` with evidence from this round; every required check ran and passed; an independent reviewer produced the verdict; and the builder did not report `BLOCKED`. Then report `ACCEPTED` with the AC evidence. A review PASS alone never accepts.
84
- - **Blocked (exit):** the builder reports `BLOCKED`, or a required check cannot be discovered or run, or no independent reviewer is available. Stop, report `BLOCKED` with the blocker and what would unblock it. Never mark blocked work accepted.
85
- - **Needs user decision (exit):** the task is unclear in a way only the user can settle. Stop, report `NOT ACCEPTED: needs decision` with the question. This is not acceptance.
88
+ - **Blocked (exit for the affected work):** the builder reports `BLOCKED`, a required check cannot be discovered or run, or no independent reviewer is available. Report `BLOCKED` with the blocker and what would unblock it. Never mark blocked work accepted. Work that depends on it stops; independent authorized work with its own checks and reviewer continues. Without an independent reviewer nothing is accepted, but discovery and builds that do not need acceptance may continue and be reported as awaiting review. Stop the run only when no authorized work remains or a mandatory approval, security, or permission gate applies.
89
+ - **Needs user decision (exit for the affected work):** the task is unclear in a way only the user can settle. Stop work on that task and its dependents, report `NOT ACCEPTED: needs decision` with the question, and continue independent authorized work. This is not acceptance.
86
90
 
87
91
  No other exit exists. An unmet requirement, a failing check, or a `not verified` result always loops back to repair. There is no round limit to escape the loop.
88
92
 
93
+ **Evidence freshness.** Acceptance uses evidence from the tree it accepts. Any edit after a verify or review, whether by the builder, a repair, or the orchestrator, invalidates the evidence it affects: rerun the checks covering those ACs and re-review the changed diff. Reuse evidence that the edit cannot affect. If unsure whether an edit affects a check, treat it as affected. Do not rerun everything for an unrelated edit.
94
+
89
95
  ### Commit (only when the calling flow asks)
90
96
 
91
97
  The loop never commits by itself. Accepting reports the result; it does not create a commit. The calling command decides whether accepted work is committed, and only when its own flow says so and the user has not asked otherwise. When it does commit:
@@ -95,13 +101,15 @@ The loop never commits by itself. Accepting reports the result; it does not crea
95
101
 
96
102
  ### Limits
97
103
 
98
- - **No independent reviewer means BLOCKED.** The orchestrator may run its own verify and report the evidence, but it cannot accept the work on its own review. Report `BLOCKED`, and stop.
104
+ - **No independent reviewer means nothing is accepted.** The orchestrator may run its own verify and report the evidence, but it cannot accept the work on its own review. Report `BLOCKED` for acceptance. Do not treat all work as blocked when independent discovery or build can proceed (see the Blocked exit in step 5).
105
+ - Mandatory approval, security, and permission gates are never bypassed. They apply to the affected work, or to the whole run when the gate is global.
99
106
  - A self-review is never presented as an independent review.
107
+ - These gates are prompt instructions, not host enforcement. Resuming after a pause depends on the host; this prompt does not guarantee automatic resume.
100
108
 
101
109
  ## Your Task
102
110
 
103
111
  1. **Analyze**: identify the files to create or modify, the dependencies between tasks, and the `[P]` tasks.
104
- Dispatch `[P]` tasks in parallel only when they touch different files with no shared state. Otherwise keep them sequential.
112
+ Dispatch `[P]` tasks in parallel only when they touch different files with no shared state. Otherwise keep them sequential. A task whose write set is unknown or undeclared runs serially until the builder's changed-file list establishes its scope.
105
113
  2. **Run the delivery loop** for each task, in dependency order, until it exits as accepted, blocked, or needs a user decision.
106
114
  3. **Track progress**: tick a task only after the orchestrator accepts it. Report blockers and summarize the accepted changes.
107
115
 
@@ -55,8 +55,8 @@ Plan how to implement the supplied feature or requirement; a prior specification
55
55
  - `docs/features/{{ISSUE_ID}}-{{FEATURE_NAME}}/api-contract.md` - API specifications
56
56
 
57
57
  5. **Review and Accept Planning Artifacts**:
58
- - The orchestrator dispatches an independent, read-only reviewer with the original request, requirements/context, plan and any additional artifact paths. Review the actual artifacts for completeness, dependencies/order, actionability, and coverage of the request; return `VERDICT: PASS` or `VERDICT: CHANGES` with blocking findings and section references.
59
- - Repair blocking findings within the agreed scope, repeat affected artifact checks, and re-review the changed artifacts independently. Repeat until PASS or blocked; unresolved decisions go to the user.
58
+ - The orchestrator dispatches an independent, read-only reviewer with the original request, requirements/context, plan and any additional artifact paths. Use the goal-fit brief (read and follow [fit-review](../rules-snippets/fit-review.md)): Oracle when available read-only, otherwise a separate reviewer; the author's self-review does not count. Review the actual artifacts for completeness, dependencies/order, actionability, and coverage of the request, and trace goals and plan items both ways. Return `VERDICT: PASS` or `VERDICT: CHANGES` with blocking findings and section references. A finding that needs a user decision is blocking, marked `requires user decision; do not auto-repair`; stop and ask the user.
59
+ - Repair blocking findings within the agreed scope, repeat affected artifact checks, and re-review the changed artifacts independently. Repeat until PASS or blocked, or until the user decides. Stop as BLOCKED with the reason when a repair changes nothing or the same finding returns unchanged. A goal change from the review is a user decision, not a repair. Open decisions block PASS until the user resolves them.
60
60
  - Only the orchestrator accepts, after an independent PASS and evidence for every requirement and applicable artifact check. If an independent reviewer is unavailable, report BLOCKED; self-review cannot substitute for independent acceptance.
61
61
  - This is a lightweight artifact review, not a code build loop: do not implement the plan, run runtime build/TDD/git procedures, or add commit, push, or apply steps. Keep any required human approval separate from artifact acceptance.
62
62
 
@@ -65,12 +65,19 @@ Start a new feature by creating a specification. This is the first step in the d
65
65
  - [ ] [Questions needing clarification]
66
66
  ```
67
67
 
68
- 5. **Create Git Branch** (optional):
68
+ 5. **Review and Accept the Specification**:
69
+ - Dispatch an independent, read-only reviewer with the original request (verbatim, with any later user amendments), the feature description, any intake answers, and `spec.md`. Use the goal-fit brief (read and follow [fit-review](../rules-snippets/fit-review.md)): Oracle when available read-only, otherwise a separate reviewer; the author's self-review does not count.
70
+ - The reviewer traces requirements and acceptance criteria both ways against the original request, checks that each criterion is testable, and returns `VERDICT: PASS` or `VERDICT: CHANGES` with blocking findings and section references. A finding that needs a user decision is blocking, marked `requires user decision; do not auto-repair`; stop and ask the user.
71
+ - Repair blocking findings within the agreed scope, repeat the affected checks, and re-review the changed spec independently. Repeat until PASS or blocked, or until the user decides. Stop as BLOCKED with the reason when a repair changes nothing or the same finding returns unchanged. A goal change from the review is a user decision, not a repair. Open decisions block PASS until the user resolves them.
72
+ - Only the orchestrator accepts, after an independent PASS. If an independent reviewer is unavailable, report BLOCKED; self-review cannot substitute for independent acceptance.
73
+ - Acceptance is separate from human approval: the human still confirms the spec.
74
+
75
+ 6. **Create Git Branch** (optional):
69
76
  ```bash
70
77
  git checkout -b feature/{{FEATURE_NAME}}
71
78
  ```
72
79
 
73
- 6. **Report Completion**:
80
+ 7. **Report Completion** only after artifact acceptance:
74
81
  - Feature directory path
75
82
  - Spec file path
76
83
  - Branch name (if created)