@anhth2/spec-driven-dev-plugin 0.6.0 → 0.8.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 (86) hide show
  1. package/bin/index.js +285 -11
  2. package/commands/debug.md +233 -11
  3. package/commands/debug.tmpl +170 -6
  4. package/commands/define-product.md +68 -6
  5. package/commands/define-product.tmpl +5 -1
  6. package/commands/fix-bug.md +111 -11
  7. package/commands/fix-bug.tmpl +48 -6
  8. package/commands/generate-bdd.md +86 -9
  9. package/commands/generate-bdd.tmpl +23 -4
  10. package/commands/generate-code.md +146 -19
  11. package/commands/generate-code.tmpl +83 -14
  12. package/commands/generate-design-spec.md +754 -0
  13. package/commands/generate-design-spec.tmpl +399 -0
  14. package/commands/generate-prd.md +91 -7
  15. package/commands/generate-prd.tmpl +28 -2
  16. package/commands/generate-spec-manifest.md +519 -0
  17. package/commands/generate-spec-manifest.tmpl +164 -0
  18. package/commands/generate-tech-docs.md +122 -9
  19. package/commands/generate-tech-docs.tmpl +59 -4
  20. package/commands/generate-tests.md +491 -37
  21. package/commands/generate-tests.tmpl +428 -32
  22. package/commands/refine-prd.md +76 -8
  23. package/commands/refine-prd.tmpl +13 -3
  24. package/commands/review-code.md +94 -6
  25. package/commands/review-code.tmpl +31 -1
  26. package/commands/review-context.md +118 -12
  27. package/commands/review-context.tmpl +55 -7
  28. package/commands/review-tech-docs.md +76 -9
  29. package/commands/review-tech-docs.tmpl +13 -4
  30. package/commands/run-tests.md +196 -18
  31. package/commands/run-tests.tmpl +133 -13
  32. package/commands/setup-ai-first.md +192 -6
  33. package/commands/setup-ai-first.tmpl +136 -5
  34. package/commands/smoke-test.md +228 -22
  35. package/commands/smoke-test.tmpl +165 -17
  36. package/commands/validate-traces.md +77 -8
  37. package/commands/validate-traces.tmpl +14 -3
  38. package/core/FRAMEWORK_VERSION +1 -1
  39. package/core/commands/debug.md +233 -11
  40. package/core/commands/define-product.md +68 -6
  41. package/core/commands/fix-bug.md +111 -11
  42. package/core/commands/generate-bdd.md +86 -9
  43. package/core/commands/generate-code.md +146 -19
  44. package/core/commands/generate-design-spec.md +754 -0
  45. package/core/commands/generate-prd.md +91 -7
  46. package/core/commands/generate-spec-manifest.md +519 -0
  47. package/core/commands/generate-tech-docs.md +122 -9
  48. package/core/commands/generate-tests.md +491 -37
  49. package/core/commands/refine-prd.md +76 -8
  50. package/core/commands/review-code.md +94 -6
  51. package/core/commands/review-context.md +118 -12
  52. package/core/commands/review-tech-docs.md +76 -9
  53. package/core/commands/run-tests.md +196 -18
  54. package/core/commands/setup-ai-first.md +192 -6
  55. package/core/commands/smoke-test.md +228 -22
  56. package/core/commands/validate-traces.md +77 -8
  57. package/core/skills/code/SKILL.md +68 -8
  58. package/core/skills/debug/SKILL.md +72 -10
  59. package/core/skills/design-spec/SKILL.md +450 -0
  60. package/core/skills/discovery/SKILL.md +62 -4
  61. package/core/skills/prd/SKILL.md +12 -8
  62. package/core/skills/setup-ai-first/SKILL.md +5 -3
  63. package/core/skills/spec/SKILL.md +11 -7
  64. package/core/skills/test/SKILL.md +130 -12
  65. package/core/steps/context-loader.md +57 -1
  66. package/core/steps/gate.md +1 -1
  67. package/core/steps/report-footer.md +5 -3
  68. package/core/steps/spawn-agent.md +3 -1
  69. package/core/templates/design-spec.template.md +209 -0
  70. package/core/templates/project-context.yaml +29 -0
  71. package/package.json +1 -1
  72. package/skills/code/SKILL.md +68 -8
  73. package/skills/debug/SKILL.md +72 -10
  74. package/skills/design-spec/SKILL.md +450 -0
  75. package/skills/design-spec/SKILL.tmpl +95 -0
  76. package/skills/discovery/SKILL.md +62 -4
  77. package/skills/prd/SKILL.md +12 -8
  78. package/skills/setup-ai-first/SKILL.md +5 -3
  79. package/skills/spec/SKILL.md +11 -7
  80. package/skills/test/SKILL.md +130 -12
  81. package/steps/context-loader.md +57 -1
  82. package/steps/gate.md +1 -1
  83. package/steps/report-footer.md +5 -3
  84. package/steps/spawn-agent.md +3 -1
  85. package/templates/design-spec.template.md +209 -0
  86. package/templates/project-context.yaml +29 -0
