@anhth2/spec-driven-dev-plugin 0.6.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 (73) hide show
  1. package/bin/index.js +180 -11
  2. package/commands/debug.md +196 -10
  3. package/commands/debug.tmpl +170 -6
  4. package/commands/define-product.md +31 -5
  5. package/commands/define-product.tmpl +5 -1
  6. package/commands/fix-bug.md +74 -10
  7. package/commands/fix-bug.tmpl +48 -6
  8. package/commands/generate-bdd.md +49 -8
  9. package/commands/generate-bdd.tmpl +23 -4
  10. package/commands/generate-code.md +109 -18
  11. package/commands/generate-code.tmpl +83 -14
  12. package/commands/generate-prd.md +33 -6
  13. package/commands/generate-prd.tmpl +7 -2
  14. package/commands/generate-tech-docs.md +85 -8
  15. package/commands/generate-tech-docs.tmpl +59 -4
  16. package/commands/generate-tests.md +454 -36
  17. package/commands/generate-tests.tmpl +428 -32
  18. package/commands/refine-prd.md +39 -7
  19. package/commands/refine-prd.tmpl +13 -3
  20. package/commands/review-code.md +57 -5
  21. package/commands/review-code.tmpl +31 -1
  22. package/commands/review-context.md +41 -11
  23. package/commands/review-context.tmpl +15 -7
  24. package/commands/review-tech-docs.md +39 -8
  25. package/commands/review-tech-docs.tmpl +13 -4
  26. package/commands/run-tests.md +159 -17
  27. package/commands/run-tests.tmpl +133 -13
  28. package/commands/setup-ai-first.md +61 -3
  29. package/commands/setup-ai-first.tmpl +6 -2
  30. package/commands/smoke-test.md +191 -21
  31. package/commands/smoke-test.tmpl +165 -17
  32. package/commands/validate-traces.md +40 -7
  33. package/commands/validate-traces.tmpl +14 -3
  34. package/core/FRAMEWORK_VERSION +1 -1
  35. package/core/commands/debug.md +196 -10
  36. package/core/commands/define-product.md +31 -5
  37. package/core/commands/fix-bug.md +74 -10
  38. package/core/commands/generate-bdd.md +49 -8
  39. package/core/commands/generate-code.md +109 -18
  40. package/core/commands/generate-prd.md +33 -6
  41. package/core/commands/generate-tech-docs.md +85 -8
  42. package/core/commands/generate-tests.md +454 -36
  43. package/core/commands/refine-prd.md +39 -7
  44. package/core/commands/review-code.md +57 -5
  45. package/core/commands/review-context.md +41 -11
  46. package/core/commands/review-tech-docs.md +39 -8
  47. package/core/commands/run-tests.md +159 -17
  48. package/core/commands/setup-ai-first.md +61 -3
  49. package/core/commands/smoke-test.md +191 -21
  50. package/core/commands/validate-traces.md +40 -7
  51. package/core/skills/code/SKILL.md +29 -6
  52. package/core/skills/debug/SKILL.md +31 -7
  53. package/core/skills/discovery/SKILL.md +25 -3
  54. package/core/skills/prd/SKILL.md +8 -6
  55. package/core/skills/setup-ai-first/SKILL.md +3 -2
  56. package/core/skills/spec/SKILL.md +7 -5
  57. package/core/skills/test/SKILL.md +54 -9
  58. package/core/steps/context-loader.md +22 -1
  59. package/core/steps/gate.md +1 -1
  60. package/core/steps/report-footer.md +3 -2
  61. package/core/steps/spawn-agent.md +3 -1
  62. package/package.json +1 -1
  63. package/skills/code/SKILL.md +29 -6
  64. package/skills/debug/SKILL.md +31 -7
  65. package/skills/discovery/SKILL.md +25 -3
  66. package/skills/prd/SKILL.md +8 -6
  67. package/skills/setup-ai-first/SKILL.md +3 -2
  68. package/skills/spec/SKILL.md +7 -5
  69. package/skills/test/SKILL.md +54 -9
  70. package/steps/context-loader.md +22 -1
  71. package/steps/gate.md +1 -1
  72. package/steps/report-footer.md +3 -2
  73. package/steps/spawn-agent.md +3 -1
