dev-loops 0.6.0 → 0.7.2

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 (203) hide show
  1. package/.claude/.claude-plugin/plugin.json +1 -1
  2. package/.claude/agents/dev-loop.md +8 -7
  3. package/.claude/agents/fixer.md +1 -0
  4. package/.claude/agents/refiner.md +2 -2
  5. package/.claude/agents/review.md +4 -3
  6. package/.claude/commands/{auto.md → loop-auto.md} +1 -1
  7. package/.claude/commands/loop-continue.md +15 -0
  8. package/.claude/commands/loop-enqueue.md +22 -0
  9. package/.claude/commands/loop-grill.md +17 -0
  10. package/.claude/commands/{info.md → loop-info.md} +2 -2
  11. package/.claude/commands/loop-queue-status.md +24 -0
  12. package/.claude/commands/{start-spike.md → loop-start-spike.md} +2 -2
  13. package/.claude/commands/{start.md → loop-start.md} +1 -1
  14. package/.claude/commands/{status.md → loop-status.md} +1 -1
  15. package/.claude/hooks/_bash-command-classify.mjs +333 -29
  16. package/.claude/hooks/_hook-decisions.mjs +138 -15
  17. package/.claude/hooks/pre-tool-use-bash-gate.mjs +36 -15
  18. package/.claude/skills/copilot-pr-followup/SKILL.md +60 -34
  19. package/.claude/skills/dev-loop/SKILL.md +16 -12
  20. package/.claude/skills/docs/acceptance-criteria-verification.md +8 -3
  21. package/.claude/skills/docs/anti-patterns.md +5 -3
  22. package/.claude/skills/docs/artifact-authority-contract.md +30 -11
  23. package/.claude/skills/docs/confirmation-rules.md +1 -0
  24. package/.claude/skills/docs/contract-style-guide.md +37 -0
  25. package/.claude/skills/docs/copilot-loop-operations.md +19 -15
  26. package/.claude/skills/docs/cross-harness-regression-contract.md +60 -0
  27. package/.claude/skills/docs/debt-remediation-contract.md +1 -1
  28. package/.claude/skills/docs/epic-tree-refinement-procedure.md +25 -22
  29. package/.claude/skills/docs/issue-intake-procedure.md +26 -19
  30. package/.claude/skills/docs/local-planning-flow.md +1 -1
  31. package/.claude/skills/docs/local-planning-worked-example.md +1 -1
  32. package/.claude/skills/docs/merge-preconditions.md +30 -12
  33. package/.claude/skills/docs/plan-file-contract.md +1 -1
  34. package/.claude/skills/docs/pr-lifecycle-contract.md +44 -35
  35. package/.claude/skills/docs/public-dev-loop-contract.md +60 -44
  36. package/.claude/skills/docs/retrospective-checkpoint-contract.md +106 -79
  37. package/.claude/skills/docs/spike-mode-contract.md +14 -7
  38. package/.claude/skills/docs/stop-conditions.md +30 -15
  39. package/.claude/skills/docs/tracker-first-loop-state.md +13 -8
  40. package/.claude/skills/docs/ui-e2e-scoping-step.md +32 -0
  41. package/.claude/skills/docs/validation-policy.md +4 -5
  42. package/.claude/skills/docs/workflow-handoff-contract.md +39 -0
  43. package/.claude/skills/local-implementation/SKILL.md +62 -145
  44. package/.claude/skills/loop-grill/SKILL.md +163 -0
  45. package/AGENTS.md +1 -0
  46. package/CHANGELOG.md +101 -0
  47. package/README.md +9 -9
  48. package/agents/dev-loop.agent.md +11 -10
  49. package/agents/developer.agent.md +1 -1
  50. package/agents/docs.agent.md +1 -1
  51. package/agents/fixer.agent.md +2 -1
  52. package/agents/quality.agent.md +1 -1
  53. package/agents/refiner.agent.md +3 -3
  54. package/agents/review.agent.md +5 -4
  55. package/cli/index.mjs +35 -42
  56. package/extension/README.md +4 -4
  57. package/extension/checks.ts +1 -5
  58. package/extension/harness-types.ts +1 -0
  59. package/extension/index.ts +6 -0
  60. package/extension/pi-extension-adapter.ts +2 -0
  61. package/extension/presentation.ts +7 -19
  62. package/package.json +12 -12
  63. package/scripts/_core-helpers.mjs +2 -0
  64. package/scripts/claude/headless-dev-loop.mjs +1 -1
  65. package/scripts/docs/validate-rule-ownership.mjs +442 -0
  66. package/scripts/docs/validate-state-machine-conformance.mjs +1092 -0
  67. package/scripts/github/_review-thread-mutations.mjs +5 -2
  68. package/scripts/github/capture-review-threads.mjs +2 -9
  69. package/scripts/github/comment-issue.mjs +2 -9
  70. package/scripts/github/create-label.mjs +133 -0
  71. package/scripts/github/create-pr.mjs +119 -10
  72. package/scripts/github/detect-checkpoint-evidence.mjs +259 -18
  73. package/scripts/github/detect-linked-issue-pr.mjs +22 -6
  74. package/scripts/github/edit-pr.mjs +259 -0
  75. package/scripts/github/fetch-ci-logs.mjs +2 -9
  76. package/scripts/github/list-issues.mjs +2 -9
  77. package/scripts/github/list-review-threads.mjs +277 -0
  78. package/scripts/github/manage-sub-issues.mjs +46 -10
  79. package/scripts/github/offer-human-handoff.mjs +8 -5
  80. package/scripts/github/post-gate-findings.mjs +20 -5
  81. package/scripts/github/probe-ci-status.mjs +8 -2
  82. package/scripts/github/probe-copilot-review.mjs +21 -14
  83. package/scripts/github/ready-for-review.mjs +26 -8
  84. package/scripts/github/reconcile-draft-gate.mjs +7 -3
  85. package/scripts/github/reply-resolve-review-thread.mjs +16 -5
  86. package/scripts/github/reply-resolve-review-threads.mjs +69 -7
  87. package/scripts/github/request-copilot-review.mjs +98 -26
  88. package/scripts/github/resolve-handoff-candidates.mjs +7 -3
  89. package/scripts/github/resolve-tracker-local-spec.mjs +9 -3
  90. package/scripts/github/stage-reviewer-draft.mjs +10 -2
  91. package/scripts/github/tick-verified-checkboxes.mjs +202 -0
  92. package/scripts/github/upsert-checkpoint-verdict.mjs +105 -15
  93. package/scripts/github/verify-briefing-prefixes.mjs +191 -0
  94. package/scripts/github/verify-fresh-review-context.mjs +226 -32
  95. package/scripts/github/view-pr.mjs +150 -0
  96. package/scripts/github/wait-pr-checks.mjs +171 -0
  97. package/scripts/github/write-gate-context.mjs +458 -65
  98. package/scripts/github/write-gate-findings-log.mjs +128 -2
  99. package/scripts/lib/jq-output.mjs +18 -0
  100. package/scripts/loop/_post-convergence-change.mjs +211 -0
  101. package/scripts/loop/_pr-runner-coordination.mjs +70 -0
  102. package/scripts/loop/_repo-root-resolver.mjs +47 -0
  103. package/scripts/loop/build-handoff-envelope.mjs +14 -4
  104. package/scripts/loop/check-retro-tooling.mjs +14 -3
  105. package/scripts/loop/checkpoint-contract.mjs +7 -4
  106. package/scripts/loop/cleanup-worktree.mjs +12 -3
  107. package/scripts/loop/conductor-monitor.mjs +12 -18
  108. package/scripts/loop/copilot-pr-handoff.mjs +162 -14
  109. package/scripts/loop/debt-remediate.mjs +24 -12
  110. package/scripts/loop/detect-change-scope.mjs +38 -9
  111. package/scripts/loop/detect-copilot-loop-state.mjs +34 -8
  112. package/scripts/loop/detect-copilot-session-activity.mjs +7 -3
  113. package/scripts/loop/detect-initial-copilot-pr-state.mjs +7 -3
  114. package/scripts/loop/detect-internal-only-pr.mjs +8 -2
  115. package/scripts/loop/detect-issue-refinement-artifact.mjs +6 -3
  116. package/scripts/loop/detect-pr-gate-coordination-state.mjs +184 -69
  117. package/scripts/loop/detect-reviewer-loop-state.mjs +12 -2
  118. package/scripts/loop/detect-tracker-first-loop-state.mjs +9 -1
  119. package/scripts/loop/detect-tracker-pr-state.mjs +10 -3
  120. package/scripts/loop/ensure-worktree.mjs +8 -3
  121. package/scripts/loop/info.mjs +12 -4
  122. package/scripts/loop/inspect-run-viewer/constants.mjs +4 -18
  123. package/scripts/loop/inspect-run-viewer/vendor/mermaid.min.js +3405 -0
  124. package/scripts/loop/inspect-run-viewer-ci-changes.mjs +18 -6
  125. package/scripts/loop/inspect-run-viewer.mjs +67 -4
  126. package/scripts/loop/inspect-run.mjs +8 -2
  127. package/scripts/loop/outer-loop.mjs +8 -4
  128. package/scripts/loop/pr-runner-coordination.mjs +2 -9
  129. package/scripts/loop/pre-commit-branch-guard.mjs +16 -10
  130. package/scripts/loop/pre-flight-gate.mjs +9 -9
  131. package/scripts/loop/pre-pr-ready-gate.mjs +8 -4
  132. package/scripts/loop/pre-write-remote-freshness-guard.mjs +13 -4
  133. package/scripts/loop/provision-worktree.mjs +74 -3
  134. package/scripts/loop/resolve-dev-loop-startup.mjs +216 -10
  135. package/scripts/loop/resolve-gate-dispatch.mjs +134 -0
  136. package/scripts/loop/resolve-pr-conflicts.mjs +14 -7
  137. package/scripts/loop/run-conductor-cycle.mjs +8 -2
  138. package/scripts/loop/run-queue.mjs +18 -9
  139. package/scripts/loop/run-refinement-audit.mjs +8 -9
  140. package/scripts/loop/run-watch-cycle.mjs +2 -9
  141. package/scripts/loop/sanctioned-commands.mjs +106 -0
  142. package/scripts/loop/steer-loop.mjs +29 -16
  143. package/scripts/loop/validate-pr-body-spec.mjs +223 -0
  144. package/scripts/loop/watch-initial-copilot-pr.mjs +8 -3
  145. package/scripts/pages/build-site.mjs +59 -8
  146. package/scripts/pages/build-state-atlas.mjs +443 -0
  147. package/scripts/projects/_resolve-project.mjs +1 -0
  148. package/scripts/projects/add-queue-item.mjs +60 -54
  149. package/scripts/projects/archive-done-items.mjs +49 -84
  150. package/scripts/projects/ensure-queue-board.mjs +10 -36
  151. package/scripts/projects/list-queue-items.mjs +59 -382
  152. package/scripts/projects/move-queue-item.mjs +21 -449
  153. package/scripts/projects/reconcile-queue.mjs +253 -0
  154. package/scripts/projects/reorder-queue-item.mjs +43 -68
  155. package/scripts/projects/resolve-active-board-item.mjs +108 -46
  156. package/scripts/projects/sync-item-status.mjs +15 -10
  157. package/scripts/refine/_refine-helpers.mjs +21 -5
  158. package/scripts/refine/exit-spike.mjs +18 -8
  159. package/scripts/refine/promote-plan.mjs +22 -16
  160. package/scripts/refine/prose-linkage-detector.mjs +1 -1
  161. package/scripts/refine/refine-plan-file.mjs +13 -4
  162. package/scripts/refine/refinement-completeness-checker.mjs +1 -1
  163. package/scripts/refine/scaffold-spike-file.mjs +4 -8
  164. package/scripts/refine/scope-boundary-cross-checker.mjs +1 -1
  165. package/scripts/refine/tree-integrity-validator.mjs +1 -1
  166. package/scripts/refine/validate-plan-file.mjs +1 -1
  167. package/scripts/refine/validate-spike-file.mjs +1 -1
  168. package/scripts/refine/verify.mjs +11 -6
  169. package/scripts/release/assert-core-dependency-version.mjs +123 -0
  170. package/scripts/release/extract-changelog-section.mjs +16 -2
  171. package/skills/copilot-pr-followup/SKILL.md +60 -34
  172. package/skills/dev-loop/SKILL.md +11 -7
  173. package/skills/docs/acceptance-criteria-verification.md +8 -3
  174. package/skills/docs/anti-patterns.md +5 -3
  175. package/skills/docs/artifact-authority-contract.md +30 -11
  176. package/skills/docs/confirmation-rules.md +1 -0
  177. package/skills/docs/contract-style-guide.md +37 -0
  178. package/skills/docs/copilot-loop-operations.md +19 -15
  179. package/skills/docs/cross-harness-regression-contract.md +60 -0
  180. package/skills/docs/debt-remediation-contract.md +1 -1
  181. package/skills/docs/epic-tree-refinement-procedure.md +25 -22
  182. package/skills/docs/issue-intake-procedure.md +26 -19
  183. package/skills/docs/local-planning-flow.md +1 -1
  184. package/skills/docs/local-planning-worked-example.md +1 -1
  185. package/skills/docs/merge-preconditions.md +30 -12
  186. package/skills/docs/plan-file-contract.md +1 -1
  187. package/skills/docs/pr-lifecycle-contract.md +44 -35
  188. package/skills/docs/public-dev-loop-contract.md +60 -44
  189. package/skills/docs/required-rules.json +149 -0
  190. package/skills/docs/retrospective-checkpoint-contract.md +106 -79
  191. package/skills/docs/spike-mode-contract.md +14 -7
  192. package/skills/docs/stop-conditions.md +30 -15
  193. package/skills/docs/tracker-first-loop-state.md +13 -8
  194. package/skills/docs/ui-e2e-scoping-step.md +32 -0
  195. package/skills/docs/validation-policy.md +4 -5
  196. package/skills/docs/workflow-handoff-contract.md +39 -0
  197. package/skills/local-implementation/SKILL.md +62 -145
  198. package/skills/loop-grill/SKILL.md +165 -0
  199. package/.claude/commands/continue.md +0 -15
  200. package/scripts/docs/validate-no-duplicate-rules.mjs +0 -250
  201. package/scripts/loop/conductor.mjs +0 -233
  202. package/scripts/loop/detect-stale-runner.mjs +0 -265
  203. package/scripts/loop/pre-push-main-guard.mjs +0 -117
