@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
@@ -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
 
@@ -84,7 +84,7 @@ Wait for explicit "Y" or "N" from the user before continuing.
84
84
  - "N" → stop and ask what the user wants to change.
85
85
 
86
86
 
87
- *Note: For this command, the target in Step 1 is a UC-ID or service name from `$ARGUMENTS`. Context loading provides `conventions.test_command`.*
87
+ *Note: For this command, the target in Step 1 is a UC-ID or service name. Context loading provides `conventions.test_command` and `tech_stack.module`.*
88
88
 
89
89
  ## Context
90
90
  # Context Loader — Load All Project Context
@@ -140,7 +140,7 @@ If `paths` section is absent, use these defaults:
140
140
  - `domain_knowledge_dir` = `specs/domain-knowledge`
141
141
  - `business_dictionary` = `specs/domain-knowledge/business-dictionary.md`
142
142
  - `core_entities` = `specs/domain-knowledge/core-entities.md`
143
- - `tech_docs_dir` = `tech-docs`
143
+ - `tech_docs_dir` = `specs/tech-docs`
144
144
  - `trace_dir` = `.trace`
145
145
 
146
146
  If `tech_stack.module` is set, also load `.agent/modules/{module}/stack-profile.yaml` if it exists.
@@ -217,6 +217,26 @@ If the file does not exist → skip silently.
217
217
 
218
218
  ---
219
219
 
220
+ ## Step 6.5 — [PLATFORM] Derive active_module and platform_type
221
+
222
+ Using `tech_stack.module` loaded in Step 1, derive and store two variables for use by all downstream commands:
223
+
224
+ ```
225
+ active_module = tech_stack.module (e.g. "java-spring", "react", "flutter")
226
+ ```
227
+
228
+ | `platform_type` | Modules |
229
+ |---|---|
230
+ | `backend` | `java-spring`, `golang`, `dotnet`, `php-laravel`, `context-engineering` |
231
+ | `web-frontend` | `react`, `nextjs`, `vue`, `nuxt`, `angular` |
232
+ | `mobile` | `flutter`, `react-native`, `ios-swiftui`, `android-compose` |
233
+
234
+ If `tech_stack.module` is blank or not recognized → set `platform_type = "unknown"` and flag as ⚠️ in the Step 7 recap.
235
+
236
+ These two variables (`active_module`, `platform_type`) are the canonical source for all branching logic in commands that need platform-specific behavior (generate-tests, debug, fix-bug, smoke-test).
237
+
238
+ ---
239
+
220
240
  ## Step 7 — [RECAP] Working Memory Recap (anti-lost-in-middle)
221
241
 
222
242
  After loading all context, synthesize and output a compact summary block.
@@ -227,6 +247,7 @@ Output exactly this block:
227
247
  ```
228
248
  [CTX LOADED]
229
249
  Stack : {language} / {framework} / {database}
250
+ Platform : {active_module} ({platform_type})
230
251
  Layers : {layer order from CLAUDE.md §2, e.g., Controller → Facade → Service → Repository}
231
252
  Ticket : {ticket_prefix}-
232
253
  Dict : {loaded — N canonical terms, M banned terms | missing}
@@ -252,25 +273,142 @@ After completing all steps, you have loaded:
252
273
  Proceed to the next step of the calling command.
253
274
 
254
275
 
276
+ ---
277
+
278
+ ## Service Detection
279
+
280
+ Read `active_module` from context (resolved in context-loader Step 1).
281
+ Use it to select the correct run command and error analysis table below.
282
+
255
283
  ---
256
284
 
257
285
  ## Run
286
+
287
+ ### If `platform_type = backend`
288
+
258
289
  ```bash