@@ -19,6 +19,13 @@ Read-only check of coverage between specs, code, and tests — including PRD ver
19
19
  Read all `{paths.trace_dir}/{UC-ID}.tsv` files matching the target domain (or all domains if no domain filter).
20
20
  Each file gives the persisted trace state for that UC.
21
21
 
22
+ **If no `.tsv` files found** in `{paths.trace_dir}`:
23
+ - Scan all `{paths.specs_dir}/**/*.feature` files in the target domain to build an in-memory list of all scenarios.
24
+ - Treat all scenarios as `UNTRACKED` (no code generated yet).
25
+ - Print: "⚠️ No trace files found. All {N} scenarios across {M} UCs are UNTRACKED."
26
+ - Suggest: "Run `/generate-bdd {prd-file}` to initialize trace state, or `/generate-code {feature-file}` to generate code."
27
+ - **Skip Steps 2–6 entirely.** Proceed directly to Step 7 using this in-memory state — do NOT abort.
28
+
22
29
  ### Step 2 — Reconcile with current `.feature` files
23
30
 
24
31
  For each `.tsv` row, read the corresponding `.feature` file and get the **current** `@trace.sc_version` for that SC.
@@ -56,6 +63,8 @@ If code was generated from an older revision → flag `TECHDOC_DRIFT`.
56
63
 
57
64
  ### Step 6 — Write status back to TSV
58
65
 
66
+ *Skip this step if no TSV files existed (handled by Step 1 no-TSV path).*
67
+
59
68
  For each `.tsv` file processed: write updated `spec_ver`, `status`, `last_updated` back to disk.
60
69
 
61
70
  ### Step 7 — Compute dashboard aggregates
@@ -65,6 +74,7 @@ total_prds = count distinct PRD files in {paths.prd_dir}/{domain}/
65
74
  approved_prds = PRDs with | Status | approved
66
75
  total_ucs = count distinct UC-IDs across all .tsv files
67
76
  approved_ucs = UCs with uc_status == approved
77
+ draft_ucs = UCs with uc_status == draft
68
78
  total_scs = total rows across all .tsv files
69
79
  code_coverage = rows where implemented_by != — / total_scs
70
80
  test_coverage = rows where test_count > 0 / total_scs
@@ -76,7 +86,7 @@ tech_docs_count = count .md files in {paths.tech_docs_dir}/{domain}/
76
86
 
77
87
  ### Step 8 — Write JSON report
78
88
 
79
- Write `.trace/trace-report.json` (overwrite if exists). This file is the single source of truth for web dashboards — it contains the full snapshot at the time `/validate-traces` was last run.
89
+ Write `{paths.trace_dir}/trace-report.json` (overwrite if exists). This file is the single source of truth for web dashboards — it contains the full snapshot at the time `/validate-traces` was last run.
80
90
 
81
91
  Schema:
82
92
 
@@ -186,7 +196,8 @@ Schema:
186
196
  - `test_classes`: use `[]` (not `"—"`) when no test classes
187
197
  - `tech_doc_revision`: use integer; `0` if not yet generated
188
198
  - `code_coverage_pct` / `test_coverage_pct`: round to nearest integer (0–100)
189
- - Always write to `.trace/trace-report.json` regardless of domain filter — if a domain filter was applied, include only those PRDs in `prds[]` but note the domain in the `domain` field
199
+ - Always write to `{paths.trace_dir}/trace-report.json` regardless of domain filter — if a domain filter was applied, include only those PRDs in `prds[]` but note the domain in the `domain` field
200
+ - **TSV `"—"` mapping**: when reading TSV files, map dash values to JSON types: `implemented_by: "—"` → `null`; `test_count: "—"` → `0`; `test_classes: "—"` → `[]`; `tech_doc_revision: "—"` → `0`
190
201
 
