@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
@@ -33,7 +33,7 @@ Display and wait for response:
33
33
  ```
34
34
  ⚙️ MODEL CHECK
35
35
  ──────────────────────────────────────────────────────────────────
36
- Recommended : claude-opus-4-5 (or claude-opus-4)
36
+ Recommended : claude-opus-4 (or latest Opus model)
37
37
  Why needed : Spec analysis, architecture review, code generation
38
38
  require deep reasoning. Smaller models miss edge cases.
39
39
 
@@ -142,7 +142,7 @@ If `paths` section is absent, use these defaults:
142
142
  - `domain_knowledge_dir` = `specs/domain-knowledge`
143
143
  - `business_dictionary` = `specs/domain-knowledge/business-dictionary.md`
144
144
  - `core_entities` = `specs/domain-knowledge/core-entities.md`
145
- - `tech_docs_dir` = `tech-docs`
145
+ - `tech_docs_dir` = `specs/tech-docs`
146
146
  - `trace_dir` = `.trace`
147
147
 
148
148
  If `tech_stack.module` is set, also load `.agent/modules/{module}/stack-profile.yaml` if it exists.
@@ -219,6 +219,26 @@ If the file does not exist → skip silently.
219
219
 
220
220
  ---
221
221
 
222
+ ## Step 6.5 — [PLATFORM] Derive active_module and platform_type
223
+
224
+ Using `tech_stack.module` loaded in Step 1, derive and store two variables for use by all downstream commands:
225
+
226
+ ```
227
+ active_module = tech_stack.module (e.g. "java-spring", "react", "flutter")
228
+ ```
229
+
230
+ | `platform_type` | Modules |
231
+ |---|---|
232
+ | `backend` | `java-spring`, `golang`, `dotnet`, `php-laravel`, `context-engineering` |
233
+ | `web-frontend` | `react`, `nextjs`, `vue`, `nuxt`, `angular` |
234
+ | `mobile` | `flutter`, `react-native`, `ios-swiftui`, `android-compose` |
235
+
236
+ If `tech_stack.module` is blank or not recognized → set `platform_type = "unknown"` and flag as ⚠️ in the Step 7 recap.
237
+
238
+ 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).
239
+
240
+ ---
241
+
222
242
  ## Step 7 — [RECAP] Working Memory Recap (anti-lost-in-middle)
223
243
 
224
244
  After loading all context, synthesize and output a compact summary block.
@@ -229,6 +249,7 @@ Output exactly this block:
229
249
  ```
230
250
  [CTX LOADED]
231
251
  Stack : {language} / {framework} / {database}
252
+ Platform : {active_module} ({platform_type})
232
253
  Layers : {layer order from CLAUDE.md §2, e.g., Controller → Facade → Service → Repository}
233
254
  Ticket : {ticket_prefix}-
234
255
  Dict : {loaded — N canonical terms, M banned terms | missing}
@@ -263,6 +284,13 @@ Proceed to the next step of the calling command.
263
284
  Read all `{paths.trace_dir}/{UC-ID}.tsv` files matching the target domain (or all domains if no domain filter).
264
285
  Each file gives the persisted trace state for that UC.
265
286
 
287
+ **If no `.tsv` files found** in `{paths.trace_dir}`:
288
+ - Scan all `{paths.specs_dir}/**/*.feature` files in the target domain to build an in-memory list of all scenarios.
289
+ - Treat all scenarios as `UNTRACKED` (no code generated yet).
290
+ - Print: "⚠️ No trace files found. All {N} scenarios across {M} UCs are UNTRACKED."
291
+ - Suggest: "Run `/generate-bdd {prd-file}` to initialize trace state, or `/generate-code {feature-file}` to generate code."
292
+ - **Skip Steps 2–6 entirely.** Proceed directly to Step 7 using this in-memory state — do NOT abort.
293
+
266
294
  ### Step 2 — Reconcile with current `.feature` files
267
295
 
268
296
  For each `.tsv` row, read the corresponding `.feature` file and get the **current** `@trace.sc_version` for that SC.
@@ -300,6 +328,8 @@ If code was generated from an older revision → flag `TECHDOC_DRIFT`.
300
328
 
301
329
  ### Step 6 — Write status back to TSV
302
330
 