259
- {conventions.test_command} # all tests in module
260
- {conventions.test_command} --class {ClassName} # specific class (faster)
261
- {conventions.test_command} --pattern "*{Resource}*" # by pattern
290
+ # Run all tests for this UC
291
+ {conventions.test_command}
292
+
293
+ # Scoped to specific class (faster feedback)
294
+ # java-spring:
295
+ mvn test -Dtest={ClassName}
296
+ # golang:
297
+ go test ./... -run Test{FunctionName}
298
+ # dotnet:
299
+ dotnet test --filter "FullyQualifiedName~{ClassName}"
300
+ # php-laravel:
301
+ php artisan test --filter {ClassName}
302
+ # context-engineering (pytest):
303
+ pytest tests/{domain}/{test_file}.py -v
304
+ pytest tests/{domain}/{test_file}.py::{TestClass}::{test_method} -v
305
+ pytest tests/ --cov={source_dir} --cov-report=term-missing
306
+ ```
307
+
308
+ ### If `platform_type = web-frontend`
309
+
310
+ ```bash
311
+ # Run all tests
312
+ {conventions.test_command}
313
+
314
+ # Scoped (Vitest / Jest):
315
+ npx vitest run src/features/{domain}/{Component}.test.tsx
316
+ npx jest src/features/{domain}/{Component}.test.tsx
317
+
318
+ # E2E (Playwright):
319
+ npx playwright test {UC-ID}
320
+ # E2E (Cypress):
321
+ npx cypress run --spec "cypress/e2e/{UC-ID}*"
322
+ ```
323
+
324
+ ### If `platform_type = mobile`
325
+
326
+ ```bash
327
+ # Flutter:
328
+ flutter test test/{domain}/{UC-ID}_test.dart
329
+ flutter test integration_test/{UC-ID}_test.dart # integration
330
+
331
+ # React Native:
332
+ npx jest {UC-ID}
333
+
334
+ # iOS (Xcode command line):
335
+ xcodebuild test -scheme {Scheme} -destination 'platform=iOS Simulator,name=iPhone 15'
336
+
337
+ # Android:
338
+ ./gradlew test # unit tests
339
+ ./gradlew connectedAndroidTest # instrumented (device/emulator required)
262
340
  ```
263
341
 
342
+ > **Note for Android instrumented tests:** a running emulator or connected device is required before running `connectedAndroidTest`. Start one via Android Studio or: `emulator -avd {AVD_NAME} &`
343
+
344
+ ---
345
+
264
346
  ## Analyze Failures
265
347
 
348
+ ### Backend failure patterns
349
+
350
+ #### java-spring / golang / dotnet / php-laravel
351
+
352
+ | Error Pattern | Common Cause | Suggested Fix |
353
+ |---|---|---|
354
+ | `NullPointerException` | Missing mock setup | Check `given(...)`/`coEvery`/`mockk` for null dependency |
355
+ | `Bean not found` | Missing mock declaration | Add `@MockBean` / inject mock |
356
+ | `Expected 200, got 401` | Missing auth setup | Add auth token/user to test context |
357
+ | `Expected 200, got 400` | Request body fails validation | Check required fields in DTO |
358
+ | `Expected 200, got 403` | Wrong role | Add correct role to test user |
359
+ | `LazyInitializationException` | Lazy collection outside transaction | Add `@Transactional` or eager fetch |
360
+ | `Mapper not found` | Code not compiled | Run build step before tests |
361
+ | `DataIntegrityViolationException` | Duplicate key in DB setup | Use `@Transactional` + rollback, or clean DB between tests |
362
+ | Assertion mismatch | Wrong mock return value | Re-read `given(...).willReturn(...)` setup |
363
+
364
+ #### context-engineering (AI/LLM pipelines)
365
+
366
+ | Error Pattern | Common Cause | Suggested Fix |
367
+ |---|---|---|
368
+ | `AssertionError` on LLM mock output | Mock return value not matching schema | Re-check `mock_llm.return_value` / `mock_llm.complete.return_value` setup |
369
+ | `ValidationError` on response | LLM output structure doesn't match expected schema | Tighten schema check or add retry logic in test |
370
+ | `ConnectionError` / `APIError` | Real LLM API being called in test | Ensure `patch('...')` mock is applied — never call real LLM in unit tests |
371
+ | `TimeoutError` | Test calling live LLM endpoint | Add mock; check test fixtures |
372
+ | Flaky / non-deterministic results | Real LLM response used in assertion | Replace with deterministic mock return value |
373
+
374
+ ### Web frontend failure patterns
375
+
266
376
  | Error Pattern | Common Cause | Suggested Fix |
267
377
  |---|---|---|
268
- | NullPointerException | Missing mock setup | Check `given(...)` for null dependency |
269
- | Bean not found | Missing mock declaration | Add mock for missing dependency |
270
- | Expected 200, got 403 | Missing auth setup | Add auth user/role to test context |
271
- | Expected 200, got 400 | Request body fails validation | Check required fields in DTO |
272
- | LazyInitializationException | Lazy collection outside transaction | Add `@Transactional` or eager fetch |
273
- | Mapper not found | Code generator not run | Run compile step before tests |
378
+ | `Unable to find role "..."` | Element not rendered yet | Wrap in `await waitFor(() => ...)` |
379
+ | `TestingLibraryElementError: Found multiple elements` | Selector too broad | Use `getByRole(..., { name: '...' })` to narrow |
380
+ | `Network request not intercepted` | Missing MSW handler / `cy.intercept` | Add handler for the endpoint |
381
+ | `act(...)` warning | State update after test ended | Await async events / `await userEvent.click(...)` |
382
+ | `Cannot read properties of undefined` | Component rendered before data loaded | Add loading state or mock resolved data |
383
+ | Playwright timeout | Page not navigated / element hidden | Check route, add `waitForSelector` |
384
+ | `expect(page.locator(...)).toBeVisible` fails | Wrong selector | Use Playwright Inspector to find correct locator |
385
+
386
+ ### Mobile failure patterns
387
+
388
+ #### Flutter
389
+ | Error Pattern | Common Cause | Suggested Fix |
390
+ |---|---|---|
391
+ | `pumpAndSettle timed out` | Async operation not completing | Use `pump(Duration(...))` for specific delay |
392
+ | `No widget found` | Widget not rendered / wrong finder | Check `find.byType`, `find.text`, `find.byKey` |
393
+ | `setState called after dispose` | Widget disposed before async completes | Cancel async in `dispose()` |
394
+ | BLoC state mismatch | Wrong event emitted | Verify `mockBloc` received correct event |
395
+
396
+ #### React Native
397
+ | Error Pattern | Common Cause | Suggested Fix |
398
+ |---|---|---|
399
+ | `Unable to find element` | Missing `testID` or wrong query | Add `accessibilityLabel` or `testID` to component |
400
+ | `act(...)` warning | Async state updates | Wrap in `act(async () => { ... })` |
401
+ | Navigation mock missing | `useNavigation` not mocked | Add jest mock for `@react-navigation/native` |
402
+
403
+ #### iOS / Android
404
+ | Error Pattern | Common Cause | Suggested Fix |
405
+ |---|---|---|
406
+ | `XCTAssertEqual failed` | Wrong expected value | Check ViewModel output for given mock |
407
+ | `Compose node not found` | Wrong `contentDescription` / `testTag` | Add `Modifier.testTag(...)` to composable |
408
+ | `Hilt injection failed` | Missing test module | Add `@UninstallModules` + `@BindValue` in test class |
409
+ | Emulator not available | `connectedAndroidTest` without device | Start emulator first, wait for it to boot |
410
+
411
+ ---
274
412
 
275
413
  ## Output
276
414
 
@@ -302,6 +440,7 @@ Suggest the logical next command based on workflow phase:
302
440
 
303
441
  | Current command | Suggest next |
304
442
  |-------------------------|-----------------------------------------------|
443
+ | /setup-ai-first | `/define-product` to start your first feature |
305
444
  | /define-product | `/generate-prd {product-definition-file}` |
306
445
  | /generate-prd | `/refine-prd {prd-file}` then `/review-context {prd-file}` |
307
446
  | /refine-prd | Open Review Board → update PRD → `/review-context {prd-file}` |
@@ -310,13 +449,13 @@ Suggest the logical next command based on workflow phase:
310
449
  | /review-context (BDD) | `/generate-tech-docs {UC-ID}` if APPROVED; regenerate if NEEDS_FIX |
311
450
  | /generate-tech-docs | `/review-tech-docs {tech-design-file}` |
312
451
  | /review-tech-docs | `/generate-code {feature-file}` if APPROVED; fix doc if NEEDS_FIX |
313
- | /generate-code | `/generate-tests {UC-ID}` |
452
+ | /generate-code | First gen → `/review-code {UC-ID}`; re-gen → `/generate-tests {UC-ID}` |
314
453
  | /generate-tests | `/run-tests {UC-ID}` |
315
454
  | /run-tests (passing) | `/review-code {UC-ID}` |
316
455
  | /run-tests (failing) | `/fix-bug {ticket-id}` or `/debug {error}` |
317
456
  | /review-code | `/smoke-test {UC-ID}` or create PR |
318
457
  | /smoke-test | Create PR and link to ticket |
319
- | /validate-traces | `/generate-code {UC-ID}` for gaps |
458
+ | /validate-traces | DRIFT/UNTRACKED → `/generate-code {UC-ID}`; GAP → `/generate-tests {UC-ID}`; all OK → create PR |
320
459
  | /fix-bug | Create PR and link to ticket |
321
460
  | /debug | `/fix-bug {ticket-id}` if fix needed |
322
461
 
@@ -330,14 +469,17 @@ Next : {suggested command with example arguments}
330
469
 
331
470
 
332
471
  ```
