@anhth2/spec-driven-dev-plugin 0.7.0 → 0.9.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (96) hide show
  1. package/ARCHITECTURE.md +6 -2
  2. package/bin/index.js +105 -0
  3. package/commands/debug.md +189 -1
  4. package/commands/debug.tmpl +16 -0
  5. package/commands/define-product.md +94 -1
  6. package/commands/fix-bug.md +190 -1
  7. package/commands/fix-bug.tmpl +17 -0
  8. package/commands/generate-bdd.md +314 -14
  9. package/commands/generate-bdd.tmpl +220 -13
  10. package/commands/generate-code.md +191 -3
  11. package/commands/generate-code.tmpl +97 -2
  12. package/commands/generate-design-spec.md +811 -0
  13. package/commands/generate-design-spec.tmpl +399 -0
  14. package/commands/generate-prd.md +133 -1
  15. package/commands/generate-prd.tmpl +39 -0
  16. package/commands/generate-spec-manifest.md +576 -0
  17. package/commands/generate-spec-manifest.tmpl +164 -0
  18. package/commands/generate-tech-docs.md +116 -2
  19. package/commands/generate-tech-docs.tmpl +22 -1
  20. package/commands/generate-tests.md +94 -1
  21. package/commands/learn.md +554 -0
  22. package/commands/learn.tmpl +63 -0
  23. package/commands/propose-scenario.md +521 -0
  24. package/commands/propose-scenario.tmpl +109 -0
  25. package/commands/refine-prd.md +94 -1
  26. package/commands/report-bug.md +543 -0
  27. package/commands/report-bug.tmpl +131 -0
  28. package/commands/review-code.md +190 -1
  29. package/commands/review-code.tmpl +17 -0
  30. package/commands/review-context.md +134 -1
  31. package/commands/review-context.tmpl +40 -0
  32. package/commands/review-tech-docs.md +176 -5
  33. package/commands/review-tech-docs.tmpl +82 -4
  34. package/commands/run-tests.md +119 -1
  35. package/commands/run-tests.tmpl +25 -0
  36. package/commands/setup-ai-first.md +142 -4
  37. package/commands/setup-ai-first.tmpl +135 -3
  38. package/commands/smoke-test.md +94 -1
  39. package/commands/sync.md +405 -0
  40. package/commands/sync.tmpl +345 -0
  41. package/commands/update-framework.md +211 -0
  42. package/commands/update-framework.tmpl +151 -0
  43. package/commands/validate-traces.md +152 -3
  44. package/commands/validate-traces.tmpl +58 -2
  45. package/core/FRAMEWORK_VERSION +1 -1
  46. package/core/commands/debug.md +189 -1
  47. package/core/commands/define-product.md +94 -1
  48. package/core/commands/fix-bug.md +190 -1
  49. package/core/commands/generate-bdd.md +314 -14
  50. package/core/commands/generate-code.md +191 -3
  51. package/core/commands/generate-design-spec.md +811 -0
  52. package/core/commands/generate-prd.md +133 -1
  53. package/core/commands/generate-spec-manifest.md +576 -0
  54. package/core/commands/generate-tech-docs.md +116 -2
  55. package/core/commands/generate-tests.md +94 -1
  56. package/core/commands/learn.md +554 -0
  57. package/core/commands/propose-scenario.md +521 -0
  58. package/core/commands/refine-prd.md +94 -1
  59. package/core/commands/report-bug.md +543 -0
  60. package/core/commands/review-code.md +190 -1
  61. package/core/commands/review-context.md +134 -1
  62. package/core/commands/review-tech-docs.md +176 -5
  63. package/core/commands/run-tests.md +119 -1
  64. package/core/commands/setup-ai-first.md +142 -4
  65. package/core/commands/smoke-test.md +94 -1
  66. package/core/commands/sync.md +405 -0
  67. package/core/commands/update-framework.md +211 -0
  68. package/core/commands/validate-traces.md +152 -3
  69. package/core/skills/code/SKILL.md +101 -2
  70. package/core/skills/debug/SKILL.md +108 -3
  71. package/core/skills/design-spec/SKILL.md +507 -0
  72. package/core/skills/discovery/SKILL.md +94 -1
  73. package/core/skills/prd/SKILL.md +14 -2
  74. package/core/skills/setup-ai-first/SKILL.md +7 -1
  75. package/core/skills/spec/SKILL.md +14 -2
  76. package/core/skills/test/SKILL.md +195 -3
  77. package/core/steps/capture-lesson.md +79 -0
  78. package/core/steps/context-loader.md +87 -0
  79. package/core/steps/report-footer.md +7 -1
  80. package/core/templates/design-spec.template.md +209 -0
  81. package/core/templates/project-context.yaml +40 -0
  82. package/package.json +1 -1
  83. package/skills/code/SKILL.md +101 -2
  84. package/skills/debug/SKILL.md +108 -3
  85. package/skills/design-spec/SKILL.md +507 -0
  86. package/skills/design-spec/SKILL.tmpl +95 -0
  87. package/skills/discovery/SKILL.md +94 -1
  88. package/skills/prd/SKILL.md +14 -2
  89. package/skills/setup-ai-first/SKILL.md +7 -1
  90. package/skills/spec/SKILL.md +14 -2
  91. package/skills/test/SKILL.md +195 -3
  92. package/steps/capture-lesson.md +79 -0
  93. package/steps/context-loader.md +87 -0
  94. package/steps/report-footer.md +7 -1
  95. package/templates/design-spec.template.md +209 -0
  96. package/templates/project-context.yaml +40 -0