331
+ *Skip this step if no TSV files existed (handled by Step 1 no-TSV path).*
332
+
303
333
  For each `.tsv` file processed: write updated `spec_ver`, `status`, `last_updated` back to disk.
304
334
 
305
335
  ### Step 7 — Compute dashboard aggregates
@@ -309,6 +339,7 @@ total_prds = count distinct PRD files in {paths.prd_dir}/{domain}/
309
339
  approved_prds = PRDs with | Status | approved
310
340
  total_ucs = count distinct UC-IDs across all .tsv files
311
341
  approved_ucs = UCs with uc_status == approved
342
+ draft_ucs = UCs with uc_status == draft
312
343
  total_scs = total rows across all .tsv files
313
344
  code_coverage = rows where implemented_by != — / total_scs
314
345
  test_coverage = rows where test_count > 0 / total_scs
@@ -320,7 +351,7 @@ tech_docs_count = count .md files in {paths.tech_docs_dir}/{domain}/
320
351
 
321
352
  ### Step 8 — Write JSON report
322
353
 
323
- 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.
354
+ 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.
324
355
 
325
356
  Schema:
326
357
 
@@ -430,7 +461,8 @@ Schema:
430
461
  - `test_classes`: use `[]` (not `"—"`) when no test classes
431
462
  - `tech_doc_revision`: use integer; `0` if not yet generated
432
463
  - `code_coverage_pct` / `test_coverage_pct`: round to nearest integer (0–100)
433
- - 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
464
+ - 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
465
+ - **TSV `"—"` mapping**: when reading TSV files, map dash values to JSON types: `implemented_by: "—"` → `null`; `test_count: "—"` → `0`; `test_classes: "—"` → `[]`; `tech_doc_revision: "—"` → `0`
434
466
 
435
467
  ## Output
436
468
 
@@ -462,6 +494,7 @@ Suggest the logical next command based on workflow phase:
462
494
 
463
495
  | Current command | Suggest next |
464
496
  |-------------------------|-----------------------------------------------|
497
+ | /setup-ai-first | `/define-product` to start your first feature |
465
498
  | /define-product | `/generate-prd {product-definition-file}` |
466
499
  | /generate-prd | `/refine-prd {prd-file}` then `/review-context {prd-file}` |
467
500
  | /refine-prd | Open Review Board → update PRD → `/review-context {prd-file}` |
@@ -470,13 +503,13 @@ Suggest the logical next command based on workflow phase:
470
503
  | /review-context (BDD) | `/generate-tech-docs {UC-ID}` if APPROVED; regenerate if NEEDS_FIX |
471
504
  | /generate-tech-docs | `/review-tech-docs {tech-design-file}` |
472
505
  | /review-tech-docs | `/generate-code {feature-file}` if APPROVED; fix doc if NEEDS_FIX |
473
- | /generate-code | `/generate-tests {UC-ID}` |
506
+ | /generate-code | First gen → `/review-code {UC-ID}`; re-gen → `/generate-tests {UC-ID}` |
474
507
  | /generate-tests | `/run-tests {UC-ID}` |
475
508
  | /run-tests (passing) | `/review-code {UC-ID}` |
476
509
  | /run-tests (failing) | `/fix-bug {ticket-id}` or `/debug {error}` |
477
510
  | /review-code | `/smoke-test {UC-ID}` or create PR |
478
511
  | /smoke-test | Create PR and link to ticket |
479
- | /validate-traces | `/generate-code {UC-ID}` for gaps |
512
+ | /validate-traces | DRIFT/UNTRACKED → `/generate-code {UC-ID}`; GAP → `/generate-tests {UC-ID}`; all OK → create PR |
480
513
  | /fix-bug | Create PR and link to ticket |
481
514
  | /debug | `/fix-bug {ticket-id}` if fix needed |
482
515
 
@@ -492,7 +525,7 @@ Next : {suggested command with example arguments}
492
525
  ```
493
526
  /validate-traces — {domain}
494
527
 
495
- 📄 .trace/trace-report.json ← updated
528
+ 📄 {paths.trace_dir}/trace-report.json ← updated
496
529
 
497
530
  ┌─────────────────────────────────────────────────────────────────────────────────────┐
498
531
  │ PRDs Use Cases Scenarios Code Cov. Test Cov. Drift Untracked Gap │
@@ -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.5.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