191
202
  ## Output
192
203
 
@@ -195,7 +206,7 @@ Schema:
195
206
  ```
196
207
  /validate-traces — {domain}
197
208
 
198
- 📄 .trace/trace-report.json ← updated
209
+ 📄 {paths.trace_dir}/trace-report.json ← updated
199
210
 
200
211
  ┌─────────────────────────────────────────────────────────────────────────────────────┐
201
212
  │ PRDs Use Cases Scenarios Code Cov. Test Cov. Drift Untracked Gap │
@@ -1 +1 @@
1
- 0.6.0
1
+ 0.7.0
@@ -34,7 +34,7 @@ Display and wait for response:
34
34
  ```
35
35
  ⚙️ MODEL CHECK
36
36
  ──────────────────────────────────────────────────────────────────
37
- Recommended : claude-opus-4-5 (or claude-opus-4)
37
+ Recommended : claude-opus-4 (or latest Opus model)
38
38
  Why needed : Spec analysis, architecture review, code generation
39
39
  require deep reasoning. Smaller models miss edge cases.
40
40
 
@@ -143,7 +143,7 @@ If `paths` section is absent, use these defaults:
143
143
  - `domain_knowledge_dir` = `specs/domain-knowledge`
144
144
  - `business_dictionary` = `specs/domain-knowledge/business-dictionary.md`
145
145
  - `core_entities` = `specs/domain-knowledge/core-entities.md`
146
- - `tech_docs_dir` = `tech-docs`
146
+ - `tech_docs_dir` = `specs/tech-docs`
147
147
  - `trace_dir` = `.trace`
148
148
 
149
149
  If `tech_stack.module` is set, also load `.agent/modules/{module}/stack-profile.yaml` if it exists.
@@ -220,6 +220,26 @@ If the file does not exist → skip silently.
220
220
 
221
221
  ---
222
222
 
223
+ ## Step 6.5 — [PLATFORM] Derive active_module and platform_type
224
+
225
+ Using `tech_stack.module` loaded in Step 1, derive and store two variables for use by all downstream commands:
226
+
227
+ ```
228
+ active_module = tech_stack.module (e.g. "java-spring", "react", "flutter")
229
+ ```
230
+
231
+ | `platform_type` | Modules |
232
+ |---|---|
233
+ | `backend` | `java-spring`, `golang`, `dotnet`, `php-laravel`, `context-engineering` |
234
+ | `web-frontend` | `react`, `nextjs`, `vue`, `nuxt`, `angular` |
235
+ | `mobile` | `flutter`, `react-native`, `ios-swiftui`, `android-compose` |
236
+
237
+ If `tech_stack.module` is blank or not recognized → set `platform_type = "unknown"` and flag as ⚠️ in the Step 7 recap.
238
+
239
+ 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).
240
+
241
+ ---
242
+
223
243
  ## Step 7 — [RECAP] Working Memory Recap (anti-lost-in-middle)
224
244
 
225
245
  After loading all context, synthesize and output a compact summary block.