@@ -43,11 +43,17 @@ Treat missing optional files as normal bootstrap conditions, not errors.
43
43
 
44
44
  ### Tracker-backed local implementation
45
45
 
46
- Local implementation supports two durable spec inputs:
46
+ Local implementation supports these spec-of-record inputs. The first two are durable/committed artifacts; the third is a spec-of-record that is NOT a durable committed artifact:
47
+
48
+ Durable/committed spec artifacts:
47
49
 
48
50
  - phase-doc-backed local sessions ([Phase Plan](../../docs/phases/phase-x.md) is canonical)
49
51
  - tracker-backed local sessions (the tracker issue is canonical)
50
52
 
53
+ Non-durable spec-of-record (no committed plan artifact):
54
+
55
+ - lightweight PR-body-as-spec sessions (`--lightweight`; the PR description is the canonical spec-of-record but NOT a durable committed artifact — the resolver output carries `canonicalSpecSource: pr_body` and the derived handoff envelope carries `specSource: pr_body`; no phase/plan doc minted or committed). Same gate sequence as the phase-doc path; only the backing artifact differs. See [Artifact Authority Contract](../docs/artifact-authority-contract.md) "Lightweight (PR-body-as-spec)".
56
+
51
57
  Tracker-backed local implementation stays inside the existing `local_implementation` path. For sub-issue tree decomposition, see [Sub-Issue Tree Contract](../../docs/sub-issue-tree-contract.md) (this is a source-repo reference; it is not part of the bundled `../docs/` runtime contract surface for installed skill copies). It does not introduce a new routing mode.
