@anhth2/spec-driven-dev-plugin 0.5.0 → 0.7.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 (76) hide show
  1. package/ARCHITECTURE.md +1 -1
  2. package/bin/index.js +184 -15
  3. package/commands/debug.md +196 -10
  4. package/commands/debug.tmpl +170 -6
  5. package/commands/define-product.md +31 -5
  6. package/commands/define-product.tmpl +5 -1
  7. package/commands/fix-bug.md +74 -10
  8. package/commands/fix-bug.tmpl +48 -6
  9. package/commands/generate-bdd.md +49 -8
  10. package/commands/generate-bdd.tmpl +23 -4
  11. package/commands/generate-code.md +109 -18
  12. package/commands/generate-code.tmpl +83 -14
  13. package/commands/generate-prd.md +33 -6
  14. package/commands/generate-prd.tmpl +7 -2
  15. package/commands/generate-tech-docs.md +85 -8
  16. package/commands/generate-tech-docs.tmpl +59 -4
  17. package/commands/generate-tests.md +454 -36
  18. package/commands/generate-tests.tmpl +428 -32
  19. package/commands/refine-prd.md +39 -7
  20. package/commands/refine-prd.tmpl +13 -3
  21. package/commands/review-code.md +57 -5
  22. package/commands/review-code.tmpl +31 -1
  23. package/commands/review-context.md +41 -11
  24. package/commands/review-context.tmpl +15 -7
  25. package/commands/review-tech-docs.md +39 -8
  26. package/commands/review-tech-docs.tmpl +13 -4
  27. package/commands/run-tests.md +159 -17
  28. package/commands/run-tests.tmpl +133 -13
  29. package/commands/setup-ai-first.md +85 -9
  30. package/commands/setup-ai-first.tmpl +30 -8
  31. package/commands/smoke-test.md +191 -21
  32. package/commands/smoke-test.tmpl +165 -17
  33. package/commands/validate-traces.md +40 -7
  34. package/commands/validate-traces.tmpl +14 -3
  35. package/core/FRAMEWORK_VERSION +1 -1
  36. package/core/commands/debug.md +196 -10
  37. package/core/commands/define-product.md +31 -5
  38. package/core/commands/fix-bug.md +74 -10
  39. package/core/commands/generate-bdd.md +49 -8
  40. package/core/commands/generate-code.md +109 -18
  41. package/core/commands/generate-prd.md +33 -6
  42. package/core/commands/generate-tech-docs.md +85 -8
  43. package/core/commands/generate-tests.md +454 -36
  44. package/core/commands/refine-prd.md +39 -7
  45. package/core/commands/review-code.md +57 -5
  46. package/core/commands/review-context.md +41 -11
  47. package/core/commands/review-tech-docs.md +39 -8
  48. package/core/commands/run-tests.md +159 -17
  49. package/core/commands/setup-ai-first.md +85 -9
  50. package/core/commands/smoke-test.md +191 -21
  51. package/core/commands/validate-traces.md +40 -7
  52. package/core/skills/code/SKILL.md +29 -6
  53. package/core/skills/debug/SKILL.md +31 -7
  54. package/core/skills/discovery/SKILL.md +25 -3
  55. package/core/skills/prd/SKILL.md +8 -6
  56. package/core/skills/setup-ai-first/SKILL.md +3 -2
  57. package/core/skills/spec/SKILL.md +7 -5
  58. package/core/skills/test/SKILL.md +54 -9
  59. package/core/steps/context-loader.md +22 -1
  60. package/core/steps/gate.md +1 -1
  61. package/core/steps/report-footer.md +3 -2
  62. package/core/steps/spawn-agent.md +3 -1
  63. package/package.json +1 -1
  64. package/scripts/init.sh +2 -2
  65. package/scripts/upgrade.sh +4 -4
  66. package/skills/code/SKILL.md +29 -6
  67. package/skills/debug/SKILL.md +31 -7
  68. package/skills/discovery/SKILL.md +25 -3
  69. package/skills/prd/SKILL.md +8 -6
  70. package/skills/setup-ai-first/SKILL.md +3 -2
  71. package/skills/spec/SKILL.md +7 -5
  72. package/skills/test/SKILL.md +54 -9
  73. package/steps/context-loader.md +22 -1
  74. package/steps/gate.md +1 -1
  75. package/steps/report-footer.md +3 -2
  76. package/steps/spawn-agent.md +3 -1
@@ -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
 
@@ -140,7 +140,7 @@ If `paths` section is absent, use these defaults:
140
140
  - `domain_knowledge_dir` = `specs/domain-knowledge`
141
141
  - `business_dictionary` = `specs/domain-knowledge/business-dictionary.md`
