zoe-agent 0.3.1

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 (267) hide show
  1. package/CHANGELOG.md +154 -0
  2. package/LICENSE +96 -0
  3. package/README.md +568 -0
  4. package/dist/adapters/cli/agent.d.ts +59 -0
  5. package/dist/adapters/cli/agent.js +232 -0
  6. package/dist/adapters/cli/bootstrap.d.ts +25 -0
  7. package/dist/adapters/cli/bootstrap.js +204 -0
  8. package/dist/adapters/cli/commands/build-registry.d.ts +14 -0
  9. package/dist/adapters/cli/commands/build-registry.js +88 -0
  10. package/dist/adapters/cli/commands/clear.d.ts +7 -0
  11. package/dist/adapters/cli/commands/clear.js +10 -0
  12. package/dist/adapters/cli/commands/compact.d.ts +13 -0
  13. package/dist/adapters/cli/commands/compact.js +96 -0
  14. package/dist/adapters/cli/commands/exit.d.ts +7 -0
  15. package/dist/adapters/cli/commands/exit.js +9 -0
  16. package/dist/adapters/cli/commands/gateway.d.ts +7 -0
  17. package/dist/adapters/cli/commands/gateway.js +152 -0
  18. package/dist/adapters/cli/commands/help.d.ts +9 -0
  19. package/dist/adapters/cli/commands/help.js +12 -0
  20. package/dist/adapters/cli/commands/models.d.ts +10 -0
  21. package/dist/adapters/cli/commands/models.js +32 -0
  22. package/dist/adapters/cli/commands/registry.d.ts +70 -0
  23. package/dist/adapters/cli/commands/registry.js +111 -0
  24. package/dist/adapters/cli/commands/settings-utils.d.ts +38 -0
  25. package/dist/adapters/cli/commands/settings-utils.js +182 -0
  26. package/dist/adapters/cli/commands/settings.d.ts +9 -0
  27. package/dist/adapters/cli/commands/settings.js +395 -0
  28. package/dist/adapters/cli/commands/skills.d.ts +7 -0
  29. package/dist/adapters/cli/commands/skills.js +21 -0
  30. package/dist/adapters/cli/config-loader.d.ts +27 -0
  31. package/dist/adapters/cli/config-loader.js +48 -0
  32. package/dist/adapters/cli/docker-utils.d.ts +37 -0
  33. package/dist/adapters/cli/docker-utils.js +90 -0
  34. package/dist/adapters/cli/index.d.ts +2 -0
  35. package/dist/adapters/cli/index.js +88 -0
  36. package/dist/adapters/cli/repl.d.ts +22 -0
  37. package/dist/adapters/cli/repl.js +256 -0
  38. package/dist/adapters/cli/setup.d.ts +19 -0
  39. package/dist/adapters/cli/setup.js +613 -0
  40. package/dist/adapters/cli/system-prompts.d.ts +56 -0
  41. package/dist/adapters/cli/system-prompts.js +131 -0
  42. package/dist/adapters/cli/tui/app.d.ts +58 -0
  43. package/dist/adapters/cli/tui/app.js +314 -0
  44. package/dist/adapters/cli/tui/components/assistant-message.d.ts +5 -0
  45. package/dist/adapters/cli/tui/components/assistant-message.js +9 -0
  46. package/dist/adapters/cli/tui/components/autocomplete.d.ts +19 -0
  47. package/dist/adapters/cli/tui/components/autocomplete.js +75 -0
  48. package/dist/adapters/cli/tui/components/command-palette.d.ts +15 -0
  49. package/dist/adapters/cli/tui/components/command-palette.js +50 -0
  50. package/dist/adapters/cli/tui/components/diff-viewer.d.ts +5 -0
  51. package/dist/adapters/cli/tui/components/diff-viewer.js +109 -0
  52. package/dist/adapters/cli/tui/components/error-message.d.ts +5 -0
  53. package/dist/adapters/cli/tui/components/error-message.js +8 -0
  54. package/dist/adapters/cli/tui/components/footer.d.ts +20 -0
  55. package/dist/adapters/cli/tui/components/footer.js +19 -0
  56. package/dist/adapters/cli/tui/components/goal-status.d.ts +12 -0
  57. package/dist/adapters/cli/tui/components/goal-status.js +22 -0
  58. package/dist/adapters/cli/tui/components/info-message.d.ts +5 -0
  59. package/dist/adapters/cli/tui/components/info-message.js +8 -0
  60. package/dist/adapters/cli/tui/components/logo-banner.d.ts +7 -0
  61. package/dist/adapters/cli/tui/components/logo-banner.js +33 -0
  62. package/dist/adapters/cli/tui/components/markdown.d.ts +9 -0
  63. package/dist/adapters/cli/tui/components/markdown.js +92 -0
  64. package/dist/adapters/cli/tui/components/message-area.d.ts +19 -0
  65. package/dist/adapters/cli/tui/components/message-area.js +55 -0
  66. package/dist/adapters/cli/tui/components/permission-prompt.d.ts +13 -0
  67. package/dist/adapters/cli/tui/components/permission-prompt.js +32 -0
  68. package/dist/adapters/cli/tui/components/prompt-area.d.ts +22 -0
  69. package/dist/adapters/cli/tui/components/prompt-area.js +68 -0
  70. package/dist/adapters/cli/tui/components/text-input.d.ts +27 -0
  71. package/dist/adapters/cli/tui/components/text-input.js +142 -0
  72. package/dist/adapters/cli/tui/components/tool-call-block.d.ts +11 -0
  73. package/dist/adapters/cli/tui/components/tool-call-block.js +68 -0
  74. package/dist/adapters/cli/tui/components/user-message.d.ts +5 -0
  75. package/dist/adapters/cli/tui/components/user-message.js +8 -0
  76. package/dist/adapters/cli/tui/diff/file-write-meta.d.ts +11 -0
  77. package/dist/adapters/cli/tui/diff/file-write-meta.js +11 -0
  78. package/dist/adapters/cli/tui/diff/line-diff.d.ts +17 -0
  79. package/dist/adapters/cli/tui/diff/line-diff.js +44 -0
  80. package/dist/adapters/cli/tui/feed-serializer.d.ts +29 -0
  81. package/dist/adapters/cli/tui/feed-serializer.js +70 -0
  82. package/dist/adapters/cli/tui/file-index.d.ts +8 -0
  83. package/dist/adapters/cli/tui/file-index.js +41 -0
  84. package/dist/adapters/cli/tui/hooks/use-agent.d.ts +54 -0
  85. package/dist/adapters/cli/tui/hooks/use-agent.js +177 -0
  86. package/dist/adapters/cli/tui/hooks/use-feed.d.ts +16 -0
  87. package/dist/adapters/cli/tui/hooks/use-feed.js +25 -0
  88. package/dist/adapters/cli/tui/hooks/use-file-watcher.d.ts +10 -0
  89. package/dist/adapters/cli/tui/hooks/use-file-watcher.js +43 -0
  90. package/dist/adapters/cli/tui/hooks/use-keybindings.d.ts +16 -0
  91. package/dist/adapters/cli/tui/hooks/use-keybindings.js +25 -0
  92. package/dist/adapters/cli/tui/hooks/use-theme.d.ts +8 -0
  93. package/dist/adapters/cli/tui/hooks/use-theme.js +12 -0
  94. package/dist/adapters/cli/tui/index.d.ts +19 -0
  95. package/dist/adapters/cli/tui/index.js +206 -0
  96. package/dist/adapters/cli/tui/ink-reset.d.ts +29 -0
  97. package/dist/adapters/cli/tui/ink-reset.js +57 -0
  98. package/dist/adapters/cli/tui/layout.d.ts +15 -0
  99. package/dist/adapters/cli/tui/layout.js +15 -0
  100. package/dist/adapters/cli/tui/logo/gradient.d.ts +11 -0
  101. package/dist/adapters/cli/tui/logo/gradient.js +31 -0
  102. package/dist/adapters/cli/tui/overlays/help-dialog.d.ts +4 -0
  103. package/dist/adapters/cli/tui/overlays/help-dialog.js +26 -0
  104. package/dist/adapters/cli/tui/overlays/model-selector.d.ts +14 -0
  105. package/dist/adapters/cli/tui/overlays/model-selector.js +43 -0
  106. package/dist/adapters/cli/tui/overlays/session-selector.d.ts +35 -0
  107. package/dist/adapters/cli/tui/overlays/session-selector.js +162 -0
  108. package/dist/adapters/cli/tui/overlays/settings-overlay.d.ts +24 -0
  109. package/dist/adapters/cli/tui/overlays/settings-overlay.js +126 -0
  110. package/dist/adapters/cli/tui/session-export.d.ts +21 -0
  111. package/dist/adapters/cli/tui/session-export.js +63 -0
  112. package/dist/adapters/cli/tui/theme.d.ts +23 -0
  113. package/dist/adapters/cli/tui/theme.js +22 -0
  114. package/dist/adapters/cli/tui/types.d.ts +52 -0
  115. package/dist/adapters/cli/tui/types.js +12 -0
  116. package/dist/adapters/sdk/agent.d.ts +20 -0
  117. package/dist/adapters/sdk/agent.js +356 -0
  118. package/dist/adapters/sdk/http.d.ts +43 -0
  119. package/dist/adapters/sdk/http.js +61 -0
  120. package/dist/adapters/sdk/index.d.ts +58 -0
  121. package/dist/adapters/sdk/index.js +209 -0
  122. package/dist/adapters/sdk/settings.d.ts +18 -0
  123. package/dist/adapters/sdk/settings.js +57 -0
  124. package/dist/adapters/sdk/tools.d.ts +7 -0
  125. package/dist/adapters/sdk/tools.js +13 -0
  126. package/dist/adapters/server/auth.d.ts +53 -0
  127. package/dist/adapters/server/auth.js +168 -0
  128. package/dist/adapters/server/index.d.ts +40 -0
  129. package/dist/adapters/server/index.js +255 -0
  130. package/dist/adapters/server/rest-gateway.d.ts +13 -0
  131. package/dist/adapters/server/rest-gateway.js +218 -0
  132. package/dist/adapters/server/rest.d.ts +37 -0
  133. package/dist/adapters/server/rest.js +341 -0
  134. package/dist/adapters/server/server-core.d.ts +55 -0
  135. package/dist/adapters/server/server-core.js +121 -0
  136. package/dist/adapters/server/session-store.d.ts +81 -0
  137. package/dist/adapters/server/session-store.js +272 -0
  138. package/dist/adapters/server/settings-handlers.d.ts +24 -0
  139. package/dist/adapters/server/settings-handlers.js +360 -0
  140. package/dist/adapters/server/standalone.d.ts +19 -0
  141. package/dist/adapters/server/standalone.js +113 -0
  142. package/dist/adapters/server/websocket.d.ts +26 -0
  143. package/dist/adapters/server/websocket.js +68 -0
  144. package/dist/adapters/server/ws-handlers.d.ts +32 -0
  145. package/dist/adapters/server/ws-handlers.js +523 -0
  146. package/dist/adapters/server/ws-types.d.ts +304 -0
  147. package/dist/adapters/server/ws-types.js +7 -0
  148. package/dist/core/agent-loop.d.ts +68 -0
  149. package/dist/core/agent-loop.js +423 -0
  150. package/dist/core/config.d.ts +115 -0
  151. package/dist/core/config.js +189 -0
  152. package/dist/core/errors.d.ts +58 -0
  153. package/dist/core/errors.js +88 -0
  154. package/dist/core/hooks.d.ts +35 -0
  155. package/dist/core/hooks.js +49 -0
  156. package/dist/core/index.d.ts +23 -0
  157. package/dist/core/index.js +29 -0
  158. package/dist/core/message-convert.d.ts +41 -0
  159. package/dist/core/message-convert.js +94 -0
  160. package/dist/core/middleware/auth.d.ts +24 -0
  161. package/dist/core/middleware/auth.js +28 -0
  162. package/dist/core/middleware/logging.d.ts +23 -0
  163. package/dist/core/middleware/logging.js +28 -0
  164. package/dist/core/middleware/rate-limit.d.ts +27 -0
  165. package/dist/core/middleware/rate-limit.js +38 -0
  166. package/dist/core/middleware/semantic-tools.d.ts +10 -0
  167. package/dist/core/middleware/semantic-tools.js +43 -0
  168. package/dist/core/middleware.d.ts +48 -0
  169. package/dist/core/middleware.js +38 -0
  170. package/dist/core/permission.d.ts +25 -0
  171. package/dist/core/permission.js +50 -0
  172. package/dist/core/provider-config.d.ts +129 -0
  173. package/dist/core/provider-config.js +273 -0
  174. package/dist/core/provider-env.d.ts +39 -0
  175. package/dist/core/provider-env.js +142 -0
  176. package/dist/core/provider-resolver.d.ts +12 -0
  177. package/dist/core/provider-resolver.js +12 -0
  178. package/dist/core/session-store.d.ts +75 -0
  179. package/dist/core/session-store.js +245 -0
  180. package/dist/core/settings-manager.d.ts +57 -0
  181. package/dist/core/settings-manager.js +359 -0
  182. package/dist/core/settings-schema.d.ts +38 -0
  183. package/dist/core/settings-schema.js +171 -0
  184. package/dist/core/skill-catalog.d.ts +6 -0
  185. package/dist/core/skill-catalog.js +17 -0
  186. package/dist/core/skill-invoker.d.ts +127 -0
  187. package/dist/core/skill-invoker.js +182 -0
  188. package/dist/core/stream-accumulator.d.ts +21 -0
  189. package/dist/core/stream-accumulator.js +51 -0
  190. package/dist/core/stream-manager.d.ts +58 -0
  191. package/dist/core/stream-manager.js +212 -0
  192. package/dist/core/tool-executor.d.ts +84 -0
  193. package/dist/core/tool-executor.js +256 -0
  194. package/dist/core/types.d.ts +259 -0
  195. package/dist/core/types.js +11 -0
  196. package/dist/gateway/gateway.d.ts +52 -0
  197. package/dist/gateway/gateway.js +537 -0
  198. package/dist/gateway/index.d.ts +21 -0
  199. package/dist/gateway/index.js +31 -0
  200. package/dist/gateway/openapi-importer.d.ts +15 -0
  201. package/dist/gateway/openapi-importer.js +66 -0
  202. package/dist/gateway/semantic-scorer.d.ts +7 -0
  203. package/dist/gateway/semantic-scorer.js +24 -0
  204. package/dist/gateway/settings-adapter.d.ts +49 -0
  205. package/dist/gateway/settings-adapter.js +137 -0
  206. package/dist/gateway/tool-factory.d.ts +9 -0
  207. package/dist/gateway/tool-factory.js +414 -0
  208. package/dist/gateway/types.d.ts +68 -0
  209. package/dist/gateway/types.js +7 -0
  210. package/dist/models-catalog.js +46 -0
  211. package/dist/providers/anthropic.d.ts +22 -0
  212. package/dist/providers/anthropic.js +148 -0
  213. package/dist/providers/factory.d.ts +10 -0
  214. package/dist/providers/factory.js +25 -0
  215. package/dist/providers/openai.d.ts +15 -0
  216. package/dist/providers/openai.js +71 -0
  217. package/dist/providers/types.d.ts +48 -0
  218. package/dist/providers/types.js +1 -0
  219. package/dist/skills/args.d.ts +37 -0
  220. package/dist/skills/args.js +99 -0
  221. package/dist/skills/index.d.ts +11 -0
  222. package/dist/skills/index.js +23 -0
  223. package/dist/skills/loader.d.ts +3 -0
  224. package/dist/skills/loader.js +59 -0
  225. package/dist/skills/parser.d.ts +7 -0
  226. package/dist/skills/parser.js +152 -0
  227. package/dist/skills/registry.d.ts +13 -0
  228. package/dist/skills/registry.js +74 -0
  229. package/dist/skills/resolver.d.ts +19 -0
  230. package/dist/skills/resolver.js +116 -0
  231. package/dist/skills/types.d.ts +74 -0
  232. package/dist/skills/types.js +50 -0
  233. package/dist/tools/browser.d.ts +2 -0
  234. package/dist/tools/browser.js +68 -0
  235. package/dist/tools/core.d.ts +20 -0
  236. package/dist/tools/core.js +244 -0
  237. package/dist/tools/email.d.ts +2 -0
  238. package/dist/tools/email.js +61 -0
  239. package/dist/tools/image.d.ts +2 -0
  240. package/dist/tools/image.js +257 -0
  241. package/dist/tools/index.d.ts +2 -0
  242. package/dist/tools/index.js +88 -0
  243. package/dist/tools/interface.d.ts +22 -0
  244. package/dist/tools/interface.js +1 -0
  245. package/dist/tools/notify.d.ts +2 -0
  246. package/dist/tools/notify.js +100 -0
  247. package/dist/tools/prompt-optimizer.d.ts +2 -0
  248. package/dist/tools/prompt-optimizer.js +65 -0
  249. package/dist/tools/screenshot.d.ts +2 -0
  250. package/dist/tools/screenshot.js +184 -0
  251. package/dist/tools/search.d.ts +2 -0
  252. package/dist/tools/search.js +78 -0
  253. package/dist/tools/todos.d.ts +10 -0
  254. package/dist/tools/todos.js +50 -0
  255. package/package.json +119 -0
  256. package/skills/docker-ops/SKILL.md +329 -0
  257. package/skills/k8s-deploy/SKILL.md +397 -0
  258. package/skills/log-analyzer/SKILL.md +331 -0
  259. package/skills/speckit-analyze/SKILL.md +260 -0
  260. package/skills/speckit-checklist/SKILL.md +374 -0
  261. package/skills/speckit-clarify/SKILL.md +286 -0
  262. package/skills/speckit-constitution/SKILL.md +157 -0
  263. package/skills/speckit-implement/SKILL.md +224 -0
  264. package/skills/speckit-plan/SKILL.md +171 -0
  265. package/skills/speckit-specify/SKILL.md +346 -0
  266. package/skills/speckit-tasks/SKILL.md +215 -0
  267. package/skills/speckit-taskstoissues/SKILL.md +107 -0