333
- /run-tests Report — {service}
472
+ /run-tests Report — {UC-ID} ({active_module})
334
473
  ✅ Passed: {N} | ❌ Failed: {M} | ⏭️ Skipped: {K} | Duration: {X}s
335
474
 
336
475
  ## Failed Tests
337
476
  | Test | Error | Root Cause |
338
- |------|-------|-----------|
477
+ |------|-------|------------|
339
478
 
340
479
  ## Recommendations
341
480
  {specific fix per failure}
342
- Next: /fix-bug if real bug, or correct test if wrong expectation.
481
+
482
+ Next:
483
+ All tests pass → /review-code {UC-ID}
484
+ Tests fail → /fix-bug {TICKET_ID} (real bug) or fix test (wrong expectation)
343
485
  ```
@@ -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
 
@@ -108,8 +108,8 @@ Create these directories (skip if they exist):
108
108
  │ ├── product-definition/
109
109
  │ ├── prd/
110
110
  │ ├── bdd/
111
+ │ ├── tech-docs/ ← technical design documents
111
112
  │ └── domain-knowledge/ ← business dictionary & domain context
112
- ├── tech-docs/
113
113
  ├── .trace/
114
114
  └── .agent/
115
115
  └── review/
@@ -153,7 +153,7 @@ forbidden:
153
153
  # §4. Traceability
154
154
  # Every controller method must be tagged:
155
155
  # @trace.implements={UC-ID}-{SC-ID}
156
- # @trace.source=specs/bdd/{domain}/{UC-ID}.feature
156
+ # @trace.source=specs/bdd/{domain}/{UC-ID}.feature ← adjust if specs_dir differs in .agent/project-context.yaml
157
157
  # Tests must be tagged:
158
158
  # @trace.verifies={UC-ID}
159
159
 
@@ -273,6 +273,8 @@ Or: VS Code → `Ctrl+Shift+P` → **"Extensions: Install from Marketplace"**
273
273
  ## Step 7 — Verify
274
274
 
275
275
  - [ ] `specs/` exists
276
+ - [ ] `specs/bdd/` exists
277
+ - [ ] `specs/tech-docs/` exists
276
278
  - [ ] `specs/domain-knowledge/` exists
277
279
  - [ ] `.trace/` exists
278
280
  - [ ] `.agent/project-context.yaml` exists
@@ -282,6 +284,62 @@ Or: VS Code → `Ctrl+Shift+P` → **"Extensions: Install from Marketplace"**
282
284
 
283
285
  ## Output
284
286
 
287
+ # Report Footer — Standard Command Output Format
288
+
289
+ Every command report must end with this standard footer section.
290
+
291
+ ## Status Badge
292
+
293
+ Choose one based on outcome:
294
+ - `✅ Complete` — all steps succeeded, no issues found
295
+ - `❌ Failed` — command could not complete due to a blocking error
296
+ - `⚠️ Warnings` — completed with non-blocking issues that should be reviewed
297
+
298
+ ## Output Artifacts
299
+
300
+ List every file created or modified by this command:
301
+ ```
302
+ Output Artifacts:
303
+ {created|updated} {file-path} ({brief description})
304
+ {created|updated} {file-path} ({brief description})
305
+ ```
306
+
307
+ If no files were written (e.g., review or analysis commands) → write `Output Artifacts: none (read-only)`.
308
+
309
+ ## Next Command Suggestion
310
+
311
+ Suggest the logical next command based on workflow phase:
312
+
313
+ | Current command | Suggest next |
314
+ |-------------------------|-----------------------------------------------|
315
+ | /setup-ai-first | `/define-product` to start your first feature |
316
+ | /define-product | `/generate-prd {product-definition-file}` |
317
+ | /generate-prd | `/refine-prd {prd-file}` then `/review-context {prd-file}` |
318
+ | /refine-prd | Open Review Board → update PRD → `/review-context {prd-file}` |
319
+ | /review-context (PRD) | `/generate-bdd {prd-file}` if APPROVED; fix PRD if NEEDS_FIX |
320
+ | /generate-bdd | `/review-context {feature-file}` to verify coverage |
321
+ | /review-context (BDD) | `/generate-tech-docs {UC-ID}` if APPROVED; regenerate if NEEDS_FIX |
322
+ | /generate-tech-docs | `/review-tech-docs {tech-design-file}` |
323
+ | /review-tech-docs | `/generate-code {feature-file}` if APPROVED; fix doc if NEEDS_FIX |
324
+ | /generate-code | First gen → `/review-code {UC-ID}`; re-gen → `/generate-tests {UC-ID}` |
325
+ | /generate-tests | `/run-tests {UC-ID}` |
326
+ | /run-tests (passing) | `/review-code {UC-ID}` |
327
+ | /run-tests (failing) | `/fix-bug {ticket-id}` or `/debug {error}` |
328
+ | /review-code | `/smoke-test {UC-ID}` or create PR |
329
+ | /smoke-test | Create PR and link to ticket |
330
+ | /validate-traces | DRIFT/UNTRACKED → `/generate-code {UC-ID}`; GAP → `/generate-tests {UC-ID}`; all OK → create PR |
331
+ | /fix-bug | Create PR and link to ticket |
332
+ | /debug | `/fix-bug {ticket-id}` if fix needed |
333
+
334
+ Format the footer as:
335
+ ```
336
+ ---
337
+ Status : {badge}
338
+ {Output Artifacts block}
339
+ Next : {suggested command with example arguments}
340
+ ```
341
+
342
+
285
343
  ```