142
142
  - `core_entities` = `specs/domain-knowledge/core-entities.md`
143
- - `tech_docs_dir` = `tech-docs`
143
+ - `tech_docs_dir` = `specs/tech-docs`
144
144
  - `trace_dir` = `.trace`
145
145
 
146
146
  If `tech_stack.module` is set, also load `.agent/modules/{module}/stack-profile.yaml` if it exists.
@@ -217,6 +217,26 @@ If the file does not exist → skip silently.
217
217
 
218
218
  ---
219
219
 
220
+ ## Step 6.5 — [PLATFORM] Derive active_module and platform_type
221
+
222
+ Using `tech_stack.module` loaded in Step 1, derive and store two variables for use by all downstream commands:
223
+
224
+ ```
225
+ active_module = tech_stack.module (e.g. "java-spring", "react", "flutter")
226
+ ```
227
+
228
+ | `platform_type` | Modules |
229
+ |---|---|
230
+ | `backend` | `java-spring`, `golang`, `dotnet`, `php-laravel`, `context-engineering` |
231
+ | `web-frontend` | `react`, `nextjs`, `vue`, `nuxt`, `angular` |
232
+ | `mobile` | `flutter`, `react-native`, `ios-swiftui`, `android-compose` |
233
+
234
+ If `tech_stack.module` is blank or not recognized → set `platform_type = "unknown"` and flag as ⚠️ in the Step 7 recap.
235
+
236
+ 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).
237
+
238
+ ---
239
+
220
240
  ## Step 7 — [RECAP] Working Memory Recap (anti-lost-in-middle)
221
241
 
222
242
  After loading all context, synthesize and output a compact summary block.
@@ -227,6 +247,7 @@ Output exactly this block:
227
247
  ```
228
248
  [CTX LOADED]
229
249
  Stack : {language} / {framework} / {database}
250
+ Platform : {active_module} ({platform_type})
230
251
  Layers : {layer order from CLAUDE.md §2, e.g., Controller → Facade → Service → Repository}
231
252
  Ticket : {ticket_prefix}-
232
253
  Dict : {loaded — N canonical terms, M banned terms | missing}
@@ -264,17 +285,59 @@ If no ticket — CHECKPOINT:
264
285
 
265
286
  ## Phase 2 — Root Cause Analysis
266
287
 
288
+ Use `active_module` from context to select the relevant table.
289
+
290
+ ### If `platform_type = backend`
291
+
292
+ #### java-spring / golang / dotnet / php-laravel
293
+
267
294
  | Bug Type | Common Location | How to Check |
268
295
  |----------|----------------|--------------|
269
296
  | Wrong response data | Mapping layer | Check field mapping, DTO conversions |
270
- | 400 Bad Request | Input validation | Check DTO constraints |
297
+ | 400 Bad Request | Input validation | Check DTO constraints / validators |
298
+ | 401 Unauthorized | Auth filter | Check token config, filter order |
271
299
  | 403 Forbidden | Auth config | Check role-based access rules |
272
300
  | 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 |
301
+ | N+1 Query | Data access | Check for missing JOIN FETCH / eager load |
302
+ | Null Pointer | Optional not handled | Check Optional.orElseThrow, null guards |
303
+ | Transaction rollback | Missing @Transactional | Check transaction scope, propagation |
304
+ | Stale cache | Missing eviction | Check cache invalidation triggers |
305
+ | Type mismatch | Filter / specification | Check field types in predicates |
306
+
307
+ #### context-engineering (AI/LLM pipelines)
308
+
309
+ | Bug Type | Common Location | How to Check |
310
+ |----------|----------------|--------------|
311
+ | Wrong pipeline output | Prompt template | Check prompt content; verify variables are substituted correctly |
312
+ | Missing context in output | Context assembly | Verify all required context blocks are included and non-empty |
313
+ | Schema validation failure | Output parser | Compare raw LLM output vs expected schema; add stricter output instructions |
314
+ | Flaky / non-deterministic results | LLM temperature | Check temperature setting; use fixed seed/mock in tests |
315
+ | API rate limit errors | LLM client | Implement backoff; check quota usage in provider dashboard |
316
+ | Token limit exceeded | Prompt assembly | Reduce context size; add chunking strategy |
317
+
318
+ ### If `platform_type = web-frontend`
319
+
320
+ | Bug Type | Common Location | How to Check |
321
+ |----------|----------------|--------------|
322
+ | Wrong data displayed | State / store | Check state update logic, selector |
323
+ | UI not re-rendering | Missing reactive dep | Check deps array, state immutability |
324
+ | API data not loading | HTTP client / hook | Check network tab, error handler |
325
+ | 401 on API call | Auth token | Check token refresh, header injection |
326
+ | Form not submitting | Validation / handler | Check form state, required fields, errors |
327
+ | Route not found | Router config | Check route definition, lazy import |
328
+ | Build / type error | TypeScript types | Compare type definitions vs actual API shape |
329
+
330
+ ### If `platform_type = mobile`
331
+
332
+ | Bug Type | Common Location | How to Check |
333
+ |----------|----------------|--------------|
334
+ | Screen shows stale data | State / BLoC / ViewModel | Check event dispatched, state emitted correctly |
335
+ | Crash on navigation | Route param missing | Check params passed, null safety |
336
+ | API call not firing | Repository / service layer | Add log in repo method, check network |
337
+ | UI not reflecting state | Widget not observing stream | Check `BlocBuilder` / `StateObserver` setup |
338
+ | Crash on app resume | Lifecycle handler | Check `onResume` / `viewDidAppear` logic |
339
+ | Auth token expired | Token refresh logic | Check refresh flow, token storage |
340
+ | Permission denied | OS permission | Check runtime permission request code |
278
341
 
279
342
  CHECKPOINT — Root Cause Report:
280
343
  ```
