@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
package/bin/index.js CHANGED
@@ -19,30 +19,64 @@ const showHelp = args.includes('--help') || args.includes('-h');
19
19
  const moduleIdx = args.indexOf('--module');
20
20
  const moduleName = moduleIdx !== -1 ? args[moduleIdx + 1] : null;
21
21
 
22
+ // --services backend:java-spring,web-admin:react,app-mobile:flutter
23
+ const servicesIdx = args.indexOf('--services');
24
+ const servicesRaw = servicesIdx !== -1 ? args[servicesIdx + 1] : null;
25
+ const serviceList = servicesRaw
26
+ ? servicesRaw.split(',').map(s => {
27
+ const [name, mod] = s.trim().split(':');
28
+ return { name: name.trim(), module: (mod || '').trim() };
29
+ }).filter(s => s.name)
30
+ : [];
31
+
22
32
  const AVAILABLE_MODULES = [
23
33
  'java-spring', 'angular', 'react', 'nextjs',
24
34
  'dotnet', 'golang', 'php-laravel', 'context-engineering',
35
+ 'flutter', 'react-native', 'ios-swiftui', 'android-compose',
25
36
  ];
26
37
 
38
+ // Language/framework labels per module (for generated project-context.yaml)
39
+ const MODULE_STACK = {
40
+ 'java-spring': { language: 'Java 17', framework: 'Spring Boot 3.x' },
41
+ 'golang': { language: 'Go', framework: 'Gin / Echo' },
42
+ 'dotnet': { language: 'C#', framework: '.NET / ASP.NET Core' },
43
+ 'php-laravel': { language: 'PHP', framework: 'Laravel' },
44
+ 'context-engineering': { language: 'TypeScript', framework: 'Node.js' },
45
+ 'react': { language: 'TypeScript', framework: 'React' },
46
+ 'nextjs': { language: 'TypeScript', framework: 'Next.js' },
47
+ 'vue': { language: 'TypeScript', framework: 'Vue 3' },
48
+ 'nuxt': { language: 'TypeScript', framework: 'Nuxt 3' },
49
+ 'angular': { language: 'TypeScript', framework: 'Angular' },
50
+ 'flutter': { language: 'Dart', framework: 'Flutter' },
51
+ 'react-native': { language: 'TypeScript', framework: 'React Native / Expo' },
52
+ 'ios-swiftui': { language: 'Swift', framework: 'SwiftUI' },
53
+ 'android-compose': { language: 'Kotlin', framework: 'Jetpack Compose' },
54
+ };
55
+
27
56
  if (showHelp) {
28
57
  console.log('Usage: npx @anhth2/spec-driven-dev-plugin [options]');
29
58
  console.log('');
30
59
  console.log('Install modes:');
31
- console.log(' --init NEW: Install framework to .agent/ + create shortcuts in .claude/commands/');
32
- console.log(' Recommended for new projects. Run upgrade.sh to upgrade later.');
33
- console.log(' --project Install full commands to ./.claude/commands/ (project-scoped, legacy)');
34
- console.log(' (no flag) Install full commands to ~/.claude/commands/ (global, legacy)');
60
+ console.log(' --init Install framework to .agent/ + create shortcuts in .claude/commands/');
61
+ console.log(' Recommended for new projects. Run upgrade.sh to upgrade later.');
62
+ console.log(' --project Install full commands to ./.claude/commands/ (project-scoped, legacy)');
63
+ console.log(' (no flag) Install full commands to ~/.claude/commands/ (global, legacy)');
35
64
  console.log('');
36
65
  console.log('Options:');
37
- console.log(' --module <name> Copy stack module to .agent/modules/<name>/');
38
- console.log(' --hooks Install data-guard hook to .claude/hooks/ + update .claude/settings.json');
66
+ console.log(' --module <name> Copy stack module to .agent/modules/<name>/');
67
+ console.log(' --services <list> Monorepo setup: install into each service subfolder in one command.');
68
+ console.log(' Format: name:module,name:module,...');
69
+ console.log(' Example: backend:java-spring,web-admin:react,app-mobile:flutter');
70
+ console.log(' --hooks Install data-guard hook to .claude/hooks/ + update .claude/settings.json');
39
71
  console.log('');
40
72
  console.log('Available modules:');
41
73
  AVAILABLE_MODULES.forEach(m => console.log(` ${m}`));
42
74
  console.log('');
43
75
  console.log('Examples:');
44
- console.log(' npx @anhth2/spec-driven-dev-plugin --init # new project setup');
76
+ console.log(' npx @anhth2/spec-driven-dev-plugin --init # single-service project');
45
77
  console.log(' npx @anhth2/spec-driven-dev-plugin --init --module java-spring # with stack module');
78
+ console.log(' npx @anhth2/spec-driven-dev-plugin --init \\');
79
+ console.log(' --services backend:java-spring,web-admin:react,app-mobile:flutter # monorepo setup');
46
80
  console.log(' npx @anhth2/spec-driven-dev-plugin --project --hooks # legacy project install');
47
81
  process.exit(0);
48
82
  }