286
344
  /setup-ai-first Complete ✅
287
345
  Next:
@@ -1,6 +1,6 @@
1
- # /smoke-test — Test Live API Endpoints
1
+ # /smoke-test — Smoke Test Live Service or App
2
2
 
3
- Use when service is **already running**. Different from `/run-tests` (no live server needed).
3
+ Use when service/app is **already running**. Different from `/run-tests` (no live server needed).
4
4
 
5
5
  ## Gate
6
6
  # Gate — Universal Entry Procedure
@@ -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
 
@@ -86,7 +86,7 @@ Wait for explicit "Y" or "N" from the user before continuing.
86
86
  - "N" → stop and ask what the user wants to change.
87
87
 
88
88
 
89
- *Note: For this command, the target in Step 1 is a UC-ID from `$ARGUMENTS`. Context loading provides `conventions.service_run` and port information.*
89
+ *Note: For this command, the target in Step 1 is a UC-ID from `$ARGUMENTS`. Context loading provides `conventions.service_run`, port information, and `tech_stack.module`.*
90
90
 
91
91
  ## Context
92
92
  # Context Loader — Load All Project Context
@@ -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}
@@ -256,19 +277,40 @@ Proceed to the next step of the calling command.
256
277
 
257
278
  ---
258
279
 
259
- ## Phase 1 — Find Service URL
280
+ ## Service Detection
281
+
282
+ Read `active_module` from context. Use to select the correct smoke-test approach.
283
+
284
+ | Platform | Modules |
285
+ |---|---|
286
+ | `backend` | `java-spring`, `golang`, `dotnet`, `php-laravel`, `context-engineering` |
287
+ | `web-frontend` | `react`, `nextjs`, `vue`, `nuxt`, `angular` |
288
+ | `mobile` | `flutter`, `react-native`, `ios-swiftui`, `android-compose` |
289
+
290
+ ---
291
+
292
+ ## If `platform_type = backend`
293
+
294
+ ### Phase 1 — Verify service is running
295
+
260
296
  Read `conventions.service_run` from project-context.yaml to determine port.