@@ -342,6 +405,7 @@ Suggest the logical next command based on workflow phase:
342
405
 
343
406
  | Current command | Suggest next |
344
407
  |-------------------------|-----------------------------------------------|
408
+ | /setup-ai-first | `/define-product` to start your first feature |
345
409
  | /define-product | `/generate-prd {product-definition-file}` |
346
410
  | /generate-prd | `/refine-prd {prd-file}` then `/review-context {prd-file}` |
347
411
  | /refine-prd | Open Review Board → update PRD → `/review-context {prd-file}` |
@@ -350,13 +414,13 @@ Suggest the logical next command based on workflow phase:
350
414
  | /review-context (BDD) | `/generate-tech-docs {UC-ID}` if APPROVED; regenerate if NEEDS_FIX |
351
415
  | /generate-tech-docs | `/review-tech-docs {tech-design-file}` |
352
416
  | /review-tech-docs | `/generate-code {feature-file}` if APPROVED; fix doc if NEEDS_FIX |
353
- | /generate-code | `/generate-tests {UC-ID}` |
417
+ | /generate-code | First gen → `/review-code {UC-ID}`; re-gen → `/generate-tests {UC-ID}` |
354
418
  | /generate-tests | `/run-tests {UC-ID}` |
355
419
  | /run-tests (passing) | `/review-code {UC-ID}` |
356
420
  | /run-tests (failing) | `/fix-bug {ticket-id}` or `/debug {error}` |
357
421
  | /review-code | `/smoke-test {UC-ID}` or create PR |
358
422
  | /smoke-test | Create PR and link to ticket |
359
- | /validate-traces | `/generate-code {UC-ID}` for gaps |
423
+ | /validate-traces | DRIFT/UNTRACKED → `/generate-code {UC-ID}`; GAP → `/generate-tests {UC-ID}`; all OK → create PR |
360
424
  | /fix-bug | Create PR and link to ticket |
361
425
  | /debug | `/fix-bug {ticket-id}` if fix needed |
362
426
 
@@ -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
 
@@ -138,7 +138,7 @@ If `paths` section is absent, use these defaults:
138
138
  - `domain_knowledge_dir` = `specs/domain-knowledge`
139
139
  - `business_dictionary` = `specs/domain-knowledge/business-dictionary.md`
140
140
  - `core_entities` = `specs/domain-knowledge/core-entities.md`
141
- - `tech_docs_dir` = `tech-docs`
141
+ - `tech_docs_dir` = `specs/tech-docs`
142
142
  - `trace_dir` = `.trace`
143
143
 
144
144
  If `tech_stack.module` is set, also load `.agent/modules/{module}/stack-profile.yaml` if it exists.
@@ -215,6 +215,26 @@ If the file does not exist → skip silently.
215
215
 
216
216
  ---
217
217
 
218
+ ## Step 6.5 — [PLATFORM] Derive active_module and platform_type
219
+
220
+ Using `tech_stack.module` loaded in Step 1, derive and store two variables for use by all downstream commands:
221
+
222
+ ```
223
+ active_module = tech_stack.module (e.g. "java-spring", "react", "flutter")
224
+ ```
225
+
226
+ | `platform_type` | Modules |
227
+ |---|---|
228
+ | `backend` | `java-spring`, `golang`, `dotnet`, `php-laravel`, `context-engineering` |
229
+ | `web-frontend` | `react`, `nextjs`, `vue`, `nuxt`, `angular` |
230
+ | `mobile` | `flutter`, `react-native`, `ios-swiftui`, `android-compose` |
231
+
232
+ If `tech_stack.module` is blank or not recognized → set `platform_type = "unknown"` and flag as ⚠️ in the Step 7 recap.
233
+
234
+ 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).
235
+
236
+ ---
237
+
218
238
  ## Step 7 — [RECAP] Working Memory Recap (anti-lost-in-middle)