@@ -144,7 +178,128 @@ if (isInit) {
144
178
  installDataGuardHook();
145
179
  }
146
180
 
147
- // 5. Summary
181
+ // 5. Monorepo: install into each service subfolder
182
+ if (serviceList.length > 0) {
183
+ console.log('');
184
+ console.log(`Setting up ${serviceList.length} service workspace(s)...`);
185
+
186
+ for (const svc of serviceList) {
187
+ const svcDir = path.join(projectRoot, svc.name);
188
+ const svcAgentDir = path.join(svcDir, '.agent');
189
+ const svcClaudeCmds = path.join(svcDir, '.claude', 'commands');
190
+
191
+ console.log('');
192
+ console.log(` ── ${svc.name} (${svc.module || 'no module'}) ──`);
193
+
194
+ // Create service dir if needed
195
+ fs.mkdirSync(svcDir, { recursive: true });
196
+
197
+ // Copy core → service/.agent/
198
+ copyDirRecursive(coreDir, svcAgentDir);
199
+ console.log(` ✅ ${svc.name}/.agent/`);
200
+
201
+ // Install module
202
+ if (svc.module) {
203
+ if (!AVAILABLE_MODULES.includes(svc.module)) {
204
+ console.log(` ⚠️ Unknown module "${svc.module}" — skipped`);
205
+ } else {
206
+ const srcMod = path.join(ROOT, 'modules', svc.module);
207
+ const destMod = path.join(svcAgentDir, 'modules', svc.module);
208
+ if (fs.existsSync(srcMod)) {
209
+ fs.mkdirSync(destMod, { recursive: true });
210
+ copyDirRecursive(srcMod, destMod);
211
+ console.log(` ✅ ${svc.name}/.agent/modules/${svc.module}/`);
212
+ }
213
+ }
214
+ }
215
+
216
+ // Create .claude/commands/ shortcuts
217
+ fs.mkdirSync(svcClaudeCmds, { recursive: true });
218
+ const svcCmdFiles = fs.readdirSync(path.join(svcAgentDir, 'commands')).filter(f => f.endsWith('.md'));
219
+ for (const cmdFile of svcCmdFiles) {
220
+ const cmdName = cmdFile.replace('.md', '');
221
+ const shortcut =
222
+ `# /${cmdName}\n\nRead the full command definition from \`.agent/commands/${cmdFile}\`` +
223
+ ` and execute it with arguments: $ARGUMENTS\n`;
224
+ fs.writeFileSync(path.join(svcClaudeCmds, cmdFile), shortcut, 'utf8');
225
+ }
226
+ console.log(` ✅ ${svc.name}/.claude/commands/ (${svcCmdFiles.length} shortcuts)`);
227
+
228
+ // Generate project-context.yaml (only if not already present)
229
+ const ctxPath = path.join(svcAgentDir, 'project-context.yaml');
230
+ if (!fs.existsSync(ctxPath)) {
231
+ const stack = MODULE_STACK[svc.module] || { language: 'TODO', framework: 'TODO' };
232
+ const yaml = [
233
+ `project:`,
234
+ ` name: ${path.basename(projectRoot)} — ${svc.name}`,
235
+ ``,
236
+ `tech_stack:`,
237
+ ` language: ${stack.language}`,
238
+ ` framework: ${stack.framework}`,
239
+ ` module: ${svc.module || 'TODO'}`,
240
+ ``,
241
+ `conventions:`,
242
+ ` ticket_prefix: FEAT`,
243
+ ``,
244
+ `paths:`,
245
+ ` specs_dir: ../specs/bdd`,
246
+ ` prd_dir: ../specs/prd`,
247
+ ` tech_docs_dir: ../specs/tech-docs`,
248
+ ` domain_knowledge_dir: ../specs/domain-knowledge`,
249
+ ` business_dictionary: ../specs/domain-knowledge/business-dictionary.md`,
250
+ ` core_entities: ../specs/domain-knowledge/core-entities.md`,
251
+ ` refinement_dir: ../specs/.review`,
252
+ ` product_definitions_dir: ../specs/product-definition`,
253
+ ` trace_dir: ../.trace`,
254
+ ``,
255
+ ].join('\n');
256
+ fs.writeFileSync(ctxPath, yaml, 'utf8');
257
+ console.log(` ✅ ${svc.name}/.agent/project-context.yaml (generated)`);
258
+ } else {
259
+ console.log(` ℹ️ ${svc.name}/.agent/project-context.yaml (already exists — skipped)`);
260
+ }
261
+ }
262
+
263
+ // Generate root project-context.yaml for PO/BA (only if not present)
264
+ const rootCtxPath = path.join(agentDir, 'project-context.yaml');
265
+ if (!fs.existsSync(rootCtxPath)) {
266
+ const svcYaml = serviceList.map(s => [
267
+ ` - name: ${s.name}`,
268
+ ` module: ${s.module || 'TODO'}`,
269
+ ` description: ""`,
270
+ ].join('\n')).join('\n');
271
+ const rootYaml = [
272
+ `project:`,
273
+ ` name: ${path.basename(projectRoot)}`,
274
+ ``,
275
+ `tech_stack:`,
276
+ ` language: multi-service`,
277
+ ``,
278
+ `services:`,
279
+ svcYaml,
280
+ ``,
281
+ `conventions:`,
282
+ ` ticket_prefix: FEAT`,
283
+ ``,
284
+ `paths:`,
285
+ ` specs_dir: specs/bdd`,
286
+ ` prd_dir: specs/prd`,
287
+ ` tech_docs_dir: specs/tech-docs`,
288
+ ` domain_knowledge_dir: specs/domain-knowledge`,
289
+ ` business_dictionary: specs/domain-knowledge/business-dictionary.md`,
290
+ ` core_entities: specs/domain-knowledge/core-entities.md`,
291
+ ` refinement_dir: specs/.review`,
292
+ ` product_definitions_dir: specs/product-definition`,
293
+ ` trace_dir: .trace`,
294
+ ``,
295
+ ].join('\n');
296
+ fs.writeFileSync(rootCtxPath, rootYaml, 'utf8');
297
+ console.log('');
298
+ console.log(' ✅ .agent/project-context.yaml (root — PO/BA workspace, generated)');
299
+ }
300
+ }
301
+
302
+ // 6. Summary
148
303
  console.log('');
