@anhth2/spec-driven-dev-plugin 0.9.1 → 0.10.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 (124) hide show
  1. package/ARCHITECTURE.md +20 -9
  2. package/bin/index.js +1 -2
  3. package/commands/debug.md +13 -12
  4. package/commands/define-product.md +12 -11
  5. package/commands/{generate-tests.md → dev-gen-test.md} +48 -15
  6. package/commands/{generate-tests.tmpl → dev-gen-test.tmpl} +18 -4
  7. package/{core/commands/run-tests.md → commands/dev-run-test.md} +62 -13
  8. package/commands/{run-tests.tmpl → dev-run-test.tmpl} +32 -2
  9. package/{core/commands/smoke-test.md → commands/dev-smoke-test.md} +17 -16
  10. package/commands/{smoke-test.tmpl → dev-smoke-test.tmpl} +5 -5
  11. package/commands/fix-bug.md +13 -12
  12. package/commands/generate-bdd.md +39 -13
  13. package/commands/generate-bdd.tmpl +9 -2
  14. package/commands/generate-code.md +86 -15
  15. package/commands/generate-code.tmpl +56 -4
  16. package/commands/generate-design-spec.md +105 -39
  17. package/commands/generate-design-spec.tmpl +93 -28
  18. package/commands/generate-prd.md +12 -11
  19. package/commands/generate-spec-manifest.md +12 -11
  20. package/commands/generate-tech-docs.md +63 -22
  21. package/commands/generate-tech-docs.tmpl +51 -11
  22. package/commands/learn.md +13 -12
  23. package/commands/propose-scenario.md +13 -12
  24. package/commands/propose-scenario.tmpl +1 -1
  25. package/commands/refine-prd.md +166 -16
  26. package/commands/refine-prd.tmpl +16 -5
  27. package/commands/report-bug.md +12 -11
  28. package/commands/review-code.md +14 -13
  29. package/commands/review-code.tmpl +1 -1
  30. package/commands/review-context.md +161 -12
  31. package/commands/review-context.tmpl +11 -1
  32. package/commands/review-tech-docs.md +13 -11
  33. package/commands/review-tech-docs.tmpl +1 -0
  34. package/commands/setup-ai-first.md +7 -7
  35. package/commands/sync.md +23 -20
  36. package/commands/sync.tmpl +16 -13
  37. package/commands/update-framework.md +7 -7
  38. package/commands/validate-traces.md +57 -37
  39. package/commands/validate-traces.tmpl +45 -26
  40. package/core/FRAMEWORK_VERSION +1 -1
  41. package/core/commands/debug.md +13 -12
  42. package/core/commands/define-product.md +12 -11
  43. package/core/commands/{generate-tests.md → dev-gen-test.md} +48 -15
  44. package/{commands/run-tests.md → core/commands/dev-run-test.md} +62 -13
  45. package/{commands/smoke-test.md → core/commands/dev-smoke-test.md} +17 -16
  46. package/core/commands/fix-bug.md +13 -12
  47. package/core/commands/generate-bdd.md +39 -13
  48. package/core/commands/generate-code.md +86 -15
  49. package/core/commands/generate-design-spec.md +105 -39
  50. package/core/commands/generate-prd.md +12 -11
  51. package/core/commands/generate-spec-manifest.md +12 -11
  52. package/core/commands/generate-tech-docs.md +63 -22
  53. package/core/commands/learn.md +13 -12
  54. package/core/commands/propose-scenario.md +13 -12
  55. package/core/commands/refine-prd.md +166 -16
  56. package/core/commands/report-bug.md +12 -11
  57. package/core/commands/review-code.md +14 -13
  58. package/core/commands/review-context.md +161 -12
  59. package/core/commands/review-tech-docs.md +13 -11
  60. package/core/commands/setup-ai-first.md +7 -7
  61. package/core/commands/sync.md +23 -20
  62. package/core/commands/update-framework.md +7 -7
  63. package/core/commands/validate-traces.md +57 -37
  64. package/core/modules/android-compose/module.yaml +13 -0
  65. package/core/modules/android-compose/stack-profile.yaml +57 -0
  66. package/core/modules/flutter/module.yaml +14 -0
  67. package/core/modules/flutter/stack-profile.yaml +59 -0
  68. package/core/modules/ios-swiftui/module.yaml +13 -0
  69. package/core/modules/ios-swiftui/stack-profile.yaml +55 -0
  70. package/core/modules/nuxt/module.yaml +14 -0
  71. package/core/modules/nuxt/stack-profile.yaml +58 -0
  72. package/core/modules/react-native/module.yaml +14 -0
  73. package/core/modules/react-native/stack-profile.yaml +56 -0
  74. package/core/modules/vue/module.yaml +14 -0
  75. package/core/modules/vue/stack-profile.yaml +65 -0
  76. package/core/skills/code/SKILL.md +19 -18
  77. package/core/skills/debug/SKILL.md +27 -26
  78. package/core/skills/design-spec/SKILL.md +12 -11
  79. package/core/skills/discovery/SKILL.md +12 -11
  80. package/core/skills/prd/SKILL.md +14 -14
  81. package/core/skills/setup-ai-first/SKILL.md +7 -7
  82. package/core/skills/spec/SKILL.md +14 -14
  83. package/core/skills/test/SKILL.md +40 -38
  84. package/core/steps/capture-lesson.md +1 -1
  85. package/core/steps/context-loader.md +5 -4
  86. package/core/steps/report-footer.md +7 -7
  87. package/core/steps/review-fanout.md +138 -0
  88. package/core/steps/spawn-agent.md +1 -1
  89. package/core/steps/trace-mirror.md +18 -0
  90. package/core/templates/design-spec.template.md +16 -8
  91. package/core/templates/product-definition.template.md +3 -3
  92. package/core/templates/project-context.yaml +4 -1
  93. package/modules/android-compose/module.yaml +13 -0
  94. package/modules/android-compose/stack-profile.yaml +57 -0
  95. package/modules/flutter/module.yaml +14 -0
  96. package/modules/flutter/stack-profile.yaml +59 -0
  97. package/modules/ios-swiftui/module.yaml +13 -0
  98. package/modules/ios-swiftui/stack-profile.yaml +55 -0
  99. package/modules/nuxt/module.yaml +14 -0
  100. package/modules/nuxt/stack-profile.yaml +58 -0
  101. package/modules/react-native/module.yaml +14 -0
  102. package/modules/react-native/stack-profile.yaml +56 -0
  103. package/modules/vue/module.yaml +14 -0
  104. package/modules/vue/stack-profile.yaml +65 -0
  105. package/package.json +1 -1
  106. package/skills/code/SKILL.md +19 -18
  107. package/skills/debug/SKILL.md +27 -26
  108. package/skills/debug/SKILL.tmpl +1 -1
  109. package/skills/design-spec/SKILL.md +12 -11
  110. package/skills/discovery/SKILL.md +12 -11
  111. package/skills/prd/SKILL.md +14 -14
  112. package/skills/setup-ai-first/SKILL.md +7 -7
  113. package/skills/spec/SKILL.md +14 -14
  114. package/skills/test/SKILL.md +40 -38
  115. package/skills/test/SKILL.tmpl +9 -9
  116. package/steps/capture-lesson.md +1 -1
  117. package/steps/context-loader.md +5 -4
  118. package/steps/report-footer.md +7 -7
  119. package/steps/review-fanout.md +138 -0
  120. package/steps/spawn-agent.md +1 -1
  121. package/steps/trace-mirror.md +18 -0
  122. package/templates/design-spec.template.md +16 -8
  123. package/templates/product-definition.template.md +3 -3
  124. package/templates/project-context.yaml +4 -1