219
239
 
220
240
  After loading all context, synthesize and output a compact summary block.
@@ -225,6 +245,7 @@ Output exactly this block:
225
245
  ```
226
246
  [CTX LOADED]
227
247
  Stack : {language} / {framework} / {database}
248
+ Platform : {active_module} ({platform_type})
228
249
  Layers : {layer order from CLAUDE.md §2, e.g., Controller → Facade → Service → Repository}
229
250
  Ticket : {ticket_prefix}-
230
251
  Dict : {loaded — N canonical terms, M banned terms | missing}
@@ -270,6 +291,18 @@ After loading context, check if the target PRD is large enough to warrant sub-ag
270
291
 
271
292
  ---
272
293
 
294
+ ## Sub-Agent Return Format
295
+
296
+ *This section applies when running as a sub-agent (Gate Step 0 detected `_agent_mode: true`).*
297
+
298
+ 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):
299
+
300
+ ```json
301
+ { "uc_id": "{TICKET-ID}-UC{N}", "files_created": ["path/to/file1", "path/to/file2"], "status": "success | error", "errors": [] }
302
+ ```
303
+
304
+ ---
305
+
273
306
  ## Version Check
274
307
 
275
308
  Before generating, check for existing `.feature` files for this PRD:
@@ -383,15 +416,16 @@ For each UC, write `{paths.specs_dir}/{domain}/{TICKET-ID}-UC{N}-{slug}.feature`
383
416
  # ============================================================
384
417
  # @trace.id: {TICKET-ID}-UC{N}
385
418
  # @trace.title: <Feature name>
386
- # @trace.revision: 1
419
+ # @trace.revision: 1 ← static field; use @trace.bdd_version for version tracking (incremented by /review-context --fix or --resume)
387
420
  # @trace.domain: <domain>
388
421
  # @trace.service: <ServiceName>
422
+ # @trace.module: {tech_stack.module value — e.g. java-spring | react | flutter; write "unknown" if not set in project-context.yaml}
389
423
  # @trace.status: draft
390
424
  # @trace.author: AI-generated
391
425
  # @trace.created_at: {YYYY-MM-DD}
392
426
  # @trace.prd: {TICKET-ID}
393
427
  # @trace.prd_version: {read from PRD metadata "| **Version** |"}
394
- # @trace.bdd_version: {1 if fresh generation; increment by 1 if re-generation}
428
+ # @trace.bdd_version: {1.0 if fresh generation; increment by 0.1 on re-generation — e.g. 1.0 → 1.1}
395
429
  # @trace.business_rules: {TICKET-ID}-UC{N}-BR1, {TICKET-ID}-UC{N}-BR2
396
430
  # @trace.dataset: {domain}.testdata.yaml
397
431
  # ============================================================
@@ -499,7 +533,8 @@ sc_id\tsc_title\tspec_ver\tgen_ver\timplemented_by\ttest_count\ttest_classes\tpr
499
533
  **Rules:**
500
534
  - If file does not exist → create with header row + all scenario rows.
501
535
  - 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.
536
+ - 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.
537
+ - 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
538
  - 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
539
  - SC no longer in `.feature` (removed) → delete its row.
505
540
 
@@ -552,6 +587,7 @@ Suggest the logical next command based on workflow phase:
552
587
 
553
588
  | Current command | Suggest next |
554
589
  |-------------------------|-----------------------------------------------|
590
+ | /setup-ai-first | `/define-product` to start your first feature |
555
591
  | /define-product | `/generate-prd {product-definition-file}` |
556
592
  | /generate-prd | `/refine-prd {prd-file}` then `/review-context {prd-file}` |
557
593
  | /refine-prd | Open Review Board → update PRD → `/review-context {prd-file}` |
@@ -560,13 +596,13 @@ Suggest the logical next command based on workflow phase:
560
596
  | /review-context (BDD) | `/generate-tech-docs {UC-ID}` if APPROVED; regenerate if NEEDS_FIX |
561
597
  | /generate-tech-docs | `/review-tech-docs {tech-design-file}` |
562
598
  | /review-tech-docs | `/generate-code {feature-file}` if APPROVED; fix doc if NEEDS_FIX |
563
- | /generate-code | `/generate-tests {UC-ID}` |
599
+ | /generate-code | First gen → `/review-code {UC-ID}`; re-gen → `/generate-tests {UC-ID}` |
564
600
  | /generate-tests | `/run-tests {UC-ID}` |
565
601
  | /run-tests (passing) | `/review-code {UC-ID}` |
566
602
  | /run-tests (failing) | `/fix-bug {ticket-id}` or `/debug {error}` |
567
603
  | /review-code | `/smoke-test {UC-ID}` or create PR |
568
604
  | /smoke-test | Create PR and link to ticket |
569
- | /validate-traces | `/generate-code {UC-ID}` for gaps |
605
+ | /validate-traces | DRIFT/UNTRACKED → `/generate-code {UC-ID}`; GAP → `/generate-tests {UC-ID}`; all OK → create PR |
570
606
  | /fix-bug | Create PR and link to ticket |
571
607
  | /debug | `/fix-bug {ticket-id}` if fix needed |
572
608
 
@@ -587,5 +623,10 @@ Files:
587
623
  Trace:
588
624
  {paths.trace_dir}/{TICKET-ID}-UC1.tsv ({N} rows)
589
625
  {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
626
+ Next: Run /review-context on EACH generated feature file (one per UC):
627
+ /review-context {paths.specs_dir}/{domain}/{TICKET-ID}-UC1-{slug}.feature
628
+ /review-context {paths.specs_dir}/{domain}/{TICKET-ID}-UC2-{slug}.feature
629
+ ...
630
+ → then per UC: /generate-tech-docs {feature-file} (if tech design required)
631
+ → or per UC: /generate-code {feature-file} (if skipping tech design)
591
632
  ```