52
58
 
53
59
  When the local spec already lives in a tracker issue:
@@ -55,47 +61,38 @@ When the local spec already lives in a tracker issue:
55
61
  - resolve the tracker reference deterministically from a GitHub issue URL or explicit `<owner/name>` + issue number
56
62
  - use the bounded GitHub helper `scripts/github/resolve-tracker-local-spec.mjs` when you need a machine-readable spec bundle
57
63
  - treat the tracker issue title/body/url/state as the durable local spec bundle
58
- - do not create or read [Phase Plan](../../docs/phases/phase-x.md) for that same tracker-backed session
64
+ - the no-duplicate-phase-doc rule is owned by `ARTIFACT-TRACKER-FIRST-NO-DUP` in [Artifact Authority Contract](../docs/artifact-authority-contract.md); do not read [Phase Plan](../../docs/phases/phase-x.md) for that same tracker-backed session either
59
65
  - sync durable scope / acceptance / status changes back to the tracker issue rather than maintaining a duplicate local phase doc
60
66
  - keep `tmp/` as temporary local execution state only; it does not become a second durable spec surface
61
67
  - for tracker-backed sessions, the handoff path is always: push the working branch → open a PR → merge via GitHub
62
- - for tracker-backed sessions, always open PRs through the canonical `dev-loops pr create` path, which is ALWAYS draft and always assigned — self-assigned by default (`--assignee @me` when none is given; honors an explicit `--assignee <login>` / `-a <login>`), never via raw `gh pr create`. The PR body must contain `Closes #N` (or `Fixes #N`) for the linked issue so GitHub auto-closes it on merge. When `.devloops` sets `workflow.requireDraftFirst` to true, use `dev-loops pr create --assignee @me ...`. Do not create a fresh PR directly in ready-for-review state unless the user explicitly overrides that policy for the current PR scope. The draft gate inspection is a real workflow boundary.
63
- - do not suggest a direct local-main merge for tracker-backed sessions; do not merge the working branch into local `main` at phase completion
68
+ - <!-- rule: LOCAL-PR-CREATE-CANONICAL --> for tracker-backed sessions, you MUST open PRs through the canonical `dev-loops pr create` path always draft and always assigned — self-assigned by default (`--assignee @me` when none is given; honors an explicit `--assignee <login>` / `-a <login>`) and MUST NOT open them via raw `gh pr create`. The PR body MUST contain `Closes #N` (or `Fixes #N`) for the linked issue so GitHub auto-closes it on merge. When `.devloops` sets `workflow.requireDraftFirst` to true, use `dev-loops pr create --assignee @me ...`; the draft-first requirement itself is owned by [`OPS-DRAFT-FIRST-PR`](../docs/copilot-loop-operations.md).
69
+ - <!-- rule: LOCAL-TRACKER-NO-DIRECT-MERGE --> `LOCAL-TRACKER-NO-DIRECT-MERGE`: for tracker-backed sessions, agents MUST NOT suggest a direct local-main merge and MUST NOT merge the working branch into local `main` at phase completion
64
70
 
65
71
  ## Primary execution rules
66
72
 
67
73
  ### Step 0: Pre-flight gate (mandatory for local_implementation)
68
74
 
69
- For the `local_implementation` strategy, before any planning or implementation mutation, run the pre-flight gate:
75
+ <!-- rule: LOCAL-PREFLIGHT-GATE-MANDATORY -->
76
+ For the `local_implementation` strategy, before any planning or implementation mutation, you MUST run the pre-flight gate:
70
77
 
71
78
  ```sh
72
79
  node scripts/loop/pre-flight-gate.mjs --expected-branch <working-branch> --check-subagents
73
80
  ```
74
81
 