@@ -163,7 +163,7 @@ If `services` section is present:
163
163
 
164
164
  **2. Route to service** — if active domain matches a key in `services`:
165
165
  - Override `paths.specs_dir` → `services.{domain}.specs_dir`
166
- - Override `paths.tech_docs_dir` → `services.{domain}.tech_docs_dir`
166
+ - Override `paths.tech_docs_dir` → `services.{domain}.tech_docs_dir` — **only if `setup.spec_source` is NOT set.** When `spec_source` IS set, the tech-design (API contract) is a cross-team artifact and must live in the shared spec repo (handled in step 4), so leave `tech_docs_dir` for step 4 to route — do NOT pin it per-service here.
167
167
  - Store `active_service` = `services.{domain}.path`
168
168
  - Store `active_service_module` = `services.{domain}.module`
169
169
  - If service has its own `module` → use it as `active_module` (overrides `tech_stack.module`)
@@ -175,13 +175,14 @@ If `services` section is present:
175
175
  **4. Spec source auto-override** — if `setup.spec_source` is set AND the corresponding path was not already explicitly set in `paths:`:
176
176
  - Override `paths.prd_dir` → `{spec_source}/specs/prd`
177
177
  - Override `paths.design_spec_dir` → `{spec_source}/specs/design-spec`
178
+ - Override `paths.tech_docs_dir` → `{spec_source}/specs/tech-docs` — **always when `spec_source` is set** (step 2 no longer pins tech-docs per-service in this case). The tech-design IS the cross-team API contract: BE authors it here, and FE/App read it from the same spec submodule at `/generate-code --phase=integration`. *(Per-service tech-docs only happen when there is no `spec_source` — a pure multi-service BE repo with no shared spec module.)*
178
179
  - Override `paths.domain_knowledge_dir` → `{spec_source}/specs/domain-knowledge`
179
180
  - Override `paths.business_dictionary` → `{spec_source}/specs/domain-knowledge/business-dictionary.md`
180
181
  - Override `paths.core_entities` → `{spec_source}/specs/domain-knowledge/core-entities.md`
181
182
  - Override `paths.bug_reports_dir` → `{spec_source}/feedback/bug-reports`
182
183
  - Override `paths.bdd_proposals_dir` → `{spec_source}/feedback/bdd-proposals`
183
184
 