@@ -31,7 +31,7 @@ Display and wait for response:
31
31
  ```
32
32
  ⚙️ MODEL CHECK
33
33
  ──────────────────────────────────────────────────────────────────
34
- Recommended : claude-opus-4-5 (or claude-opus-4)
34
+ Recommended : claude-opus-4 (or latest Opus model)
35
35
  Why needed : Spec analysis, architecture review, code generation
36
36
  require deep reasoning. Smaller models miss edge cases.
37
37
 
@@ -131,6 +131,7 @@ Read `.agent/project-context.yaml`. Extract and store:
131
131
  - `paths.core_entities` → path to core-entities.md
132
132
  - `paths.tech_docs_dir` → technical documentation root
133
133
  - `paths.trace_dir` → trace state directory
134
+ - `paths.design_spec_dir` → Design Spec documents root (FE/App only)
134
135
 
135
136
  If `paths` section is absent, use these defaults:
136
137
  - `specs_dir` = `specs/bdd`
@@ -140,13 +141,46 @@ If `paths` section is absent, use these defaults:
140
141
  - `domain_knowledge_dir` = `specs/domain-knowledge`
141
142
  - `business_dictionary` = `specs/domain-knowledge/business-dictionary.md`
142
143
  - `core_entities` = `specs/domain-knowledge/core-entities.md`
143
- - `tech_docs_dir` = `tech-docs`
144
+ - `tech_docs_dir` = `specs/tech-docs`
144
145
  - `trace_dir` = `.trace`
146
+ - `design_spec_dir` = `specs/design-spec`
145
147
 
146
148
  If `tech_stack.module` is set, also load `.agent/modules/{module}/stack-profile.yaml` if it exists.
147
149
 
148
150
  ---
149
151
 
152
+ ## Step 1.5 — [SERVICE ROUTING] Resolve service paths (umbrella mode)
153
+
154
+ *Skip this step entirely if `setup.mode` is not `"umbrella"` and `services` section is absent from project-context.yaml.*
155
+
156
+ If `services` section is present:
157
+
158
+ **1. Detect active domain** (in priority order):
159
+ - Read `@trace.domain` from target file frontmatter (if Gate loaded a target file)
160
+ - Extract from target file path: segment immediately after `prd_dir` base path
161
+ *(e.g., `specs/prd/user/FEAT-01.md` → domain = `user`)*
162
+ - If `$ARGUMENTS` contains a path, extract the segment after `prd_dir`
163
+
164
+ **2. Route to service** — if active domain matches a key in `services`:
165
+ - Override `paths.specs_dir` → `services.{domain}.specs_dir`
166
+ - Override `paths.tech_docs_dir` → `services.{domain}.tech_docs_dir`
167
+ - Store `active_service` = `services.{domain}.path`
168
+ - Store `active_service_module` = `services.{domain}.module`
169
+ - If service has its own `module` → use it as `active_module` (overrides `tech_stack.module`)
170
+
171
+ **3. Fallback** — if domain not detected or no matching service key:
172
+ - Keep default paths from Step 1
173
+ - Set `active_service = unresolved`
174
+
175
+ **4. Spec source auto-override** — if `setup.spec_source` is set AND the corresponding path was not already explicitly set in `paths:`:
176
+ - Override `paths.prd_dir` → `{spec_source}/specs/prd`
177
+ - Override `paths.design_spec_dir` → `{spec_source}/specs/design-spec`
178
+ - Override `paths.domain_knowledge_dir` → `{spec_source}/specs/domain-knowledge`
179
+ - Override `paths.business_dictionary` → `{spec_source}/specs/domain-knowledge/business-dictionary.md`
180
+ - Override `paths.core_entities` → `{spec_source}/specs/domain-knowledge/core-entities.md`
181
+
182
+ ---
183
+
150
184
  ## Step 2 — [PROJECT-CONFIG] Load module stack profile (conditional)
151
185
 
152
186
  If `tech_stack.module` is set, read `.agent/modules/{module}/stack-profile.yaml`.
@@ -217,6 +251,26 @@ If the file does not exist → skip silently.
217
251
 
218
252
  ---
219
253
 
254
+ ## Step 6.5 — [PLATFORM] Derive active_module and platform_type
255
+
256
+ Using `tech_stack.module` loaded in Step 1, derive and store two variables for use by all downstream commands:
257
+
258
+ ```
259
+ active_module = tech_stack.module (e.g. "java-spring", "react", "flutter")
260
+ ```
261
+
262
+ | `platform_type` | Modules |
263
+ |---|---|
264
+ | `backend` | `java-spring`, `golang`, `dotnet`, `php-laravel`, `context-engineering` |
265
+ | `web-frontend` | `react`, `nextjs`, `vue`, `nuxt`, `angular` |
266
+ | `mobile` | `flutter`, `react-native`, `ios-swiftui`, `android-compose` |
267
+
268
+ If `tech_stack.module` is blank or not recognized → set `platform_type = "unknown"` and flag as ⚠️ in the Step 7 recap.
269
+
270
+ 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).
271
+
272
+ ---
273
+
220
274
  ## Step 7 — [RECAP] Working Memory Recap (anti-lost-in-middle)
221
275
 
222
276
  After loading all context, synthesize and output a compact summary block.
@@ -227,10 +281,12 @@ Output exactly this block:
227
281
  ```