@@ -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
 
@@ -140,7 +140,7 @@ If `paths` section is absent, use these defaults:
140
140
  - `domain_knowledge_dir` = `specs/domain-knowledge`
141
141
  - `business_dictionary` = `specs/domain-knowledge/business-dictionary.md`
142
142
  - `core_entities` = `specs/domain-knowledge/core-entities.md`
143
- - `tech_docs_dir` = `tech-docs`
143
+ - `tech_docs_dir` = `specs/tech-docs`
144
144
  - `trace_dir` = `.trace`
145
145
 
146
146
  If `tech_stack.module` is set, also load `.agent/modules/{module}/stack-profile.yaml` if it exists.
@@ -217,6 +217,26 @@ If the file does not exist → skip silently.
217
217
 
218
218
  ---
219
219
 
220
+ ## Step 6.5 — [PLATFORM] Derive active_module and platform_type
221
+
222
+ Using `tech_stack.module` loaded in Step 1, derive and store two variables for use by all downstream commands:
223
+
224
+ ```
225
+ active_module = tech_stack.module (e.g. "java-spring", "react", "flutter")
226
+ ```
227
+
228
+ | `platform_type` | Modules |
229
+ |---|---|
230
+ | `backend` | `java-spring`, `golang`, `dotnet`, `php-laravel`, `context-engineering` |
231
+ | `web-frontend` | `react`, `nextjs`, `vue`, `nuxt`, `angular` |
232
+ | `mobile` | `flutter`, `react-native`, `ios-swiftui`, `android-compose` |
233
+
234
+ If `tech_stack.module` is blank or not recognized → set `platform_type = "unknown"` and flag as ⚠️ in the Step 7 recap.
235
+
236
+ 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).
237
+
238
+ ---
239
+
220
240
  ## Step 7 — [RECAP] Working Memory Recap (anti-lost-in-middle)
221
241
 
222
242
  After loading all context, synthesize and output a compact summary block.