184
- > **Why under `spec_source`:** tester feedback (`/report-bug`, `/propose-scenario`) must land in the **shared spec repo** so PO/Dev see it when they `/sync`. In single-service mode (no `spec_source`), these default to `feedback/bug-reports` and `feedback/bdd-proposals` at repo root — still shared, same repo.
185
+ > **Why under `spec_source`:** PRD, design-spec, domain knowledge, the **API contract (tech-docs)**, and tester feedback are all **cross-team artifacts** — they must live in the **shared spec repo** so every umbrella (FE/App/BE) reads the same source via `/sync`. Tech-docs specifically: BE authors the tech-design (API contract), commits + pushes it into the spec submodule (2-layer commit), and FE/App pull it on their next `/sync` to wire the real API in `/generate-code --phase=integration`. In single-service mode (no `spec_source`), these default under the repo root — still shared, same repo.
185
186
 
186
187
  ---
187
188
 
@@ -205,7 +206,7 @@ When `active_service` has been resolved to a real path in Step 1.5 (e.g., `user-
205
206
  | `paths.specs_dir` | `{active_service}/{service paths.specs_dir}` (if set in service config, else keep Step 1.5 override) |
206
207
 
207
208
  **3. Store** `service_root = {active_service}` as the working directory anchor for all downstream commands:
208
- - Shell commands (`/run-tests`, `/generate-tests`) run **from within** `service_root`
209
+ - Shell commands (`/dev-run-test`, `/dev-gen-test`) run **from within** `service_root`
209
210
  - File write operations (test files, trace TSVs) use paths **relative to** `service_root`
210
211
 
211
212
  **4. If service config not found** — keep umbrella defaults, still set `service_root = {active_service}` (path anchor is always needed even without a config override).
@@ -298,7 +299,7 @@ active_module = tech_stack.module (e.g. "java-spring", "react", "flutter")
298
299
 
299
300
  If `tech_stack.module` is blank or not recognized → set `platform_type = "unknown"` and flag as ⚠️ in the Step 7 recap.
300
301
 
301
- 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).
302
+ These two variables (`active_module`, `platform_type`) are the canonical source for all branching logic in commands that need platform-specific behavior (dev-gen-test, debug, fix-bug, dev-smoke-test).
302
303
 
303
304
  ---
304
305
 
@@ -362,15 +363,164 @@ Proceed to the next step of the calling command.
362
363
 
363
364
  ---
364
365
 
365
- ## Analyze — 4 Lenses (run all four)
366
+ ## Review Procedure
367
+ # Exhaustive Review Fan-Out + Completeness Convergence
366
368
 
367
- **QA Lens**: Are ACs testable? Edge cases specified? Boundary conditions defined?
369
+ **Why this exists:** A single-pass review never lists every issue at once — the model
370
+ stops at "enough" findings, so each later review round surfaces *new* problems
371
+ (whack-a-mole). This procedure forces the review to **converge in one command run**:
372
+ fan out across review dimensions in parallel, then loop a completeness critic until a
373
+ round produces nothing new, *before* writing the findings file.
368
374
 
369
- **DEV Lens**: Are API inputs/outputs clear? Business rules unambiguous? Cross-service deps fully described? Any technical risk?
375
+ The calling command supplies two things:
376
+ - **DIMENSIONS** — the list of review dimensions to fan out over
377
+ (`/refine-prd` → the 4 lenses; `/review-context` → the P-checks or B-checks).
378
+ - **FINDINGS SCHEMA** — the YAML shape each finding must follow (defined in the command).
370
379
 
371
- **SA Lens**: Fits existing architecture? Security/auth implications? Data modeling clear?
380
+ > **Sub-agent mode bypass:** If Gate Step 0 set `_agent_mode: true`, this whole
381
+ > procedure is **skipped** — the orchestrator is already running one dimension/UC per
382
+ > sub-agent. Run the command's checks directly on the scoped section and return findings.
372
383
 
373
- **PO Lens**: Scope bounded? Priorities clear? Success metrics defined? Scope creep risk?
384
+ ---
385
+
386
+ ## Phase 1 — Parallel dimension scan
387
+
388
+ **How many sub-agents:** the agent *count* is not the completeness lever — breadth is
389
+ fixed by the DIMENSION taxonomy (adding agents to the same dimension just re-finds the
390
+ same issues), and *depth* is owned by the Phase 2 critic loop. Pick the **fan-out
391
+ granularity** by target size, reusing the `steps/spawn-agent.md` thresholds:
392
+
393
+ | Target size | Granularity | Agent count |
394
+ |-------------|-------------|-------------|
395
+ | ≤ 3 UCs **and** ≤ 300 lines | one agent per DIMENSION over the whole file | = number of dimensions |
396
+ | > 3 UCs **or** > 300 lines | one agent per **DIMENSION × UC-scope** (UCs + a PRD-global scope), batched to fit the agent cap | `dimensions × (UCs + 1)`, capped (see below) |
397
+
398
+ The larger granularity keeps each sub-agent's context small and its scan exhaustive on a
399
+ single UC — which is what prevents misses on big PRDs.
400
+
401
+ > **Global (non-UC) sections — required in `DIMENSION × UC` mode.** Per-UC agents only
402
+ > see one UC each, so PRD-wide sections that belong to no UC (scope, success metrics,
403
+ > problem statement, terminology, glossary, changelog) would go unscanned. Whenever you
404
+ > fan out per UC, also include a **"PRD-global"** scope (the non-UC sections, findings get
405
+ > `uc_id: ""`) alongside the UC list. So the natural agent count is `dimensions × (UCs + 1)`.
406
+ > (Not needed in the whole-file mode — there each agent already sees the global sections.)
407
+
408
+ ### Agent cap — batch UCs when the fan-out gets too wide
409
+
410
+ `dimensions × (UCs + 1)` can explode on large PRDs (e.g. 6 checks × (8 UCs + 1) = 54
411
+ agents). Cap the wave at **`AGENT_CAP = 12`** agents and batch UC scopes to fit:
412
+
413
+ 1. Build the scope list = `[UC1, UC2, …, UCn, PRD-global]` (length `UCs + 1`).
414
+ 2. Compute scopes-per-agent-bucket: `groups = max(1, floor(AGENT_CAP / dimensions))`.
415
+ - If `groups ≥ UCs + 1` → no batching needed, run one agent per `DIMENSION × scope`.
416
+ - Else split the scope list into `groups` contiguous buckets of roughly equal size
417
+ (keep `PRD-global` in its own bucket if it fits; otherwise append it to the last
418
+ bucket). Each agent then handles **one DIMENSION over one bucket of UCs**.
419
+ 3. Resulting wave size = `dimensions × groups ≤ AGENT_CAP`.
420
+
421
+ A batched agent reviews several UCs at once — still scoped far tighter than the whole
422
+ file, so coverage stays high. `AGENT_CAP` is the only knob; raise it if the host allows
423
+ more concurrency, lower it to save tokens. Whole-file mode (≤ 3 UCs) never hits the cap.
424
+
425
+ Spawn the chosen sub-agents using the Agent tool (send them in a single message so they
426
+ run concurrently). Each sub-agent gets a **fresh context window** and scans its scope
427
+ through its **one** dimension only — deeper coverage than one session juggling every
428
+ dimension at once (avoids lost-in-the-middle).
429
+
430
+ Sub-agent prompt template (fill the braces):
431
+
432
+ ```
433
+ You are a {DIMENSION_NAME} reviewer. Read the full target file at {target_file}.
434
+ Scope: review ONLY through the {DIMENSION_NAME} lens/check — {DIMENSION_DESCRIPTION}.
435
+ Be exhaustive: scan every section, every UC, every AC/BR/scenario. Do not stop early.
436
+ Project context (terminology, entities, architecture):
437
+ {slim_context — banned terms, canonical entities, layer order, domains}
438
+
439
+ Return a JSON array of findings, each:
440
+ { "dimension": "{DIMENSION_NAME}", "severity": "critical|major|minor",
441
+ "section": "...", "uc_id": "...", "quote": "<verbatim ≤120 chars>",
442
+ "finding": "...", "suggestion": "...", "auto_fixable": true|false }
443
+ Return [] if this dimension is clean. Return ONLY the JSON array.
444
+ ```
445
+
446
+ Collect every sub-agent's array into one consolidated list `ALL_FINDINGS`.
447
+
448
+ ---
449
+
450
+ ## Phase 2 — Completeness-critic convergence loop
451
+
452
+ This is the anti-whack-a-mole step. Repeat until **two consecutive rounds add zero new
453
+ findings**, or a hard cap of **3 rounds**, whichever comes first:
454
+
455
+ 1. Spawn one **completeness-critic** sub-agent with the Agent tool. Give it:
456
+ - the full target file (`{target_file}`),
457
+ - the current `ALL_FINDINGS` list (so it knows what is already captured),
458
+ - the same slim context.
459
+ Prompt it:
460
+ ```
461
+ Here is a document and a list of issues already found. Read the WHOLE document.
462
+ List ONLY real, additional issues NOT already in the list — gaps, ambiguities,
463
+ contradictions, missing edge/negative paths, coverage holes, terminology drift,
464
+ structural omissions, and any issue that a fix to an existing finding would expose.
465
+ Do NOT repeat anything already listed. Return the same finding JSON shape, or [] if
466
+ nothing new.
467
+ ```
468
+ 2. Append any genuinely new findings (not already in `ALL_FINDINGS`) to the list.
469
+ 3. If this round returned 0 new → increment the dry-round counter; else reset it to 0.
470
+ 4. Stop when dry-round counter reaches 2, or after 3 rounds total.
471
+
472
+ Record `convergence_rounds` (how many critic rounds ran) for the report.
473
+
474
+ ---
475
+
476
+ ## Phase 3 — Dedup, resolve conflicts, merge
477
+
478
+ Sub-agents run **blind to each other** (independence = diverse coverage). They never
479
+ talk or reconcile among themselves — all duplicate/conflict resolution happens **here in
480
+ the orchestrator**, where the full set is visible.
481
+
482
+ 1. **Deduplicate** `ALL_FINDINGS`: two findings are duplicates if they target the same
483
+ `section` + `uc_id` and describe the same underlying issue. Keep the one with the
484
+ richer `suggestion`; if they differ on severity, keep the **higher** severity.
485
+ 2. **Resolve conflicts** — group remaining findings by `section` + `uc_id` and check for
486
+ contradictions (two findings whose `suggestion`s cannot both be applied, or that
487
+ propose opposite fixes for the same spot):
488
+ - If the two suggestions can be **merged** into one coherent fix → merge them into a
489
+ single finding.
490
+ - If they are **mutually exclusive** → emit **one** finding that states both options
491
+ and set `auto_fixable: false` with `status: "needs_discussion"` (PRD) /
492
+ `status: "pending"` (review) so a human picks — never silently drop one side.
493
+ - If a finding is **invalidated** by another (e.g. a structural finding says a section
494
+ is missing, but another quotes content from it) → drop the invalid one.
495
+ 3. **Sort** by severity (critical → major → minor), then by `section` order in the file.
496
+ 4. **Assign stable IDs** `F001, F002, …` in that sorted order.
497
+ 5. Map each finding's `dimension` into the command's schema field
498
+ (`lens` for `/refine-prd`; `check_id` for `/review-context`).
499
+ 6. Write the **single** findings file in the FINDINGS SCHEMA the command defines.
500
+
501
+ In the command's final report, add one line:
502
+ ```
503
+ Convergence: {convergence_rounds} critic round(s) — findings file is complete; re-running should surface 0 new issues.
504
+ ```
505
+
506
+
507
+ ---
508
+
509
+ ## Analyze — 4 Lenses (fan out over all four, then converge)
510
+
511
+ Run the review through the **Review Procedure** above (`steps/review-fanout.md`).
512
+
513
+ **DIMENSIONS** = the 4 lenses below — fan out one sub-agent per lens, each scanning the
514
+ full PRD through its single lens:
515
+
516
+ - **QA Lens**: Are ACs testable? Edge cases specified? Boundary conditions defined?
517
+ - **DEV Lens**: Are API inputs/outputs clear? Business rules unambiguous? Cross-service deps fully described? Any technical risk?
518
+ - **SA Lens**: Fits existing architecture? Security/auth implications? Data modeling clear?
519
+ - **PO Lens**: Scope bounded? Priorities clear? Success metrics defined? Scope creep risk?
520
+
521
+ The completeness-critic loop (Phase 2) is what guarantees the findings file is complete
522
+ in one run — re-running `/refine-prd` should surface **0 new** findings. Map each
523
+ dimension into the `lens` field of the schema below.
374
524
 
375
525
  ## Output File
376
526
 
@@ -450,13 +600,13 @@ Suggest the logical next command based on workflow phase:
450
600
  | /review-context (BDD) | `/generate-tech-docs {UC-ID}` if APPROVED; regenerate if NEEDS_FIX |
451
601
  | /generate-tech-docs | `/review-tech-docs {tech-design-file}` |
452
602
  | /review-tech-docs | `/generate-code {feature-file}` if APPROVED; fix doc if NEEDS_FIX |
453
- | /generate-code | First gen → `/review-code {UC-ID}`; re-gen → `/generate-tests {UC-ID}` |
454
- | /generate-tests | `/run-tests {UC-ID}` |
455
- | /run-tests (passing) | `/review-code {UC-ID}` |
456
- | /run-tests (failing) | `/fix-bug {ticket-id}` or `/debug {error}` |
457
- | /review-code | `/smoke-test {UC-ID}` or create PR |
458
- | /smoke-test | Create PR and link to ticket |
459
- | /validate-traces | DRIFT/UNTRACKED → `/generate-code {UC-ID}`; GAP → `/generate-tests {UC-ID}`; all OK → create PR |
603
+ | /generate-code | First gen → `/review-code {UC-ID}`; re-gen → `/dev-gen-test {UC-ID}` |
604
+ | /dev-gen-test | `/dev-run-test {UC-ID}` |
605
+ | /dev-run-test (passing) | `/review-code {UC-ID}` |
606
+ | /dev-run-test (failing) | `/fix-bug {ticket-id}` or `/debug {error}` |
607
+ | /review-code | `/dev-smoke-test {UC-ID}` or create PR |
608
+ | /dev-smoke-test | Create PR and link to ticket |
609
+ | /validate-traces | DRIFT/UNTRACKED → `/generate-code {UC-ID}`; GAP → `/dev-gen-test {UC-ID}`; all OK → create PR |
460
610
  | /fix-bug | Create PR and link to ticket |
461
611
  | /debug | `/fix-bug {ticket-id}` if fix needed |
462
612
  | /report-bug | Send to dev (`/fix-bug {BUG-ID}`); if coverage gap → `/propose-scenario {UC-ID}` |
@@ -10,15 +10,26 @@
10
10
 
11
11
  ---
12
12
 
13
- ## Analyze — 4 Lenses (run all four)
13
+ ## Review Procedure
14
+ {{include:steps/review-fanout.md}}
14
15
 
15
- **QA Lens**: Are ACs testable? Edge cases specified? Boundary conditions defined?
16
+ ---
17
+
18
+ ## Analyze — 4 Lenses (fan out over all four, then converge)
19
+
20
+ Run the review through the **Review Procedure** above (`steps/review-fanout.md`).
16
21
 
17
- **DEV Lens**: Are API inputs/outputs clear? Business rules unambiguous? Cross-service deps fully described? Any technical risk?
22
+ **DIMENSIONS** = the 4 lenses below fan out one sub-agent per lens, each scanning the
23
+ full PRD through its single lens:
18
24
 
19
- **SA Lens**: Fits existing architecture? Security/auth implications? Data modeling clear?
25
+ - **QA Lens**: Are ACs testable? Edge cases specified? Boundary conditions defined?
26
+ - **DEV Lens**: Are API inputs/outputs clear? Business rules unambiguous? Cross-service deps fully described? Any technical risk?
27
+ - **SA Lens**: Fits existing architecture? Security/auth implications? Data modeling clear?
28
+ - **PO Lens**: Scope bounded? Priorities clear? Success metrics defined? Scope creep risk?
20
29
 
21
- **PO Lens**: Scope bounded? Priorities clear? Success metrics defined? Scope creep risk?
30
+ The completeness-critic loop (Phase 2) is what guarantees the findings file is complete
31
+ in one run — re-running `/refine-prd` should surface **0 new** findings. Map each
32
+ dimension into the `lens` field of the schema below.
22
33
 
23
34
  ## Output File
24
35
 
@@ -172,7 +172,7 @@ If `services` section is present:
172
172
 
173
173
  **2. Route to service** — if active domain matches a key in `services`:
174
174
  - Override `paths.specs_dir` → `services.{domain}.specs_dir`
175
- - Override `paths.tech_docs_dir` → `services.{domain}.tech_docs_dir`
175
+ - Override `paths.tech_docs_dir` → `services.{domain}.tech_docs_dir` — **only if `setup.spec_source` is NOT set.** When `spec_source` IS set, the tech-design (API contract) is a cross-team artifact and must live in the shared spec repo (handled in step 4), so leave `tech_docs_dir` for step 4 to route — do NOT pin it per-service here.
176
176
  - Store `active_service` = `services.{domain}.path`
177
177
  - Store `active_service_module` = `services.{domain}.module`
178
178
  - If service has its own `module` → use it as `active_module` (overrides `tech_stack.module`)
@@ -184,13 +184,14 @@ If `services` section is present:
184
184
  **4. Spec source auto-override** — if `setup.spec_source` is set AND the corresponding path was not already explicitly set in `paths:`:
185
185
  - Override `paths.prd_dir` → `{spec_source}/specs/prd`
186
186
  - Override `paths.design_spec_dir` → `{spec_source}/specs/design-spec`
187
+ - Override `paths.tech_docs_dir` → `{spec_source}/specs/tech-docs` — **always when `spec_source` is set** (step 2 no longer pins tech-docs per-service in this case). The tech-design IS the cross-team API contract: BE authors it here, and FE/App read it from the same spec submodule at `/generate-code --phase=integration`. *(Per-service tech-docs only happen when there is no `spec_source` — a pure multi-service BE repo with no shared spec module.)*
187
188
  - Override `paths.domain_knowledge_dir` → `{spec_source}/specs/domain-knowledge`
188
189
  - Override `paths.business_dictionary` → `{spec_source}/specs/domain-knowledge/business-dictionary.md`
189
190
  - Override `paths.core_entities` → `{spec_source}/specs/domain-knowledge/core-entities.md`
190
191
  - Override `paths.bug_reports_dir` → `{spec_source}/feedback/bug-reports`
191
192
  - Override `paths.bdd_proposals_dir` → `{spec_source}/feedback/bdd-proposals`
192
193
 
193
- > **Why under `spec_source`:** tester feedback (`/report-bug`, `/propose-scenario`) must land in the **shared spec repo** so PO/Dev see it when they `/sync`. In single-service mode (no `spec_source`), these default to `feedback/bug-reports` and `feedback/bdd-proposals` at repo root — still shared, same repo.
194
+ > **Why under `spec_source`:** PRD, design-spec, domain knowledge, the **API contract (tech-docs)**, and tester feedback are all **cross-team artifacts** — they must live in the **shared spec repo** so every umbrella (FE/App/BE) reads the same source via `/sync`. Tech-docs specifically: BE authors the tech-design (API contract), commits + pushes it into the spec submodule (2-layer commit), and FE/App pull it on their next `/sync` to wire the real API in `/generate-code --phase=integration`. In single-service mode (no `spec_source`), these default under the repo root — still shared, same repo.
194
195
 
195
196
  ---
196
197
 
@@ -214,7 +215,7 @@ When `active_service` has been resolved to a real path in Step 1.5 (e.g., `user-
214
215
  | `paths.specs_dir` | `{active_service}/{service paths.specs_dir}` (if set in service config, else keep Step 1.5 override) |
215
216
 
216
217
  **3. Store** `service_root = {active_service}` as the working directory anchor for all downstream commands:
217
- - Shell commands (`/run-tests`, `/generate-tests`) run **from within** `service_root`
218
+ - Shell commands (`/dev-run-test`, `/dev-gen-test`) run **from within** `service_root`
218
219
  - File write operations (test files, trace TSVs) use paths **relative to** `service_root`
219
220
 
220
221
  **4. If service config not found** — keep umbrella defaults, still set `service_root = {active_service}` (path anchor is always needed even without a config override).
@@ -307,7 +308,7 @@ active_module = tech_stack.module (e.g. "java-spring", "react", "flutter")
307
308
 
308
309
  If `tech_stack.module` is blank or not recognized → set `platform_type = "unknown"` and flag as ⚠️ in the Step 7 recap.
309
310
 
310
- 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).
311
+ These two variables (`active_module`, `platform_type`) are the canonical source for all branching logic in commands that need platform-specific behavior (dev-gen-test, debug, fix-bug, dev-smoke-test).
311
312
 