228
282
  [CTX LOADED]
229
283
  Stack : {language} / {framework} / {database}
284
+ Platform : {active_module} ({platform_type})
230
285
  Layers : {layer order from CLAUDE.md §2, e.g., Controller → Facade → Service → Repository}
231
286
  Ticket : {ticket_prefix}-
232
287
  Dict : {loaded — N canonical terms, M banned terms | missing}
233
288
  Entities : {loaded — EntityA, EntityB, EntityC | missing}
289
+ Service : {active_service} ({active_service_module}) | single-service
234
290
  Status : {FULL | PARTIAL — missing: CLAUDE.md / business-dict / core-entities | MINIMAL}
235
291
  ```
236
292
 
@@ -269,6 +325,8 @@ AI scans the project and writes:
269
325
  | {original} | {canonical} |
270
326
  ```
271
327
 
328
+ Store this terminology map in the output product-definition file under a `## Terminology Map` section — `/generate-prd` will reference it during its Terminology Rules step to ensure consistency.
329
+
272
330
  ---
273
331
 
274
332
  ## Phase 1 — Feature Definition *(CHECKPOINT 1)*
@@ -305,7 +363,7 @@ Confirm → write `✅ PO Confirmed: Yes` → proceed.
305
363
 
306
364
  ---
307
365
 
308
- ## Phase 3 — Clarification Log
366
+ ## Phase 3 — Clarification Log *(CHECKPOINT 3)*
309
367
 
310
368
  Based on Phases 1-2, AI identifies gaps and asks follow-up questions. Continue rounds until no Unresolved Items remain.
311
369
 
@@ -321,6 +379,8 @@ Based on Phases 1-2, AI identifies gaps and asks follow-up questions. Continue r
321
379
  ### Unresolved Items
322
380
  - {item — or "None"}
323
381
 
382
+ When all Unresolved Items are resolved → write `✅ CHECKPOINT 3: No Unresolved Items` → proceed to Phase 4.
383
+
324
384
  ---
325
385
 
326
386
  ## Phase 4 — Business Rules *(CHECKPOINT 4)*
@@ -417,21 +477,23 @@ Suggest the logical next command based on workflow phase:
417
477
 
418
478
  | Current command | Suggest next |
419
479
  |-------------------------|-----------------------------------------------|
480
+ | /setup-ai-first | `/define-product` to start your first feature |
420
481
  | /define-product | `/generate-prd {product-definition-file}` |
421
482
  | /generate-prd | `/refine-prd {prd-file}` then `/review-context {prd-file}` |
422
483
  | /refine-prd | Open Review Board → update PRD → `/review-context {prd-file}` |
423
- | /review-context (PRD) | `/generate-bdd {prd-file}` if APPROVED; fix PRD if NEEDS_FIX |
484
+ | /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 |
485
+ | /generate-design-spec | Designer review → Figma links confirmed → PO + Designer sign-off → `/generate-bdd {prd-file}` |
424
486
  | /generate-bdd | `/review-context {feature-file}` to verify coverage |
425
487
  | /review-context (BDD) | `/generate-tech-docs {UC-ID}` if APPROVED; regenerate if NEEDS_FIX |
426
488
  | /generate-tech-docs | `/review-tech-docs {tech-design-file}` |
427
489
  | /review-tech-docs | `/generate-code {feature-file}` if APPROVED; fix doc if NEEDS_FIX |
428
- | /generate-code | `/generate-tests {UC-ID}` |
490
+ | /generate-code | First gen → `/review-code {UC-ID}`; re-gen → `/generate-tests {UC-ID}` |
429
491
  | /generate-tests | `/run-tests {UC-ID}` |
430
492
  | /run-tests (passing) | `/review-code {UC-ID}` |
431
493
  | /run-tests (failing) | `/fix-bug {ticket-id}` or `/debug {error}` |
432
494
  | /review-code | `/smoke-test {UC-ID}` or create PR |
433
495
  | /smoke-test | Create PR and link to ticket |
434
- | /validate-traces | `/generate-code {UC-ID}` for gaps |
496
+ | /validate-traces | DRIFT/UNTRACKED → `/generate-code {UC-ID}`; GAP → `/generate-tests {UC-ID}`; all OK → create PR |
435
497
  | /fix-bug | Create PR and link to ticket |
436
498
  | /debug | `/fix-bug {ticket-id}` if fix needed |
437
499
 