@@ -227,6 +247,7 @@ Output exactly this block:
227
247
  ```
228
248
  [CTX LOADED]
229
249
  Stack : {language} / {framework} / {database}
250
+ Platform : {active_module} ({platform_type})
230
251
  Layers : {layer order from CLAUDE.md §2, e.g., Controller → Facade → Service → Repository}
231
252
  Ticket : {ticket_prefix}-
232
253
  Dict : {loaded — N canonical terms, M banned terms | missing}
@@ -252,27 +273,88 @@ After completing all steps, you have loaded:
252
273
  Proceed to the next step of the calling command.
253
274
 
254
275
 
276
+ ---
277
+
278
+ ## Scope Lock
279
+
280
+ This command is strictly scoped to the **single feature file** passed as `$ARGUMENTS`:
281
+
282
+ - Feature file: `{exact path from $ARGUMENTS}`
283
+ - UC: `{UC-ID}` (read from `@trace.id` in that file's header)
284
+
285
+ **Do NOT read or implement scenarios from any other `.feature` file** in the same domain folder, even if they share the same entity, domain concept, or service name.
286
+
287
+ ---
288
+
289
+ ## Context Load (additional)
290
+
291
+ Read:
292
+ 1. The scoped `.feature` file only
293
+ 2. Tech-doc at `{paths.tech_docs_dir}/{domain}/{UC-ID}-tech-design.md` (if exists)
294
+ 3. CLAUDE.md §architecture + §coding_standards
295
+
296
+ ---
297
+
298
+ ## Read Trace State
299
+
300
+ Read `{paths.trace_dir}/{UC-ID}.tsv` if it exists. For each scenario row, note its current `status`:
301
+
302
+ | Status | Meaning | Action in this run |
303
+ |--------|---------|-------------------|
304
+ | `UNTRACKED` | `implemented_by == —` | Generate — scenario has no code yet |
305
+ | `DRIFT` | `spec_ver != gen_ver` | Regenerate — scenario updated since last codegen |
306
+ | `OK` | implemented + tested | Skip unless explicitly re-generating |
307
+ | `GAP` | implemented, no tests | Skip codegen — already coded; run `/generate-tests` instead |
308
+
309
+ Use these statuses to populate the **Scenarios** count in the CHECKPOINT plan (`{X} new, {Y} drifted, {Z} synced-skip`).
310
+ If `.tsv` does not exist → treat all scenarios as `UNTRACKED`.
311
+
312
+ ---
313
+
314
+ ## File Scan
315
+
316
+ Before generating, determine which files will be needed for this UC's scenarios. Check whether each file already exists on disk.
317
+
318
+ Classify each file:
319
+
320
+ | Status | Meaning | Action |
321
+ |--------|---------|--------|
322
+ | `CREATE` | File does not exist | Generate full new file |
323
+ | `EXTEND` | File exists, new methods needed | Add new methods only — do NOT rewrite existing code |
324
+ | `SKIP` | File exists and already covers all UC scenarios | Leave untouched |
325
+
326
+ > **EXTEND rule:** Read the existing file fully. Locate the correct class/interface. Add only the methods required by `{UC-ID}` scenarios. Preserve all existing methods, fields, and annotations exactly as-is. Attach `@trace.implements={UC-ID}-SC{N}` on each new method.
327
+
255
328
  ---
256
329
 
257
330
  ## CHECKPOINT — Code Generation Plan
258
331
 
259
332
  Before generating any code, show:
333
+
260
334
  ```
261
- I understand:
262
- - Feature: {name} | Ticket: {ID if known}
263
- - UC: {UC-ID} | Domain: {domain}
264
- - Scenarios: {N} total ({X} new, {Y} drifted, {Z} synced-skip)
265
- - Layer order: {from CLAUDE.md §2 architecture}
266
- - Tech stack: {language} / {framework}
267
- - Files to create: [list]
335
+ Code Generation Plan — {UC-ID}
336
+ ──────────────────────────────────────────────────────
337
+ Feature : {name}
338
+ Ticket : {TICKET_ID if known}
339
+ Domain : {domain}
340
+ UC : {UC-ID} only ← other feature files in this folder are NOT read
341
+ Tech : {language} / {framework}
342
+ Scenarios: {N} total ({X} new, {Y} drifted, {Z} synced-skip)
343
+ Layer : {from CLAUDE.md §2}
344
+
345
+ Files:
346
+ CREATE {N} new files
347
+ + {path/FileName.ext}
348
+ EXTEND {M} existing files (add methods only)
349
+ ~ {path/FileName.ext} — adding: {methodA}, {methodB}
350
+ SKIP {K} files (no change needed)
351
+ = {path/FileName.ext}
352
+ ──────────────────────────────────────────────────────
268
353
  Proceed? (Y/N)
269
354
  ```
270
355
 
271
356
  Wait for explicit "Y" before generating.
272
357
 
273
- ## Context Load (additional)
274
- Read: `.feature` file, tech-doc (if exists at `{paths.tech_docs_dir}/{domain}/{UC-ID}-tech-design.md`), CLAUDE.md §architecture + §coding_standards, existing entity files.
275
-
276
358
  ## Branch
277
359
  ```bash
278
360
  git checkout -b feature/{TICKET_ID}-{slug}
@@ -283,13 +365,17 @@ git checkout -b feature/{TICKET_ID}-{slug}
283
365
  Default order (override from CLAUDE.md if different):
284
366
  DTOs → Entity/Model → Repository → Service interface → Service impl → Facade (if applicable) → Controller
285
367
 