312
313
  ---
313
314
 
@@ -486,13 +487,13 @@ Suggest the logical next command based on workflow phase:
486
487
  | /review-context (BDD) | `/generate-tech-docs {UC-ID}` if APPROVED; regenerate if NEEDS_FIX |
487
488
  | /generate-tech-docs | `/review-tech-docs {tech-design-file}` |
488
489
  | /review-tech-docs | `/generate-code {feature-file}` if APPROVED; fix doc if NEEDS_FIX |
489
- | /generate-code | First gen → `/review-code {UC-ID}`; re-gen → `/generate-tests {UC-ID}` |
490
- | /generate-tests | `/run-tests {UC-ID}` |
491
- | /run-tests (passing) | `/review-code {UC-ID}` |
492
- | /run-tests (failing) | `/fix-bug {ticket-id}` or `/debug {error}` |
493
- | /review-code | `/smoke-test {UC-ID}` or create PR |
494
- | /smoke-test | Create PR and link to ticket |
495
- | /validate-traces | DRIFT/UNTRACKED → `/generate-code {UC-ID}`; GAP → `/generate-tests {UC-ID}`; all OK → create PR |
490
+ | /generate-code | First gen → `/review-code {UC-ID}`; re-gen → `/dev-gen-test {UC-ID}` |
491
+ | /dev-gen-test | `/dev-run-test {UC-ID}` |
492
+ | /dev-run-test (passing) | `/review-code {UC-ID}` |
493
+ | /dev-run-test (failing) | `/fix-bug {ticket-id}` or `/debug {error}` |
494
+ | /review-code | `/dev-smoke-test {UC-ID}` or create PR |
495
+ | /dev-smoke-test | Create PR and link to ticket |
496
+ | /validate-traces | DRIFT/UNTRACKED → `/generate-code {UC-ID}`; GAP → `/dev-gen-test {UC-ID}`; all OK → create PR |
496
497
  | /fix-bug | Create PR and link to ticket |