@@ -31,7 +31,7 @@ Display and wait for response:
31
31
  ```
32
32
  ⚙️ MODEL CHECK
33
33
  ──────────────────────────────────────────────────────────────────
34
- Recommended : claude-opus-4-5 (or claude-opus-4)
34
+ Recommended : claude-opus-4 (or latest Opus model)
35
35
  Why needed : Spec analysis, architecture review, code generation
36
36
  require deep reasoning. Smaller models miss edge cases.
37
37
 
@@ -131,6 +131,7 @@ Read `.agent/project-context.yaml`. Extract and store:
131
131
  - `paths.core_entities` → path to core-entities.md
132
132
  - `paths.tech_docs_dir` → technical documentation root
133
133
  - `paths.trace_dir` → trace state directory
134
+ - `paths.design_spec_dir` → Design Spec documents root (FE/App only)
134
135
 
135
136
  If `paths` section is absent, use these defaults:
136
137
  - `specs_dir` = `specs/bdd`
@@ -140,13 +141,46 @@ If `paths` section is absent, use these defaults:
140
141
  - `domain_knowledge_dir` = `specs/domain-knowledge`
141
142
  - `business_dictionary` = `specs/domain-knowledge/business-dictionary.md`
142
143
  - `core_entities` = `specs/domain-knowledge/core-entities.md`
143
- - `tech_docs_dir` = `tech-docs`
144
+ - `tech_docs_dir` = `specs/tech-docs`
144
145
  - `trace_dir` = `.trace`
146
+ - `design_spec_dir` = `specs/design-spec`
145
147
 
146
148
  If `tech_stack.module` is set, also load `.agent/modules/{module}/stack-profile.yaml` if it exists.
147
149
 
148
150
  ---
149
151
 
152
+ ## Step 1.5 — [SERVICE ROUTING] Resolve service paths (umbrella mode)
153
+
154
+ *Skip this step entirely if `setup.mode` is not `"umbrella"` and `services` section is absent from project-context.yaml.*
155
+
156
+ If `services` section is present:
157
+
158
+ **1. Detect active domain** (in priority order):
159
+ - Read `@trace.domain` from target file frontmatter (if Gate loaded a target file)
160
+ - Extract from target file path: segment immediately after `prd_dir` base path
161
+ *(e.g., `specs/prd/user/FEAT-01.md` → domain = `user`)*
162
+ - If `$ARGUMENTS` contains a path, extract the segment after `prd_dir`
163
+
164
+ **2. Route to service** — if active domain matches a key in `services`:
165
+ - Override `paths.specs_dir` → `services.{domain}.specs_dir`
166
+ - Override `paths.tech_docs_dir` → `services.{domain}.tech_docs_dir`
167
+ - Store `active_service` = `services.{domain}.path`
168
+ - Store `active_service_module` = `services.{domain}.module`
169
+ - If service has its own `module` → use it as `active_module` (overrides `tech_stack.module`)
170
+
171
+ **3. Fallback** — if domain not detected or no matching service key:
172
+ - Keep default paths from Step 1
173
+ - Set `active_service = unresolved`
174
+
175
+ **4. Spec source auto-override** — if `setup.spec_source` is set AND the corresponding path was not already explicitly set in `paths:`:
176
+ - Override `paths.prd_dir` → `{spec_source}/specs/prd`
177
+ - Override `paths.design_spec_dir` → `{spec_source}/specs/design-spec`
178
+ - Override `paths.domain_knowledge_dir` → `{spec_source}/specs/domain-knowledge`
179
+ - Override `paths.business_dictionary` → `{spec_source}/specs/domain-knowledge/business-dictionary.md`
180
+ - Override `paths.core_entities` → `{spec_source}/specs/domain-knowledge/core-entities.md`
181
+
182
+ ---
183
+
150
184
  ## Step 2 — [PROJECT-CONFIG] Load module stack profile (conditional)
151
185
 
152
186
  If `tech_stack.module` is set, read `.agent/modules/{module}/stack-profile.yaml`.
@@ -217,6 +251,26 @@ If the file does not exist → skip silently.
217
251
 
218
252
  ---
219
253
 
254
+ ## Step 6.5 — [PLATFORM] Derive active_module and platform_type
255
+
256
+ Using `tech_stack.module` loaded in Step 1, derive and store two variables for use by all downstream commands:
257
+
258
+ ```
259
+ active_module = tech_stack.module (e.g. "java-spring", "react", "flutter")
260
+ ```
261
+
262
+ | `platform_type` | Modules |
263
+ |---|---|
264
+ | `backend` | `java-spring`, `golang`, `dotnet`, `php-laravel`, `context-engineering` |
265
+ | `web-frontend` | `react`, `nextjs`, `vue`, `nuxt`, `angular` |
266
+ | `mobile` | `flutter`, `react-native`, `ios-swiftui`, `android-compose` |
267
+
268
+ If `tech_stack.module` is blank or not recognized → set `platform_type = "unknown"` and flag as ⚠️ in the Step 7 recap.
269
+
270
+ 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).
271
+
272
+ ---
273
+
220
274
  ## Step 7 — [RECAP] Working Memory Recap (anti-lost-in-middle)
221
275
 
222
276
  After loading all context, synthesize and output a compact summary block.
@@ -227,10 +281,12 @@ Output exactly this block:
227
281
  ```
228
282
  [CTX LOADED]
229
283
  Stack : {language} / {framework} / {database}