286
- **Controller must have traceability tags (adapt to your language's comment syntax):**
368
+ **For `CREATE` files:** generate the full file.
369
+
370
+ **For `EXTEND` files:** open the existing file → add only the new methods for `{UC-ID}` → do not touch anything else.
371
+
372
+ **Traceability tags on controller/handler (adapt to your language's comment syntax):**
287
373
  ```
288
374
  @trace.implements={UC-ID}-SC{N}
289
375
  @trace.prd_version={read @trace.prd_version from the .feature file header}
290
376
  @trace.bdd_version={read @trace.bdd_version from the .feature file header}
291
377
  @trace.tech_doc_revision={read @trace.revision from tech-doc header, or omit if no tech-doc}
292
- @trace.source={paths.specs_dir}/{domain}/{UC-ID}.feature
378
+ @trace.source={paths.specs_dir}/{domain}/{UC-ID}-{slug}.feature
293
379
  ```
294
380
 
295
381
  `@trace.prd_version` records which PRD version this code was written against.
@@ -297,6 +383,8 @@ DTOs → Entity/Model → Repository → Service interface → Service impl →
297
383
  `@trace.tech_doc_revision` records which tech-design revision this code follows.
298
384
  `/validate-traces` will flag drift if any upstream artifact is updated to a newer version.
299
385
 
386
+ > **Entry-point rule:** `@trace.implements` must appear on the **entry-point layer** as defined in `CLAUDE.md §2`. For REST APIs → Controller. For event-driven modules → event handler / consumer class. For context-engineering → the prompt orchestration function. Never put it only on an inner layer.
387
+
300
388
  ## Self-Review (3 rounds)
301
389
  - [ ] Every scenario has a corresponding endpoint
302
390
  - [ ] @trace.implements on every endpoint
@@ -360,6 +448,7 @@ Suggest the logical next command based on workflow phase:
360
448
 
361
449
  | Current command | Suggest next |
362
450
  |-------------------------|-----------------------------------------------|
451
+ | /setup-ai-first | `/define-product` to start your first feature |
363
452
  | /define-product | `/generate-prd {product-definition-file}` |
364
453
  | /generate-prd | `/refine-prd {prd-file}` then `/review-context {prd-file}` |
365
454
  | /refine-prd | Open Review Board → update PRD → `/review-context {prd-file}` |
@@ -368,13 +457,13 @@ Suggest the logical next command based on workflow phase:
368
457
  | /review-context (BDD) | `/generate-tech-docs {UC-ID}` if APPROVED; regenerate if NEEDS_FIX |
369
458
  | /generate-tech-docs | `/review-tech-docs {tech-design-file}` |
370
459
  | /review-tech-docs | `/generate-code {feature-file}` if APPROVED; fix doc if NEEDS_FIX |
371
- | /generate-code | `/generate-tests {UC-ID}` |
460
+ | /generate-code | First gen → `/review-code {UC-ID}`; re-gen → `/generate-tests {UC-ID}` |
372
461
  | /generate-tests | `/run-tests {UC-ID}` |
373
462
  | /run-tests (passing) | `/review-code {UC-ID}` |
374
463
  | /run-tests (failing) | `/fix-bug {ticket-id}` or `/debug {error}` |
375
464
  | /review-code | `/smoke-test {UC-ID}` or create PR |
376
465
  | /smoke-test | Create PR and link to ticket |
377
- | /validate-traces | `/generate-code {UC-ID}` for gaps |
466
+ | /validate-traces | DRIFT/UNTRACKED → `/generate-code {UC-ID}`; GAP → `/generate-tests {UC-ID}`; all OK → create PR |
378
467
  | /fix-bug | Create PR and link to ticket |
379
468
  | /debug | `/fix-bug {ticket-id}` if fix needed |
380
469
 
@@ -389,7 +478,9 @@ Next : {suggested command with example arguments}
389
478
 
390
479
  ```
391
480
  /generate-code Complete — {UC-ID}
392
- Files: created={N}, updated={M} | Build: SUCCESS
481
+ Files: created={N}, extended={M}, skipped={K} | Build: SUCCESS
393
482
  Branch: feature/{TICKET_ID}-{slug}
394
- Next: /review-code OR /generate-tests {UC-ID}
483
+ Next:
484
+ First generation for this UC → /review-code {UC-ID} ← code review required before tests
485
+ Re-generation (already reviewed) → /generate-tests {UC-ID}
395
486
  ```
@@ -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
 
@@ -140,7 +140,7 @@ If `paths` section is absent, use these defaults:
140
140
  - `domain_knowledge_dir` = `specs/domain-knowledge`
141
141
  - `business_dictionary` = `specs/domain-knowledge/business-dictionary.md`
142
142
  - `core_entities` = `specs/domain-knowledge/core-entities.md`
143
- - `tech_docs_dir` = `tech-docs`
143
+ - `tech_docs_dir` = `specs/tech-docs`
144
144
  - `trace_dir` = `.trace`
145
145
 
146
146
  If `tech_stack.module` is set, also load `.agent/modules/{module}/stack-profile.yaml` if it exists.
@@ -217,6 +217,26 @@ If the file does not exist → skip silently.
217
217
 
218
218
  ---
219
219
 
220
+ ## Step 6.5 — [PLATFORM] Derive active_module and platform_type
221
+
222
+ Using `tech_stack.module` loaded in Step 1, derive and store two variables for use by all downstream commands:
223
+
224
+ ```
225
+ active_module = tech_stack.module (e.g. "java-spring", "react", "flutter")
226
+ ```
227
+
228
+ | `platform_type` | Modules |
229
+ |---|---|
230
+ | `backend` | `java-spring`, `golang`, `dotnet`, `php-laravel`, `context-engineering` |
231
+ | `web-frontend` | `react`, `nextjs`, `vue`, `nuxt`, `angular` |
232
+ | `mobile` | `flutter`, `react-native`, `ios-swiftui`, `android-compose` |
233
+
234
+ If `tech_stack.module` is blank or not recognized → set `platform_type = "unknown"` and flag as ⚠️ in the Step 7 recap.
235
+
236
+ 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).
237
+
238
+ ---
239
+
220
240
  ## Step 7 — [RECAP] Working Memory Recap (anti-lost-in-middle)
221
241
 
222
242
  After loading all context, synthesize and output a compact summary block.
@@ -227,6 +247,7 @@ Output exactly this block:
227
247
  ```
228
248
  [CTX LOADED]
229
249
  Stack : {language} / {framework} / {database}
250
+ Platform : {active_module} ({platform_type})
230
251
  Layers : {layer order from CLAUDE.md §2, e.g., Controller → Facade → Service → Repository}
231
252
  Ticket : {ticket_prefix}-
232
253
  Dict : {loaded — N canonical terms, M banned terms | missing}
@@ -455,6 +476,7 @@ Suggest the logical next command based on workflow phase:
455
476
 
456
477
  | Current command | Suggest next |
457
478
  |-------------------------|-----------------------------------------------|
479
+ | /setup-ai-first | `/define-product` to start your first feature |
458
480
  | /define-product | `/generate-prd {product-definition-file}` |
459
481
  | /generate-prd | `/refine-prd {prd-file}` then `/review-context {prd-file}` |
460
482
  | /refine-prd | Open Review Board → update PRD → `/review-context {prd-file}` |
@@ -463,13 +485,13 @@ Suggest the logical next command based on workflow phase:
463
485
  | /review-context (BDD) | `/generate-tech-docs {UC-ID}` if APPROVED; regenerate if NEEDS_FIX |
464
486
  | /generate-tech-docs | `/review-tech-docs {tech-design-file}` |
465
487
  | /review-tech-docs | `/generate-code {feature-file}` if APPROVED; fix doc if NEEDS_FIX |
466
- | /generate-code | `/generate-tests {UC-ID}` |
488
+ | /generate-code | First gen → `/review-code {UC-ID}`; re-gen → `/generate-tests {UC-ID}` |
467
489
  | /generate-tests | `/run-tests {UC-ID}` |
468
490
  | /run-tests (passing) | `/review-code {UC-ID}` |
469
491
  | /run-tests (failing) | `/fix-bug {ticket-id}` or `/debug {error}` |
470
492
  | /review-code | `/smoke-test {UC-ID}` or create PR |
471
493
  | /smoke-test | Create PR and link to ticket |
472
- | /validate-traces | `/generate-code {UC-ID}` for gaps |
494
+ | /validate-traces | DRIFT/UNTRACKED → `/generate-code {UC-ID}`; GAP → `/generate-tests {UC-ID}`; all OK → create PR |
473
495
  | /fix-bug | Create PR and link to ticket |
474
496
  | /debug | `/fix-bug {ticket-id}` if fix needed |
475
497
 
@@ -483,6 +505,11 @@ Next : {suggested command with example arguments}
483
505
 
484
506
 
485
507
  ```
486
- PRD created: {paths.prd_dir}/{domain}/{TICKET-ID}-{slug}.md (v1.0)
487
- Next: /refine-prd {paths.prd_dir}/{domain}/{TICKET-ID}-{slug}.md
508
+ /generate-prd Complete {TICKET-ID}
509
+ ---
510
+ Status : ✅ Complete
511
+ Output Artifacts:
512
+ created {paths.prd_dir}/{domain}/{TICKET-ID}-{slug}.md (PRD v1.0)
513
+ Next : /refine-prd {paths.prd_dir}/{domain}/{TICKET-ID}-{slug}.md
514
+ → then /review-context {prd-file} ← verify PRD quality before generating BDD
488
515
  ```