497
498
  | /debug | `/fix-bug {ticket-id}` if fix needed |
498
499
  | /report-bug | Send to dev (`/fix-bug {BUG-ID}`); if coverage gap → `/propose-scenario {UC-ID}` |
@@ -165,7 +165,7 @@ If `services` section is present:
165
165
 
166
166
  **2. Route to service** — if active domain matches a key in `services`:
167
167
  - Override `paths.specs_dir` → `services.{domain}.specs_dir`
168
- - Override `paths.tech_docs_dir` → `services.{domain}.tech_docs_dir`
168
+ - Override `paths.tech_docs_dir` → `services.{domain}.tech_docs_dir` — **only if `setup.spec_source` is NOT set.** When `spec_source` IS set, the tech-design (API contract) is a cross-team artifact and must live in the shared spec repo (handled in step 4), so leave `tech_docs_dir` for step 4 to route — do NOT pin it per-service here.
169
169
  - Store `active_service` = `services.{domain}.path`
170
170
  - Store `active_service_module` = `services.{domain}.module`
171
171
  - If service has its own `module` → use it as `active_module` (overrides `tech_stack.module`)
@@ -177,13 +177,14 @@ If `services` section is present:
177
177
  **4. Spec source auto-override** — if `setup.spec_source` is set AND the corresponding path was not already explicitly set in `paths:`:
178
178
  - Override `paths.prd_dir` → `{spec_source}/specs/prd`
179
179
  - Override `paths.design_spec_dir` → `{spec_source}/specs/design-spec`
180
+ - Override `paths.tech_docs_dir` → `{spec_source}/specs/tech-docs` — **always when `spec_source` is set** (step 2 no longer pins tech-docs per-service in this case). The tech-design IS the cross-team API contract: BE authors it here, and FE/App read it from the same spec submodule at `/generate-code --phase=integration`. *(Per-service tech-docs only happen when there is no `spec_source` — a pure multi-service BE repo with no shared spec module.)*
180
181
  - Override `paths.domain_knowledge_dir` → `{spec_source}/specs/domain-knowledge`
181
182
  - Override `paths.business_dictionary` → `{spec_source}/specs/domain-knowledge/business-dictionary.md`
182
183
  - Override `paths.core_entities` → `{spec_source}/specs/domain-knowledge/core-entities.md`
183
184
  - Override `paths.bug_reports_dir` → `{spec_source}/feedback/bug-reports`
184
185
  - Override `paths.bdd_proposals_dir` → `{spec_source}/feedback/bdd-proposals`
185
186
 
186
- > **Why under `spec_source`:** tester feedback (`/report-bug`, `/propose-scenario`) must land in the **shared spec repo** so PO/Dev see it when they `/sync`. In single-service mode (no `spec_source`), these default to `feedback/bug-reports` and `feedback/bdd-proposals` at repo root — still shared, same repo.
187
+ > **Why under `spec_source`:** PRD, design-spec, domain knowledge, the **API contract (tech-docs)**, and tester feedback are all **cross-team artifacts** — they must live in the **shared spec repo** so every umbrella (FE/App/BE) reads the same source via `/sync`. Tech-docs specifically: BE authors the tech-design (API contract), commits + pushes it into the spec submodule (2-layer commit), and FE/App pull it on their next `/sync` to wire the real API in `/generate-code --phase=integration`. In single-service mode (no `spec_source`), these default under the repo root — still shared, same repo.
187
188
 