@@ -230,6 +250,7 @@ Output exactly this block:
230
250
  ```
231
251
  [CTX LOADED]
232
252
  Stack : {language} / {framework} / {database}
253
+ Platform : {active_module} ({platform_type})
233
254
  Layers : {layer order from CLAUDE.md §2, e.g., Controller → Facade → Service → Repository}
234
255
  Ticket : {ticket_prefix}-
235
256
  Dict : {loaded — N canonical terms, M banned terms | missing}
@@ -257,13 +278,112 @@ Proceed to the next step of the calling command.
257
278
 
258
279
  ---
259
280
 
260
- ## InputPaste one of:
261
- 1. Stack trace / error log
262
- 2. Test failure output
263
- 3. File path + description of unexpected behavior
264
- 4. A specific question about a code snippet
281
+ ## Step 1 Classify debug type
282
+
283
+ After loading context, display this prompt and wait for the user's choice:
284
+
285
+ ```
286
+ DEBUG SESSION
287
+ ──────────────────────────────────────────────────────────────
288
+ What's your situation?
289
+
290
+ 1 I already have a stack trace / error log → paste it
291
+ 2 I need to reproduce the error first → show me the run command
292
+ 3 A test is failing → I'll run tests, then paste output
293
+ 4 Code question (no runtime needed) → ask away
294
+ ──────────────────────────────────────────────────────────────
295
+ Enter 1 / 2 / 3 / 4:
296
+ ```
297
+
298
+ Wait for the user's choice, then follow the corresponding path below.
299
+
300
+ ---
301
+
302
+ ### Path 1 — Already have error output
303
+
304
+ Ask:
305
+ ```
306
+ Paste your stack trace / error log below:
307
+ ```
308
+
309
+ Wait for input, then proceed to [Stack Trace Analysis](#stack-trace-analysis).
310
+
311
+ ---
312
+
313
+ ### Path 2 — Need to reproduce first
314
+
315
+ Display the run command from `conventions.service_run` in `project-context.yaml`:
316
+
317
+ ```
318
+ Start your service first:
319
+
320
+ {conventions.service_run}
321
+
322
+ (If you use Docker: `docker compose up -d`, then verify with `docker compose ps`)
323
+
324
+ Once the service is running:
325
+ 1. Trigger the behavior that causes the error
326
+ 2. Copy the full stack trace or error log
327
+ 3. Paste it here
328
+
329
+ Waiting for your error output...
330
+ ```
331
+
332
+ Wait for the user to paste the error, then proceed to [Stack Trace Analysis](#stack-trace-analysis).
333
+
334
+ If `conventions.service_run` is not set → show:
335
+ ```
336
+ ⚠️ service_run is not configured in .agent/project-context.yaml.
337
+ Add it so this command can show the correct start command:
338
+
339
+ conventions:
340
+ service_run: "mvn spring-boot:run" # or: npm run dev / go run . / etc.
341
+ ```
342
+ Then ask the user to start the service manually and paste the error when ready.
343
+
344
+ ---
345
+
346
+ ### Path 3 — Test is failing
347
+
348
+ Display the test command from `conventions.test_command` in `project-context.yaml`:
349
+
350
+ ```
351
+ Run your tests first:
352
+
353
+ {conventions.test_command}
354
+
355
+ Once the run finishes, paste the full test failure output here.
356
+
357
+ Waiting...
358
+ ```
359
+
360
+ Wait for the user to paste the failure output, then proceed to [Test Failure Analysis](#test-failure-analysis).
361
+
362
+ If `conventions.test_command` is not set → show:
363
+ ```
364
+ ⚠️ test_command is not configured in .agent/project-context.yaml.
365
+ Add it so this command can show the correct test command:
366
+
367
+ conventions:
368
+ test_command: "mvn test" # or: npm test / go test ./... / etc.
369
+ ```
370
+ Then ask the user to run tests manually and paste the output when ready.
371
+
372
+ ---
373
+
374
+ ### Path 4 — Code question
375
+
376
+ Ask:
377
+ ```
378
+ Describe your question or paste the code snippet you're asking about:
379
+ ```
380
+
381
+ Wait for input, then answer directly using loaded project context (architecture rules, layer order, coding standards from CLAUDE.md).
382
+
383
+ ---
265
384
 
266
385
  ## Stack Trace Analysis
386
+
267
387
  Read from **bottom up** — `Caused by:` is the real root cause:
268
388
  ```
269
389
  Caused by: {RealException} ← start here