284
+ Platform : {active_module} ({platform_type})
230
285
  Layers : {layer order from CLAUDE.md §2, e.g., Controller → Facade → Service → Repository}
231
286
  Ticket : {ticket_prefix}-
232
287
  Dict : {loaded — N canonical terms, M banned terms | missing}
233
288
  Entities : {loaded — EntityA, EntityB, EntityC | missing}
289
+ Service : {active_service} ({active_service_module}) | single-service
234
290
  Status : {FULL | PARTIAL — missing: CLAUDE.md / business-dict / core-entities | MINIMAL}
235
291
  ```
236
292
 
@@ -264,17 +320,59 @@ If no ticket — CHECKPOINT:
264
320
 
265
321
  ## Phase 2 — Root Cause Analysis
266
322
 
323
+ Use `active_module` from context to select the relevant table.
324
+
325
+ ### If `platform_type = backend`
326
+
327
+ #### java-spring / golang / dotnet / php-laravel
328
+
267
329
  | Bug Type | Common Location | How to Check |
268
330
  |----------|----------------|--------------|
269
331
  | Wrong response data | Mapping layer | Check field mapping, DTO conversions |
270
- | 400 Bad Request | Input validation | Check DTO constraints |
332
+ | 400 Bad Request | Input validation | Check DTO constraints / validators |
333
+ | 401 Unauthorized | Auth filter | Check token config, filter order |
271
334
  | 403 Forbidden | Auth config | Check role-based access rules |
272
335
  | 404 Not Found | Repository query | Check find method, ID types |
273
- | N+1 Query | Data access | Check for missing JOIN FETCH |
274
- | Null Pointer | Optional not handled | Check Optional.orElseThrow |
275
- | Transaction rollback | Missing @Transactional | Check transaction scope |
276
- | Stale cache | Missing cache eviction | Check cache invalidation |
277
- | Type mismatch in query | Filter/specification | Check field types in predicates |
336
+ | N+1 Query | Data access | Check for missing JOIN FETCH / eager load |
337
+ | Null Pointer | Optional not handled | Check Optional.orElseThrow, null guards |
338
+ | Transaction rollback | Missing @Transactional | Check transaction scope, propagation |
339
+ | Stale cache | Missing eviction | Check cache invalidation triggers |
340
+ | Type mismatch | Filter / specification | Check field types in predicates |
341
+
342
+ #### context-engineering (AI/LLM pipelines)
343
+
344
+ | Bug Type | Common Location | How to Check |
345
+ |----------|----------------|--------------|
346
+ | Wrong pipeline output | Prompt template | Check prompt content; verify variables are substituted correctly |
347
+ | Missing context in output | Context assembly | Verify all required context blocks are included and non-empty |
348
+ | Schema validation failure | Output parser | Compare raw LLM output vs expected schema; add stricter output instructions |
349
+ | Flaky / non-deterministic results | LLM temperature | Check temperature setting; use fixed seed/mock in tests |
350
+ | API rate limit errors | LLM client | Implement backoff; check quota usage in provider dashboard |
351
+ | Token limit exceeded | Prompt assembly | Reduce context size; add chunking strategy |
352
+
353
+ ### If `platform_type = web-frontend`
354
+
355
+ | Bug Type | Common Location | How to Check |
356
+ |----------|----------------|--------------|
357
+ | Wrong data displayed | State / store | Check state update logic, selector |
358
+ | UI not re-rendering | Missing reactive dep | Check deps array, state immutability |
359
+ | API data not loading | HTTP client / hook | Check network tab, error handler |
360
+ | 401 on API call | Auth token | Check token refresh, header injection |
361
+ | Form not submitting | Validation / handler | Check form state, required fields, errors |
362
+ | Route not found | Router config | Check route definition, lazy import |
363
+ | Build / type error | TypeScript types | Compare type definitions vs actual API shape |
364
+
365
+ ### If `platform_type = mobile`
366
+
367
+ | Bug Type | Common Location | How to Check |
368
+ |----------|----------------|--------------|
369
+ | Screen shows stale data | State / BLoC / ViewModel | Check event dispatched, state emitted correctly |
370
+ | Crash on navigation | Route param missing | Check params passed, null safety |
371
+ | API call not firing | Repository / service layer | Add log in repo method, check network |
372
+ | UI not reflecting state | Widget not observing stream | Check `BlocBuilder` / `StateObserver` setup |
373
+ | Crash on app resume | Lifecycle handler | Check `onResume` / `viewDidAppear` logic |
374
+ | Auth token expired | Token refresh logic | Check refresh flow, token storage |
375
+ | Permission denied | OS permission | Check runtime permission request code |
278
376
 
279
377
  CHECKPOINT — Root Cause Report:
280
378
  ```
@@ -342,21 +440,23 @@ Suggest the logical next command based on workflow phase:
342
440
 
343
441
  | Current command | Suggest next |
344
442
  |-------------------------|-----------------------------------------------|
443
+ | /setup-ai-first | `/define-product` to start your first feature |
345
444
  | /define-product | `/generate-prd {product-definition-file}` |