188
189
  ---
189
190
 
@@ -207,7 +208,7 @@ When `active_service` has been resolved to a real path in Step 1.5 (e.g., `user-
207
208
  | `paths.specs_dir` | `{active_service}/{service paths.specs_dir}` (if set in service config, else keep Step 1.5 override) |
208
209
 
209
210
  **3. Store** `service_root = {active_service}` as the working directory anchor for all downstream commands:
210
- - Shell commands (`/run-tests`, `/generate-tests`) run **from within** `service_root`
211
+ - Shell commands (`/dev-run-test`, `/dev-gen-test`) run **from within** `service_root`
211
212
  - File write operations (test files, trace TSVs) use paths **relative to** `service_root`
212
213
 
213
214
  **4. If service config not found** — keep umbrella defaults, still set `service_root = {active_service}` (path anchor is always needed even without a config override).
@@ -300,7 +301,7 @@ active_module = tech_stack.module (e.g. "java-spring", "react", "flutter")
300
301
 
301
302
  If `tech_stack.module` is blank or not recognized → set `platform_type = "unknown"` and flag as ⚠️ in the Step 7 recap.
302
303
 
303
- 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).
304
+ These two variables (`active_module`, `platform_type`) are the canonical source for all branching logic in commands that need platform-specific behavior (dev-gen-test, debug, fix-bug, dev-smoke-test).
304
305
 
305
306
  ---
306
307
 
@@ -448,13 +449,13 @@ Suggest the logical next command based on workflow phase:
448
449
  | /review-context (BDD) | `/generate-tech-docs {UC-ID}` if APPROVED; regenerate if NEEDS_FIX |
449
450
  | /generate-tech-docs | `/review-tech-docs {tech-design-file}` |
450
451
  | /review-tech-docs | `/generate-code {feature-file}` if APPROVED; fix doc if NEEDS_FIX |
451
- | /generate-code | First gen → `/review-code {UC-ID}`; re-gen → `/generate-tests {UC-ID}` |
452
- | /generate-tests | `/run-tests {UC-ID}` |
453
- | /run-tests (passing) | `/review-code {UC-ID}` |
454
- | /run-tests (failing) | `/fix-bug {ticket-id}` or `/debug {error}` |
455
- | /review-code | `/smoke-test {UC-ID}` or create PR |
456
- | /smoke-test | Create PR and link to ticket |
457
- | /validate-traces | DRIFT/UNTRACKED → `/generate-code {UC-ID}`; GAP → `/generate-tests {UC-ID}`; all OK → create PR |
452
+ | /generate-code | First gen → `/review-code {UC-ID}`; re-gen → `/dev-gen-test {UC-ID}` |
453
+ | /dev-gen-test | `/dev-run-test {UC-ID}` |
454
+ | /dev-run-test (passing) | `/review-code {UC-ID}` |
455
+ | /dev-run-test (failing) | `/fix-bug {ticket-id}` or `/debug {error}` |
456
+ | /review-code | `/dev-smoke-test {UC-ID}` or create PR |
457
+ | /dev-smoke-test | Create PR and link to ticket |
458
+ | /validate-traces | DRIFT/UNTRACKED → `/generate-code {UC-ID}`; GAP → `/dev-gen-test {UC-ID}`; all OK → create PR |
458
459
  | /fix-bug | Create PR and link to ticket |
459
460
  | /debug | `/fix-bug {ticket-id}` if fix needed |
460
461
  | /report-bug | Send to dev (`/fix-bug {BUG-ID}`); if coverage gap → `/propose-scenario {UC-ID}` |
@@ -490,7 +491,7 @@ Output Artifacts: none (read-only)
490
491
  Verdict: APPROVED ✅ | NEEDS_FIX ❌
491
492
 
492
493
  If APPROVED ✅:
493
- Next: /generate-tests {UC-ID}
494
+ Next: /dev-gen-test {UC-ID}
494
495
 
495
496
  If NEEDS_FIX ❌:
496
497
  - Small fix (1–3 lines, no logic change) → fix inline → re-run /review-code {UC-ID}
@@ -569,7 +570,7 @@ If `lessons_path` does not exist, create it with this header first:
569
570
  | code-gen | /generate-code output |
570
571
  | bdd | /generate-bdd output |
571
572
  | tech-docs | /generate-tech-docs output |
572
- | tests | /generate-tests output |
573
+ | tests | /dev-gen-test output |
573
574
  | prd | /generate-prd, /refine-prd output |
574
575
  | general | every command |
575
576
 
@@ -78,7 +78,7 @@ Output Artifacts: none (read-only)
78
78
  Verdict: APPROVED ✅ | NEEDS_FIX ❌
79
79
 
80
80
  If APPROVED ✅:
81
- Next: /generate-tests {UC-ID}
81
+ Next: /dev-gen-test {UC-ID}
82
82
 
83
83
  If NEEDS_FIX ❌:
84
84
  - Small fix (1–3 lines, no logic change) → fix inline → re-run /review-code {UC-ID}