@@ -0,0 +1,374 @@
1
+ ---
2
+ name: "speckit-checklist"
3
+ description: "Generate a custom checklist for the current feature based on user requirements."
4
+ argument-hint: "Domain or focus area for the checklist"
5
+ compatibility: "Requires spec-kit project structure with .specify/ directory"
6
+ metadata:
7
+ author: "github-spec-kit"
8
+ source: "templates/commands/checklist.md"
9
+ user-invocable: true
10
+ disable-model-invocation: false
11
+ ---
12
+
13
+
14
+ ## Checklist Purpose: "Unit Tests for English"
15
+
16
+ **CRITICAL CONCEPT**: Checklists are **UNIT TESTS FOR REQUIREMENTS WRITING** - they validate the quality, clarity, and completeness of requirements in a given domain.
17
+
18
+ **NOT for verification/testing**:
19
+
20
+ - ❌ NOT "Verify the button clicks correctly"
21
+ - ❌ NOT "Test error handling works"
22
+ - ❌ NOT "Confirm the API returns 200"
23
+ - ❌ NOT checking if code/implementation matches the spec
24
+
25
+ **FOR requirements quality validation**:
26
+
27
+ - ✅ "Are visual hierarchy requirements defined for all card types?" (completeness)
28
+ - ✅ "Is 'prominent display' quantified with specific sizing/positioning?" (clarity)
29
+ - ✅ "Are hover state requirements consistent across all interactive elements?" (consistency)
30
+ - ✅ "Are accessibility requirements defined for keyboard navigation?" (coverage)
31
+ - ✅ "Does the spec define what happens when logo image fails to load?" (edge cases)
32
+
33
+ **Metaphor**: If your spec is code written in English, the checklist is its unit test suite. You're testing whether the requirements are well-written, complete, unambiguous, and ready for implementation - NOT whether the implementation works.
34
+
35
+ ## User Input
36
+
37
+ ```text
38
+ $ARGUMENTS
39
+ ```
40
+
41
+ You **MUST** consider the user input before proceeding (if not empty).
42
+
43
+ ## Pre-Execution Checks
44
+
45
+ **Check for extension hooks (before checklist generation)**:
46
+ - Check if `.specify/extensions.yml` exists in the project root.
47
+ - If it exists, read it and look for entries under the `hooks.before_checklist` key
48
+ - If the YAML cannot be parsed or is invalid, skip hook checking silently and continue normally
49
+ - Filter out hooks where `enabled` is explicitly `false`. Treat hooks without an `enabled` field as enabled by default.
50
+ - For each remaining hook, do **not** attempt to interpret or evaluate hook `condition` expressions:
51
+ - If the hook has no `condition` field, or it is null/empty, treat the hook as executable
52
+ - If the hook defines a non-empty `condition`, skip the hook and leave condition evaluation to the HookExecutor implementation
53
+ - When constructing slash commands from hook command names, replace dots (`.`) with hyphens (`-`). For example, `speckit.git.commit` → `/speckit-git-commit`.
54
+ - For each executable hook, output the following based on its `optional` flag:
55
+ - **Optional hook** (`optional: true`):
56
+ ```
57
+ ## Extension Hooks
58
+
59
+ **Optional Pre-Hook**: {extension}
60
+ Command: `/{command}`
61
+ Description: {description}
62
+
63
+ Prompt: {prompt}
64
+ To execute: `/{command}`
65
+ ```
66
+ - **Mandatory hook** (`optional: false`):
67
+ ```
68
+ ## Extension Hooks
69
+
70
+ **Automatic Pre-Hook**: {extension}
71
+ Executing: `/{command}`
72
+ EXECUTE_COMMAND: {command}
73
+
74
+ Wait for the result of the hook command before proceeding to the Execution Steps.
75
+ ```
76
+ - If no hooks are registered or `.specify/extensions.yml` does not exist, skip silently
77
+
78
+ ## Execution Steps
79
+
80
+ 1. **Setup**: Run `.specify/scripts/bash/check-prerequisites.sh --json` from repo root and parse JSON for FEATURE_DIR and AVAILABLE_DOCS list.
81
+ - All file paths must be absolute.
82
+ - For single quotes in args like "I'm Groot", use escape syntax: e.g 'I'\''m Groot' (or double-quote if possible: "I'm Groot").
83
+
84
+ 2. **IF EXISTS**: Load `.specify/memory/constitution.md` for project principles and governance constraints.
85
+
86
+ 3. **Clarify intent (dynamic)**: Derive up to THREE initial contextual clarifying questions (no pre-baked catalog). They MUST:
87
+ - Be generated from the user's phrasing + extracted signals from spec/plan/tasks
88
+ - Only ask about information that materially changes checklist content
89
+ - Be skipped individually if already unambiguous in `$ARGUMENTS`
90
+ - Prefer precision over breadth
91
+
92
+ Generation algorithm:
93
+ 1. Extract signals: feature domain keywords (e.g., auth, latency, UX, API), risk indicators ("critical", "must", "compliance"), stakeholder hints ("QA", "review", "security team"), and explicit deliverables ("a11y", "rollback", "contracts").
94
+ 2. Cluster signals into candidate focus areas (max 4) ranked by relevance.
95
+ 3. Identify probable audience & timing (author, reviewer, QA, release) if not explicit.
96
+ 4. Detect missing dimensions: scope breadth, depth/rigor, risk emphasis, exclusion boundaries, measurable acceptance criteria.
97
+ 5. Formulate questions chosen from these archetypes:
98
+ - Scope refinement (e.g., "Should this include integration touchpoints with X and Y or stay limited to local module correctness?")
99
+ - Risk prioritization (e.g., "Which of these potential risk areas should receive mandatory gating checks?")
100
+ - Depth calibration (e.g., "Is this a lightweight pre-commit sanity list or a formal release gate?")
101
+ - Audience framing (e.g., "Will this be used by the author only or peers during PR review?")
102
+ - Boundary exclusion (e.g., "Should we explicitly exclude performance tuning items this round?")
103
+ - Scenario class gap (e.g., "No recovery flows detected—are rollback / partial failure paths in scope?")
104
+
105
+ Question formatting rules:
106
+ - If presenting options, generate a compact table with columns: Option | Candidate | Why It Matters
107
+ - Limit to A–E options maximum; omit table if a free-form answer is clearer
108
+ - Never ask the user to restate what they already said
109
+ - Avoid speculative categories (no hallucination). If uncertain, ask explicitly: "Confirm whether X belongs in scope."
110
+
111
+ Defaults when interaction impossible:
112
+ - Depth: Standard
113
+ - Audience: Reviewer (PR) if code-related; Author otherwise
114
+ - Focus: Top 2 relevance clusters
115
+
116
+ Output the questions (label Q1/Q2/Q3). After answers: if ≥2 scenario classes (Alternate / Exception / Recovery / Non-Functional domain) remain unclear, you MAY ask up to TWO more targeted follow‑ups (Q4/Q5) with a one-line justification each (e.g., "Unresolved recovery path risk"). Do not exceed five total questions. Skip escalation if user explicitly declines more.
117
+
118
+ 4. **Understand user request**: Combine `$ARGUMENTS` + clarifying answers:
119
+ - Derive checklist theme (e.g., security, review, deploy, ux)
120
+ - Consolidate explicit must-have items mentioned by user
121
+ - Map focus selections to category scaffolding
122
+ - Infer any missing context from spec/plan/tasks (do NOT hallucinate)
123
+
124
+ 5. **Load feature context**: Read from FEATURE_DIR:
125
+ - spec.md: Feature requirements and scope
126
+ - plan.md (if exists): Technical details, dependencies
127
+ - tasks.md (if exists): Implementation tasks
128
+
129
+ **Context Loading Strategy**:
130
+ - Load only necessary portions relevant to active focus areas (avoid full-file dumping)
131
+ - Prefer summarizing long sections into concise scenario/requirement bullets
132
+ - Use progressive disclosure: add follow-on retrieval only if gaps detected
133
+ - If source docs are large, generate interim summary items instead of embedding raw text
134
+
135
+ 6. **Generate checklist** - Create "Unit Tests for Requirements":
136
+ - Create `FEATURE_DIR/checklists/` directory if it doesn't exist
137
+ - Generate unique checklist filename:
138
+ - Use short, descriptive name based on domain (e.g., `ux.md`, `api.md`, `security.md`)
139
+ - Format: `[domain].md`
140
+ - File handling behavior:
141
+ - If file does NOT exist: Create new file and number items starting from CHK001
142
+ - If file exists: Append new items to existing file, continuing from the last CHK ID (e.g., if last item is CHK015, start new items at CHK016)
143
+ - Never delete or replace existing checklist content - always preserve and append
144
+
145
+ **CORE PRINCIPLE - Test the Requirements, Not the Implementation**:
146
+ Every checklist item MUST evaluate the REQUIREMENTS THEMSELVES for:
147
+ - **Completeness**: Are all necessary requirements present?
148
+ - **Clarity**: Are requirements unambiguous and specific?
149
+ - **Consistency**: Do requirements align with each other?
150
+ - **Measurability**: Can requirements be objectively verified?
151
+ - **Coverage**: Are all scenarios/edge cases addressed?
152
+
153
+ **Category Structure** - Group items by requirement quality dimensions:
154
+ - **Requirement Completeness** (Are all necessary requirements documented?)
155
+ - **Requirement Clarity** (Are requirements specific and unambiguous?)
156
+ - **Requirement Consistency** (Do requirements align without conflicts?)
157
+ - **Acceptance Criteria Quality** (Are success criteria measurable?)
158
+ - **Scenario Coverage** (Are all flows/cases addressed?)
159
+ - **Edge Case Coverage** (Are boundary conditions defined?)
160
+ - **Non-Functional Requirements** (Performance, Security, Accessibility, etc. - are they specified?)
161
+ - **Dependencies & Assumptions** (Are they documented and validated?)
162
+ - **Ambiguities & Conflicts** (What needs clarification?)
163
+
164
+ **HOW TO WRITE CHECKLIST ITEMS - "Unit Tests for English"**:
165
+
166
+ ❌ **WRONG** (Testing implementation):
167
+ - "Verify landing page displays 3 episode cards"
168
+ - "Test hover states work on desktop"
169
+ - "Confirm logo click navigates home"
170
+
171
+ ✅ **CORRECT** (Testing requirements quality):
172
+ - "Are the exact number and layout of featured episodes specified?" [Completeness]
173
+ - "Is 'prominent display' quantified with specific sizing/positioning?" [Clarity]
174
+ - "Are hover state requirements consistent across all interactive elements?" [Consistency]
175
+ - "Are keyboard navigation requirements defined for all interactive UI?" [Coverage]
176
+ - "Is the fallback behavior specified when logo image fails to load?" [Edge Cases]
177
+ - "Are loading states defined for asynchronous episode data?" [Completeness]
178
+ - "Does the spec define visual hierarchy for competing UI elements?" [Clarity]
179
+
180
+ **ITEM STRUCTURE**:
181
+ Each item should follow this pattern:
182
+ - Question format asking about requirement quality
183
+ - Focus on what's WRITTEN (or not written) in the spec/plan
184
+ - Include quality dimension in brackets [Completeness/Clarity/Consistency/etc.]
185
+ - Reference spec section `[Spec §X.Y]` when checking existing requirements
186
+ - Use `[Gap]` marker when checking for missing requirements
187
+
188
+ **EXAMPLES BY QUALITY DIMENSION**:
189
+
190
+ Completeness:
191
+ - "Are error handling requirements defined for all API failure modes? [Gap]"
192
+ - "Are accessibility requirements specified for all interactive elements? [Completeness]"
193
+ - "Are mobile breakpoint requirements defined for responsive layouts? [Gap]"
194
+
195
+ Clarity:
196
+ - "Is 'fast loading' quantified with specific timing thresholds? [Clarity, Spec §NFR-2]"
197
+ - "Are 'related episodes' selection criteria explicitly defined? [Clarity, Spec §FR-5]"
198
+ - "Is 'prominent' defined with measurable visual properties? [Ambiguity, Spec §FR-4]"
199
+
200
+ Consistency:
201
+ - "Do navigation requirements align across all pages? [Consistency, Spec §FR-10]"
202
+ - "Are card component requirements consistent between landing and detail pages? [Consistency]"
203
+
204
+ Coverage:
205
+ - "Are requirements defined for zero-state scenarios (no episodes)? [Coverage, Edge Case]"
206
+ - "Are concurrent user interaction scenarios addressed? [Coverage, Gap]"
207
+ - "Are requirements specified for partial data loading failures? [Coverage, Exception Flow]"
208
+
209
+ Measurability:
210
+ - "Are visual hierarchy requirements measurable/testable? [Acceptance Criteria, Spec §FR-1]"
211
+ - "Can 'balanced visual weight' be objectively verified? [Measurability, Spec §FR-2]"
212
+
213
+ **Scenario Classification & Coverage** (Requirements Quality Focus):
214
+ - Check if requirements exist for: Primary, Alternate, Exception/Error, Recovery, Non-Functional scenarios
215
+ - For each scenario class, ask: "Are [scenario type] requirements complete, clear, and consistent?"
216
+ - If scenario class missing: "Are [scenario type] requirements intentionally excluded or missing? [Gap]"
217
+ - Include resilience/rollback when state mutation occurs: "Are rollback requirements defined for migration failures? [Gap]"
218
+
219
+ **Traceability Requirements**:
220
+ - MINIMUM: ≥80% of items MUST include at least one traceability reference
221
+ - Each item should reference: spec section `[Spec §X.Y]`, or use markers: `[Gap]`, `[Ambiguity]`, `[Conflict]`, `[Assumption]`
222
+ - If no ID system exists: "Is a requirement & acceptance criteria ID scheme established? [Traceability]"
223
+
224
+ **Surface & Resolve Issues** (Requirements Quality Problems):
225
+ Ask questions about the requirements themselves:
226
+ - Ambiguities: "Is the term 'fast' quantified with specific metrics? [Ambiguity, Spec §NFR-1]"
227
+ - Conflicts: "Do navigation requirements conflict between §FR-10 and §FR-10a? [Conflict]"
228
+ - Assumptions: "Is the assumption of 'always available podcast API' validated? [Assumption]"
229
+ - Dependencies: "Are external podcast API requirements documented? [Dependency, Gap]"
230
+ - Missing definitions: "Is 'visual hierarchy' defined with measurable criteria? [Gap]"
231
+
232
+ **Content Consolidation**:
233
+ - Soft cap: If raw candidate items > 40, prioritize by risk/impact
234
+ - Merge near-duplicates checking the same requirement aspect
235
+ - If >5 low-impact edge cases, create one item: "Are edge cases X, Y, Z addressed in requirements? [Coverage]"
236
+
237
+ **🚫 ABSOLUTELY PROHIBITED** - These make it an implementation test, not a requirements test:
238
+ - ❌ Any item starting with "Verify", "Test", "Confirm", "Check" + implementation behavior
239
+ - ❌ References to code execution, user actions, system behavior
240
+ - ❌ "Displays correctly", "works properly", "functions as expected"
241
+ - ❌ "Click", "navigate", "render", "load", "execute"
242
+ - ❌ Test cases, test plans, QA procedures
243
+ - ❌ Implementation details (frameworks, APIs, algorithms)
244
+
245
+ **✅ REQUIRED PATTERNS** - These test requirements quality:
246
+ - ✅ "Are [requirement type] defined/specified/documented for [scenario]?"
247
+ - ✅ "Is [vague term] quantified/clarified with specific criteria?"
248
+ - ✅ "Are requirements consistent between [section A] and [section B]?"
249
+ - ✅ "Can [requirement] be objectively measured/verified?"
250
+ - ✅ "Are [edge cases/scenarios] addressed in requirements?"
251
+ - ✅ "Does the spec define [missing aspect]?"
252
+
253
+ 7. **Structure Reference**: Generate the checklist following the canonical template in `.specify/templates/checklist-template.md` for title, meta section, category headings, and ID formatting. If template is unavailable, use: H1 title, purpose/created meta lines, `##` category sections containing `- [ ] CHK### <requirement item>` lines with globally incrementing IDs starting at CHK001.
254
+
255
+ 8. **Report**: Output full path to checklist file, item count, and summarize whether the run created a new file or appended to an existing one. Summarize:
256
+ - Focus areas selected
257
+ - Depth level
258
+ - Actor/timing
259
+ - Any explicit user-specified must-have items incorporated
260
+
261
+ **Important**: Each `/speckit-checklist` command invocation uses a short, descriptive checklist filename and either creates a new file or appends to an existing one. This allows:
262
+
263
+ - Multiple checklists of different types (e.g., `ux.md`, `test.md`, `security.md`)
264
+ - Simple, memorable filenames that indicate checklist purpose
265
+ - Easy identification and navigation in the `checklists/` folder
266
+
267
+ To avoid clutter, use descriptive types and clean up obsolete checklists when done.
268
+
269
+ ## Example Checklist Types & Sample Items
270
+
271
+ **UX Requirements Quality:** `ux.md`
272
+
273
+ Sample items (testing the requirements, NOT the implementation):
274
+
275
+ - "Are visual hierarchy requirements defined with measurable criteria? [Clarity, Spec §FR-1]"
276
+ - "Is the number and positioning of UI elements explicitly specified? [Completeness, Spec §FR-1]"
277
+ - "Are interaction state requirements (hover, focus, active) consistently defined? [Consistency]"
278
+ - "Are accessibility requirements specified for all interactive elements? [Coverage, Gap]"
279
+ - "Is fallback behavior defined when images fail to load? [Edge Case, Gap]"
280
+ - "Can 'prominent display' be objectively measured? [Measurability, Spec §FR-4]"
281
+
282
+ **API Requirements Quality:** `api.md`
283
+
284
+ Sample items:
285
+
286
+ - "Are error response formats specified for all failure scenarios? [Completeness]"
287
+ - "Are rate limiting requirements quantified with specific thresholds? [Clarity]"
288
+ - "Are authentication requirements consistent across all endpoints? [Consistency]"
289
+ - "Are retry/timeout requirements defined for external dependencies? [Coverage, Gap]"
290
+ - "Is versioning strategy documented in requirements? [Gap]"
291
+
292
+ **Performance Requirements Quality:** `performance.md`
293
+
294
+ Sample items:
295
+
296
+ - "Are performance requirements quantified with specific metrics? [Clarity]"
297
+ - "Are performance targets defined for all critical user journeys? [Coverage]"
298
+ - "Are performance requirements under different load conditions specified? [Completeness]"
299
+ - "Can performance requirements be objectively measured? [Measurability]"
300
+ - "Are degradation requirements defined for high-load scenarios? [Edge Case, Gap]"
301
+
302
+ **Security Requirements Quality:** `security.md`
303
+
304
+ Sample items:
305
+
306
+ - "Are authentication requirements specified for all protected resources? [Coverage]"
307
+ - "Are data protection requirements defined for sensitive information? [Completeness]"
308
+ - "Is the threat model documented and requirements aligned to it? [Traceability]"
309
+ - "Are security requirements consistent with compliance obligations? [Consistency]"
310
+ - "Are security failure/breach response requirements defined? [Gap, Exception Flow]"
311
+
312
+ ## Anti-Examples: What NOT To Do
313
+
314
+ **❌ WRONG - These test implementation, not requirements:**
315
+
316
+ ```markdown
317
+ - [ ] CHK001 - Verify landing page displays 3 episode cards [Spec §FR-001]
318
+ - [ ] CHK002 - Test hover states work correctly on desktop [Spec §FR-003]
319
+ - [ ] CHK003 - Confirm logo click navigates to home page [Spec §FR-010]
320
+ - [ ] CHK004 - Check that related episodes section shows 3-5 items [Spec §FR-005]
321
+ ```
322
+
323
+ **✅ CORRECT - These test requirements quality:**
324
+
325
+ ```markdown
326
+ - [ ] CHK001 - Are the number and layout of featured episodes explicitly specified? [Completeness, Spec §FR-001]
327
+ - [ ] CHK002 - Are hover state requirements consistently defined for all interactive elements? [Consistency, Spec §FR-003]
328
+ - [ ] CHK003 - Are navigation requirements clear for all clickable brand elements? [Clarity, Spec §FR-010]
329
+ - [ ] CHK004 - Is the selection criteria for related episodes documented? [Gap, Spec §FR-005]
330
+ - [ ] CHK005 - Are loading state requirements defined for asynchronous episode data? [Gap]
331
+ - [ ] CHK006 - Can "visual hierarchy" requirements be objectively measured? [Measurability, Spec §FR-001]
332
+ ```
333
+
334
+ **Key Differences:**
335
+
336
+ - Wrong: Tests if the system works correctly
337
+ - Correct: Tests if the requirements are written correctly
338
+ - Wrong: Verification of behavior
339
+ - Correct: Validation of requirement quality
340
+ - Wrong: "Does it do X?"
341
+ - Correct: "Is X clearly specified?"
342
+
343
+ ## Post-Execution Checks
344
+
345
+ **Check for extension hooks (after checklist generation)**:
346
+ Check if `.specify/extensions.yml` exists in the project root.
347
+ - If it exists, read it and look for entries under the `hooks.after_checklist` key
348
+ - If the YAML cannot be parsed or is invalid, skip hook checking silently and continue normally
349
+ - Filter out hooks where `enabled` is explicitly `false`. Treat hooks without an `enabled` field as enabled by default.
350
+ - For each remaining hook, do **not** attempt to interpret or evaluate hook `condition` expressions:
351
+ - If the hook has no `condition` field, or it is null/empty, treat the hook as executable
352
+ - If the hook defines a non-empty `condition`, skip the hook and leave condition evaluation to the HookExecutor implementation
353
+ - When constructing slash commands from hook command names, replace dots (`.`) with hyphens (`-`). For example, `speckit.git.commit` → `/speckit-git-commit`.
354
+ - For each executable hook, output the following based on its `optional` flag:
355
+ - **Optional hook** (`optional: true`):
356
+ ```
357
+ ## Extension Hooks
358
+
359
+ **Optional Hook**: {extension}
360
+ Command: `/{command}`
361
+ Description: {description}
362
+
363
+ Prompt: {prompt}
364
+ To execute: `/{command}`
365
+ ```
366
+ - **Mandatory hook** (`optional: false`):
367
+ ```
368
+ ## Extension Hooks
369
+
370
+ **Automatic Hook**: {extension}
371
+ Executing: `/{command}`
372
+ EXECUTE_COMMAND: {command}
373
+ ```
374
+ - If no hooks are registered or `.specify/extensions.yml` does not exist, skip silently
@@ -0,0 +1,286 @@
1
+ ---
2
+ name: "speckit-clarify"
3
+ description: "Identify underspecified areas in the current feature spec by asking up to 5 highly targeted clarification questions and encoding answers back into the spec."
4
+ argument-hint: "Optional areas to clarify in the spec"
5
+ compatibility: "Requires spec-kit project structure with .specify/ directory"
6
+ metadata:
7
+ author: "github-spec-kit"
8
+ source: "templates/commands/clarify.md"
9
+ user-invocable: true
10
+ disable-model-invocation: false
11
+ ---
12
+
13
+
14
+ ## User Input
15
+
16
+ ```text
17
+ $ARGUMENTS
18
+ ```
19
+
20
+ You **MUST** consider the user input before proceeding (if not empty).
21
+
22
+ ## Pre-Execution Checks
23
+
24
+ **Check for extension hooks (before clarification)**:
25
+ - Check if `.specify/extensions.yml` exists in the project root.
26
+ - If it exists, read it and look for entries under the `hooks.before_clarify` key
27
+ - If the YAML cannot be parsed or is invalid, skip hook checking silently and continue normally
28
+ - Filter out hooks where `enabled` is explicitly `false`. Treat hooks without an `enabled` field as enabled by default.
29
+ - For each remaining hook, do **not** attempt to interpret or evaluate hook `condition` expressions:
30
+ - If the hook has no `condition` field, or it is null/empty, treat the hook as executable
31
+ - If the hook defines a non-empty `condition`, skip the hook and leave condition evaluation to the HookExecutor implementation
32
+ - When constructing slash commands from hook command names, replace dots (`.`) with hyphens (`-`). For example, `speckit.git.commit` → `/speckit-git-commit`.
33
+ - For each executable hook, output the following based on its `optional` flag:
34
+ - **Optional hook** (`optional: true`):
35
+ ```
36
+ ## Extension Hooks
37
+
38
+ **Optional Pre-Hook**: {extension}
39
+ Command: `/{command}`
40
+ Description: {description}
41
+
42
+ Prompt: {prompt}
43
+ To execute: `/{command}`
44
+ ```
45
+ - **Mandatory hook** (`optional: false`):
46
+ ```
47
+ ## Extension Hooks
48
+
49
+ **Automatic Pre-Hook**: {extension}
50
+ Executing: `/{command}`
51
+ EXECUTE_COMMAND: {command}
52
+
53
+ Wait for the result of the hook command before proceeding to the Outline.
54
+ ```
55
+ - If no hooks are registered or `.specify/extensions.yml` does not exist, skip silently
56
+
57
+ ## Outline
58
+
59
+ Goal: Detect and reduce ambiguity or missing decision points in the active feature specification and record the clarifications directly in the spec file.
60
+
61
+ Note: This clarification workflow is expected to run (and be completed) BEFORE invoking `/speckit-plan`. If the user explicitly states they are skipping clarification (e.g., exploratory spike), you may proceed, but must warn that downstream rework risk increases.
62
+
63
+ Execution steps:
64
+
65
+ 1. Run `.specify/scripts/bash/check-prerequisites.sh --json --paths-only` from repo root **once** (combined `--json --paths-only` mode / `-Json -PathsOnly`). Parse minimal JSON payload fields:
66
+ - `FEATURE_DIR`
67
+ - `FEATURE_SPEC`
68
+ - (Optionally capture `IMPL_PLAN`, `TASKS` for future chained flows.)
69
+ - If JSON parsing fails, abort and instruct user to re-run `/speckit-specify` or verify feature branch environment.
70
+ - For single quotes in args like "I'm Groot", use escape syntax: e.g 'I'\''m Groot' (or double-quote if possible: "I'm Groot").
71
+
72
+ 2. **IF EXISTS**: Load `.specify/memory/constitution.md` for project principles and governance constraints.
73
+
74
+ 3. Load the current spec file. Perform a structured ambiguity & coverage scan using this taxonomy. For each category, mark status: Clear / Partial / Missing. Produce an internal coverage map used for prioritization (do not output raw map unless no questions will be asked).
75
+
76
+ Functional Scope & Behavior:
77
+ - Core user goals & success criteria
78
+ - Explicit out-of-scope declarations
79
+ - User roles / personas differentiation
80
+
81
+ Domain & Data Model:
82
+ - Entities, attributes, relationships
83
+ - Identity & uniqueness rules
84
+ - Lifecycle/state transitions
85
+ - Data volume / scale assumptions
86
+
87
+ Interaction & UX Flow:
88
+ - Critical user journeys / sequences
89
+ - Error/empty/loading states
90
+ - Accessibility or localization notes
91
+
92
+ Non-Functional Quality Attributes:
93
+ - Performance (latency, throughput targets)
94
+ - Scalability (horizontal/vertical, limits)
95
+ - Reliability & availability (uptime, recovery expectations)
96
+ - Observability (logging, metrics, tracing signals)
97
+ - Security & privacy (authN/Z, data protection, threat assumptions)
98
+ - Compliance / regulatory constraints (if any)
99
+
100
+ Integration & External Dependencies:
101
+ - External services/APIs and failure modes
102
+ - Data import/export formats
103
+ - Protocol/versioning assumptions
104
+
105
+ Edge Cases & Failure Handling:
106
+ - Negative scenarios
107
+ - Rate limiting / throttling
108
+ - Conflict resolution (e.g., concurrent edits)
109
+
110
+ Constraints & Tradeoffs:
111
+ - Technical constraints (language, storage, hosting)
112
+ - Explicit tradeoffs or rejected alternatives
113
+
114
+ Terminology & Consistency:
115
+ - Canonical glossary terms
116
+ - Avoided synonyms / deprecated terms
117
+
118
+ Completion Signals:
119
+ - Acceptance criteria testability
120
+ - Measurable Definition of Done style indicators
121
+
122
+ Misc / Placeholders:
123
+ - TODO markers / unresolved decisions
124
+ - Ambiguous adjectives ("robust", "intuitive") lacking quantification
125
+
126
+ For each category with Partial or Missing status, add a candidate question opportunity unless:
127
+ - Clarification would not materially change implementation or validation strategy
128
+ - Information is better deferred to planning phase (note internally)
129
+
130
+ 4. Generate (internally) a prioritized queue of candidate clarification questions (maximum 5). Do NOT output them all at once. Apply these constraints:
131
+ - Maximum of 5 total questions across the whole session.
132
+ - Each question must be answerable with EITHER:
133
+ - A short multiple‑choice selection (2–5 distinct, mutually exclusive options), OR
134
+ - A one-word / short‑phrase answer (explicitly constrain: "Answer in <=5 words").
135
+ - Only include questions whose answers materially impact architecture, data modeling, task decomposition, test design, UX behavior, operational readiness, or compliance validation.
136
+ - Ensure category coverage balance: attempt to cover the highest impact unresolved categories first; avoid asking two low-impact questions when a single high-impact area (e.g., security posture) is unresolved.
137
+ - Exclude questions already answered, trivial stylistic preferences, or plan-level execution details (unless blocking correctness).
138
+ - Favor clarifications that reduce downstream rework risk or prevent misaligned acceptance tests.
139
+ - If more than 5 categories remain unresolved, select the top 5 by (Impact * Uncertainty) heuristic.
140
+
141
+ 5. Sequential questioning loop (interactive):
142
+ - Present EXACTLY ONE question at a time.
143
+ - For multiple‑choice questions:
144
+ - **Analyze all options** and determine the **most suitable option** based on:
145
+ - Best practices for the project type
146
+ - Common patterns in similar implementations
147
+ - Risk reduction (security, performance, maintainability)
148
+ - Alignment with any explicit project goals or constraints visible in the spec
149
+ - Present your **recommended option prominently** at the top with clear reasoning (1-2 sentences explaining why this is the best choice).
150
+ - Format as: `**Recommended:** Option [X] - <reasoning>`
151
+ - Then render all options as a Markdown table:
152
+
153
+ | Option | Description |
154
+ |--------|-------------|
155
+ | A | <Option A description> |
156
+ | B | <Option B description> |
157
+ | C | <Option C description> (add D/E as needed up to 5) |
158
+ | Short | Provide a different short answer (<=5 words) (Include only if free-form alternative is appropriate) |
159
+
160
+ - After the table, add: `You can reply with the option letter (e.g., "A"), accept the recommendation by saying "yes" or "recommended", or provide your own short answer.`
161
+ - For short‑answer style (no meaningful discrete options):
162
+ - Provide your **suggested answer** based on best practices and context.
163
+ - Format as: `**Suggested:** <your proposed answer> - <brief reasoning>`
164
+ - Then output: `Format: Short answer (<=5 words). You can accept the suggestion by saying "yes" or "suggested", or provide your own answer.`
165
+ - After the user answers:
166
+ - If the user replies with "yes", "recommended", or "suggested", use your previously stated recommendation/suggestion as the answer.
167
+ - Otherwise, validate the answer maps to one option or fits the <=5 word constraint.
168
+ - If ambiguous, ask for a quick disambiguation (count still belongs to same question; do not advance).
169
+ - Once satisfactory, record it in working memory (do not yet write to disk) and move to the next queued question.
170
+ - Stop asking further questions when:
171
+ - All critical ambiguities resolved early (remaining queued items become unnecessary), OR
172
+ - User signals completion ("done", "good", "no more"), OR
173
+ - You reach 5 asked questions.
174
+ - Never reveal future queued questions in advance.
175
+ - If no valid questions exist at start, immediately report no critical ambiguities.
176
+
177
+ 6. Integration after EACH accepted answer (incremental update approach):
178
+ - Maintain in-memory representation of the spec (loaded once at start) plus the raw file contents.
179
+ - For the first integrated answer in this session:
180
+ - Ensure a `## Clarifications` section exists (create it just after the highest-level contextual/overview section per the spec template if missing).
181
+ - Under it, create (if not present) a `### Session YYYY-MM-DD` subheading for today.
182
+ - Append a bullet line immediately after acceptance: `- Q: <question> → A: <final answer>`.
183
+ - Then immediately apply the clarification to the most appropriate section(s):
184
+ - Functional ambiguity → Update or add a bullet in Functional Requirements.
185
+ - User interaction / actor distinction → Update User Stories or Actors subsection (if present) with clarified role, constraint, or scenario.
186
+ - Data shape / entities → Update Data Model (add fields, types, relationships) preserving ordering; note added constraints succinctly.
187
+ - Non-functional constraint → Add/modify measurable criteria in Success Criteria > Measurable Outcomes (convert vague adjective to metric or explicit target).
188
+ - Edge case / negative flow → Add a new bullet under Edge Cases / Error Handling (or create such subsection if template provides placeholder for it).
189
+ - Terminology conflict → Normalize term across spec; retain original only if necessary by adding `(formerly referred to as "X")` once.
190
+ - If the clarification invalidates an earlier ambiguous statement, replace that statement instead of duplicating; leave no obsolete contradictory text.
191
+ - Save the spec file AFTER each integration to minimize risk of context loss (atomic overwrite).
192
+ - Preserve formatting: do not reorder unrelated sections; keep heading hierarchy intact.
193
+ - Keep each inserted clarification minimal and testable (avoid narrative drift).
194
+
195
+ 7. Validation (performed after EACH write plus final pass):
196
+ - Clarifications session contains exactly one bullet per accepted answer (no duplicates).
197
+ - Total asked (accepted) questions ≤ 5.
198
+ - Updated sections contain no lingering vague placeholders the new answer was meant to resolve.
199
+ - No contradictory earlier statement remains (scan for now-invalid alternative choices removed).
200
+ - Markdown structure valid; only allowed new headings: `## Clarifications`, `### Session YYYY-MM-DD`.
201
+ - Terminology consistency: same canonical term used across all updated sections.
202
+
203
+ 8. Write the updated spec back to `FEATURE_SPEC`.
204
+
205
+ 9. **Re-validate Spec Quality Checklist** (if it exists):
206
+ - Check if `FEATURE_DIR/checklists/requirements.md` exists.
207
+ - If it does NOT exist, skip this step silently.
208
+ - If it exists:
209
+ 1. Read the checklist file.
210
+ 2. Identify all GitHub task-list checkbox lines — lines matching `- [ ]`, `- [x]`, or `- [X]` (case-insensitive, tolerant of leading whitespace for nested items) outside of code fences. Ignore all other content (headings, notes, non-checkbox bullets, metadata).
211
+ 3. For each checkbox line, record its current marker state (checked or unchecked) and item text into a before-snapshot list.
212
+ 4. Re-evaluate each checkbox item against the **updated** spec (the version just saved in step 7).
213
+ 5. For each checkbox item, update only if the checked/unchecked state actually changes:
214
+ - If the item now passes and was unchecked: change `[ ]` to `[x]`.
215
+ - If the item now fails and was checked: change `[x]`/`[X]` to `[ ]`.
216
+ - If the state is unchanged: leave the marker as-is (preserve existing case to avoid cosmetic diffs).
217
+ 6. Save the updated checklist file. **Only toggle the `[ ]`/`[x]` marker portion of checkbox lines whose state changed.** All other file content — headings, metadata, notes, line ordering, whitespace — must remain unchanged to avoid noisy diffs.
218
+ 7. Compare the before-snapshot with the current state to compute three lists for the Completion Report:
219
+ - **Newly passing**: items that changed from unchecked to checked.
220
+ - **Regressions**: items that changed from checked to unchecked.
221
+ - **Still unchecked**: items that remain unchecked.
222
+ 8. Record the before/after pass counts as checked/total checkbox items (e.g., "12/16 → 15/16 items passing").
223
+
224
+ Behavior rules:
225
+
226
+ - If no meaningful ambiguities found (or all potential questions would be low-impact), respond: "No critical ambiguities detected worth formal clarification." and suggest proceeding.
227
+ - If spec file missing, instruct user to run `/speckit-specify` first (do not create a new spec here).
228
+ - Never exceed 5 total asked questions (clarification retries for a single question do not count as new questions).
229
+ - Avoid speculative tech stack questions unless the absence blocks functional clarity.
230
+ - Respect user early termination signals ("stop", "done", "proceed").
231
+ - If no questions asked due to full coverage, output a compact coverage summary (all categories Clear) then suggest advancing.
232
+ - If quota reached with unresolved high-impact categories remaining, explicitly flag them under Deferred with rationale.
233
+
234
+ Context for prioritization: $ARGUMENTS
235
+
236
+ ## Mandatory Post-Execution Hooks
237
+
238
+ **You MUST complete this section before reporting completion to the user.**
239
+
240
+ Check if `.specify/extensions.yml` exists in the project root.
241
+ - If it does not exist, or no hooks are registered under `hooks.after_clarify`, skip to the Completion Report.
242
+ - If it exists, read it and look for entries under the `hooks.after_clarify` key.
243
+ - If the YAML cannot be parsed or is invalid, skip hook checking silently and continue to the Completion Report.
244
+ - Filter out hooks where `enabled` is explicitly `false`. Treat hooks without an `enabled` field as enabled by default.
245
+ - For each remaining hook, do **not** attempt to interpret or evaluate hook `condition` expressions:
246
+ - If the hook has no `condition` field, or it is null/empty, treat the hook as executable
247
+ - If the hook defines a non-empty `condition`, skip the hook and leave condition evaluation to the HookExecutor implementation
248
+ - When constructing slash commands from hook command names, replace dots (`.`) with hyphens (`-`). For example, `speckit.git.commit` → `/speckit-git-commit`.
249
+ - For each executable hook, output the following based on its `optional` flag:
250
+ - **Mandatory hook** (`optional: false`) — **You MUST emit `EXECUTE_COMMAND:` for each mandatory hook**:
251
+ ```
252
+ ## Extension Hooks
253
+
254
+ **Automatic Hook**: {extension}
255
+ Executing: `/{command}`
256
+ EXECUTE_COMMAND: {command}
257
+ ```
258
+ - **Optional hook** (`optional: true`):
259
+ ```
260
+ ## Extension Hooks
261
+
262
+ **Optional Hook**: {extension}
263
+ Command: `/{command}`
264
+ Description: {description}
265
+
266
+ Prompt: {prompt}
267
+ To execute: `/{command}`
268
+ ```
269
+
270
+ ## Completion Report
271
+
272
+ Report completion (after questioning loop ends or early termination):
273
+ - Number of questions asked & answered.
274
+ - Path to updated spec.
275
+ - Sections touched (list names).
276
+ - Spec quality checklist status (if `FEATURE_DIR/checklists/requirements.md` was re-validated): show before/after pass counts (e.g., "Spec Quality Checklist: 12/16 → 15/16 items passing") and list any items that changed state — both newly checked (unchecked → checked) and any regressions (checked → unchecked). If any items remain unchecked, list them as areas needing attention.
277
+ - Coverage summary table listing each taxonomy category with Status: Resolved (was Partial/Missing and addressed), Deferred (exceeds question quota or better suited for planning), Clear (already sufficient), Outstanding (still Partial/Missing but low impact).
278
+ - If any Outstanding or Deferred remain, recommend whether to proceed to `/speckit-plan` or run `/speckit-clarify` again later post-plan.
279
+ - Suggested next command.
280
+
281
+ ## Done When
282
+
283
+ - [ ] Spec ambiguities identified and clarifications integrated into spec file
284
+ - [ ] Spec quality checklist re-validated against updated spec (if `FEATURE_DIR/checklists/requirements.md` exists)
285
+ - [ ] Extension hooks dispatched or skipped according to the rules in Mandatory Post-Execution Hooks above
286
+ - [ ] Completion reported to user with questions answered, sections touched, checklist status, and coverage summary