149
304
  if (failedShortcuts.length > 0) {
150
305
  console.log(`⚠️ ${commandFiles.length - failedShortcuts.length}/${commandFiles.length} shortcuts created.`);
@@ -152,9 +307,23 @@ if (isInit) {
152
307
  }
153
308
  console.log(`✅ Framework v${frameworkVersion} installed!`);
154
309
  console.log('');
155
- console.log('Next steps:');
156
- console.log(' 1. Open Claude Code and run /setup-ai-first');
157
- console.log(' 2. Commit .agent/ to git so your whole team has the framework');
310
+ if (serviceList.length > 0) {
311
+ console.log('Monorepo workspaces ready:');
312
+ console.log(' PO/BA → open Claude Code at project root');
313
+ serviceList.forEach(s => {
314
+ console.log(` ${s.name.padEnd(10)} → open Claude Code at ./${s.name}/`);
315
+ });
316
+ console.log('');
317
+ console.log('Next steps:');
318
+ console.log(' 1. Fill in CLAUDE.md in each service subfolder (architecture + coding standards)');
319
+ console.log(' 2. Fill in .agent/project-context.yaml in each subfolder (review generated values)');
320
+ console.log(' 3. PO/BA: open root in Claude Code and run /setup-ai-first');
321
+ console.log(' 4. Commit everything to git so the whole team has the framework');
322
+ } else {
323
+ console.log('Next steps:');
324
+ console.log(' 1. Open Claude Code and run /setup-ai-first');
325
+ console.log(' 2. Commit .agent/ to git so your whole team has the framework');
326
+ }
158
327
  console.log('');
159
328
  console.log('To upgrade later: bash scripts/upgrade.sh');
160
329
  console.log(' (or: npx @anhth2/spec-driven-dev-plugin@latest --init)');
package/commands/debug.md CHANGED
@@ -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