297
+
261
298
  ```bash
262
- curl -s http://localhost:{port}/health
299
+ # Try common health endpoints (use whichever applies):
300
+ curl -s http://localhost:{port}/health # generic / Go / Node
301
+ curl -s http://localhost:{port}/actuator/health # Spring Boot
302
+ curl -s http://localhost:{port}/ping # some frameworks
263
303
  ```
264
- If not running: "Start with `{conventions.service_run}` from project root."
265
304
 
266
- ## Phase 2 Identify Endpoints
267
- From UC-ID (or `$ARGUMENTS`) → find controller with `@trace.implements={UC-ID}`.
305
+ If not running "Start with `{conventions.service_run}` from project root."
306
+
307
+ ### Phase 2 — Identify endpoints
308
+
309
+ From UC-ID → find controller/handler with `@trace.implements={UC-ID}`.
268
310
  List: method, path, required auth/role.
269
311
 
270
- ## Phase 3 — Get Auth Token (if needed)
271
- Ask:
312
+ ### Phase 3 — Get auth token (if needed)
313
+
272
314
  ```
273
315
  Endpoint requires auth. Options:
274
316
  1. Paste Bearer token (from Postman/DevTools)
@@ -276,10 +318,11 @@ Endpoint requires auth. Options:
276
318
  3. Skip — test public endpoints only
277
319
  ```