@@ -272,20 +392,83 @@ Caused by: {RealException} ← start here
272
392
 
273
393
  ## Common Error Patterns
274
394
 
395
+ Use `active_module` from context to select the relevant table.
396
+
397
+ ### If `platform_type = backend`
398
+
399
+ #### java-spring / golang / dotnet / php-laravel
400
+
275
401
  | Error | Likely Cause | Fix Direction |
276
402
  |-------|-------------|---------------|
277
403
  | NullPointerException | Null object access; Optional not handled | Check Optional.orElseThrow, null guards |
278
404
  | ClassCastException | Wrong type assumption | Check type at assignment/return |
279
405
  | OutOfMemoryError | Loading too much data | Add pagination |
280
406
  | StackOverflowError | Infinite recursion | Find recursive call with no base case |
281
- | Connection refused | Dependency not running | Check config URLs |
407
+ | Connection refused | Dependency not running | Check config URLs / start service |
282
408
  | 401 Unauthorized | Token expired, wrong config | Verify token, check auth config |
283
409
  | 403 Forbidden | Wrong role | Check auth annotations |
284
410
  | DB constraint violation | Duplicate key, null in NOT NULL | Check data and constraints |
285
411
  | Serialization error | Circular reference | Check DTO/mapper config |
286
412
  | Test assertion mismatch | Wrong mock or wrong expected | Re-read mock setup |
287
413
 
414
+ #### context-engineering (AI/LLM pipelines)
415
+
416
+ | Error | Likely Cause | Fix Direction |
417
+ |-------|-------------|---------------|
418
+ | `APIError` / `RateLimitError` | LLM quota exceeded or service down | Check API key, rate limits; add exponential backoff |
419
+ | `TokenLimitError` / `context_length_exceeded` | Input prompt too long | Truncate/chunk input; review prompt template size |
420
+ | `AuthenticationError` | API key invalid or expired | Check env var; rotate key |
421
+ | Response validation / schema mismatch | LLM output doesn't match expected format | Add output parser; retry with stricter prompt |
422
+ | `JSONDecodeError` on LLM output | Model returned non-JSON text | Add JSON extraction post-processing or stricter system prompt |
423
+ | Hanging / slow test | Real LLM called in test instead of mock | Verify `patch('...')` applied; add timeout guard |
424
+ | Flaky results across runs | Non-deterministic LLM response | Use fixed mock in tests; check temperature = 0 for determinism |
425
+
426
+ ### If `platform_type = web-frontend`
427
+
428
+ | Error | Likely Cause | Fix Direction |
429
+ |-------|-------------|---------------|
430
+ | `Cannot read properties of undefined` | Data not loaded yet | Add loading guard / optional chaining `?.` |
431
+ | `useEffect` infinite loop | Dependency array wrong | Review deps, use stable refs / `useCallback` |
432
+ | `Cannot update state on unmounted component` | Async resolves after unmount | Cancel in cleanup / use AbortController |
433
+ | CORS error | API not configured | Check backend CORS config or dev proxy setup |
434
+ | 401 Unauthorized | Token expired or missing | Refresh token / check Authorization header |
435
+ | White screen / no output | Unhandled render error | Check browser console, add ErrorBoundary |
436
+ | Type error (Zod / TypeScript) | API response shape mismatch | Compare actual response vs type definition |
437
+ | `act(...)` warning in test | Async state update | Wrap in `act(async () => {...})` |
438
+ | Module not found | Import path wrong | Check relative path / tsconfig alias |
439
+
440
+ ### If `platform_type = mobile`
441
+
442
+ #### Flutter
443
+ | Error | Likely Cause | Fix Direction |
444
+ |-------|-------------|---------------|
445
+ | `Null check operator on null value` | Nullable not guarded | Add `?` or null check before `!` |
446
+ | `pumpAndSettle timed out` | Async not completing in test | Use `pump(Duration(...))` |
447
+ | `setState called after dispose` | Async continues after widget removed | Cancel in `dispose()` |
448
+ | `RenderFlex overflow` | Widget too wide for screen | Wrap with `Flexible`, `Expanded`, or `SingleChildScrollView` |
449
+ | BLoC state not updating | Event not dispatched | Verify `bloc.add(Event())` is called |
450
+ | `MissingPluginException` | Native plugin not linked | Run `flutter clean && flutter pub get` |
451
+
452
+ #### React Native
453
+ | Error | Likely Cause | Fix Direction |
454
+ |-------|-------------|---------------|
455
+ | `undefined is not an object` | Null prop access | Add null check / optional chaining |
456
+ | Metro bundler error | Cache stale | `npx react-native start --reset-cache` |
457
+ | `VirtualizedLists nested` | FlatList inside ScrollView | Use `nestedScrollEnabled` or restructure |
458
+ | Navigation `undefined` | `useNavigation` outside navigator | Wrap component inside correct navigator |
459
+ | `act(...)` warning | Async state update in test | Wrap in `act(async () => {...})` |
460
+
461
+ #### iOS / Android
462
+ | Error | Likely Cause | Fix Direction |
463
+ |-------|-------------|---------------|
464
+ | `SIGABRT` / `EXC_BAD_ACCESS` (iOS) | Nil dereference | Add optional binding `if let` / `guard let` |
465
+ | `IllegalStateException` (Android) | Lifecycle violation | Check if fragment/activity still attached |
466
+ | `NetworkOnMainThreadException` | Network call on UI thread | Move to coroutine / background thread |
467
+ | Build fails after pod install | Pod cache stale | `pod deintegrate && pod install` |
468
+ | `Hilt injection failed` | Missing `@AndroidEntryPoint` | Add annotation to Activity/Fragment |
469
+
288
470
  ## Test Failure Analysis
