@anhth2/spec-driven-dev-plugin 0.5.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 (152) hide show
  1. package/ARCHITECTURE.md +243 -0
  2. package/bin/build.js +230 -0
  3. package/bin/index.js +311 -0
  4. package/commands/debug.md +374 -0
  5. package/commands/debug.tmpl +77 -0
  6. package/commands/define-product.md +451 -0
  7. package/commands/define-product.tmpl +154 -0
  8. package/commands/fix-bug.md +379 -0
  9. package/commands/fix-bug.tmpl +82 -0
  10. package/commands/generate-bdd.md +591 -0
  11. package/commands/generate-bdd.tmpl +294 -0
  12. package/commands/generate-code.md +395 -0
  13. package/commands/generate-code.tmpl +98 -0
  14. package/commands/generate-prd.md +488 -0
  15. package/commands/generate-prd.tmpl +191 -0
  16. package/commands/generate-tech-docs.md +362 -0
  17. package/commands/generate-tech-docs.tmpl +65 -0
  18. package/commands/generate-tests.md +377 -0
  19. package/commands/generate-tests.tmpl +80 -0
  20. package/commands/refine-prd.md +408 -0
  21. package/commands/refine-prd.tmpl +111 -0
  22. package/commands/review-code.md +354 -0
  23. package/commands/review-code.tmpl +57 -0
  24. package/commands/review-context.md +646 -0
  25. package/commands/review-context.tmpl +349 -0
  26. package/commands/review-tech-docs.md +518 -0
  27. package/commands/review-tech-docs.tmpl +221 -0
  28. package/commands/run-tests.md +343 -0
  29. package/commands/run-tests.tmpl +46 -0
  30. package/commands/setup-ai-first.md +278 -0
  31. package/commands/setup-ai-first.tmpl +197 -0
  32. package/commands/smoke-test.md +366 -0
  33. package/commands/smoke-test.tmpl +69 -0
  34. package/commands/validate-traces.md +529 -0
  35. package/commands/validate-traces.tmpl +232 -0
  36. package/core/FRAMEWORK_VERSION +1 -0
  37. package/core/commands/debug.md +374 -0
  38. package/core/commands/define-product.md +451 -0
  39. package/core/commands/fix-bug.md +379 -0
  40. package/core/commands/generate-bdd.md +591 -0
  41. package/core/commands/generate-code.md +395 -0
  42. package/core/commands/generate-prd.md +488 -0
  43. package/core/commands/generate-tech-docs.md +362 -0
  44. package/core/commands/generate-tests.md +377 -0
  45. package/core/commands/refine-prd.md +408 -0
  46. package/core/commands/review-code.md +354 -0
  47. package/core/commands/review-context.md +646 -0
  48. package/core/commands/review-tech-docs.md +518 -0
  49. package/core/commands/run-tests.md +343 -0
  50. package/core/commands/setup-ai-first.md +278 -0
  51. package/core/commands/smoke-test.md +366 -0
  52. package/core/commands/validate-traces.md +529 -0
  53. package/core/hooks/data-guard.js +141 -0
  54. package/core/hooks/settings.json +18 -0
  55. package/core/modules/angular/architecture-snippets/component-patterns.md +187 -0
  56. package/core/modules/angular/module.yaml +6 -0
  57. package/core/modules/angular/stack-profile.yaml +38 -0
  58. package/core/modules/context-engineering/architecture-snippets/context-design.md +119 -0
  59. package/core/modules/context-engineering/module.yaml +9 -0
  60. package/core/modules/context-engineering/stack-profile.yaml +61 -0
  61. package/core/modules/dotnet/architecture-snippets/clean-arch.md +160 -0
  62. package/core/modules/dotnet/module.yaml +6 -0
  63. package/core/modules/dotnet/stack-profile.yaml +50 -0
  64. package/core/modules/golang/architecture-snippets/domain-layout.md +283 -0
  65. package/core/modules/golang/module.yaml +6 -0
  66. package/core/modules/golang/stack-profile.yaml +40 -0
  67. package/core/modules/java-spring/architecture-snippets/layered-arch.md +201 -0
  68. package/core/modules/java-spring/module.yaml +15 -0
  69. package/core/modules/java-spring/stack-profile.yaml +28 -0
  70. package/core/modules/nextjs/architecture-snippets/app-router-patterns.md +269 -0
  71. package/core/modules/nextjs/module.yaml +14 -0
  72. package/core/modules/nextjs/stack-profile.yaml +74 -0
  73. package/core/modules/php-laravel/architecture-snippets/service-repository.md +302 -0
  74. package/core/modules/php-laravel/module.yaml +15 -0
  75. package/core/modules/php-laravel/stack-profile.yaml +56 -0
  76. package/core/modules/react/architecture-snippets/hooks-query-patterns.md +254 -0
  77. package/core/modules/react/module.yaml +14 -0
  78. package/core/modules/react/stack-profile.yaml +63 -0
  79. package/core/rules/data-protection.md +80 -0
  80. package/core/rules/workflow.md +44 -0
  81. package/core/skills/code/SKILL.md +526 -0
  82. package/core/skills/debug/SKILL.md +584 -0
  83. package/core/skills/discovery/SKILL.md +363 -0
  84. package/core/skills/prd/SKILL.md +456 -0
  85. package/core/skills/setup-ai-first/SKILL.md +160 -0
  86. package/core/skills/spec/SKILL.md +361 -0
  87. package/core/skills/test/SKILL.md +862 -0
  88. package/core/steps/context-loader.md +163 -0
  89. package/core/steps/gate.md +81 -0
  90. package/core/steps/report-footer.md +53 -0
  91. package/core/steps/spawn-agent.md +123 -0
  92. package/core/templates/architecture.template.md +113 -0
  93. package/core/templates/feature.template +259 -0
  94. package/core/templates/platform-guide.template.md +145 -0
  95. package/core/templates/prd.template.md +312 -0
  96. package/core/templates/product-definition.template.md +168 -0
  97. package/core/templates/project-context.yaml +78 -0
  98. package/hooks/data-guard.js +141 -0
  99. package/hooks/settings.json +18 -0
  100. package/modules/angular/architecture-snippets/component-patterns.md +187 -0
  101. package/modules/angular/module.yaml +6 -0
  102. package/modules/angular/stack-profile.yaml +38 -0
  103. package/modules/context-engineering/architecture-snippets/context-design.md +119 -0
  104. package/modules/context-engineering/module.yaml +9 -0
  105. package/modules/context-engineering/stack-profile.yaml +61 -0
  106. package/modules/dotnet/architecture-snippets/clean-arch.md +160 -0
  107. package/modules/dotnet/module.yaml +6 -0
  108. package/modules/dotnet/stack-profile.yaml +50 -0
  109. package/modules/golang/architecture-snippets/domain-layout.md +283 -0
  110. package/modules/golang/module.yaml +6 -0
  111. package/modules/golang/stack-profile.yaml +40 -0
  112. package/modules/java-spring/architecture-snippets/layered-arch.md +201 -0
  113. package/modules/java-spring/module.yaml +15 -0
  114. package/modules/java-spring/stack-profile.yaml +28 -0
  115. package/modules/nextjs/architecture-snippets/app-router-patterns.md +269 -0
  116. package/modules/nextjs/module.yaml +14 -0
  117. package/modules/nextjs/stack-profile.yaml +74 -0
  118. package/modules/php-laravel/architecture-snippets/service-repository.md +302 -0
  119. package/modules/php-laravel/module.yaml +15 -0
  120. package/modules/php-laravel/stack-profile.yaml +56 -0
  121. package/modules/react/architecture-snippets/hooks-query-patterns.md +254 -0
  122. package/modules/react/module.yaml +14 -0
  123. package/modules/react/stack-profile.yaml +63 -0
  124. package/package.json +42 -0
  125. package/rules/data-protection.md +80 -0
  126. package/rules/workflow.md +44 -0
  127. package/scripts/init.sh +49 -0
  128. package/scripts/upgrade.sh +94 -0
  129. package/skills/code/SKILL.md +526 -0
  130. package/skills/code/SKILL.tmpl +176 -0
  131. package/skills/debug/SKILL.md +584 -0
  132. package/skills/debug/SKILL.tmpl +262 -0
  133. package/skills/discovery/SKILL.md +363 -0
  134. package/skills/discovery/SKILL.tmpl +147 -0
  135. package/skills/prd/SKILL.md +456 -0
  136. package/skills/prd/SKILL.tmpl +188 -0
  137. package/skills/setup-ai-first/SKILL.md +160 -0
  138. package/skills/setup-ai-first/SKILL.tmpl +107 -0
  139. package/skills/spec/SKILL.md +361 -0
  140. package/skills/spec/SKILL.tmpl +174 -0
  141. package/skills/test/SKILL.md +862 -0
  142. package/skills/test/SKILL.tmpl +296 -0
  143. package/steps/context-loader.md +163 -0
  144. package/steps/gate.md +81 -0
  145. package/steps/report-footer.md +53 -0
  146. package/steps/spawn-agent.md +123 -0
  147. package/templates/architecture.template.md +113 -0
  148. package/templates/feature.template +259 -0
  149. package/templates/platform-guide.template.md +145 -0
  150. package/templates/prd.template.md +312 -0
  151. package/templates/product-definition.template.md +168 -0
  152. package/templates/project-context.yaml +78 -0