278
320
 
279
- ## Phase 4 — Run Smoke Test
321
+ ### Phase 4 — Run
322
+
280
323
  ```bash
281
324
  # GET
282
- curl -s -X GET "http://localhost:{port}/v1/{resource}?page=0&size=5" \
325
+ curl -s -X GET "http://localhost:{port}/v1/{resource}" \
283
326
  -H "Authorization: Bearer {token}" | {JSON_FORMATTER}
284
327
 
285
328
  # POST
@@ -289,7 +332,6 @@ curl -s -X POST "http://localhost:{port}/v1/{resource}" \
289
332
  -d '{"field1": "test_value"}'
290
333
  ```
291
334
 
292
- ## Interpret Results
293
335
  | Result | Meaning |
294
336
  |--------|---------|
295
337
  | 200/201 + correct data | ✅ OK |
@@ -297,9 +339,131 @@ curl -s -X POST "http://localhost:{port}/v1/{resource}" \
297
339
  | 400 | Wrong request body → check required fields |
298
340
  | 401 | Token expired or wrong config |
299
341
  | 403 | Wrong role → check auth rules |
300
- | 500 | Server error → paste into /debug |
342
+ | 500 | Server error → /debug |
301
343
  | Connection refused | Service not running |
302
344
 
345
+ ### If `active_module = context-engineering`
346
+
347
+ #### Phase 1 — Verify pipeline entry point is reachable
348
+
349
+ Run the prompt function directly with a minimal valid input:
350
+
351
+ ```bash
352
+ # Python (pytest / script):
353
+ python -c "from {module}.{function} import {function}; print({function}(input='{test_input}'))"
354
+
355
+ # Or using the project test command with a smoke marker:
356
+ {conventions.test_command} -m smoke -v
357
+ ```
358
+
359
+ #### Phase 2 — Verify output structure
360
+
361
+ Check the output conforms to the expected schema:
362
+
363
+ ```
364
+ Expected output schema: {output fields from @trace or tech-doc}
365
+ Actual output: {paste output here}
366
+ ```
367
+
368
+ #### Phase 3 — Interpret results
369
+
370
+ | Result | Meaning |
371
+ |--------|---------|
372
+ | Output matches schema | ✅ OK |
373
+ | Output present but wrong format | ⚠️ Logic bug → /debug |
374
+ | `APIError` / `AuthenticationError` | API key invalid or service unavailable |
375
+ | `TokenLimitError` | Input too long — check prompt template size |
376
+ | Exception / traceback | Code error → /debug |
377
+
378
+ ---
379
+
380
+ ## If `platform_type = web-frontend`
381
+
382
+ ### Phase 1 — Verify dev server is running
383
+
384
+ ```bash
385
+ # Linux / macOS:
386
+ curl -s -o /dev/null -w "%{http_code}" http://localhost:{port}
387
+
388
+ # Windows (cmd / PowerShell):
389
+ curl -s -o NUL -w "%{http_code}" http://localhost:{port}
390
+
391
+ # Should return 200. If not: start with {conventions.service_run} (e.g., npm run dev)
392
+ ```
393
+
394
+ ### Phase 2 — Run E2E smoke test
395
+
396
+ Identify E2E tool in the project (Playwright or Cypress):
397
+
398
+ ```bash
399
+ # Playwright — run scenarios tagged with this UC:
400
+ npx playwright test --grep "{UC-ID}"
401
+
402
+ # Cypress:
403
+ npx cypress run --spec "cypress/e2e/{UC-ID}*"
404
+ ```
405
+
406
+ If no E2E tests exist yet → open browser and manually verify:
407
+ 1. Navigate to the route for this UC
408
+ 2. Perform the main user action
409
+ 3. Confirm the expected outcome is visible
410
+
411
+ ### Phase 3 — Interpret results
412
+
413
+ | Result | Meaning |
414
+ |--------|---------|
415
+ | All E2E tests pass | ✅ OK |
416
+ | Assertion failed | ⚠️ Logic bug → /debug |
417
+ | `ERR_CONNECTION_REFUSED` | Dev server not running |
418
+ | API returns 4xx/5xx | Backend issue → check backend service |
419
+
420
+ ---
421
+
422
+ ## If `platform_type = mobile`
423
+
424
+ ### Phase 1 — Verify device/emulator is ready
425
+
426
+ ```bash
427
+ # Flutter:
428
+ flutter devices # list connected devices/emulators
429
+ flutter install # install current build on device
430
+
431
+ # React Native:
432
+ npx react-native run-android # build + install on connected Android
433
+ npx react-native run-ios # build + install on iOS simulator
434
+
435
+ # Android (Compose):
436
+ ./gradlew installDebug # install APK on connected device/emulator
437
+
438
+ # iOS (SwiftUI):
439
+ # Open Xcode → select simulator → Product → Run
440
+ ```
441
+
442
+ ### Phase 2 — Manual smoke-test checklist
443
+
444
+ For the UC under test, verify on device:
445
+ 1. Navigate to the screen for this UC
446
+ 2. Perform the main action from the `.feature` Scenario (`When` step)
447
+ 3. Confirm the expected outcome is visible (`Then` step)
448
+ 4. Check for any crash or unexpected error dialog
449
+
450
+ ### Phase 3 — Capture issues if found
451
+
452
+ ```bash
453
+ # Flutter:
454
+ flutter logs
455
+
456
+ # Android:
457
+ adb logcat -d | grep -i "error\|exception\|crash"
458
+
459
+ # iOS:
460
+ # Copy crash log from Xcode → Devices and Simulators → View Device Logs
461
+ ```
462
+
463
+ Paste output into `/debug`.
464
+
465
+ ---
466
+
303
467
  ## Output