75
- Before creating or reusing a worktree for local implementation, use the canonical lifecycle entrypoint, which fetches the base remote, then creates-or-reuses the worktree at its namespaced path and provisions it in one step:
82
+ Before creating or reusing a worktree for local implementation, use the canonical lifecycle entrypoint (`WORKTREE-CREATE-PROVISION`, see [Worktree usage guidance](../../docs/worktree-guidance.md#create-or-reuse--provision-ensure-worktreemjs)):
76
83
 
77
84
  ```sh
78
85
  node scripts/loop/ensure-worktree.mjs --repo-root <main> --issue <n>
79
86
  ```
80
87
 
81
- This creates (or reuses) the worktree at `tmp/worktrees/dev-loops/<kind>-<n>` from a freshly fetched `origin/main` (the authoritative base for all worktree creation) and provisions its gitignored runtime files. Raw `git worktree add -b <branch> tmp/worktrees/dev-loops/<kind>-<n> origin/main` is the underlying mechanism `ensure-worktree.mjs` runs for you. See [worktree guidance](../../docs/worktree-guidance.md).
82
-
83
- This validates:
84
- - Worktree isolation (current directory is under `tmp/worktrees/`)
85
- - Branch identity (current branch matches the working branch)
86
- - Subagent availability (subagents should be used for fan-out when available)
87
-
88
- If the gate fails, **stop and fix the violation** before proceeding. Do not bypass the gate in normal workflow execution.
88
+ This validates worktree isolation (current directory under `tmp/worktrees/`) and branch identity (current branch matches the working branch); `--check-subagents` only reports subagent availability and is advisory (fails-open, does not block the gate). If the gate fails, **stop and fix the violation** before proceeding do not bypass it in normal workflow execution.
89
89
 
90
- Note: `--check-subagents` is advisory it reports availability but does not block the gate. The worktree and branch checks are the mandatory gates.
91
-
92
- This gate does **not** apply to other routed strategies (`copilot_pr_followup`, `external_pr_followup`, `reviewer_fixer`, `wait_watch`, `final_approval`, `issue_intake`). Those strategies have their own execution rules and may edit code from any checkout as needed.
93
-
94
- Development-only bypass (`DEVLOOPS_PREFLIGHT_BYPASS=1`) exists for testing the gate itself but must not be used in production workflow runs. The bypass variable is a testing convenience, not an operational escape hatch.
90
+ This gate does **not** apply to other routed strategies (`copilot_pr_followup`, `external_pr_followup`, `reviewer_fixer`, `wait_watch`, `final_approval`, `issue_intake`); those strategies have their own execution rules and may edit code from any checkout as needed. The development-only bypass (`DEVLOOPS_PREFLIGHT_BYPASS=1`) exists for testing the gate itself and MUST NOT be used in production workflow runs — it is a testing convenience, not an operational escape hatch.
95
91
 
96
92
  ## Narrow failure-triage fast path
97
93
 
98
- When resuming local implementation with dirty work or an observed failing command, use this path before broad discovery:
94
+ <!-- rule: LOCAL-FAILURE-TRIAGE-ORDER -->
95
+ When resuming local implementation with dirty work or an observed failing command, you MUST follow this ordered path before broad discovery:
99
96
 
100
97
  1. run startup once from the relevant worktree/context
101
98
  2. inspect current state with `git status` and the changed files
@@ -109,20 +106,13 @@ Follow [Anti-patterns](../docs/anti-patterns.md) for the general tooling-interna
109
106
 
110
107
  ### Step 1
111
108
 
112
- - Implement **one phase at a time**.
113
- - Do not refine later phases in detail before the current phase is complete.
109
+ - <!-- rule: LOCAL-PHASE-ONE-AT-A-TIME --> You MUST implement **one phase at a time** and MUST NOT refine later phases in detail before the current phase is complete.
114
110
  - Use the `refiner` agent for phase-refinement work when subagents are available; escalate RFC-worthy technical decisions to the parent session / human operator.
115
- - Work **test-first** for all non-trivial logic.
116
- - Maintain **90% coverage** thresholds.
111
+ - <!-- rule: LOCAL-TEST-FIRST-COVERAGE --> You MUST work **test-first** for all non-trivial logic and SHOULD maintain **90% coverage** thresholds (coverage is not enforced by the shipped verify config; treat it as the working target).
117
112
  - Log detailed iteration artifacts under `tmp/` using the required structure below.
118
- - For phase-doc-backed local sessions, keep durable phase intent and acceptance criteria in [Phase Plan](../../docs/phases/phase-x.md); for tracker-backed local sessions, keep that durable intent in the tracker issue and do not duplicate it into [Phase Plan](../../docs/phases/phase-x.md). Keep detailed execution artifacts in `tmp/`.
119
- - Treat `tmp/` as temporary local execution state. Do not rely on it as durable repo history and do not force-add it to git unless the user explicitly wants checked-in examples or fixtures.
113
+ - Spec-of-record split (phase-doc-backed vs. tracker-backed vs. lightweight): see [Tracker-backed local implementation](#tracker-backed-local-implementation) above.
120
114
  - When a phase changes durable product truth in ways `PLAN.md` should express (for example command surface, accepted product decisions, resolved open questions, or scope changes), update [Project Plan](../../PLAN.md) before closing the phase.
121
- - Do implementation work on a dedicated local branch, not directly on `main`.
122
- - If the repo has no commits yet, still create the working branch first so the first commits land off `main`; only move `main` forward after review and validation.
123
- - Use small atomic local commits as progress checkpoints whenever a coherent slice is green and reviewable.
124
- - Before a branch is considered review-complete, approval-ready, merge-ready, or ready for final handoff, run the default pre-approval gate as a full review / fix loop with the review angles resolved from config (`resolveGateAngles(config, "preApproval")`), then apply accepted fixes and rerun validation. Shipped defaults include the `deep` angle.
125
- - A phase is only fully complete when its scoped work, required support files, artifacts, validation, review/fix pass, commit(s), and finalization (merge into local `main` for phase-doc-backed sessions; PR merge for tracker-backed sessions) are done, or when the only remaining step is an explicitly noted authorization-gated finalization action.
115
+ - Branch, commit, pre-approval-gate, and finalization mechanics: see [Branch / review / merge policy](#branch--review--merge-policy), [Commit policy](#commit-policy), and [Implementation loop for the phase](#implementation-loop-for-the-phase) below.
126
116
  - When subagents are used, log what each subagent was asked to do and what it concluded.
127
117
  - If [Project Plan](../../PLAN.md) is too rough or ambiguous to safely start the current phase, do not guess: run a clarification/interview step with the user first.
128
118
 
@@ -130,34 +120,16 @@ Follow [Anti-patterns](../docs/anti-patterns.md) for the general tooling-interna
130
120
 
131
121
  Apply [Structural Quality](../docs/structural-quality.md) from the `deep` review angle.
132
122
 
133
- ## Light mode (small changes) — config-only
123
+ ## Light mode (small changes)
134
124
 
135
- Light mode is currently **config-only**: the schema, resolver, and scope detector are implemented, but no functional wiring exists yet in the local-implementation flow. When scope is small enough, the intent is to skip fan-out/fan-in and use a single review pass instead. Light mode will still require validation and pre-approval gate once wired.
125
+ <!-- rule: LOCAL-LIGHT-MODE-CONFIG-SURFACE -->
126
+ `localImplementation.lightMode` (`.devloops` field; this repo sets `maxLines: 20`, `maxFiles: 2`) is this skill's config surface for light-mode gate dispatch. Gate-collapse mechanics, escalation, and dispatch resolution (`resolveGateDispatchMode`, `scripts/loop/resolve-gate-dispatch.mjs`) are owned by [Light-mode inline acceptance](../../docs/gate-review-sub-loop-contract.md#light-mode-inline-acceptance-under-threshold-micro-prs); this skill MUST NOT redefine them.
136
127
 
137
- **Eligibility:** ≤3 files AND ≤200 lines changed (configurable via `.devloops` field `localImplementation.lightMode`).
138
-
139
- Use `scripts/loop/detect-change-scope.mjs` to determine eligibility:
128
+ Use `scripts/loop/detect-change-scope.mjs` to determine scope:
140
129
  ```sh
141
130
  node scripts/loop/detect-change-scope.mjs
142
131
  ```
143
132
 
144
- **Planned light mode path (not yet wired):**
145
- 1. Validation (`npm run verify`)
146
- 2. Single review pass (not multi-angle fan-out)
147
- 3. Pre-approval gate
148
- 4. Finalization
149
-
150
- **Override threshold:**
151
- ```yaml
152
- localImplementation:
153
- lightMode:
154
- enabled: true
155
- maxFiles: 5
156
- maxLines: 300
157
- ```
158
-
159
- Disabled by default (opt-in). Scope above threshold falls back to full fan-out/fan-in path.
160
-
161
133
  ## Deterministic logging structure
162
134
 
163
135
  Treat the workflow as three layers:
@@ -264,6 +236,10 @@ For the **current phase only**, run this loop before implementation.
264
236
 
265
237
  ### 1. Create or update the durable phase doc and tmp scaffold
266
238
 
239
+ **Lightweight (PR-body-as-spec) exception:** when the session is lightweight — the resolver output carries `canonicalSpecSource: pr_body` and the derived handoff envelope carries `specSource: pr_body` (started via `resolve-dev-loop-startup.mjs --issue <n> --lightweight`) — SKIP the durable phase-doc mint entirely. The PR description is the spec-of-record; do NOT create or commit any `docs/phases/*.md` for this session. The ephemeral `tmp/phases/` scaffold may still be used for local execution state. All other steps (read prior learning, plan, implement) proceed unchanged, and the gate sequence (draft → pre-approval fanout → detect-evidence → human merge) is identical. See [Artifact Authority Contract](../docs/artifact-authority-contract.md) "Lightweight (PR-body-as-spec)".
240
+
241
+ Otherwise (default phase-doc path), create or update the durable phase doc.
242
+
267
243
  Use paths like:
268
244
  - `docs/phases/phase-0.md`
269
245
  - `tmp/phases/phase-0/`
@@ -399,7 +375,8 @@ If the review finds real issues, revise the merged plan and briefly update the r
399
375
 
400
376
  ### 6. Only then start implementation
401
377
 
402
- Do not begin coding before the merged phase plan has passed review.
378
+ <!-- rule: LOCAL-PLAN-REVIEW-GATE -->
379
+ You MUST NOT begin coding before the merged phase plan has passed review.
403
380
  Update `manifest.json` to show that phase implementation has started.
404
381
 
405
382
  ## Task breakdown & delegation
@@ -418,7 +395,8 @@ into parallel executable tasks and dispatch them to the right specialist subagen
418
395
 
419
396
  ### Delegation contract
420
397
 
421
- Dispatch implementation tasks to dedicated specialist agents:
398
+ <!-- rule: LOCAL-DELEGATION-TABLE -->
399
+ Implementation tasks MUST be dispatched to dedicated specialist agents per this table:
422
400
 
423
401
  | Task type | Delegate to |
424
402
  |---|---|
@@ -518,7 +496,7 @@ After the phase plan passes review:
518
496
  5. Run the default pre-approval gate as a full review / fix loop on the branch before calling it review-complete, approval-ready, merge-ready, or ready for final handoff:
519
497
  - resolve review angles from config: `resolveGateAngles(config, "preApproval")` from `@dev-loops/core/config` (shipped defaults enable all 11 pre-approval gate angle families; consumer repos may opt out individual angles via `excludeAngles`); run via the chain prescription below
520
498
  - run the resolved angle-focused passes in parallel with fresh context when practical
521
- - if parallel execution is impractical (for example due to tooling or resource constraints), run all angles sequentially and explicitly record why parallel execution was impractical in `Phase Review` (`tmp/phases/phase-x/review.md`) (or the equivalent merged review artifact)
499
+ - the sequential-fallback rule is owned by `GATE-EXEC-FANOUT-SEQUENTIAL-FALLBACK` in [Gate Review Sub-Loop Contract](../../docs/gate-review-sub-loop-contract.md); when it applies, record the fallback in `Phase Review` (`tmp/phases/phase-x/review.md`) (or the equivalent merged review artifact)
522
500
  - for each angle, resolve its persona and prompt via `resolveReviewerRole(config, angle)` — start each reviewer in fresh context with a concise briefing including the angle-specific prompt, the branch/phase, intended behavior, acceptance criteria, relevant files or artifacts, and current validation status
523
501
  - run the mandatory chain defined in [Gate Review Sub-Loop Contract](../../docs/gate-review-sub-loop-contract.md). Retry rule: in subsequent cycles, only re-run reviewers that produced findings in the previous pass. Do not fork the parent session for parallel reviewers; write a compact handoff artifact under `tmp/` and point the reviewer at it.
524
502
  - when reviewer subagents stumble on raw source-tree reads (for example unresolved build artifacts or import assumptions), generate a deterministic diff/review artifact under `tmp/` and have reviewers inspect that artifact instead of the raw file set
@@ -532,8 +510,8 @@ After the phase plan passes review:
532
510
  9. Write `Retrospective` (`tmp/phases/phase-x/retrospective.md`) using [Retrospective Template](../dev-loop/templates/retrospective.md).
533
511
  10. Update `tmp/phases/phase-x/manifest.json` and `tmp/phases/index.json`.
534
512
  11. Update [Implementation State](../../docs/IMPLEMENTATION_STATE.md).
535
- 12. **Exit validation gate — no uncommitted changes.** Before the subagent session terminates, run `git status --porcelain` and verify the output is empty. If uncommitted changes exist, first determine whether they are intended implementation changes or unintended/post-validation deltas. Revert any unintended or speculative changes. For intended changes, rerun the narrowest justified validation (`npm run verify` or equivalent) before staging and committing with an appropriate message; for tracker-backed sessions, also push the branch. A subagent session that exits with uncommitted changes in the worktree is a workflow defect and must not be treated as a clean completion. After committing, verify `git status --porcelain` is empty before declaring phase completion.
536
- 13. For tracker-backed sessions, create the PR from the working branch using the canonical `dev-loops pr create --assignee @me --repo <owner/name> --base main --head <branch> --title "..." --body-file <body-file>` (always draft, self-assigned by default; `--assignee @me` is the default and is shown here for clarity). When the `dev-loops` CLI helper is unavailable, use the equivalent `create-pr.mjs` script directly: `node <resolved-skill-scripts>/github/create-pr.mjs --repo <owner/name> --assignee @me --base main --head <branch> --title "..." --body-file <body-file>`. Never open a PR with raw `gh pr create`. The PR body must contain `Closes #N` (or `Fixes #N`) for the linked issue. Do not create a fresh PR directly in ready-for-review state unless the user explicitly overrides that policy.
513
+ 12. <!-- rule: LOCAL-COMMIT-BEFORE-EXIT --> **Exit validation gate — no uncommitted changes.** Before the subagent session terminates, run `git status --porcelain` and verify the output is empty. If uncommitted changes exist, first determine whether they are intended implementation changes or unintended/post-validation deltas. Revert any unintended or speculative changes. For intended changes, rerun the narrowest justified validation (`npm run verify` or equivalent) before staging and committing with an appropriate message; for tracker-backed sessions, also push the branch. A subagent session that exits with uncommitted changes in the worktree is a workflow defect and MUST NOT be treated as a clean completion. After committing, verify `git status --porcelain` is empty before declaring phase completion.
514
+ 13. For tracker-backed sessions, create the PR from the working branch: `dev-loops pr create --assignee @me --repo <owner/name> --base main --head <branch> --title "..." --body-file <body-file>` (fallback when the CLI helper is unavailable: `node <resolved-skill-scripts>/github/create-pr.mjs --repo <owner/name> --assignee @me --base main --head <branch> --title "..." --body-file <body-file>`); never raw `gh pr create`. Draft/assignment/`Closes #N` policy: [LOCAL-PR-CREATE-CANONICAL](#tracker-backed-local-implementation) above.
537
515
  14. If authorized, merge the fully reviewed, locally validated phase branch back into local `main` (phase-doc-backed sessions) or proceed through the PR gate pipeline (tracker-backed sessions).
538
516
  15. If authorization for PR creation or merge is still pending (commit authorization is already enforced by the exit validation gate in step 12), mark the phase as `awaiting-finalization` rather than `completed`, and record exactly which finalization step is pending.
539
517
 
@@ -546,85 +524,32 @@ The retrospective must capture:
546
524
  - what should change in the skill or workflow next time
547
525
  - what a fresh session should know before the next phase
548
526
 
549
- This is the infrastructure for self-improvement. Do not skip it.
527
+ <!-- rule: LOCAL-RETROSPECTIVE-REQUIRED -->
528
+ This is the infrastructure for self-improvement; you MUST NOT skip it.
550
529
 
551
530
  ## Dev mode
552
531
 
553
- Dev mode is for improving the local implementation loop itself while using it.
554
-
555
- A repository may also declare a formal-dev-mode default through `.devloops` field `workflow.devModeDefault`. Treat that config as the policy source of truth when present, but explicit user opt-in or opt-out for the current run still wins. Runtime consumption of that config may be staged separately from this documentation update.
556
-
557
- Trigger it when the user explicitly asks for dev mode, self-improvement mode, or says they want the skill to refine itself as it goes.
558
-
559
- In dev mode, after the normal phase summary and retrospective are written, run one extra bounded self-improvement pass before moving on:
560
-
561
- 1. collect a deterministic context bundle for the phase using:
562
- - `../dev-loop/scripts/dev-mode-context.mjs`
563
- - output to `tmp/phases/phase-x/dev-mode-context.json`
564
- 2. review the phase artifacts and logs with emphasis on the workflow itself:
565
- - planning quality
566
- - review quality
567
- - validation friction
568
- - bash exit-code-1 patterns
569
- - places where skill or agent prompts should be tightened
570
- - places where deterministic tooling should replace ad hoc work
571
- 3. write `Dev Mode Retrospective` (`tmp/phases/phase-x/dev-mode-retrospective.md`)
572
- - this is the required dev-mode retrospective artifact
573
- - it should name the highest-value prompt/workflow follow-ups revealed by the phase
574
- 4. optionally write `Dev Mode Review` (`tmp/phases/phase-x/dev-mode-review.md`) when separate analytical notes help support the retrospective
575
- 5. apply at least one bounded follow-up update to a relevant skill and/or agent prompt
576
- - deterministic tooling, docs, templates, or tests may accompany that change
577
- - but they do not replace the required prompt update
578
- - keep the change phase-bounded and tied directly to the retrospective findings
579
- 6. write `Dev Mode Skill Changes` (`tmp/phases/phase-x/dev-mode-skill-changes.md`)
580
- - record which skill and/or agent prompts changed
581
- - record any supporting tooling/docs/template changes that accompanied them
582
- - if no prompt update can be justified safely, stop and report that dev-mode exit criteria were not met
583
- 7. if skill scripts or deterministic tooling changed, rerun the skill-local tests
584
- 8. stop after this bounded self-improvement pass; do not recurse into endless self-editing loops
585
-
586
- Dev mode is still phase-bounded. It improves the loop around the completed phase; it does not authorize work on the next product phase.
532
+ Dev mode improves the local implementation loop itself while using it. A repo may declare a default via `.devloops` field `workflow.devModeDefault`; explicit user opt-in/opt-out for the current run still wins over that default. Trigger it when the user explicitly asks for dev mode, self-improvement mode, or says they want the skill to refine itself as it goes.
587
533
 
588
- ## tmp/ logging requirements
534
+ After the normal phase summary and retrospective, run one extra bounded self-improvement pass:
589
535
 
590
- At minimum, each phase should leave behind:
591
- - a durable phase doc at [Phase Plan](../../docs/phases/phase-x.md)
592
- - local `tmp/` execution artifacts needed to resume and audit the phase, including:
593
- - `manifest.json`
594
- - `Variant A` (`tmp/phases/phase-x/variant-a.md`)
595
- - `Variant B` (`tmp/phases/phase-x/variant-b.md`)
596
- - `merged-plan.md`
597
- - `review.md`
598
- - `summary.md`
599
- - `retrospective.md`
600
- - optional `Variant C` (`tmp/phases/phase-x/variant-c.md`) when a third variant was actually useful
601
- - `bash-exit-1.jsonl` when any bash call during the phase exited with code `1`
602
- - `clarification.md` when a plan-sufficiency interview or auto-clarification step was needed
603
- - subagent summaries when subagents were used
604
- - raw subagent outputs only when they were saved separately on purpose
605
- - in dev mode: `dev-mode-context.json`, `dev-mode-retrospective.md`, and `dev-mode-skill-changes.md`
606
- - optional in dev mode: `dev-mode-review.md` when separate analytical notes were useful
607
-
608
- These `tmp/` artifacts are normally temporary and do not need to be checked into git.
609
-
610
- Also log validation output summaries and notable decisions if they help evaluate the local dev loop later.
611
-
612
- Additionally, append every bash call that exits with code `1` to:
613
- - `tmp/phases/phase-x/bash-exit-1.jsonl`
536
+ 1. Collect a deterministic context bundle: `../dev-loop/scripts/dev-mode-context.mjs` → `tmp/phases/phase-x/dev-mode-context.json`.
537
+ 2. Review the phase artifacts/logs for planning quality, review quality, validation friction, bash exit-code-1 patterns, and places where prompts or deterministic tooling should improve.
538
+ 3. Write `Dev Mode Retrospective` (`tmp/phases/phase-x/dev-mode-retrospective.md`) required; name the highest-value prompt/workflow follow-ups revealed by the phase.
539
+ 4. Optionally write `Dev Mode Review` (`tmp/phases/phase-x/dev-mode-review.md`) when separate analytical notes help.
540
+ 5. Apply at least one bounded follow-up update to a relevant skill and/or agent prompt (supporting tooling/docs/template changes may accompany it but do not replace the prompt update), kept phase-bounded and tied directly to the retrospective findings.
541
+ 6. Write `Dev Mode Skill Changes` (`tmp/phases/phase-x/dev-mode-skill-changes.md`) recording which prompts and supporting changes landed; if no prompt update can be justified safely, stop and report that dev-mode exit criteria were not met.
542
+ 7. If skill scripts or deterministic tooling changed, rerun the skill-local tests.
543
+ 8. Stop after this bounded pass — do not recurse into endless self-editing loops.
614
544
 
615
- Use the deterministic helper:
616
- - `../dev-loop/scripts/log-bash-exit-1.mjs`
545
+ Dev mode is still phase-bounded: it improves the loop around the completed phase and does not authorize work on the next product phase.
546
+
547
+ ## tmp/ logging requirements
617
548
 
618
- Each line should be one JSON object with at least:
619
- - `timestamp`
620
- - `phase`
621
- - `cwd`
622
- - `command`
623
- - `exitCode`
624
- - `purpose`
625
- - `summary`
549
+ <!-- rule: LOCAL-TMP-EPHEMERAL-STATE -->
550
+ The required durable-doc + `tmp/` artifact set for a phase is defined once in [Deterministic logging structure](#deterministic-logging-structure); this section MUST NOT duplicate that list. Those artifacts are normally temporary and do not need to be checked into git; do not force-add them unless the user explicitly wants checked-in examples or fixtures. Also log validation output summaries and notable decisions if they help evaluate the local dev loop later.
626
551
 
627
- If useful, also include truncated `stdout` and `stderr` fields or a path to a larger saved artifact. This log is for improving the local dev loop itself, so do not skip it just because the command was exploratory.
552
+ Additionally, append every bash call that exits with code `1` to `tmp/phases/phase-x/bash-exit-1.jsonl` using the deterministic helper `../dev-loop/scripts/log-bash-exit-1.mjs`. Each line is one JSON object with at least `timestamp`, `phase`, `cwd`, `command`, `exitCode`, `purpose`, `summary` (optionally truncated `stdout`/`stderr` or a path to a larger saved artifact). This log improves the local dev loop itself, so do not skip it just because the command was exploratory.
628
553
 
629
554
  ## Stop conditions
630
555
 
@@ -632,28 +557,20 @@ See [Stop Conditions](../docs/stop-conditions.md). Local-specific stops: phase c
632
557
 
633
558
  ## Branch / review / merge policy
634
559
 
635
- - Do not implement directly on `main`.
636
- - Start or switch to a dedicated local working branch before the first mutating step.
637
- - If the repository is unborn (no commits yet), still create the working branch first and make the initial atomic commits there.
638
- - Use atomic local commits to log progress, but only for coherent reviewable slices.
639
- - Before merging, run a full parallel review / fix loop and resolve accepted findings on the same branch.
640
- - Rerun validation after review-driven fixes.
641
- - A phase is not operationally closed until its branch state is captured in commit history and the reviewed branch has been finalized according to session type (merged into local `main` for phase-doc-backed sessions; merged via GitHub PR for tracker-backed sessions), unless authorization for that finalization is still pending.
642
- - For tracker-backed sessions, the handoff path is always: push the working branch → open a PR → merge via GitHub; never merge the working branch into local `main`.
643
- - PR creation always goes through `dev-loops pr create`, which is ALWAYS draft and always assigned — self-assigned by default (`--assignee @me` when none is given; honors an explicit `--assignee <login>` / `-a <login>`), never via raw `gh pr create`, and the PR body must contain `Closes #N` (or `Fixes #N`) for the linked issue so GitHub auto-closes it on merge. When `.devloops` sets `workflow.requireDraftFirst` to true, use `dev-loops pr create --assignee @me ...`. Do not create a fresh PR directly in ready-for-review state unless the user explicitly overrides that policy for the current PR scope. The draft gate inspection is a real workflow boundary, so a new PR must exist in draft before `gh pr ready` is eligible.
644
- - When authorization is pending, record the phase as `awaiting-finalization` and describe the exact missing step.
560
+ - Implement on a dedicated local working branch, never directly on `main`, switching to it before the first mutating step; if the repo is unborn (no commits yet), still create the working branch first and make the initial atomic commits there.
561
+ - Use atomic local commits to log progress, but only for coherent reviewable slices [Commit policy](#commit-policy) below governs commit timing/authorization.
562
+ - Before merging, run a full parallel review / fix loop and resolve accepted findings on the same branch; rerun validation after review-driven fixes.
563
+ - A phase is not operationally closed until its branch state is captured in commit history and the reviewed branch has been finalized according to session type (merged into local `main` for phase-doc-backed sessions; merged via GitHub PR for tracker-backed sessions); when authorization for that finalization is still pending, record the phase as `awaiting-finalization` and describe the exact missing step.
564
+ - For tracker-backed sessions, the handoff path is always: push the working branch open a PR → merge via GitHub; never merge the working branch into local `main`. PR creation follows [LOCAL-PR-CREATE-CANONICAL](#tracker-backed-local-implementation) above; a new PR must exist in draft before `gh pr ready` is eligible.
645
565
  - For phase-doc-backed sessions, merge the fully reviewed, locally validated branch back into local `main` when authorized.
566
+ - Behind-branch integration before merge (for example a sibling PR merged first and both touch shared files): prefer a merge commit (`git merge origin/main`) over rebase + force-push. Since dev-loop PRs are squash-merged, intermediate branch history is discarded at merge time, so a merge commit lands an identical result on `main` while avoiding a non-fast-forward push to the remote. Force-push (`--force-with-lease` only, never bare `--force`) remains acceptable only for a branch the loop solely owns and where no integration alternative exists (rare); document that carve-out rather than leaving it implicit. After any integration that changes the head SHA, re-verify gate evidence at the new head (existing behavior — see [Merge Preconditions](../docs/merge-preconditions.md#required-before-merge)).
646
567
 
647
568
  ## Commit policy
648
569
 
649
- - Do not commit speculative work.
650
- - Do not commit before the relevant validation for that slice passes.
570
+ - Do not commit speculative work or before the relevant validation for that slice passes.
651
571
  - Immediately before every `git add && git commit` sequence, assert branch identity with `git branch --show-current` and stop if it does not match the intended local working branch.
652
- - Keep commits small and phase-bounded.
653
- - Do not leave completed phase work stranded off `main`; once the reviewed branch is ready and authorized, finalize it according to session type (merge into local `main` for phase-doc-backed sessions; complete via PR merge for tracker-backed sessions).
654
- - Commit only when the coordination/main agent has decided the slice or phase is ready. **Exception:** in non-interactive subagent sessions, commit authorization is implicit — the subagent was dispatched to implement and must commit before exiting (see the commit sub-bullet under implementation loop step 3 and the exit validation gate in step 12).
572
+ - Commit only when the coordination/main agent has decided the slice or phase is ready. **Exception:** in non-interactive subagent sessions, commit authorization is implicit — the subagent was dispatched to implement and must commit before exiting, enforced by [LOCAL-COMMIT-BEFORE-EXIT](#implementation-loop-for-the-phase) (implementation loop step 12; `git status --porcelain` must be empty before the session terminates).
655
573
  - If commit/merge authorization has not yet been given, do not call the phase `completed`; call it `awaiting-finalization` instead.
656
- - **Subagent exit contract:** before a subagent session terminates, the exit validation gate (implementation loop step 12) must pass — `git status --porcelain` must be empty. A subagent that exits with uncommitted changes in the worktree has not completed its task, regardless of what was implemented.
657
574
 
658
575
  ## Anti-patterns
659
576
 
@@ -0,0 +1,165 @@
1
+ ---
2
+ name: loop-grill
3
+ description: >-
4
+ Standalone pre-loop Socratic Q&A grill for issues (tracker-first) or local
5
+ plan files (local-planning). Detects spec gaps, asks clarifying questions
6
+ (interactive) or self-answers them from codebase context (--auto), then
7
+ writes a ## Grill findings section back to the source artifact.
8
+ allowed-tools: read bash edit write
9
+ user-invocable: false
10
+ ---
11
+ # Loop-grill skill
12
+
13
+ A standalone, on-demand pre-loop grilling skill. Run it against an issue or a local plan file **before** the dev loop starts to surface underspecified acceptance criteria, fuzzy scope boundaries, unresolved primary actors, and undocumented hard-to-reverse decisions.
14
+
15
+ It is entirely separate from the in-loop docs-grill (`docs/docs-grill-step.md`), which audits code/doc drift while the loop runs. This skill operates on the *spec* before any implementation begins.
16
+
17
+ ## Interface
18
+
19
+ ```
20
+ /loop-grill <issue-number> # tracker-first, interactive
21
+ /loop-grill <issue-number> --auto # tracker-first, auto-answer
22
+ /loop-grill <path/to/plan.md> # local-planning, interactive
23
+ /loop-grill <path/to/plan.md> --auto # local-planning, auto-answer
24
+ ```
25
+
26
+ ## Argument validation (fail-closed)
27
+
28
+ Before doing anything else:
29
+
30
+ 1. Confirm exactly one positional argument is present (issue number or path). No argument → error, stop.
31
+ 2. Confirm the only optional flag is `--auto`. Any other flag → error, stop.
32
+ 3. **Tracker-first:** verify the issue exists. Non-existent issue → `Error: issue #<n> not found.`, stop.
33
+ 4. **Local-planning:** verify the file exists. Missing file → `Error: plan file not found: <path>`, stop.
34
+ 5. Never mutate any artifact when argument validation fails.
35
+
36
+ ## Step 1 — Load the target
37
+
38
+ - **Tracker-first:** fetch the issue body (title + description + any existing `## Grill findings` section).
39
+ - **Local-planning:** read the plan file from disk.
40
+
41
+ ## Step 1b — Surface external resources
42
+
43
+ Before detecting gaps, scan the loaded content for external resource references: links, other repo URLs, API endpoints, doc URLs, screenshots, or Playwright navigation descriptors.
44
+
45
+ - **Interactive mode:** if external resources are present, ask the operator to confirm they are accessible or to provide them before the Q&A starts.
46
+ - **`--auto` mode:** attempt to fetch each resource using bounded wrapper commands (e.g. `gh`, API wrapper scripts under `scripts/`). Do not fetch resources inline with raw `curl` or token-heavy calls. Flag any inaccessible resource as `unresolved` in the findings rather than silently skipping it.
47
+ - When no external resources are present, skip this step silently.
48
+
49
+ ## Step 2 — Detect gaps
50
+
51
+ Scan the loaded content and identify each gap. The minimum required gap detectors are:
52
+
53
+ | Gap kind | Detection signal |
54
+ |---|---|
55
+ | Missing acceptance criteria | No `## Acceptance criteria` section, or section is empty / stub |
56
+ | Missing scope boundary | No explicit in-scope / out-of-scope statement or non-goals section |
57
+ | Unresolved primary actor | No named user, system, or role that is the main beneficiary of the feature |
58
+ | Undocumented hard-to-reverse decision | Destructive or irreversible operations described without a rationale or rollback note |
59
+
60
+ Additional gaps discovered through semantic reading of the spec are also recorded.
61
+
62
+ For each gap, classify it as either:
63
+ - **Bounded choice** — the answer is one of a small discrete set (e.g. yes/no, A/B/C).
64
+ - **Open-ended** — the answer requires free-form elaboration.
65
+
66
+ ## Step 3 — Fill gaps
67
+
68
+ ### Interactive mode (default)
69
+
70
+ For each gap, in order:
71
+
72
+ - **Bounded choice gap:** use `AskUserQuestion` with the question text and the choice options, plus an "Other / free text" option. Block until the user answers.
73
+ - **Open-ended gap:** present the question as a plain text turn. Block until the user answers.
74
+
75
+ Record each answer with its source: `human`.
76
+
77
+ > `AskUserQuestion` is a Claude Code–native construct. If you are running outside Claude Code, use `--auto` mode instead.
78
+
79
+ ### Auto mode (`--auto`)
80
+
81
+ Answer every grilling question yourself without prompting the user. Source answers from (in priority order):
82
+
83
+ 1. **`codebase`** — inspectable source files, tests, scripts, config in the repository.
84
+ 2. **`docs`** — markdown files under `docs/`, `skills/docs/`, and adjacent contract docs.
85
+ 3. **`context`** — `CONTEXT.md` at the repo root, if present. When absent, skip silently — do not crash, no warning required.
86
+ 4. **`inferred`** — reasoning from the issue/plan text alone, with no external citation.
87
+
88
+ Record the evidence source for every answer. Flag a question as **`unresolved`** when:
89
+ - The only available source is `inferred`, **and**
90
+ - No codebase path, doc section, or issue/plan text can be cited as the basis for the answer.
91
+
92
+ Do not silently guess an `inferred` answer when no evidence can be cited — flag it `unresolved` instead.
93
+
94
+ ## Step 4 — Write back (replace-section semantics)
95
+
96
+ Write a `## Grill findings` section back to the source artifact using **replace-section** semantics:
97
+
98
+ - **Find** the existing `## Grill findings` section: the range from the `## Grill findings` heading through the next `##`-level heading (exclusive) or end of file.
99
+ - **Replace** that range in place with the new section content.
100
+ - If no `## Grill findings` section exists, **append** it.
101
+ - This makes re-runs idempotent — no accumulated noise, no duplicate sections.
102
+ - If parsing the section boundary fails, **abort with an error** rather than silently truncating.
103
+
104
+ **Tracker-first write-back:** update the GitHub issue body using:
105
+
106
+ ```
107
+ gh issue edit <n> --repo <owner/repo> --body-file <tmp-path>
108
+ ```
109
+
110
+ The `## Grill findings` section lives in the issue body, not as a comment. Do not use `comment-issue.mjs` here — that creates a comment, not a body update.
111
+
112
+ **GitHub body size guard:** issue bodies are capped at 65,536 characters. Before writing back, check whether the updated body would exceed this limit. If so, warn: `Warning: updated body would exceed GitHub's 65,536-character limit — write-back skipped. Truncate the findings or the issue body manually.` Do not silently truncate.
113
+
114
+ **Local-planning write-back:** update the plan file in place using the edit tool.
115
+
116
+ ## Output artifact format
117
+
118
+ The `## Grill findings` section written to the artifact:
119
+
120
+ ```markdown
121
+ ## Grill findings
122
+
123
+ <!-- loop-grill: <timestamp> mode:<interactive|auto> -->
124
+
125
+ ### Resolved gaps
126
+
127
+ | # | Gap | Question | Answer | Source |
128
+ |---|-----|----------|--------|--------|
129
+ | 1 | Missing AC | <question text> | <answer text> | codebase \| docs \| context \| inferred \| human |
130
+
131
+ ### Unresolved gaps
132
+
133
+ | # | Gap | Question | Reason unresolved |
134
+ |---|-----|----------|-------------------|
135
+ | 1 | Unresolved primary actor | <question text> | No citable evidence found |
136
+
137
+ ### Verdict
138
+
139
+ grill-clean
140
+ ```
141
+
142
+ Replace `grill-clean` with `N unresolved items` when unresolved gaps remain.
143
+
144
+ ## Step 5 — Emit verdict
145
+
146
+ After write-back, emit the verdict line to stdout:
147
+
148
+ - `grill-clean` when no unresolved gaps remain.
149
+ - `N unresolved items` (e.g. `3 unresolved items`) when gaps remain after all questions are answered.
150
+
151
+ ## CONTEXT.md degradation rule
152
+
153
+ When `CONTEXT.md` is absent from the repo root, skip the context-source check silently. Do not crash. Do not emit a warning. The grill continues with the remaining sources (`codebase`, `docs`, `inferred`).
154
+
155
+ ## Idempotency guarantee
156
+
157
+ Running `/loop-grill` twice on the same target must produce a single `## Grill findings` section, not two. The replace-section logic handles the already-present-section case. On the second run, if the gap set is identical to the first run, the section content is replaced with an equivalent section (same questions, same answers, updated timestamp).
158
+
159
+ ## Non-goals
160
+
161
+ - Auto-triggering from `issue_intake` — this is on-demand only.
162
+ - Replacing or modifying the in-loop docs-grill (`docs/docs-grill-step.md`, `scripts/loop/docs-grill-contract.mjs`) — different concern, different firing surface.
163
+ - Full DDD `CONTEXT.md` management.
164
+ - Scheduling or storing grill runs — stateless and on-demand.
165
+ - Any CI/CD integration.
@@ -1,15 +0,0 @@
1
- ---
2
- description: "Continue the dev loop — the current in-progress board item, or a given issue/PR."
3
- argument-hint: "[issue|pr]"
4
- ---
5
- <!-- GENERATED from commands/continue.command.md by scripts/claude/generate-claude-assets.mjs — do not edit; edit the source and regenerate. -->
6
-
7
- Continue a dev loop. Two forms, both handed to the `dev-loop` skill — do NOT pick an internal strategy yourself.
8
-
9
- - With an argument (`$ARGUMENTS` is an issue or PR — `123`, `#123`, or a GitHub URL): run the `dev-loop` skill with the public intent `continue dev loop on $ARGUMENTS`. Resolve that artifact's authoritative state first, then route; ignore board position.
10
-
11
- - Bare (no `$ARGUMENTS`): pick up the single in-progress board item. Resolve the board's repo and project the same way the queue commands do, then run `node scripts/projects/resolve-active-board-item.mjs --repo <owner/name> --project <number>`.
12
- - It returns `{ ok: true, target: { kind, number } }` for exactly one in-progress item → run the `dev-loop` skill with the public intent `continue dev loop on #<number>` (the resolved `target.number`), so the intent carries the concrete target instead of re-resolving board state.
13
- - It returns `{ ok: false, reason }` when there are zero or more than one in-progress items → FAIL CLOSED: print the reason verbatim (it lists the items) and instruct the user to run `/continue #N` explicitly. Do NOT guess.
14
-
15
- Resolve authoritative state before routing. All paths terminate in the dev-loop skill's `loop startup` → build-envelope → route, stopping at the human-approval checkpoint as usual. No new routing logic here.