@@ -0,0 +1,584 @@
1
+ ---
2
+ description: Fixes bugs with full workflow (branch, test, commit), performs quick debug analysis of errors or unexpected behavior, or validates traceability coverage between specs and code. Trigger when: "/fix-bug", "/debug", "/validate-traces", "fix bug", "sửa bug", "debug lỗi", "phân tích lỗi", "tại sao lỗi này", "validate traces", "kiểm tra traceability", "coverage matrix", "trace drift".
3
+ ---
4
+
5
+ # Debug & Quality Skills — Fix Bug, Debug, Validate Traces
6
+
7
+ This skill handles: `/fix-bug` (full bug fix workflow), `/debug` (quick analysis), and `/validate-traces` (traceability coverage check).
8
+
9
+ ---
10
+
11
+ ## /fix-bug — Full Bug Fix Workflow
12
+
13
+ ### Input
14
+
15
+ Accept: ticket ID (e.g. `PROJ-123`) or a direct bug description.
16
+
17
+ ### Phase 1 — Gather Information
18
+
19
+ If ticket ID provided:
20
+ - Fetch ticket details if Jira/issue tracker is connected
21
+ - Otherwise ask user to paste: title, steps to reproduce, expected vs actual
22
+
23
+ If no ticket:
24
+ **CHECKPOINT** — Ask:
25
+ 1. Where does the bug occur? (service, endpoint, flow)
26
+ 2. Steps to reproduce?
27
+ 3. Expected vs Actual behavior?
28
+ 4. Error log / stack trace (if any)?
29
+
30
+ ### Phase 2 — Root Cause Analysis
31
+
32
+ # Context Loader — Load All Project Context
33
+
34
+ Execute these steps in order. Store everything in memory for the duration of the command session.
35
+
36
+ **Priority guide (anti-lost-in-middle):**
37
+ - Steps 1–2 are PROJECT-CONFIG — loaded first, resolve all paths and metadata.
38
+ - Step 3 is CRITICAL — architecture + coding standards, the highest-priority facts for generation.
39
+ - Step 4 is SAFETY — data protection rules, enforced silently for the entire session.
40
+ - Steps 5–6 are DOMAIN KNOWLEDGE — terminology and entity definitions.
41
+ - Step 7 is the WORKING MEMORY RECAP — locks critical facts into the top of working memory.
42
+
43
+ ---
44
+
45
+ ## Step 1 — [PROJECT-CONFIG] Load project-context.yaml
46
+
47
+ Read `.agent/project-context.yaml`. Extract and store:
48
+
49
+ **Tech Stack:**
50
+ - `tech_stack.language` → active language (e.g., Java 17, TypeScript, C#, Go)
51
+ - `tech_stack.framework` → active framework (e.g., Spring Boot 3.2, Angular 17, .NET 8)
52
+ - `tech_stack.build_tool` → build tool (e.g., Maven, npm, dotnet, go)
53
+ - `tech_stack.test_framework` → test framework (e.g., JUnit 5 + Mockito, Jest, xUnit)
54
+ - `tech_stack.database` → database (e.g., PostgreSQL, MySQL, MongoDB)
55
+ - `tech_stack.module` → active module profile (e.g., java-spring, angular, dotnet, golang, context-engineering)
56
+
57
+ **Conventions:**
58
+ - `conventions.build_command` → how to compile/build
59
+ - `conventions.test_command` → how to run tests
60
+ - `conventions.service_run` → how to start the service
61
+ - `conventions.ticket_prefix` → ticket ID prefix (e.g., PROJ, FEAT, UC)
62
+
63
+ **Domains:**
64
+ - `domains` → list of active business domains
65
+
66
+ **Paths (if present):**
67
+ - `paths.specs_dir` → BDD specs root
68
+ - `paths.prd_dir` → PRD documents root
69
+ - `paths.refinement_dir` → findings/review output dir
70
+ - `paths.product_definitions_dir` → product definitions root
71
+ - `paths.domain_knowledge_dir` → domain knowledge root
72
+ - `paths.business_dictionary` → path to business-dictionary.md
73
+ - `paths.core_entities` → path to core-entities.md
74
+ - `paths.tech_docs_dir` → technical documentation root
75
+ - `paths.trace_dir` → trace state directory
76
+
77
+ If `paths` section is absent, use these defaults:
78
+ - `specs_dir` = `specs/bdd`
79
+ - `prd_dir` = `specs/prd`
80
+ - `refinement_dir` = `.agent/review`
81
+ - `product_definitions_dir` = `specs/product-definition`
82
+ - `domain_knowledge_dir` = `specs/domain-knowledge`
83
+ - `business_dictionary` = `specs/domain-knowledge/business-dictionary.md`
84
+ - `core_entities` = `specs/domain-knowledge/core-entities.md`
85
+ - `tech_docs_dir` = `tech-docs`
86
+ - `trace_dir` = `.trace`
87
+
88
+ If `tech_stack.module` is set, also load `.agent/modules/{module}/stack-profile.yaml` if it exists.
89
+
90
+ ---
91
+
92
+ ## Step 2 — [PROJECT-CONFIG] Load module stack profile (conditional)
93
+
94
+ If `tech_stack.module` is set, read `.agent/modules/{module}/stack-profile.yaml`.
95
+ Merge framework-specific conventions (layer patterns, test patterns, naming rules) into the loaded context.
96
+ If the file does not exist → skip silently.
97
+
98
+ ---
99
+
100
+ ## Step 3 — [CRITICAL] Load CLAUDE.md
101
+
102
+ *This is the highest-priority context — it defines HOW to write code and documents for this project.*
103
+
104
+ Read `CLAUDE.md`. Extract and store:
105
+
106
+ - **§1 Project Overview** → project name, language, framework, build/test commands, domains
107
+ - **§2 Architecture** → layer order (e.g., Controller → Facade → Service → Repository), architectural rules
108
+ - **§3 Coding Standards** → naming conventions (classes, methods), response wrapper type, forbidden patterns
109
+ - **§5 Error Handling** → exception types, HTTP status code mapping, not-found exception class name
110
+ - **§7 Git Conventions** → branch naming pattern, commit message format
111
+
112
+ If `CLAUDE.md` does not exist → note it as missing and continue with project-context.yaml data only.
113
+
114
+ ---
115
+
116
+ ## Step 4 — [SAFETY] Load Data Protection Rules
117
+
118
+ Read `.agent/rules/data-protection.md` (or `rules/data-protection.md` from the framework installation).
119
+
120
+ Store the sensitive file patterns — you must **never** read, write, display, or reference content from files matching those patterns for the entire session.
121
+
122
+ If neither file exists → apply built-in defaults: never access `.env*`, `*.key`, `*.pem`, `*secret*`, `*password*`, `*credential*`.
123
+
124
+ ---
125
+
126
+ ## Step 5 — [DOMAIN] Load Business Dictionary (conditional)
127
+
128
+ Check if the business dictionary file exists (use `paths.business_dictionary` resolved in Step 1).
129
+
130
+ If it exists, read it and extract:
131
+ - **Canonical Terms** → complete list of approved terms and their definitions
132
+ - **Banned Terms** → complete list of banned terms and their canonical replacements
133
+ - **Status / Enum Registry** → allowed enum values per entity
134
+
135
+ Store the banned terms list for **active enforcement** throughout the command session:
136
+ - When generating any text (PRD, BDD, code comments, tech docs), verify no banned terms appear
137
+ - Replace banned terms with their canonical equivalents automatically
138
+
139
+ If the file does not exist → skip silently. Do not warn or block.
140
+
141
+ ---
142
+
143
+ ## Step 6 — [DOMAIN] Load Core Entities (conditional)
144
+
145
+ Check if the core entities file exists at `paths.core_entities` (resolved in Step 1).
146
+ Default path: `specs/domain-knowledge/core-entities.md`.
147
+
148
+ If it exists, read it and store:
149
+ - **Entity catalog** → for each entity: its name, purpose, owner service, key fields (name + type), business invariants, and relationships
150
+ - **Field name registry** → canonical field names to use in generated code and documents
151
+ - **Relationship map** → how entities relate to each other (1:N, N:N, embedded, etc.)
152
+
153
+ **How to use this catalog:**
154
+ - When generating code: use the field names, types, and relationships defined here — do NOT infer from existing code
155
+ - When generating PRD/BDD: reference entity names from this catalog for consistency
156
+ - When generating tech-docs: use this catalog as the source-of-truth for entity definitions
157
+
158
+ If the file does not exist → skip silently.
159
+
160
+ ---
161
+
162
+ ## Step 7 — [RECAP] Working Memory Recap (anti-lost-in-middle)
163
+
164
+ After loading all context, synthesize and output a compact summary block.
165
+ This recap ensures the most critical facts are stated at the END of context loading
166
+ (recency effect — freshest in working memory when the task begins).
167
+
168
+ Output exactly this block:
169
+ ```
170
+ [CTX LOADED]
171
+ Stack : {language} / {framework} / {database}
172
+ Layers : {layer order from CLAUDE.md §2, e.g., Controller → Facade → Service → Repository}
173
+ Ticket : {ticket_prefix}-
174
+ Dict : {loaded — N canonical terms, M banned terms | missing}
175
+ Entities : {loaded — EntityA, EntityB, EntityC | missing}
176
+ Status : {FULL | PARTIAL — missing: CLAUDE.md / business-dict / core-entities | MINIMAL}
177
+ ```
178
+
179
+ If any CRITICAL file is missing (CLAUDE.md), flag it clearly so the user can decide whether to proceed.
180
+
181
+ ---
182
+
183
+ ## Context Load Complete
184
+
185
+ After completing all steps, you have loaded:
186
+ - Project identity, tech stack, module conventions
187
+ - Architecture rules and layer order ← **[CRITICAL — hold in working memory]**
188
+ - Coding standards and naming conventions ← **[CRITICAL — hold in working memory]**
189
+ - Data protection rules (sensitive file patterns to never access)
190
+ - Terminology rules with banned-term list ← **[DOMAIN — apply to every generated word]**
191
+ - Entity catalog (field names, types, invariants) ← **[DOMAIN — use for code generation]**
192
+ - All configured paths
193
+
194
+ Proceed to the next step of the calling command.
195
+
196
+
197
+ Trace through layers (from CLAUDE.md architecture):
198
+ 1. Identify the service/module from the failing endpoint/feature
199
+ 2. Read relevant code files, layer by layer
200
+ 3. Match against common bug patterns:
201
+
202
+ | Bug Type | Common Location | How to Check |
203
+ |----------|----------------|--------------|
204
+ | Wrong response data | Data mapping layer | Check field mapping, DTO conversions |
205
+ | 400 Bad Request | Input validation | Check DTO constraints, required fields |
206
+ | 403 Forbidden | Auth configuration | Check role-based access rules |
207
+ | 404 Not Found | Repository query | Check find method, ID types |
208
+ | Slow query / N+1 | Data access layer | Check for missing JOIN FETCH or batch loading |
209
+ | Null Pointer | Missing null checks, optional not handled | Check Optional.orElseThrow usage |
210
+ | Transaction rollback | Missing/wrong transaction scope | Check @Transactional on service methods |
211
+ | Stale cache | Missing cache eviction after write | Check cache invalidation on write operations |
212
+ | Type mismatch in query | Filter/specification code | Check field types in query predicates |
213
+ | Cross-service timeout | External service call | Check URL config, fallback behavior |
214
+
215
+ **CHECKPOINT — Root Cause Report:**
216
+
217
+ ```
218
+ Root Cause Analysis — {TICKET_ID}:
219
+
220
+ Bug: {description}
221
+ Affected module: {module/service}
222
+ Root cause: {specific technical analysis}
223
+ Affected files:
224
+ - {file}: {what's wrong}
225
+
226
+ Proposed fix:
227
+ - {file}: {what to change}
228
+
229
+ Regression risk: Low / Medium / High
230
+ → Reason: {explanation}
231
+
232
+ Proceed with fix? (Y/N)
233
+ ```
234
+
235
+ Wait for user confirmation.
236
+
237
+ ### Phase 3 — Implement Fix
238
+
239
+ ```bash
240
+ git checkout -b fix/{TICKET_ID}-{short-description}
241
+ ```
242
+
243
+ Apply the fix exactly as analyzed. Follow CLAUDE.md coding standards — do not introduce new violations.
244
+
245
+ Add traceability annotation if the file has `@trace.implements`:
246
+ ```
247
+ // @trace.implements={UC-ID}-SC{N}
248
+ // @trace.fixes={TICKET_ID}
249
+ // @trace.root_cause={brief description}
250
+ ```
251
+
252
+ ### Phase 4 — Regression Test
253
+
254
+ Generate a regression test if one doesn't exist:
255
+ ```
256
+ // @trace.verifies={UC-ID}
257
+ // @trace.regression={TICKET_ID}
258
+ Test: "Regression {TICKET_ID}: {bug description}"
259
+ → Reproduce the exact bug scenario
260
+ → Assert the fix works correctly
261
+ ```
262
+
263
+ Run the test: `{TEST_COMMAND_FOR_CLASS}`
264
+
265
+ If test fails → debug and fix (max 3 iterations).
266
+
267
+ ### Phase 5 — Build Verify
268
+
269
+ ```bash
270
+ {BUILD_COMMAND} # max 3 retries
271
+ ```
272
+
273
+ ### Phase 6 — Commit & Push
274
+
275
+ ```bash
276
+ git add {changed files}
277
+ git commit -m "fix({TICKET_ID}): {brief description}"
278
+ git push -u origin fix/{TICKET_ID}-{slug}
279
+ ```
280
+
281
+ ### Output
282
+
283
+ ```
284
+ /fix-bug Complete — {TICKET_ID}
285
+
286
+ ## Root Cause
287
+ {analysis}
288
+
289
+ ## Changes
290
+ - {file}: {what changed and why}
291
+
292
+ ## Regression Test
293
+ ✅ Added: {TestClass}.{method}
294
+ ✅ Build: SUCCESS
295
+
296
+ ## Branch
297
+ fix/{TICKET_ID}-{slug}
298
+ ```
299
+
300
+ # Report Footer — Standard Command Output Format
301
+
302
+ Every command report must end with this standard footer section.
303
+
304
+ ## Status Badge
305
+
306
+ Choose one based on outcome:
307
+ - `✅ Complete` — all steps succeeded, no issues found
308
+ - `❌ Failed` — command could not complete due to a blocking error
309
+ - `⚠️ Warnings` — completed with non-blocking issues that should be reviewed
310
+
311
+ ## Output Artifacts
312
+
313
+ List every file created or modified by this command:
314
+ ```
315
+ Output Artifacts:
316
+ {created|updated} {file-path} ({brief description})
317
+ {created|updated} {file-path} ({brief description})
318
+ ```
319
+
320
+ If no files were written (e.g., review or analysis commands) → write `Output Artifacts: none (read-only)`.
321
+
322
+ ## Next Command Suggestion
323
+
324
+ Suggest the logical next command based on workflow phase:
325
+
326
+ | Current command | Suggest next |
327
+ |-------------------------|-----------------------------------------------|
328
+ | /define-product | `/generate-prd {product-definition-file}` |
329
+ | /generate-prd | `/refine-prd {prd-file}` then `/review-context {prd-file}` |
330
+ | /refine-prd | Open Review Board → update PRD → `/review-context {prd-file}` |
331
+ | /review-context (PRD) | `/generate-bdd {prd-file}` if APPROVED; fix PRD if NEEDS_FIX |
332
+ | /generate-bdd | `/review-context {feature-file}` to verify coverage |
333
+ | /review-context (BDD) | `/generate-tech-docs {UC-ID}` if APPROVED; regenerate if NEEDS_FIX |
334
+ | /generate-tech-docs | `/review-tech-docs {tech-design-file}` |
335
+ | /review-tech-docs | `/generate-code {feature-file}` if APPROVED; fix doc if NEEDS_FIX |
336
+ | /generate-code | `/generate-tests {UC-ID}` |
337
+ | /generate-tests | `/run-tests {UC-ID}` |
338
+ | /run-tests (passing) | `/review-code {UC-ID}` |
339
+ | /run-tests (failing) | `/fix-bug {ticket-id}` or `/debug {error}` |
340
+ | /review-code | `/smoke-test {UC-ID}` or create PR |
341
+ | /smoke-test | Create PR and link to ticket |
342
+ | /validate-traces | `/generate-code {UC-ID}` for gaps |
343
+ | /fix-bug | Create PR and link to ticket |
344
+ | /debug | `/fix-bug {ticket-id}` if fix needed |
345
+
346
+ Format the footer as:
347
+ ```
348
+ ---
349
+ Status : {badge}
350
+ {Output Artifacts block}
351
+ Next : {suggested command with example arguments}
352
+ ```
353
+
354
+
355
+ ---
356
+
357
+ ## /debug — Quick Debug Analysis
358
+
359
+ Use when: IDE shows an error, test fails unexpectedly, behavior is strange, or you need to understand why code does something.
360
+
361
+ **Different from `/fix-bug`**: This is analysis only, no full workflow, no ticket required.
362
+
363
+ ### Input
364
+
365
+ Paste one of:
366
+ 1. Stack trace / error log
367
+ 2. Test failure output
368
+ 3. File path + description of unexpected behavior
369
+ 4. A specific question about a code snippet
370
+
371
+ ### Stack Trace Analysis
372
+
373
+ Read stack trace from **bottom up** — the `Caused by:` line is the real root cause.
374
+
375
+ ```
376
+ Caused by: {RealException} ← start here
377
+ at {class}.{method}({file}:{line}) ← trace from here
378
+ ...
379
+ at {entrypoint} ← where it was called from
380
+ ```
381
+
382
+ ### Common Error Patterns
383
+
384
+ | Error | Likely Cause | Fix Direction |
385
+ |-------|-------------|---------------|
386
+ | NullPointerException | Accessing field on null object; Optional not handled | Check Optional.orElseThrow, null guards |
387
+ | ClassCastException | Wrong type assumption; incorrect generic usage | Check type at assignment/return point |
388
+ | OutOfMemoryError | Loading too much data; memory leak | Add pagination, check collection sizes |
389
+ | StackOverflowError | Infinite recursion | Find recursive call with no base case |
390
+ | Connection refused | Dependency service not running | Check config URLs, start dependent service |
391
+ | Authentication/401 | Token expired, wrong config, missing header | Verify token, check auth config |
392
+ | Permission denied/403 | Wrong role in request or misconfigured access rules | Check auth annotations and role config |
393
+ | Database constraint violation | Duplicate key, missing FK, null in NOT NULL column | Check data and constraint definitions |
394
+ | Serialization error | Circular reference, unmapped field | Check DTO/mapper configuration |
395
+ | Test assertion mismatch | Wrong mock setup or wrong expected value | Re-read mock setup and assertion logic |
396
+
397
+ ### Test Failure Analysis
398
+
399
+ ```
400
+ Expected: {expected value}
401
+ Actual : {actual value}
402
+ at {test class}.{method}(line {N})
403
+ ```
404
+
405
+ 1. What is the gap between Expected and Actual?
406
+ 2. Trace to the exact test line
407
+ 3. Is the mock setup correct? (`given(...).willReturn(...)`)
408
+ 4. Is the assertion logically correct?
409
+
410
+ ### Output
411
+
412
+ ```
413
+ /debug Analysis
414
+
415
+ ## Error Encountered
416
+ {description}
417
+
418
+ ## Root Cause
419
+ {technical explanation}
420
+
421
+ ## Location in Code
422
+ File: {path}
423
+ Line: {line number if available}
424
+ Layer: {Controller/Service/Repository/Test}
425
+
426
+ ## Suggested Fix
427
+ {specific code change}
428
+
429
+ ## Related Rule
430
+ See CLAUDE.md §{section} — {section name}
431
+
432
+ ## Next Step
433
+ - To fully fix → run /fix-bug {TICKET_ID}
434
+ - Just needed analysis → done here
435
+ ```
436
+
437
+ # Report Footer — Standard Command Output Format
438
+
439
+ Every command report must end with this standard footer section.
440
+
441
+ ## Status Badge
442
+
443
+ Choose one based on outcome:
444
+ - `✅ Complete` — all steps succeeded, no issues found
445
+ - `❌ Failed` — command could not complete due to a blocking error
446
+ - `⚠️ Warnings` — completed with non-blocking issues that should be reviewed
447
+
448
+ ## Output Artifacts
449
+
450
+ List every file created or modified by this command:
451
+ ```
452
+ Output Artifacts:
453
+ {created|updated} {file-path} ({brief description})
454
+ {created|updated} {file-path} ({brief description})
455
+ ```
456
+
457
+ If no files were written (e.g., review or analysis commands) → write `Output Artifacts: none (read-only)`.
458
+
459
+ ## Next Command Suggestion
460
+
461
+ Suggest the logical next command based on workflow phase:
462
+
463
+ | Current command | Suggest next |
464
+ |-------------------------|-----------------------------------------------|
465
+ | /define-product | `/generate-prd {product-definition-file}` |
466
+ | /generate-prd | `/refine-prd {prd-file}` then `/review-context {prd-file}` |
467
+ | /refine-prd | Open Review Board → update PRD → `/review-context {prd-file}` |
468
+ | /review-context (PRD) | `/generate-bdd {prd-file}` if APPROVED; fix PRD if NEEDS_FIX |
469
+ | /generate-bdd | `/review-context {feature-file}` to verify coverage |
470
+ | /review-context (BDD) | `/generate-tech-docs {UC-ID}` if APPROVED; regenerate if NEEDS_FIX |
471
+ | /generate-tech-docs | `/review-tech-docs {tech-design-file}` |
472
+ | /review-tech-docs | `/generate-code {feature-file}` if APPROVED; fix doc if NEEDS_FIX |
473
+ | /generate-code | `/generate-tests {UC-ID}` |
474
+ | /generate-tests | `/run-tests {UC-ID}` |
475
+ | /run-tests (passing) | `/review-code {UC-ID}` |
476
+ | /run-tests (failing) | `/fix-bug {ticket-id}` or `/debug {error}` |
477
+ | /review-code | `/smoke-test {UC-ID}` or create PR |
478
+ | /smoke-test | Create PR and link to ticket |
479
+ | /validate-traces | `/generate-code {UC-ID}` for gaps |
480
+ | /fix-bug | Create PR and link to ticket |
481
+ | /debug | `/fix-bug {ticket-id}` if fix needed |
482
+
483
+ Format the footer as:
484
+ ```
485
+ ---
486
+ Status : {badge}
487
+ {Output Artifacts block}
488
+ Next : {suggested command with example arguments}
489
+ ```
490
+
491
+
492
+ ---
493
+
494
+ ## /validate-traces — Traceability Coverage Matrix
495
+
496
+ Read-only check of coverage between specs, code, and tests.
497
+
498
+ ### Input
499
+
500
+ Accept: domain name or specific UC-ID.
501
+
502
+ ### Process
503
+
504
+ 1. **Read .feature files** → collect all SC-IDs for the domain/UC
505
+ 2. **Scan controller files** → find `@trace.implements` tags
506
+ 3. **Scan test files** → find `@trace.verifies` tags
507
+ 4. **Read `.trace/{UC-ID}.tsv`** → check for drift (scenario text changed since last code gen)
508
+
509
+ ### Output
510
+
511
+ ```
512
+ /validate-traces — {domain}
513
+
514
+ | UC-ID | SC | Spec | Code | Test | Status |
515
+ |-------|----|------|------|------|--------|
516
+ | {UC}-UC1 | SC1 | ✅ | ✅ {ControllerClass} | ✅ {TestClass} | synced |
517
+ | {UC}-UC1 | SC2 | ✅ | ✅ {ControllerClass} | ❌ MISSING | gap |
518
+ | {UC}-UC2 | SC1 | ✅ | ❌ MISSING | ❌ MISSING | gap |
519
+
520
+ Gaps:
521
+ Missing code: [{UC-ID}-SC2, {UC-ID2}-SC1]
522
+ Missing tests: [{UC-ID}-SC1]
523
+ Drifted (spec changed, code not updated): [{list}]
524
+
525
+ Recommendations:
526
+ - /generate-code {UC-ID} SC2
527
+ - /generate-tests {UC-ID}
528
+ - Re-run /generate-code {UC-ID} for drifted scenarios
529
+ ```
530
+
531
+ # Report Footer — Standard Command Output Format
532
+
533
+ Every command report must end with this standard footer section.
534
+
535
+ ## Status Badge
536
+
537
+ Choose one based on outcome:
538
+ - `✅ Complete` — all steps succeeded, no issues found
539
+ - `❌ Failed` — command could not complete due to a blocking error
540
+ - `⚠️ Warnings` — completed with non-blocking issues that should be reviewed
541
+
542
+ ## Output Artifacts
543
+
544
+ List every file created or modified by this command:
545
+ ```
546
+ Output Artifacts:
547
+ {created|updated} {file-path} ({brief description})
548
+ {created|updated} {file-path} ({brief description})
549
+ ```
550
+
551
+ If no files were written (e.g., review or analysis commands) → write `Output Artifacts: none (read-only)`.
552
+
553
+ ## Next Command Suggestion
554
+
555
+ Suggest the logical next command based on workflow phase:
556
+
557
+ | Current command | Suggest next |
558
+ |-------------------------|-----------------------------------------------|
559
+ | /define-product | `/generate-prd {product-definition-file}` |
560
+ | /generate-prd | `/refine-prd {prd-file}` then `/review-context {prd-file}` |
561
+ | /refine-prd | Open Review Board → update PRD → `/review-context {prd-file}` |
562
+ | /review-context (PRD) | `/generate-bdd {prd-file}` if APPROVED; fix PRD if NEEDS_FIX |
563
+ | /generate-bdd | `/review-context {feature-file}` to verify coverage |
564
+ | /review-context (BDD) | `/generate-tech-docs {UC-ID}` if APPROVED; regenerate if NEEDS_FIX |
565
+ | /generate-tech-docs | `/review-tech-docs {tech-design-file}` |
566
+ | /review-tech-docs | `/generate-code {feature-file}` if APPROVED; fix doc if NEEDS_FIX |
567
+ | /generate-code | `/generate-tests {UC-ID}` |
568
+ | /generate-tests | `/run-tests {UC-ID}` |
569
+ | /run-tests (passing) | `/review-code {UC-ID}` |
570
+ | /run-tests (failing) | `/fix-bug {ticket-id}` or `/debug {error}` |
571
+ | /review-code | `/smoke-test {UC-ID}` or create PR |
572
+ | /smoke-test | Create PR and link to ticket |
573
+ | /validate-traces | `/generate-code {UC-ID}` for gaps |
574
+ | /fix-bug | Create PR and link to ticket |
575
+ | /debug | `/fix-bug {ticket-id}` if fix needed |
576
+
577
+ Format the footer as:
578
+ ```
579
+ ---
580
+ Status : {badge}
581
+ {Output Artifacts block}
582
+ Next : {suggested command with example arguments}
583
+ ```
584
+