304
468
 
305
469
  # Report Footer — Standard Command Output Format
@@ -330,6 +494,7 @@ Suggest the logical next command based on workflow phase:
330
494
 
331
495
  | Current command | Suggest next |
332
496
  |-------------------------|-----------------------------------------------|
497
+ | /setup-ai-first | `/define-product` to start your first feature |
333
498
  | /define-product | `/generate-prd {product-definition-file}` |
334
499
  | /generate-prd | `/refine-prd {prd-file}` then `/review-context {prd-file}` |
335
500
  | /refine-prd | Open Review Board → update PRD → `/review-context {prd-file}` |
@@ -338,13 +503,13 @@ Suggest the logical next command based on workflow phase:
338
503
  | /review-context (BDD) | `/generate-tech-docs {UC-ID}` if APPROVED; regenerate if NEEDS_FIX |
339
504
  | /generate-tech-docs | `/review-tech-docs {tech-design-file}` |
340
505
  | /review-tech-docs | `/generate-code {feature-file}` if APPROVED; fix doc if NEEDS_FIX |
341
- | /generate-code | `/generate-tests {UC-ID}` |
506
+ | /generate-code | First gen → `/review-code {UC-ID}`; re-gen → `/generate-tests {UC-ID}` |
342
507
  | /generate-tests | `/run-tests {UC-ID}` |