471
+
289
472
  ```
290
473
  Expected: {value}
291
474
  Actual : {value}
@@ -293,6 +476,8 @@ Actual : {value}
293
476
  ```
294
477
  1. What is the gap? 2. Is mock setup correct? 3. Is assertion logically correct?
295
478
 
479
+ ---
480
+
296
481
  ## Output
297
482
 
298
483
  # Report Footer — Standard Command Output Format
@@ -323,6 +508,7 @@ Suggest the logical next command based on workflow phase:
323
508
 
324
509
  | Current command | Suggest next |
325
510
  |-------------------------|-----------------------------------------------|
511
+ | /setup-ai-first | `/define-product` to start your first feature |
326
512
  | /define-product | `/generate-prd {product-definition-file}` |
327
513
  | /generate-prd | `/refine-prd {prd-file}` then `/review-context {prd-file}` |
328
514
  | /refine-prd | Open Review Board → update PRD → `/review-context {prd-file}` |
@@ -331,13 +517,13 @@ Suggest the logical next command based on workflow phase:
331
517
  | /review-context (BDD) | `/generate-tech-docs {UC-ID}` if APPROVED; regenerate if NEEDS_FIX |
332
518
  | /generate-tech-docs | `/review-tech-docs {tech-design-file}` |
333
519
  | /review-tech-docs | `/generate-code {feature-file}` if APPROVED; fix doc if NEEDS_FIX |
334
- | /generate-code | `/generate-tests {UC-ID}` |
520
+ | /generate-code | First gen → `/review-code {UC-ID}`; re-gen → `/generate-tests {UC-ID}` |
335
521
  | /generate-tests | `/run-tests {UC-ID}` |
336
522
  | /run-tests (passing) | `/review-code {UC-ID}` |
337
523
  | /run-tests (failing) | `/fix-bug {ticket-id}` or `/debug {error}` |
338
524
  | /review-code | `/smoke-test {UC-ID}` or create PR |