346
445
  | /generate-prd | `/refine-prd {prd-file}` then `/review-context {prd-file}` |
347
446
  | /refine-prd | Open Review Board → update PRD → `/review-context {prd-file}` |
348
- | /review-context (PRD) | `/generate-bdd {prd-file}` if APPROVED; fix PRD if NEEDS_FIX |
447
+ | /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 |
448
+ | /generate-design-spec | Designer review → Figma links confirmed → PO + Designer sign-off → `/generate-bdd {prd-file}` |
349
449
  | /generate-bdd | `/review-context {feature-file}` to verify coverage |
350
450
  | /review-context (BDD) | `/generate-tech-docs {UC-ID}` if APPROVED; regenerate if NEEDS_FIX |
351
451
  | /generate-tech-docs | `/review-tech-docs {tech-design-file}` |
352
452
  | /review-tech-docs | `/generate-code {feature-file}` if APPROVED; fix doc if NEEDS_FIX |
353
- | /generate-code | `/generate-tests {UC-ID}` |
453
+ | /generate-code | First gen → `/review-code {UC-ID}`; re-gen → `/generate-tests {UC-ID}` |
354
454
  | /generate-tests | `/run-tests {UC-ID}` |
355
455
  | /run-tests (passing) | `/review-code {UC-ID}` |
356
456
  | /run-tests (failing) | `/fix-bug {ticket-id}` or `/debug {error}` |
357
457
  | /review-code | `/smoke-test {UC-ID}` or create PR |
358
458
  | /smoke-test | Create PR and link to ticket |
359
- | /validate-traces | `/generate-code {UC-ID}` for gaps |
459
+ | /validate-traces | DRIFT/UNTRACKED → `/generate-code {UC-ID}`; GAP → `/generate-tests {UC-ID}`; all OK → create PR |
360
460
  | /fix-bug | Create PR and link to ticket |
361
461
  | /debug | `/fix-bug {ticket-id}` if fix needed |
362
462
 
@@ -31,7 +31,7 @@ Display and wait for response:
31
31
  ```
32
32
  ⚙️ MODEL CHECK
33
33
  ──────────────────────────────────────────────────────────────────
34
- Recommended : claude-opus-4-5 (or claude-opus-4)
34
+ Recommended : claude-opus-4 (or latest Opus model)
35
35
  Why needed : Spec analysis, architecture review, code generation
36
36
  require deep reasoning. Smaller models miss edge cases.
37
37
 
@@ -129,6 +129,7 @@ Read `.agent/project-context.yaml`. Extract and store:
129
129
  - `paths.core_entities` → path to core-entities.md
130
130
  - `paths.tech_docs_dir` → technical documentation root
131
131
  - `paths.trace_dir` → trace state directory
132
+ - `paths.design_spec_dir` → Design Spec documents root (FE/App only)
132
133
 
133
134
  If `paths` section is absent, use these defaults:
134
135
  - `specs_dir` = `specs/bdd`
@@ -138,13 +139,46 @@ If `paths` section is absent, use these defaults:
138
139
  - `domain_knowledge_dir` = `specs/domain-knowledge`
139
140
  - `business_dictionary` = `specs/domain-knowledge/business-dictionary.md`
140
141
  - `core_entities` = `specs/domain-knowledge/core-entities.md`
141
- - `tech_docs_dir` = `tech-docs`
142
+ - `tech_docs_dir` = `specs/tech-docs`
142
143
  - `trace_dir` = `.trace`
144
+ - `design_spec_dir` = `specs/design-spec`
143
145
 
144
146
  If `tech_stack.module` is set, also load `.agent/modules/{module}/stack-profile.yaml` if it exists.
145
147
 
146
148
  ---
147
149
 
150
+ ## Step 1.5 — [SERVICE ROUTING] Resolve service paths (umbrella mode)
151
+
152
+ *Skip this step entirely if `setup.mode` is not `"umbrella"` and `services` section is absent from project-context.yaml.*
153
+
154
+ If `services` section is present:
155
+
156
+ **1. Detect active domain** (in priority order):
157
+ - Read `@trace.domain` from target file frontmatter (if Gate loaded a target file)
158
+ - Extract from target file path: segment immediately after `prd_dir` base path
159
+ *(e.g., `specs/prd/user/FEAT-01.md` → domain = `user`)*
160
+ - If `$ARGUMENTS` contains a path, extract the segment after `prd_dir`
161
+
162
+ **2. Route to service** — if active domain matches a key in `services`:
163
+ - Override `paths.specs_dir` → `services.{domain}.specs_dir`
164
+ - Override `paths.tech_docs_dir` → `services.{domain}.tech_docs_dir`
165
+ - Store `active_service` = `services.{domain}.path`
166
+ - Store `active_service_module` = `services.{domain}.module`
167
+ - If service has its own `module` → use it as `active_module` (overrides `tech_stack.module`)
168
+
169
+ **3. Fallback** — if domain not detected or no matching service key:
170
+ - Keep default paths from Step 1
171
+ - Set `active_service = unresolved`
172
+
173
+ **4. Spec source auto-override** — if `setup.spec_source` is set AND the corresponding path was not already explicitly set in `paths:`:
174
+ - Override `paths.prd_dir` → `{spec_source}/specs/prd`
175
+ - Override `paths.design_spec_dir` → `{spec_source}/specs/design-spec`
176
+ - Override `paths.domain_knowledge_dir` → `{spec_source}/specs/domain-knowledge`
177
+ - Override `paths.business_dictionary` → `{spec_source}/specs/domain-knowledge/business-dictionary.md`
178
+ - Override `paths.core_entities` → `{spec_source}/specs/domain-knowledge/core-entities.md`
179
+
180
+ ---
181
+
148
182
  ## Step 2 — [PROJECT-CONFIG] Load module stack profile (conditional)
149
183
 
150
184
  If `tech_stack.module` is set, read `.agent/modules/{module}/stack-profile.yaml`.
@@ -215,6 +249,26 @@ If the file does not exist → skip silently.
215
249
 
216
250
  ---
217
251
 
252
+ ## Step 6.5 — [PLATFORM] Derive active_module and platform_type
253
+
254
+ Using `tech_stack.module` loaded in Step 1, derive and store two variables for use by all downstream commands:
255
+
256
+ ```
257
+ active_module = tech_stack.module (e.g. "java-spring", "react", "flutter")
258
+ ```
259
+
260
+ | `platform_type` | Modules |
261
+ |---|---|
262
+ | `backend` | `java-spring`, `golang`, `dotnet`, `php-laravel`, `context-engineering` |
263
+ | `web-frontend` | `react`, `nextjs`, `vue`, `nuxt`, `angular` |
264
+ | `mobile` | `flutter`, `react-native`, `ios-swiftui`, `android-compose` |
265
+
266
+ If `tech_stack.module` is blank or not recognized → set `platform_type = "unknown"` and flag as ⚠️ in the Step 7 recap.
267
+
268
+ 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).
269
+
270
+ ---
271
+
218
272
  ## Step 7 — [RECAP] Working Memory Recap (anti-lost-in-middle)
219
273
 
220
274
  After loading all context, synthesize and output a compact summary block.
@@ -225,10 +279,12 @@ Output exactly this block:
225
279
  ```
