@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
 
@@ -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
  ```
@@ -26,6 +26,18 @@ After loading context, check if the target PRD is large enough to warrant sub-ag
26
26
 
27
27
  ---
28
28
 
29
+ ## Sub-Agent Return Format
30
+
31
+ *This section applies when running as a sub-agent (Gate Step 0 detected `_agent_mode: true`).*
32
+
33
+ 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):
34
+
35
+ ```json
36
+ { "uc_id": "{TICKET-ID}-UC{N}", "files_created": ["path/to/file1", "path/to/file2"], "status": "success | error", "errors": [] }
37
+ ```
38
+
39
+ ---
40
+
29
41
  ## Version Check
30
42
 
31
43
  Before generating, check for existing `.feature` files for this PRD:
@@ -139,15 +151,16 @@ For each UC, write `{paths.specs_dir}/{domain}/{TICKET-ID}-UC{N}-{slug}.feature`
139
151
  # ============================================================
140
152
  # @trace.id: {TICKET-ID}-UC{N}
141
153
  # @trace.title: <Feature name>
142
- # @trace.revision: 1
154
+ # @trace.revision: 1 ← static field; use @trace.bdd_version for version tracking (incremented by /review-context --fix or --resume)
143
155
  # @trace.domain: <domain>
144
156
  # @trace.service: <ServiceName>
157
+ # @trace.module: {tech_stack.module value — e.g. java-spring | react | flutter; write "unknown" if not set in project-context.yaml}
145
158
  # @trace.status: draft
146
159
  # @trace.author: AI-generated
147
160
  # @trace.created_at: {YYYY-MM-DD}
148
161
  # @trace.prd: {TICKET-ID}
149
162
  # @trace.prd_version: {read from PRD metadata "| **Version** |"}
150
- # @trace.bdd_version: {1 if fresh generation; increment by 1 if re-generation}
163
+ # @trace.bdd_version: {1.0 if fresh generation; increment by 0.1 on re-generation — e.g. 1.0 → 1.1}
151
164
  # @trace.business_rules: {TICKET-ID}-UC{N}-BR1, {TICKET-ID}-UC{N}-BR2
152
165
  # @trace.dataset: {domain}.testdata.yaml
153
166
  # ============================================================
@@ -255,7 +268,8 @@ sc_id\tsc_title\tspec_ver\tgen_ver\timplemented_by\ttest_count\ttest_classes\tpr
255
268
  **Rules:**
256
269
  - If file does not exist → create with header row + all scenario rows.
257
270
  - If file exists (re-generation) → for each SC in the new `.feature`:
258
- - 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.
271
+ - 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.
272
+ - 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.
259
273
  - 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 `—`.
260
274
  - SC no longer in `.feature` (removed) → delete its row.
261
275
 
@@ -290,5 +304,10 @@ Files:
290
304
  Trace:
291
305
  {paths.trace_dir}/{TICKET-ID}-UC1.tsv ({N} rows)
292
306
  {paths.trace_dir}/{TICKET-ID}-UC2.tsv ({N} rows)
293
- Next: /generate-tech-docs OR /generate-code {paths.specs_dir}/{domain}/{TICKET-ID}-UC{N}-{slug}.feature
307
+ Next: Run /review-context on EACH generated feature file (one per UC):
308
+ /review-context {paths.specs_dir}/{domain}/{TICKET-ID}-UC1-{slug}.feature
309
+ /review-context {paths.specs_dir}/{domain}/{TICKET-ID}-UC2-{slug}.feature
310
+ ...
311
+ → then per UC: /generate-tech-docs {feature-file} (if tech design required)
312
+ → or per UC: /generate-code {feature-file} (if skipping tech design)
294
313
  ```
@@ -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
  ```
@@ -10,25 +10,86 @@
10
10
 
11
11
  ---
12
12
 
13
+ ## Scope Lock
14
+
15
+ This command is strictly scoped to the **single feature file** passed as `$ARGUMENTS`:
16
+
17
+ - Feature file: `{exact path from $ARGUMENTS}`
18
+ - UC: `{UC-ID}` (read from `@trace.id` in that file's header)
19
+
20
+ **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.
21
+
22
+ ---
23
+
24
+ ## Context Load (additional)
25
+
26
+ Read:
27
+ 1. The scoped `.feature` file only
28
+ 2. Tech-doc at `{paths.tech_docs_dir}/{domain}/{UC-ID}-tech-design.md` (if exists)
29
+ 3. CLAUDE.md §architecture + §coding_standards
30
+
31
+ ---
32
+
33
+ ## Read Trace State
34
+
35
+ Read `{paths.trace_dir}/{UC-ID}.tsv` if it exists. For each scenario row, note its current `status`:
36
+
37
+ | Status | Meaning | Action in this run |
38
+ |--------|---------|-------------------|
39
+ | `UNTRACKED` | `implemented_by == —` | Generate — scenario has no code yet |
40
+ | `DRIFT` | `spec_ver != gen_ver` | Regenerate — scenario updated since last codegen |
41
+ | `OK` | implemented + tested | Skip unless explicitly re-generating |
42
+ | `GAP` | implemented, no tests | Skip codegen — already coded; run `/generate-tests` instead |
43
+
44
+ Use these statuses to populate the **Scenarios** count in the CHECKPOINT plan (`{X} new, {Y} drifted, {Z} synced-skip`).
45
+ If `.tsv` does not exist → treat all scenarios as `UNTRACKED`.
46
+
47
+ ---
48
+
49
+ ## File Scan
50
+
51
+ Before generating, determine which files will be needed for this UC's scenarios. Check whether each file already exists on disk.
52
+
53
+ Classify each file:
54
+
55
+ | Status | Meaning | Action |
56
+ |--------|---------|--------|
57
+ | `CREATE` | File does not exist | Generate full new file |
58
+ | `EXTEND` | File exists, new methods needed | Add new methods only — do NOT rewrite existing code |
59
+ | `SKIP` | File exists and already covers all UC scenarios | Leave untouched |
60
+
61
+ > **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.
62
+
63
+ ---
64
+
13
65
  ## CHECKPOINT — Code Generation Plan
14
66
 
15
67
  Before generating any code, show:
68
+
16
69
  ```