339
525
  | /smoke-test | Create PR and link to ticket |
340
- | /validate-traces | `/generate-code {UC-ID}` for gaps |
526
+ | /validate-traces | DRIFT/UNTRACKED → `/generate-code {UC-ID}`; GAP → `/generate-tests {UC-ID}`; all OK → create PR |
341
527
  | /fix-bug | Create PR and link to ticket |
342
528
  | /debug | `/fix-bug {ticket-id}` if fix needed |
343
529
 
@@ -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}
@@ -269,6 +290,8 @@ AI scans the project and writes:
269
290
  | {original} | {canonical} |
270
291
  ```
271
292
 
293
+ Store this terminology map in the output product-definition file under a `## Terminology Map` section — `/generate-prd` will reference it during its Terminology Rules step to ensure consistency.
294
+
272
295
  ---
273
296
 
274
297
  ## Phase 1 — Feature Definition *(CHECKPOINT 1)*
@@ -305,7 +328,7 @@ Confirm → write `✅ PO Confirmed: Yes` → proceed.
305
328
 
306
329
  ---
307
330
 
308
- ## Phase 3 — Clarification Log
331
+ ## Phase 3 — Clarification Log *(CHECKPOINT 3)*
309
332
 
310
333
  Based on Phases 1-2, AI identifies gaps and asks follow-up questions. Continue rounds until no Unresolved Items remain.
311
334
 
@@ -321,6 +344,8 @@ Based on Phases 1-2, AI identifies gaps and asks follow-up questions. Continue r
321
344
  ### Unresolved Items
322
345
  - {item — or "None"}
323
346
 
347
+ When all Unresolved Items are resolved → write `✅ CHECKPOINT 3: No Unresolved Items` → proceed to Phase 4.
348
+
324
349
  ---
325
350
 
326
351
  ## Phase 4 — Business Rules *(CHECKPOINT 4)*
@@ -417,6 +442,7 @@ Suggest the logical next command based on workflow phase:
417
442
 
418
443
  | Current command | Suggest next |
419
444
  |-------------------------|-----------------------------------------------|
445
+ | /setup-ai-first | `/define-product` to start your first feature |
420
446
  | /define-product | `/generate-prd {product-definition-file}` |
421
447
  | /generate-prd | `/refine-prd {prd-file}` then `/review-context {prd-file}` |
422
448
  | /refine-prd | Open Review Board → update PRD → `/review-context {prd-file}` |
@@ -425,13 +451,13 @@ Suggest the logical next command based on workflow phase:
425
451
  | /review-context (BDD) | `/generate-tech-docs {UC-ID}` if APPROVED; regenerate if NEEDS_FIX |
426
452
  | /generate-tech-docs | `/review-tech-docs {tech-design-file}` |
427
453
  | /review-tech-docs | `/generate-code {feature-file}` if APPROVED; fix doc if NEEDS_FIX |
428
- | /generate-code | `/generate-tests {UC-ID}` |
454
+ | /generate-code | First gen → `/review-code {UC-ID}`; re-gen → `/generate-tests {UC-ID}` |
429
455
  | /generate-tests | `/run-tests {UC-ID}` |
430
456
  | /run-tests (passing) | `/review-code {UC-ID}` |
431
457
  | /run-tests (failing) | `/fix-bug {ticket-id}` or `/debug {error}` |
432
458
  | /review-code | `/smoke-test {UC-ID}` or create PR |
433
459
  | /smoke-test | Create PR and link to ticket |
434
- | /validate-traces | `/generate-code {UC-ID}` for gaps |
460
+ | /validate-traces | DRIFT/UNTRACKED → `/generate-code {UC-ID}`; GAP → `/generate-tests {UC-ID}`; all OK → create PR |
435
461
  | /fix-bug | Create PR and link to ticket |
436
462
  | /debug | `/fix-bug {ticket-id}` if fix needed |
437
463
 
@@ -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