226
280
  [CTX LOADED]
227
281
  Stack : {language} / {framework} / {database}
282
+ Platform : {active_module} ({platform_type})
228
283
  Layers : {layer order from CLAUDE.md §2, e.g., Controller → Facade → Service → Repository}
229
284
  Ticket : {ticket_prefix}-
230
285
  Dict : {loaded — N canonical terms, M banned terms | missing}
231
286
  Entities : {loaded — EntityA, EntityB, EntityC | missing}
287
+ Service : {active_service} ({active_service_module}) | single-service
232
288
  Status : {FULL | PARTIAL — missing: CLAUDE.md / business-dict / core-entities | MINIMAL}
233
289
  ```
234
290
 
@@ -270,6 +326,18 @@ After loading context, check if the target PRD is large enough to warrant sub-ag
270
326
 
271
327
  ---
272
328
 
329
+ ## Sub-Agent Return Format
330
+
331
+ *This section applies when running as a sub-agent (Gate Step 0 detected `_agent_mode: true`).*
332
+
333
+ After generating all `.feature` and `.tsv` files for the assigned UC, return the structured result JSON (as specified in `steps/spawn-agent.md` Step E):
334
+
335
+ ```json
336
+ { "uc_id": "{TICKET-ID}-UC{N}", "files_created": ["path/to/file1", "path/to/file2"], "status": "success | error", "errors": [] }
337
+ ```
338
+
339
+ ---
340
+
273
341
  ## Version Check
274
342
 
275
343
  Before generating, check for existing `.feature` files for this PRD:
@@ -383,15 +451,16 @@ For each UC, write `{paths.specs_dir}/{domain}/{TICKET-ID}-UC{N}-{slug}.feature`
383
451
  # ============================================================
384
452
  # @trace.id: {TICKET-ID}-UC{N}
385
453
  # @trace.title: <Feature name>
386
- # @trace.revision: 1
454
+ # @trace.revision: 1 ← static field; use @trace.bdd_version for version tracking (incremented by /review-context --fix or --resume)
387
455
  # @trace.domain: <domain>
388
456
  # @trace.service: <ServiceName>
457
+ # @trace.module: {tech_stack.module value — e.g. java-spring | react | flutter; write "unknown" if not set in project-context.yaml}
389
458
  # @trace.status: draft
390
459
  # @trace.author: AI-generated
391
460
  # @trace.created_at: {YYYY-MM-DD}
392
461
  # @trace.prd: {TICKET-ID}
393
462
  # @trace.prd_version: {read from PRD metadata "| **Version** |"}
394
- # @trace.bdd_version: {1 if fresh generation; increment by 1 if re-generation}
463
+ # @trace.bdd_version: {1.0 if fresh generation; increment by 0.1 on re-generation — e.g. 1.0 → 1.1}
395
464
  # @trace.business_rules: {TICKET-ID}-UC{N}-BR1, {TICKET-ID}-UC{N}-BR2
396
465
  # @trace.dataset: {domain}.testdata.yaml
397
466
  # ============================================================
@@ -499,7 +568,8 @@ sc_id\tsc_title\tspec_ver\tgen_ver\timplemented_by\ttest_count\ttest_classes\tpr
499
568
  **Rules:**
500
569
  - If file does not exist → create with header row + all scenario rows.
501
570
  - If file exists (re-generation) → for each SC in the new `.feature`:
502
- - SC already in `.tsv` → update only: `sc_title`, `spec_ver`, `prd_version`, `bdd_version`, `prd_status`, `uc_status`, `last_updated`. Leave `gen_ver`, `implemented_by`, `test_count`, `test_classes`, `tech_doc_revision` unchanged.
571
+ - SC already in `.tsv` AND `spec_ver` is unchanged → update only: `sc_title`, `prd_version`, `bdd_version`, `prd_status`, `uc_status`, `last_updated`. Leave all other columns unchanged.
572
+ - SC already in `.tsv` AND `spec_ver` changed (scenario was modified) → update: `sc_title`, `spec_ver`, `prd_version`, `bdd_version`, `prd_status`, `uc_status`, `last_updated` AND set `status = DRIFT` immediately (so the TSV reflects drift without waiting for `/validate-traces`). Leave `gen_ver`, `implemented_by`, `test_count`, `test_classes`, `tech_doc_revision` unchanged.
503
573
  - SC is new (added in this re-gen) → append new row with `gen_ver`, `implemented_by`, `test_count`, `test_classes`, `tech_doc_revision` all set to `—`.
504
574
  - SC no longer in `.feature` (removed) → delete its row.
505
575
 
@@ -552,21 +622,23 @@ Suggest the logical next command based on workflow phase:
552
622
 
553
623
  | Current command | Suggest next |
554
624
  |-------------------------|-----------------------------------------------|
625
+ | /setup-ai-first | `/define-product` to start your first feature |
555
626
  | /define-product | `/generate-prd {product-definition-file}` |
556
627
  | /generate-prd | `/refine-prd {prd-file}` then `/review-context {prd-file}` |
557
628
  | /refine-prd | Open Review Board → update PRD → `/review-context {prd-file}` |
558
- | /review-context (PRD) | `/generate-bdd {prd-file}` if APPROVED; fix PRD if NEEDS_FIX |
629
+ | /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 |
630
+ | /generate-design-spec | Designer review → Figma links confirmed → PO + Designer sign-off → `/generate-bdd {prd-file}` |
559
631
  | /generate-bdd | `/review-context {feature-file}` to verify coverage |
560
632
  | /review-context (BDD) | `/generate-tech-docs {UC-ID}` if APPROVED; regenerate if NEEDS_FIX |
561
633
  | /generate-tech-docs | `/review-tech-docs {tech-design-file}` |
562
634
  | /review-tech-docs | `/generate-code {feature-file}` if APPROVED; fix doc if NEEDS_FIX |
563
- | /generate-code | `/generate-tests {UC-ID}` |
635
+ | /generate-code | First gen → `/review-code {UC-ID}`; re-gen → `/generate-tests {UC-ID}` |
564
636
  | /generate-tests | `/run-tests {UC-ID}` |
565
637
  | /run-tests (passing) | `/review-code {UC-ID}` |
566
638
  | /run-tests (failing) | `/fix-bug {ticket-id}` or `/debug {error}` |
567
639
  | /review-code | `/smoke-test {UC-ID}` or create PR |
568
640
  | /smoke-test | Create PR and link to ticket |
569
- | /validate-traces | `/generate-code {UC-ID}` for gaps |
641
+ | /validate-traces | DRIFT/UNTRACKED → `/generate-code {UC-ID}`; GAP → `/generate-tests {UC-ID}`; all OK → create PR |
570
642
  | /fix-bug | Create PR and link to ticket |
571
643
  | /debug | `/fix-bug {ticket-id}` if fix needed |
572
644
 
@@ -587,5 +659,10 @@ Files:
587
659
  Trace:
588
660
  {paths.trace_dir}/{TICKET-ID}-UC1.tsv ({N} rows)
589
661
  {paths.trace_dir}/{TICKET-ID}-UC2.tsv ({N} rows)
590
- Next: /generate-tech-docs OR /generate-code {paths.specs_dir}/{domain}/{TICKET-ID}-UC{N}-{slug}.feature
662
+ Next: Run /review-context on EACH generated feature file (one per UC):
663
+ /review-context {paths.specs_dir}/{domain}/{TICKET-ID}-UC1-{slug}.feature
664
+ /review-context {paths.specs_dir}/{domain}/{TICKET-ID}-UC2-{slug}.feature
665
+ ...
666
+ → then per UC: /generate-tech-docs {feature-file} (if tech design required)
667
+ → or per UC: /generate-code {feature-file} (if skipping tech design)
591
668
  ```