17
- I understand:
18
- - Feature: {name} | Ticket: {ID if known}
19
- - UC: {UC-ID} | Domain: {domain}
20
- - Scenarios: {N} total ({X} new, {Y} drifted, {Z} synced-skip)
21
- - Layer order: {from CLAUDE.md §2 architecture}
22
- - Tech stack: {language} / {framework}
23
- - Files to create: [list]
70
+ Code Generation Plan — {UC-ID}
71
+ ──────────────────────────────────────────────────────
72
+ Feature : {name}
73
+ Ticket : {TICKET_ID if known}
74
+ Domain : {domain}
75
+ UC : {UC-ID} only ← other feature files in this folder are NOT read
76
+ Tech : {language} / {framework}
77
+ Scenarios: {N} total ({X} new, {Y} drifted, {Z} synced-skip)
78
+ Layer : {from CLAUDE.md §2}
79
+
80
+ Files:
81
+ CREATE {N} new files
82
+ + {path/FileName.ext}
83
+ EXTEND {M} existing files (add methods only)
84
+ ~ {path/FileName.ext} — adding: {methodA}, {methodB}
85
+ SKIP {K} files (no change needed)
86
+ = {path/FileName.ext}
87
+ ──────────────────────────────────────────────────────
24
88
  Proceed? (Y/N)
25
89
  ```
26
90
 
27
91
  Wait for explicit "Y" before generating.
28
92
 
29
- ## Context Load (additional)
30
- 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.
31
-
32
93
  ## Branch
33
94
  ```bash
34
95
  git checkout -b feature/{TICKET_ID}-{slug}
@@ -39,13 +100,17 @@ git checkout -b feature/{TICKET_ID}-{slug}
39
100
  Default order (override from CLAUDE.md if different):
40
101
  DTOs → Entity/Model → Repository → Service interface → Service impl → Facade (if applicable) → Controller
41
102
 
42
- **Controller must have traceability tags (adapt to your language's comment syntax):**
103
+ **For `CREATE` files:** generate the full file.
104
+
105
+ **For `EXTEND` files:** open the existing file → add only the new methods for `{UC-ID}` → do not touch anything else.
106
+
107
+ **Traceability tags on controller/handler (adapt to your language's comment syntax):**
43
108
  ```
44
109
  @trace.implements={UC-ID}-SC{N}
45
110
  @trace.prd_version={read @trace.prd_version from the .feature file header}
46
111
  @trace.bdd_version={read @trace.bdd_version from the .feature file header}
47
112
  @trace.tech_doc_revision={read @trace.revision from tech-doc header, or omit if no tech-doc}
48
- @trace.source={paths.specs_dir}/{domain}/{UC-ID}.feature
113
+ @trace.source={paths.specs_dir}/{domain}/{UC-ID}-{slug}.feature
49
114
  ```
50
115
 
51
116
  `@trace.prd_version` records which PRD version this code was written against.
@@ -53,6 +118,8 @@ DTOs → Entity/Model → Repository → Service interface → Service impl →
53
118
  `@trace.tech_doc_revision` records which tech-design revision this code follows.
54
119
  `/validate-traces` will flag drift if any upstream artifact is updated to a newer version.
55
120
 
121
+ > **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.
122
+
56
123
  ## Self-Review (3 rounds)
57
124
  - [ ] Every scenario has a corresponding endpoint
58
125
  - [ ] @trace.implements on every endpoint
@@ -92,7 +159,9 @@ git commit -m "{commit_format}: {description}"
92
159
 
93
160
  ```
94
161
  /generate-code Complete — {UC-ID}
95
- Files: created={N}, updated={M} | Build: SUCCESS
162
+ Files: created={N}, extended={M}, skipped={K} | Build: SUCCESS
96
163
  Branch: feature/{TICKET_ID}-{slug}
97
- Next: /review-code OR /generate-tests {UC-ID}
164
+ Next:
165
+ First generation for this UC → /review-code {UC-ID} ← code review required before tests
166
+ Re-generation (already reviewed) → /generate-tests {UC-ID}
98
167
  ```
@@ -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
  ```
@@ -186,6 +186,11 @@ Every PRD must end with this section. Start at v1.0:
186
186
  {{include:steps/report-footer.md}}
187
187
 
188
188
  ```
189
- PRD created: {paths.prd_dir}/{domain}/{TICKET-ID}-{slug}.md (v1.0)
190
- Next: /refine-prd {paths.prd_dir}/{domain}/{TICKET-ID}-{slug}.md
189
+ /generate-prd Complete {TICKET-ID}
190
+ ---
191
+ Status : ✅ Complete
192
+ Output Artifacts:
193
+ created {paths.prd_dir}/{domain}/{TICKET-ID}-{slug}.md (PRD v1.0)
194
+ Next : /refine-prd {paths.prd_dir}/{domain}/{TICKET-ID}-{slug}.md
195
+ → then /review-context {prd-file} ← verify PRD quality before generating BDD
191
196
  ```