@@ -0,0 +1,576 @@
1
+ # /generate-spec-manifest — Generate Spec Manifest for External Agents
2
+
3
+ Scans all spec files and writes a `spec-manifest.yaml` at the project root.
4
+ This file is for **external agents only** (e.g. tester's agent) — it is not committed to git.
5
+
6
+ ## Gate
7
+
8
+ # Gate — Universal Entry Procedure
9
+
10
+ Every command must execute this gate before proceeding with its specific logic.
11
+
12
+ ## Step 0 — Sub-Agent Mode Check
13
+
14
+ Before anything else, check if `$ARGUMENTS` is a JSON payload from an orchestrator:
15
+
16
+ 1. Attempt to parse `$ARGUMENTS` as JSON.
17
+ 2. If it parses successfully **and** contains `"_agent_mode": true`:
18
+ - **Skip Steps 1, 2, and 3 of this Gate entirely.**
19
+ - Set target file = `payload.target_file`
20
+ - Set loaded context = `payload.context` (do NOT run context-loader.md)
21
+ - Set UC scope = `payload.uc_id` (process only this UC)
22
+ - Set line range = `payload.uc_section` (read only that PRD section)
23
+ - Proceed directly to the command-specific logic.
24
+ 3. If `$ARGUMENTS` is not JSON or `_agent_mode` is absent → continue to Step 1 (normal mode).
25
+
26
+ ## Step 0-B — Model Check
27
+
28
+ *Skip this step if `_agent_mode: true` (sub-agent — orchestrator already validated).*
29
+
30
+ Complex generation and review commands require strong reasoning.
31
+ Using a smaller model risks missed edge cases, incomplete spec analysis, and architecture violations.
32
+
33
+ Display and wait for response:
34
+
35
+ ```
36
+ ⚙️ MODEL CHECK
37
+ ──────────────────────────────────────────────────────────────────
38
+ Recommended : claude-opus-4 (or latest Opus model)
39
+ Why needed : Spec analysis, architecture review, code generation
40
+ require deep reasoning. Smaller models miss edge cases.
41
+
42
+ To switch in Claude Code:
43
+ • Settings → Model → select "claude-opus"
44
+ • or: /model → choose claude-opus
45
+
46
+ Running on claude-opus?
47
+ Y — yes, on claude-opus → proceed
48
+ S — skip check (I accept lower quality risk with current model)
49
+ ──────────────────────────────────────────────────────────────────
50
+ ```
51
+
52
+ - "Y" → proceed to Step 1.
53
+ - "S" → proceed to Step 1 (user accepts risk, add ⚠️ to final report).
54
+ - "N" or anything else → **STOP.** Output: "Please switch to claude-opus, then re-run this command."
55
+
56
+ ## Step 1 — Resolve Target File
57
+
58
+ 1. If `$ARGUMENTS` is provided and points to an existing file → use it directly as the target.
59
+ 2. If `$ARGUMENTS` is a UC-ID, ticket ID, or partial name → search for matching files in the relevant directory.
60
+ 3. If `$ARGUMENTS` is empty or no match found:
61
+ - List files in the relevant directory for this command (e.g., `specs/prd/**/*.md` for PRD commands, `specs/bdd/**/*.feature` for BDD commands).
62
+ - Present the list to the user and ask: "Which file do you want to work with? (Enter number or filename)"
63
+ - Wait for user selection before continuing.
64
+
65
+ ## Step 2 — Execute Context Loader
66
+
67
+ Load all project context by following the procedure in `steps/context-loader.md`.
68
+ Store all loaded context in memory for use throughout this command session.
69
+
70
+ ## Step 3 — CHECKPOINT
71
+
72
+ After completing Steps 1 and 2, display a summary and wait for confirmation:
73
+
74
+ ```
75
+ CHECKPOINT
76
+ -----------
77
+ Target : {resolved file path}
78
+ Project : {project.name from project-context.yaml}
79
+ Tech stack : {language} / {framework}
80
+ Module : {module if set, else "not configured"}
81
+ Domains : {comma-separated domain list}
82
+
83
+ Proceed? (Y/N)
84
+ ```
85
+
86
+ Wait for explicit "Y" or "N" from the user before continuing.
87
+ - "Y" → proceed to the command-specific steps below.
88
+ - "N" → stop and ask what the user wants to change.
89
+
90
+
91
+ *Note: For this command, there is no target file — it scans the entire project. Ignore `$ARGUMENTS` unless a domain filter is passed.*
92
+
93
+ ## Context
94
+
95
+ # Context Loader — Load All Project Context
96
+
97
+ Execute these steps in order. Store everything in memory for the duration of the command session.
98
+
99
+ **Priority guide (anti-lost-in-middle):**
100
+ - Steps 1–2 are PROJECT-CONFIG — loaded first, resolve all paths and metadata.
101
+ - Step 3 is CRITICAL — architecture + coding standards, the highest-priority facts for generation.
102
+ - Step 4 is SAFETY — data protection rules, enforced silently for the entire session.
103
+ - Steps 5–6 are DOMAIN KNOWLEDGE — terminology and entity definitions.
104
+ - Step 7 is the WORKING MEMORY RECAP — locks critical facts into the top of working memory.
105
+
106
+ ---
107
+
108
+ ## Step 1 — [PROJECT-CONFIG] Load project-context.yaml
109
+
110
+ Read `.agent/project-context.yaml`. Extract and store:
111
+
112
+ **Tech Stack:**
113
+ - `tech_stack.language` → active language (e.g., Java 17, TypeScript, C#, Go)
114
+ - `tech_stack.framework` → active framework (e.g., Spring Boot 3.2, Angular 17, .NET 8)
115
+ - `tech_stack.build_tool` → build tool (e.g., Maven, npm, dotnet, go)
116
+ - `tech_stack.test_framework` → test framework (e.g., JUnit 5 + Mockito, Jest, xUnit)
117
+ - `tech_stack.database` → database (e.g., PostgreSQL, MySQL, MongoDB)
118
+ - `tech_stack.module` → active module profile (e.g., java-spring, angular, dotnet, golang, context-engineering)
119
+
120
+ **Conventions:**
121
+ - `conventions.build_command` → how to compile/build
122
+ - `conventions.test_command` → how to run tests
123
+ - `conventions.service_run` → how to start the service
124
+ - `conventions.ticket_prefix` → ticket ID prefix (e.g., PROJ, FEAT, UC)
125
+
126
+ **Domains:**
127
+ - `domains` → list of active business domains
128
+
129
+ **Paths (if present):**
130
+ - `paths.specs_dir` → BDD specs root
131
+ - `paths.prd_dir` → PRD documents root
132
+ - `paths.refinement_dir` → findings/review output dir
133
+ - `paths.product_definitions_dir` → product definitions root
134
+ - `paths.domain_knowledge_dir` → domain knowledge root
135
+ - `paths.business_dictionary` → path to business-dictionary.md
136
+ - `paths.core_entities` → path to core-entities.md
137
+ - `paths.tech_docs_dir` → technical documentation root
138
+ - `paths.trace_dir` → trace state directory
139
+ - `paths.design_spec_dir` → Design Spec documents root (FE/App only)
140
+
141
+ If `paths` section is absent, use these defaults:
142
+ - `specs_dir` = `specs/bdd`
143
+ - `prd_dir` = `specs/prd`
144
+ - `refinement_dir` = `.agent/review`
145
+ - `product_definitions_dir` = `specs/product-definition`
146
+ - `domain_knowledge_dir` = `specs/domain-knowledge`
147
+ - `business_dictionary` = `specs/domain-knowledge/business-dictionary.md`
148
+ - `core_entities` = `specs/domain-knowledge/core-entities.md`
149
+ - `tech_docs_dir` = `specs/tech-docs`
150
+ - `trace_dir` = `.trace`
151
+ - `design_spec_dir` = `specs/design-spec`
152
+
153
+ If `tech_stack.module` is set, also load `.agent/modules/{module}/stack-profile.yaml` if it exists.
154
+
155
+ ---
156
+
157
+ ## Step 1.5 — [SERVICE ROUTING] Resolve service paths (umbrella mode)
158
+
159
+ *Skip this step entirely if `setup.mode` is not `"umbrella"` and `services` section is absent from project-context.yaml.*
160
+
161
+ If `services` section is present:
162
+
163
+ **1. Detect active domain** (in priority order):
164
+ - Read `@trace.domain` from target file frontmatter (if Gate loaded a target file)
165
+ - Extract from target file path: segment immediately after `prd_dir` base path
166
+ *(e.g., `specs/prd/user/FEAT-01.md` → domain = `user`)*
167
+ - If `$ARGUMENTS` contains a path, extract the segment after `prd_dir`
168
+
169
+ **2. Route to service** — if active domain matches a key in `services`:
170
+ - Override `paths.specs_dir` → `services.{domain}.specs_dir`
171
+ - Override `paths.tech_docs_dir` → `services.{domain}.tech_docs_dir`
172
+ - Store `active_service` = `services.{domain}.path`
173
+ - Store `active_service_module` = `services.{domain}.module`
174
+ - If service has its own `module` → use it as `active_module` (overrides `tech_stack.module`)
175
+
176
+ **3. Fallback** — if domain not detected or no matching service key:
177
+ - Keep default paths from Step 1
178
+ - Set `active_service = unresolved`
179
+
180
+ **4. Spec source auto-override** — if `setup.spec_source` is set AND the corresponding path was not already explicitly set in `paths:`:
181
+ - Override `paths.prd_dir` → `{spec_source}/specs/prd`
182
+ - Override `paths.design_spec_dir` → `{spec_source}/specs/design-spec`
183
+ - Override `paths.domain_knowledge_dir` → `{spec_source}/specs/domain-knowledge`
184
+ - Override `paths.business_dictionary` → `{spec_source}/specs/domain-knowledge/business-dictionary.md`
185
+ - Override `paths.core_entities` → `{spec_source}/specs/domain-knowledge/core-entities.md`
186
+ - Override `paths.bug_reports_dir` → `{spec_source}/feedback/bug-reports`
187
+ - Override `paths.bdd_proposals_dir` → `{spec_source}/feedback/bdd-proposals`
188
+
189
+ > **Why under `spec_source`:** tester feedback (`/report-bug`, `/propose-scenario`) must land in the **shared spec repo** so PO/Dev see it when they `/sync`. In single-service mode (no `spec_source`), these default to `feedback/bug-reports` and `feedback/bdd-proposals` at repo root — still shared, same repo.
190
+
191
+ ---
192
+
193
+ ## Step 1.6 — [SERVICE CONVENTIONS] Load service-specific conventions (umbrella mode)
194
+
195
+ *Skip this step entirely if `active_service` is `"unresolved"` or context is single-service mode.*
196
+
197
+ When `active_service` has been resolved to a real path in Step 1.5 (e.g., `user-service/`):
198
+
199
+ **1. Locate service config** — try in priority order:
200
+ - `{active_service}/.agent/project-context.yaml`
201
+ - `{active_service}/project-context.yaml`
202
+
203
+ **2. If found, override with service-specific values:**
204
+
205
+ | Variable | Source |
206
+ |----------|--------|
207
+ | `conventions.test_command` | service's `conventions.test_command` |
208
+ | `conventions.build_command` | service's `conventions.build_command` |
209
+ | `paths.trace_dir` | `{active_service}/{service paths.trace_dir}` — default: `{active_service}/.trace` |
210
+ | `paths.specs_dir` | `{active_service}/{service paths.specs_dir}` (if set in service config, else keep Step 1.5 override) |
211
+
212
+ **3. Store** `service_root = {active_service}` as the working directory anchor for all downstream commands:
213
+ - Shell commands (`/run-tests`, `/generate-tests`) run **from within** `service_root`
214
+ - File write operations (test files, trace TSVs) use paths **relative to** `service_root`
215
+
216
+ **4. If service config not found** — keep umbrella defaults, still set `service_root = {active_service}` (path anchor is always needed even without a config override).
217
+
218
+ ---
219
+
220
+ ## Step 2 — [PROJECT-CONFIG] Load module stack profile (conditional)
221
+
222
+ If `tech_stack.module` is set, read `.agent/modules/{module}/stack-profile.yaml`.
223
+ Merge framework-specific conventions (layer patterns, test patterns, naming rules) into the loaded context.
224
+ If the file does not exist → skip silently.
225
+
226
+ ---
227
+
228
+ ## Step 3 — [CRITICAL] Load CLAUDE.md
229
+
230
+ *This is the highest-priority context — it defines HOW to write code and documents for this project.*
231
+
232
+ Read `CLAUDE.md`. Extract and store:
233
+
234
+ - **§1 Project Overview** → project name, language, framework, build/test commands, domains
235
+ - **§2 Architecture** → layer order (e.g., Controller → Facade → Service → Repository), architectural rules
236
+ - **§3 Coding Standards** → naming conventions (classes, methods), response wrapper type, forbidden patterns
237
+ - **§5 Error Handling** → exception types, HTTP status code mapping, not-found exception class name
238
+ - **§7 Git Conventions** → branch naming pattern, commit message format
239
+
240
+ If `CLAUDE.md` does not exist → note it as missing and continue with project-context.yaml data only.
241
+
242
+ ---
243
+
244
+ ## Step 4 — [SAFETY] Load Data Protection Rules
245
+
246
+ Read `.agent/rules/data-protection.md` (or `rules/data-protection.md` from the framework installation).
247
+
248
+ Store the sensitive file patterns — you must **never** read, write, display, or reference content from files matching those patterns for the entire session.
249
+
250
+ If neither file exists → apply built-in defaults: never access `.env*`, `*.key`, `*.pem`, `*secret*`, `*password*`, `*credential*`.
251
+
252
+ ---
253
+
254
+ ## Step 5 — [DOMAIN] Load Business Dictionary (conditional)
255
+
256
+ Check if the business dictionary file exists (use `paths.business_dictionary` resolved in Step 1).
257
+
258
+ If it exists, read it and extract:
259
+ - **Canonical Terms** → complete list of approved terms and their definitions
260
+ - **Banned Terms** → complete list of banned terms and their canonical replacements
261
+ - **Status / Enum Registry** → allowed enum values per entity
262
+
263
+ Store the banned terms list for **active enforcement** throughout the command session:
264
+ - When generating any text (PRD, BDD, code comments, tech docs), verify no banned terms appear
265
+ - Replace banned terms with their canonical equivalents automatically
266
+
267
+ If the file does not exist → skip silently. Do not warn or block.
268
+
269
+ ---
270
+
271
+ ## Step 6 — [DOMAIN] Load Core Entities (conditional)
272
+
273
+ Check if the core entities file exists at `paths.core_entities` (resolved in Step 1).
274
+ Default path: `specs/domain-knowledge/core-entities.md`.
275
+
276
+ If it exists, read it and store:
277
+ - **Entity catalog** → for each entity: its name, purpose, owner service, key fields (name + type), business invariants, and relationships
278
+ - **Field name registry** → canonical field names to use in generated code and documents
279
+ - **Relationship map** → how entities relate to each other (1:N, N:N, embedded, etc.)
280
+
281
+ **How to use this catalog:**
282
+ - When generating code: use the field names, types, and relationships defined here — do NOT infer from existing code
283
+ - When generating PRD/BDD: reference entity names from this catalog for consistency
284
+ - When generating tech-docs: use this catalog as the source-of-truth for entity definitions
285
+
286
+ If the file does not exist → skip silently.
287
+
288
+ ---
289
+
290
+ ## Step 6.5 — [PLATFORM] Derive active_module and platform_type
291
+
292
+ Using `tech_stack.module` loaded in Step 1, derive and store two variables for use by all downstream commands:
293
+
294
+ ```
295
+ active_module = tech_stack.module (e.g. "java-spring", "react", "flutter")
296
+ ```
297
+
298
+ | `platform_type` | Modules |
299
+ |---|---|
300
+ | `backend` | `java-spring`, `golang`, `dotnet`, `php-laravel`, `context-engineering` |
301
+ | `web-frontend` | `react`, `nextjs`, `vue`, `nuxt`, `angular` |
302
+ | `mobile` | `flutter`, `react-native`, `ios-swiftui`, `android-compose` |
303
+
304
+ If `tech_stack.module` is blank or not recognized → set `platform_type = "unknown"` and flag as ⚠️ in the Step 7 recap.
305
+
306
+ These two variables (`active_module`, `platform_type`) are the canonical source for all branching logic in commands that need platform-specific behavior (generate-tests, debug, fix-bug, smoke-test).
307
+
308
+ ---
309
+
310
+ ## Step 6.7 — [GUARDRAILS] Load Project Lessons (conditional)
311
+
312
+ *Accumulated mistakes the AI must not repeat in this project. These are added over time via `/learn`
313
+ or accepted during `/review-code`, `/fix-bug`, `/debug`.*
314
+
315
+ Resolve the lessons file path:
316
+ - Use `paths.lessons_file` if set (may be service-overridden in umbrella mode, Step 1.6)
317
+ - Else default `specs/domain-knowledge/lessons-learned.md`
318
+ - In umbrella/service mode (when `service_root` is set), if `paths.lessons_file` is unset, default to `{service_root}/.agent/project-lessons.md`
319
+
320
+ If the file exists, read it and store ALL lessons as **ACTIVE GUARDRAILS** for the session:
321
+ - Treat each lesson's **Rule** as a hard constraint — same priority as CLAUDE.md coding standards (Step 3).
322
+ - Before generating or modifying any artifact (PRD, BDD, tech-doc, code, test), check the output against every lesson whose `category` matches the current command AND whose `scope` matches the target (domain / file).
323
+ - If a generated output would violate a lesson → correct it **before** presenting, and note which lesson (`L-NNN`) was applied.
324
+
325
+ If the file does not exist → skip silently (no lessons captured yet).
326
+
327
+ ---
328
+
329
+ ## Step 7 — [RECAP] Working Memory Recap (anti-lost-in-middle)
330
+
331
+ After loading all context, synthesize and output a compact summary block.
332
+ This recap ensures the most critical facts are stated at the END of context loading
333
+ (recency effect — freshest in working memory when the task begins).
334
+
335
+ Output exactly this block:
336
+ ```
337
+ [CTX LOADED]
338
+ Stack : {language} / {framework} / {database}
339
+ Platform : {active_module} ({platform_type})
340
+ Layers : {layer order from CLAUDE.md §2, e.g., Controller → Facade → Service → Repository}
341
+ Ticket : {ticket_prefix}-
342
+ Dict : {loaded — N canonical terms, M banned terms | missing}
343
+ Entities : {loaded — EntityA, EntityB, EntityC | missing}
344
+ Lessons : {loaded — N guardrails | none yet}
345
+ Service : {active_service} ({active_service_module}) | single-service
346
+ Svc Root : {service_root} — conventions + trace_dir loaded from service config | —
347
+ Status : {FULL | PARTIAL — missing: CLAUDE.md / business-dict / core-entities | MINIMAL}
348
+ ```
349
+
350
+ If any CRITICAL file is missing (CLAUDE.md), flag it clearly so the user can decide whether to proceed.
351
+
352
+ ---
353
+
354
+ ## Context Load Complete
355
+
356
+ After completing all steps, you have loaded:
357
+ - Project identity, tech stack, module conventions
358
+ - Architecture rules and layer order ← **[CRITICAL — hold in working memory]**
359
+ - Coding standards and naming conventions ← **[CRITICAL — hold in working memory]**
360
+ - Data protection rules (sensitive file patterns to never access)
361
+ - Terminology rules with banned-term list ← **[DOMAIN — apply to every generated word]**
362
+ - Entity catalog (field names, types, invariants) ← **[DOMAIN — use for code generation]**
363
+ - All configured paths
364
+
365
+ Proceed to the next step of the calling command.
366
+
367
+
368
+ ---
369
+
370
+ ## Process
371
+
372
+ ### Step 1 — Determine scan roots
373
+
374
+ Read `project-context.yaml` to determine mode and paths:
375
+
376
+ **Umbrella mode** (`setup.mode: umbrella`):
377
+ ```
378
+ spec_root = {setup.spec_source} ← PO's spec submodule
379
+ prd_glob = {spec_root}/specs/prd/**/*.md
380
+ pdd_glob = {spec_root}/specs/product-definition/**/*.md
381
+ services = {services} ← map of domain → paths
382
+ ```
383
+
384
+ **Single-service mode** (no `setup.mode`):
385
+ ```
386
+ spec_root = .
387
+ prd_glob = {paths.prd_dir}/**/*.md
388
+ pdd_glob = {paths.product_definitions_dir}/**/*.md
389
+ services = { default: { specs_dir: {paths.specs_dir}, tech_docs_dir: {paths.tech_docs_dir} } }
390
+ ```
391
+
392
+ If a domain filter was passed in `$ARGUMENTS` → only scan PRDs matching that domain.
393
+
394
+ ---
395
+
396
+ ### Step 2 — Scan PRD files
397
+
398
+ For each `.md` file matched by `prd_glob`:
399
+
400
+ 1. Read the file metadata table:
401
+ - `TICKET-ID` from `| **PRD ID** |`
402
+ - `domain` from `| **Domain** |`
403
+ - `status` from `| **Status** |`
404
+ - `version` from `| **Version** |`
405
+ 2. Also read frontmatter `@trace.domain` if present (use this over metadata table domain if both exist)
406
+ 3. Record: `{ ticket_id, domain, status, version, prd_path }` — path relative to manifest root
407
+
408
+ Skip files where `TICKET-ID` cannot be determined.
409
+
410
+ ---
411
+
412
+ ### Step 3 — Match PDD files
413
+
414
+ For each TICKET-ID found in Step 2:
415
+
416
+ Search `pdd_glob` for a file whose name contains the TICKET-ID (e.g. `FT-001-*.md`).
417
+ - Found → record `pdd_path` (relative to manifest root)
418
+ - Not found → record `pdd: null`
419
+
420
+ ---
421
+
422
+ ### Step 4 — Match BDD and Tech-Doc files per service
423
+
424
+ For each TICKET-ID, for each service in `services` map:
425
+
426
+ **BDD:**
427
+ - Glob `{service.specs_dir}/**/{TICKET-ID}*.feature`
428
+ - Also check files containing `@trace.prd: {TICKET-ID}` in frontmatter if glob returns nothing
429
+ - Found → record path under `bdd.{service_key}`
430
+ - Not found → omit key (do not write `null` for services with no BDD yet)
431
+
432
+ **Tech-docs:**
433
+ - Glob `{service.tech_docs_dir}/**/{TICKET-ID}*.md`
434
+ - Also check files containing `@trace.prd: {TICKET-ID}` if glob returns nothing
435
+ - Found → record path under `tech_docs.{service_key}`
436
+ - Not found → omit key
437
+
438
+ All paths relative to manifest root (umbrella root or project root).
439
+
440
+ ---
441
+
442
+ ### Step 5 — Write spec-manifest.yaml
443
+
444
+ Write to `{manifest_root}/spec-manifest.yaml` (overwrite if exists).
445
+
446
+ Format:
447
+
448
+ ```yaml
449
+ # Auto-generated by /generate-spec-manifest — DO NOT edit manually
450
+ # To regenerate: /generate-spec-manifest
451
+ # This file is excluded from git — see .gitignore
452
+
453
+ version: "1.0"
454
+ generated_at: "{YYYY-MM-DD}"
455
+ project_mode: "{umbrella | single}"
456
+
457
+ features:
458
+ {TICKET-ID}:
459
+ domain: {domain}
460
+ status: {status}
461
+ prd_version: "{version}"
462
+ prd: "{prd_path}"
463
+ pdd: "{pdd_path}" # omit if null
464
+ tech_docs:
465
+ {service_key}: "{path}" # only include services where file was found
466
+ bdd:
467
+ {service_key}: "{path}" # only include services where file was found
468
+ ```
469
+
470
+ Sort features by TICKET-ID alphabetically.
471
+ Omit `tech_docs` block entirely if no tech-doc found for any service.
472
+ Omit `bdd` block entirely if no BDD found for any service.
473
+
474
+ ---
475
+
476
+ ### Step 6 — Ensure .gitignore
477
+
478
+ Check `{manifest_root}/.gitignore`:
479
+ - If `spec-manifest.yaml` is already listed → no action
480
+ - If not → append the following to `.gitignore`:
481
+
482
+ ```
483
+ # Auto-generated — do not commit
484
+ spec-manifest.yaml
485
+ ```
486
+
487
+ Print: `✅ spec-manifest.yaml added to .gitignore`
488
+
489
+ ---
490
+
491
+ ## Output
492
+
493
+ # Report Footer — Standard Command Output Format
494
+
495
+ Every command report must end with this standard footer section.
496
+
497
+ ## Status Badge
498
+
499
+ Choose one based on outcome:
500
+ - `✅ Complete` — all steps succeeded, no issues found
501
+ - `❌ Failed` — command could not complete due to a blocking error
502
+ - `⚠️ Warnings` — completed with non-blocking issues that should be reviewed
503
+
504
+ ## Output Artifacts
505
+
506
+ List every file created or modified by this command:
507
+ ```
508
+ Output Artifacts:
509
+ {created|updated} {file-path} ({brief description})
510
+ {created|updated} {file-path} ({brief description})
511
+ ```
512
+
513
+ If no files were written (e.g., review or analysis commands) → write `Output Artifacts: none (read-only)`.
514
+
515
+ ## Next Command Suggestion
516
+
517
+ Suggest the logical next command based on workflow phase:
518
+
519
+ | Current command | Suggest next |
520
+ |-------------------------|-----------------------------------------------|
521
+ | /setup-ai-first | `/define-product` to start your first feature |
522
+ | /define-product | `/generate-prd {product-definition-file}` |
523
+ | /generate-prd | `/refine-prd {prd-file}` then `/review-context {prd-file}` |
524
+ | /refine-prd | Open Review Board → update PRD → `/review-context {prd-file}` |
525
+ | /review-context (PRD) | FE/App: `/generate-design-spec {prd-file}` (then BDD after sign-off); BE: `/generate-bdd {prd-file}` directly; fix PRD if NEEDS_FIX |
526
+ | /generate-design-spec | Designer review → Figma links confirmed → PO + Designer sign-off → `/generate-bdd {prd-file}` |
527
+ | /generate-bdd | `/review-context {feature-file}` to verify coverage |
528
+ | /review-context (BDD) | `/generate-tech-docs {UC-ID}` if APPROVED; regenerate if NEEDS_FIX |
529
+ | /generate-tech-docs | `/review-tech-docs {tech-design-file}` |
530
+ | /review-tech-docs | `/generate-code {feature-file}` if APPROVED; fix doc if NEEDS_FIX |
531
+ | /generate-code | First gen → `/review-code {UC-ID}`; re-gen → `/generate-tests {UC-ID}` |
532
+ | /generate-tests | `/run-tests {UC-ID}` |
533
+ | /run-tests (passing) | `/review-code {UC-ID}` |
534
+ | /run-tests (failing) | `/fix-bug {ticket-id}` or `/debug {error}` |
535
+ | /review-code | `/smoke-test {UC-ID}` or create PR |
536
+ | /smoke-test | Create PR and link to ticket |
537
+ | /validate-traces | DRIFT/UNTRACKED → `/generate-code {UC-ID}`; GAP → `/generate-tests {UC-ID}`; all OK → create PR |
538
+ | /fix-bug | Create PR and link to ticket |
539
+ | /debug | `/fix-bug {ticket-id}` if fix needed |
540
+ | /report-bug | Send to dev (`/fix-bug {BUG-ID}`); if coverage gap → `/propose-scenario {UC-ID}` |
541
+ | /propose-scenario | Notify PO/Dev to review the proposal in `feedback/bdd-proposals/` |
542
+ | /learn | Continue working — lesson applies on next command |
543
+ | /sync | `/validate-traces` for full coverage; act on any `📥 tester feedback` surfaced |
544
+ | /update-framework | Review `git diff .agent/`, commit; `/sync` for project content |
545
+
546
+ Format the footer as:
547
+ ```
548
+ ---
549
+ Status : {badge}
550
+ {Output Artifacts block}
551
+ Next : {suggested command with example arguments}
552
+ ```
553
+
554
+
555
+ ```
556
+ /generate-spec-manifest Complete
557
+ ---
558
+ Status : ✅ Complete
559
+ Output : spec-manifest.yaml ({N} features)
560
+ Mode : {umbrella | single}
561
+ .gitignore : ✅ spec-manifest.yaml excluded
562
+
563
+ Summary:
564
+ {N} PRDs scanned ({A} approved, {D} draft)
565
+ {N} PDDs matched
566
+ {N} BDD files matched (across {S} services)
567
+ {N} Tech-doc files matched (across {S} services)
568
+
569
+ ⚠️ {N} PRDs with no matching BDD:
570
+ - {TICKET-ID} ({domain}) — run /generate-bdd first
571
+ ⚠️ {N} PRDs with no matching tech-docs:
572
+ - {TICKET-ID} ({domain}) — run /generate-tech-docs first
573
+
574
+ Next : Share spec-manifest.yaml path with tester agent
575
+ Regenerate anytime: /generate-spec-manifest
576
+ ```