343
508
  | /run-tests (passing) | `/review-code {UC-ID}` |
344
509
  | /run-tests (failing) | `/fix-bug {ticket-id}` or `/debug {error}` |
345
510
  | /review-code | `/smoke-test {UC-ID}` or create PR |
346
511
  | /smoke-test | Create PR and link to ticket |
347
- | /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 |
348
513
  | /fix-bug | Create PR and link to ticket |
349
514
  | /debug | `/fix-bug {ticket-id}` if fix needed |
350
515
 
@@ -359,8 +524,13 @@ Next : {suggested command with example arguments}
359
524
 
360
525
  ```
361
526
  /smoke-test Report — {UC-ID}
362
- | Method | Path | Status | Result |
363
- |--------|------|--------|--------|
527
+ Platform: {backend | web-frontend | mobile}
528
+ | Endpoint / Flow | Status | Result |
529
+ |-----------------------|-------------|---------|
530
+ | {method} {path/screen}| ✅/⚠️/❌ | {notes} |
531
+
532
+ Status legend: ✅ = OK | ⚠️ = Responded but wrong data / logic bug | ❌ = Error / not running
533
+
364
534
  Issues: {describe any failures}
365
- Next: /debug {stacktrace} OR /fix-bug {TICKET_ID} OR ready to PR
535
+ Next: /debug (paste error interactively) OR /fix-bug {TICKET_ID} OR ready to PR
366
536
  ```