@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,456 @@
1
+ ---
2
+ description: Generates a PRD from a product definition, or analyzes an existing PRD through 4 review lenses (QA, DEV, SA, PO) to find gaps and risks. Trigger when: "/generate-prd", "/refine-prd", "tạo PRD", "generate PRD", "phân tích PRD", "review PRD", "refine PRD", "PRD có vấn đề gì không", "check PRD quality".
3
+ ---
4
+
5
+ # PRD Skills — Generate & Refine
6
+
7
+ This skill handles two commands: `/generate-prd` to create a PRD, and `/refine-prd` to analyze it for gaps.
8
+
9
+ ---
10
+
11
+ ## /generate-prd — Generate Product Requirements Document
12
+
13
+ ### Gate
14
+
15
+ <!-- Directory: specs/product-definition/**/*.md -->
16
+ # Gate — Universal Entry Procedure
17
+
18
+ Every command must execute this gate before proceeding with its specific logic.
19
+
20
+ ## Step 0 — Sub-Agent Mode Check
21
+
22
+ Before anything else, check if `$ARGUMENTS` is a JSON payload from an orchestrator:
23
+
24
+ 1. Attempt to parse `$ARGUMENTS` as JSON.
25
+ 2. If it parses successfully **and** contains `"_agent_mode": true`:
26
+ - **Skip Steps 1, 2, and 3 of this Gate entirely.**
27
+ - Set target file = `payload.target_file`
28
+ - Set loaded context = `payload.context` (do NOT run context-loader.md)
29
+ - Set UC scope = `payload.uc_id` (process only this UC)
30
+ - Set line range = `payload.uc_section` (read only that PRD section)
31
+ - Proceed directly to the command-specific logic.
32
+ 3. If `$ARGUMENTS` is not JSON or `_agent_mode` is absent → continue to Step 1 (normal mode).
33
+
34
+ ## Step 0-B — Model Check
35
+
36
+ *Skip this step if `_agent_mode: true` (sub-agent — orchestrator already validated).*
37
+
38
+ Complex generation and review commands require strong reasoning.
39
+ Using a smaller model risks missed edge cases, incomplete spec analysis, and architecture violations.
40
+
41
+ Display and wait for response:
42
+
43
+ ```
44
+ ⚙️ MODEL CHECK
45
+ ──────────────────────────────────────────────────────────────────
46
+ Recommended : claude-opus-4-5 (or claude-opus-4)
47
+ Why needed : Spec analysis, architecture review, code generation
48
+ require deep reasoning. Smaller models miss edge cases.
49
+
50
+ To switch in Claude Code:
51
+ • Settings → Model → select "claude-opus"
52
+ • or: /model → choose claude-opus
53
+
54
+ Running on claude-opus?
55
+ Y — yes, on claude-opus → proceed
56
+ S — skip check (I accept lower quality risk with current model)
57
+ ──────────────────────────────────────────────────────────────────
58
+ ```
59
+
60
+ - "Y" → proceed to Step 1.
61
+ - "S" → proceed to Step 1 (user accepts risk, add ⚠️ to final report).
62
+ - "N" or anything else → **STOP.** Output: "Please switch to claude-opus, then re-run this command."
63
+
64
+ ## Step 1 — Resolve Target File
65
+
66
+ 1. If `$ARGUMENTS` is provided and points to an existing file → use it directly as the target.
67
+ 2. If `$ARGUMENTS` is a UC-ID, ticket ID, or partial name → search for matching files in the relevant directory.
68
+ 3. If `$ARGUMENTS` is empty or no match found:
69
+ - List files in the relevant directory for this command (e.g., `specs/prd/**/*.md` for PRD commands, `specs/bdd/**/*.feature` for BDD commands).
70
+ - Present the list to the user and ask: "Which file do you want to work with? (Enter number or filename)"
71
+ - Wait for user selection before continuing.
72
+
73
+ ## Step 2 — Execute Context Loader
74
+
75
+ Load all project context by following the procedure in `steps/context-loader.md`.
76
+ Store all loaded context in memory for use throughout this command session.
77
+
78
+ ## Step 3 — CHECKPOINT
79
+
80
+ After completing Steps 1 and 2, display a summary and wait for confirmation:
81
+
82
+ ```
83
+ CHECKPOINT
84
+ -----------
85
+ Target : {resolved file path}
86
+ Project : {project.name from project-context.yaml}
87
+ Tech stack : {language} / {framework}
88
+ Module : {module if set, else "not configured"}
89
+ Domains : {comma-separated domain list}
90
+
91
+ Proceed? (Y/N)
92
+ ```
93
+
94
+ Wait for explicit "Y" or "N" from the user before continuing.
95
+ - "Y" → proceed to the command-specific steps below.
96
+ - "N" → stop and ask what the user wants to change.
97
+
98
+
99
+ ### Generate
100
+
101
+ Write `specs/prd/{domain}/{slug}.md`:
102
+
103
+ ```markdown
104
+ # PRD — {Feature Name}
105
+
106
+ **Version**: 1.0
107
+ **Status**: draft
108
+ **Domain**: {domain}
109
+ **Ticket**: {TICKET_PREFIX}-{N} (if available)
110
+ **Date**: {date}
111
+
112
+ ## 1. Problem Statement
113
+ {from product-definition}
114
+
115
+ ## 2. Goals & Non-Goals
116
+
117
+ ### Goals
118
+ - {goal 1}
119
+
120
+ ### Non-Goals
121
+ - {non-goal 1}
122
+
123
+ ## 3. User Stories
124
+
125
+ As a {persona}, I want to {action} so that {benefit}.
126
+
127
+ ## 4. Use Cases
128
+
129
+ | UC-ID | Name | Priority | Description |
130
+ |-------|------|----------|-------------|
131
+ | {DOMAIN}-UC1 | {name} | High | {description} |
132
+
133
+ ## 5. Business Rules
134
+
135
+ | BR-ID | Rule | UC |
136
+ |-------|------|----|
137
+ | BR-1 | {rule} | UC1 |
138
+
139
+ ## 6. Acceptance Criteria
140
+
141
+ ### {DOMAIN}-UC1: {Name}
142
+ - AC1: Given {context}, when {action}, then {result}
143
+
144
+ ## 7. Out of Scope
145
+ {from product-definition}
146
+
147
+ ## 8. Cross-Service Dependencies
148
+ {from product-definition}
149
+
150
+ ## 9. Open Questions
151
+ - [ ] {question requiring clarification}
152
+ ```
153
+
154
+ ### Output
155
+
156
+ ```
157
+ ✅ PRD created: specs/prd/{domain}/{slug}.md
158
+ Status: draft
159
+ ```
160
+
161
+ # Report Footer — Standard Command Output Format
162
+
163
+ Every command report must end with this standard footer section.
164
+
165
+ ## Status Badge
166
+
167
+ Choose one based on outcome:
168
+ - `✅ Complete` — all steps succeeded, no issues found
169
+ - `❌ Failed` — command could not complete due to a blocking error
170
+ - `⚠️ Warnings` — completed with non-blocking issues that should be reviewed
171
+
172
+ ## Output Artifacts
173
+
174
+ List every file created or modified by this command:
175
+ ```
176
+ Output Artifacts:
177
+ {created|updated} {file-path} ({brief description})
178
+ {created|updated} {file-path} ({brief description})
179
+ ```
180
+
181
+ If no files were written (e.g., review or analysis commands) → write `Output Artifacts: none (read-only)`.
182
+
183
+ ## Next Command Suggestion
184
+
185
+ Suggest the logical next command based on workflow phase:
186
+
187
+ | Current command | Suggest next |
188
+ |-------------------------|-----------------------------------------------|
189
+ | /define-product | `/generate-prd {product-definition-file}` |
190
+ | /generate-prd | `/refine-prd {prd-file}` then `/review-context {prd-file}` |
191
+ | /refine-prd | Open Review Board → update PRD → `/review-context {prd-file}` |
192
+ | /review-context (PRD) | `/generate-bdd {prd-file}` if APPROVED; fix PRD if NEEDS_FIX |
193
+ | /generate-bdd | `/review-context {feature-file}` to verify coverage |
194
+ | /review-context (BDD) | `/generate-tech-docs {UC-ID}` if APPROVED; regenerate if NEEDS_FIX |
195
+ | /generate-tech-docs | `/review-tech-docs {tech-design-file}` |
196
+ | /review-tech-docs | `/generate-code {feature-file}` if APPROVED; fix doc if NEEDS_FIX |
197
+ | /generate-code | `/generate-tests {UC-ID}` |
198
+ | /generate-tests | `/run-tests {UC-ID}` |
199
+ | /run-tests (passing) | `/review-code {UC-ID}` |
200
+ | /run-tests (failing) | `/fix-bug {ticket-id}` or `/debug {error}` |
201
+ | /review-code | `/smoke-test {UC-ID}` or create PR |
202
+ | /smoke-test | Create PR and link to ticket |
203
+ | /validate-traces | `/generate-code {UC-ID}` for gaps |
204
+ | /fix-bug | Create PR and link to ticket |
205
+ | /debug | `/fix-bug {ticket-id}` if fix needed |
206
+
207
+ Format the footer as:
208
+ ```
209
+ ---
210
+ Status : {badge}
211
+ {Output Artifacts block}
212
+ Next : {suggested command with example arguments}
213
+ ```
214
+
215
+
216
+ ---
217
+
218
+ ## /refine-prd — Analyze PRD Through 4 Review Lenses
219
+
220
+ Performs a structured multi-perspective analysis of a PRD and writes findings to a YAML file for human review.
221
+
222
+ ### Gate
223
+
224
+ <!-- Directory: specs/prd/**/*.md -->
225
+ # Gate — Universal Entry Procedure
226
+
227
+ Every command must execute this gate before proceeding with its specific logic.
228
+
229
+ ## Step 0 — Sub-Agent Mode Check
230
+
231
+ Before anything else, check if `$ARGUMENTS` is a JSON payload from an orchestrator:
232
+
233
+ 1. Attempt to parse `$ARGUMENTS` as JSON.
234
+ 2. If it parses successfully **and** contains `"_agent_mode": true`:
235
+ - **Skip Steps 1, 2, and 3 of this Gate entirely.**
236
+ - Set target file = `payload.target_file`
237
+ - Set loaded context = `payload.context` (do NOT run context-loader.md)
238
+ - Set UC scope = `payload.uc_id` (process only this UC)
239
+ - Set line range = `payload.uc_section` (read only that PRD section)
240
+ - Proceed directly to the command-specific logic.
241
+ 3. If `$ARGUMENTS` is not JSON or `_agent_mode` is absent → continue to Step 1 (normal mode).
242
+
243
+ ## Step 0-B — Model Check
244
+
245
+ *Skip this step if `_agent_mode: true` (sub-agent — orchestrator already validated).*
246
+
247
+ Complex generation and review commands require strong reasoning.
248
+ Using a smaller model risks missed edge cases, incomplete spec analysis, and architecture violations.
249
+
250
+ Display and wait for response:
251
+
252
+ ```
253
+ ⚙️ MODEL CHECK
254
+ ──────────────────────────────────────────────────────────────────
255
+ Recommended : claude-opus-4-5 (or claude-opus-4)
256
+ Why needed : Spec analysis, architecture review, code generation
257
+ require deep reasoning. Smaller models miss edge cases.
258
+
259
+ To switch in Claude Code:
260
+ • Settings → Model → select "claude-opus"
261
+ • or: /model → choose claude-opus
262
+
263
+ Running on claude-opus?
264
+ Y — yes, on claude-opus → proceed
265
+ S — skip check (I accept lower quality risk with current model)
266
+ ──────────────────────────────────────────────────────────────────
267
+ ```
268
+
269
+ - "Y" → proceed to Step 1.
270
+ - "S" → proceed to Step 1 (user accepts risk, add ⚠️ to final report).
271
+ - "N" or anything else → **STOP.** Output: "Please switch to claude-opus, then re-run this command."
272
+
273
+ ## Step 1 — Resolve Target File
274
+
275
+ 1. If `$ARGUMENTS` is provided and points to an existing file → use it directly as the target.
276
+ 2. If `$ARGUMENTS` is a UC-ID, ticket ID, or partial name → search for matching files in the relevant directory.
277
+ 3. If `$ARGUMENTS` is empty or no match found:
278
+ - List files in the relevant directory for this command (e.g., `specs/prd/**/*.md` for PRD commands, `specs/bdd/**/*.feature` for BDD commands).
279
+ - Present the list to the user and ask: "Which file do you want to work with? (Enter number or filename)"
280
+ - Wait for user selection before continuing.
281
+
282
+ ## Step 2 — Execute Context Loader
283
+
284
+ Load all project context by following the procedure in `steps/context-loader.md`.
285
+ Store all loaded context in memory for use throughout this command session.
286
+
287
+ ## Step 3 — CHECKPOINT
288
+
289
+ After completing Steps 1 and 2, display a summary and wait for confirmation:
290
+
291
+ ```
292
+ CHECKPOINT
293
+ -----------
294
+ Target : {resolved file path}
295
+ Project : {project.name from project-context.yaml}
296
+ Tech stack : {language} / {framework}
297
+ Module : {module if set, else "not configured"}
298
+ Domains : {comma-separated domain list}
299
+
300
+ Proceed? (Y/N)
301
+ ```
302
+
303
+ Wait for explicit "Y" or "N" from the user before continuing.
304
+ - "Y" → proceed to the command-specific steps below.
305
+ - "N" → stop and ask what the user wants to change.
306
+
307
+
308
+ ### Analyze — 4 Lenses (run all four perspectives)
309
+
310
+ #### QA Lens — Test Coverage & Edge Cases
311
+ Evaluate:
312
+ - Are all acceptance criteria testable and measurable?
313
+ - Are edge cases and error scenarios specified?
314
+ - Are boundary conditions defined?
315
+ - Is there ambiguity in expected behavior?
316
+
317
+ #### DEV Lens — Technical Clarity & Feasibility
318
+ Evaluate:
319
+ - Are API inputs/outputs clearly defined?
320
+ - Are business rules unambiguous enough to implement?
321
+ - Are there performance or scalability concerns?
322
+ - Are cross-service dependencies fully described?
323
+ - Is there anything technically infeasible or risky?
324
+
325
+ #### SA Lens — Architecture & Design
326
+ Evaluate:
327
+ - Does this fit the existing architecture?
328
+ - Are there design patterns or constraints to apply?
329
+ - Is data modeling clear (entities, relationships)?
330
+ - Are there security or auth implications?
331
+
332
+ #### PO Lens — Business Value & Scope
333
+ Evaluate:
334
+ - Is scope clearly bounded?
335
+ - Are priorities clear?
336
+ - Are success metrics defined?
337
+ - Are stakeholder needs fully captured?
338
+ - Any scope creep risk?
339
+
340
+ ### Write Output
341
+
342
+ Derive the output filename from the PRD slug:
343
+ - PRD file: `specs/prd/payment/create-invoice.md` → output: `.agent/review/create-invoice-findings.yaml`
344
+ - Rule: take the PRD filename (without `.md`), append `-findings.yaml`
345
+
346
+ Write findings to `.agent/review/{prd-slug}-findings.yaml`:
347
+
348
+ ```yaml
349
+ # Generated by /refine-prd
350
+ # Review each finding and mark: accepted / rejected / needs_discussion
351
+ prd_source: "specs/prd/{domain}/{slug}.md"
352
+ generated_at: "{ISO datetime}"
353
+ status: "pending_review"
354
+
355
+ findings:
356
+ - id: "F001"
357
+ lens: "QA" # QA | DEV | SA | PO
358
+ severity: "major" # critical | major | minor
359
+ section: "§6. Acceptance Criteria"
360
+ finding: "{Clear description of the gap or issue}"
361
+ suggestion: "{Specific actionable improvement}"
362
+ status: "pending" # pending | accepted | rejected | needs_discussion
363
+
364
+ - id: "F002"
365
+ lens: "DEV"
366
+ severity: "minor"
367
+ section: "§8. Cross-Service Dependencies"
368
+ finding: "{finding}"
369
+ suggestion: "{suggestion}"
370
+ status: "pending"
371
+
372
+ summary:
373
+ total_findings: {N}
374
+ by_severity:
375
+ critical: {N}
376
+ major: {N}
377
+ minor: {N}
378
+ by_lens:
379
+ QA: {N}
380
+ DEV: {N}
381
+ SA: {N}
382
+ PO: {N}
383
+ recommendation: "APPROVED_WITH_MINOR_CHANGES | NEEDS_REVISION | BLOCKED"
384
+ ```
385
+
386
+ ### Report to User
387
+
388
+ ```
389
+ /refine-prd Complete — {PRD name}
390
+
391
+ Findings: {total} total
392
+ 🔴 Critical: {N} 🟡 Major: {N} 🟢 Minor: {N}
393
+
394
+ Top issues:
395
+ [F001] QA/major — {brief description}
396
+ [F002] DEV/minor — {brief description}
397
+
398
+ Review file: .agent/review/{prd-slug}-findings.yaml
399
+ → Open with Review Board extension (right-click file) to accept/reject each finding
400
+ → After review: update PRD and run /generate-bdd
401
+ ```
402
+
403
+ # Report Footer — Standard Command Output Format
404
+
405
+ Every command report must end with this standard footer section.
406
+
407
+ ## Status Badge
408
+
409
+ Choose one based on outcome:
410
+ - `✅ Complete` — all steps succeeded, no issues found
411
+ - `❌ Failed` — command could not complete due to a blocking error
412
+ - `⚠️ Warnings` — completed with non-blocking issues that should be reviewed
413
+
414
+ ## Output Artifacts
415
+
416
+ List every file created or modified by this command:
417
+ ```
418
+ Output Artifacts:
419
+ {created|updated} {file-path} ({brief description})
420
+ {created|updated} {file-path} ({brief description})
421
+ ```
422
+
423
+ If no files were written (e.g., review or analysis commands) → write `Output Artifacts: none (read-only)`.
424
+
425
+ ## Next Command Suggestion
426
+
427
+ Suggest the logical next command based on workflow phase:
428
+
429
+ | Current command | Suggest next |
430
+ |-------------------------|-----------------------------------------------|
431
+ | /define-product | `/generate-prd {product-definition-file}` |
432
+ | /generate-prd | `/refine-prd {prd-file}` then `/review-context {prd-file}` |
433
+ | /refine-prd | Open Review Board → update PRD → `/review-context {prd-file}` |
434
+ | /review-context (PRD) | `/generate-bdd {prd-file}` if APPROVED; fix PRD if NEEDS_FIX |
435
+ | /generate-bdd | `/review-context {feature-file}` to verify coverage |
436
+ | /review-context (BDD) | `/generate-tech-docs {UC-ID}` if APPROVED; regenerate if NEEDS_FIX |
437
+ | /generate-tech-docs | `/review-tech-docs {tech-design-file}` |
438
+ | /review-tech-docs | `/generate-code {feature-file}` if APPROVED; fix doc if NEEDS_FIX |
439
+ | /generate-code | `/generate-tests {UC-ID}` |
440
+ | /generate-tests | `/run-tests {UC-ID}` |
441
+ | /run-tests (passing) | `/review-code {UC-ID}` |
442
+ | /run-tests (failing) | `/fix-bug {ticket-id}` or `/debug {error}` |
443
+ | /review-code | `/smoke-test {UC-ID}` or create PR |
444
+ | /smoke-test | Create PR and link to ticket |
445
+ | /validate-traces | `/generate-code {UC-ID}` for gaps |
446
+ | /fix-bug | Create PR and link to ticket |
447
+ | /debug | `/fix-bug {ticket-id}` if fix needed |
448
+
449
+ Format the footer as:
450
+ ```
451
+ ---
452
+ Status : {badge}
453
+ {Output Artifacts block}
454
+ Next : {suggested command with example arguments}
455
+ ```
456
+
@@ -0,0 +1,160 @@
1
+ ---
2
+ description: Sets up the Spec-Driven Development framework in any backend project from scratch. Trigger when: "/setup-ai-first", "setup spec-driven workflow", "initialize ai-first framework", "cài đặt framework", "khởi tạo spec-driven", "set up this workflow", "how do I start using this plugin".
3
+ ---
4
+
5
+ # /setup-ai-first — Initialize Spec-Driven Dev in a Project
6
+
7
+ Walk the user through a one-time setup that creates all required directories, installs CLAUDE.md, and verifies the environment.
8
+
9
+ ## Precondition Check
10
+
11
+ First, ask: "Bạn đang ở project nào? Cho tôi đường dẫn root của project."
12
+
13
+ Check if already set up:
14
+ - If `.claude/commands/` exists with `.md` files → report "Already set up. Run `/validate-traces` to check status."
15
+ - If `specs/` exists → offer to re-initialize or skip
16
+
17
+ ## Step 1 — Create Directory Structure
18
+
19
+ Create the following directories (skip if already exist):
20
+
21
+ ```
22
+ {project-root}/
23
+ ├── specs/
24
+ │ ├── product-definition/ # Output of /define-product
25
+ │ ├── prd/ # Output of /generate-prd
26
+ │ └── bdd/ # Output of /generate-bdd (.feature files)
27
+ ├── tech-docs/ # Output of /generate-tech-docs
28
+ ├── .trace/ # Traceability state files (.tsv)
29
+ └── .agent/
30
+ └── review/ # Output of /refine-prd ({prd-slug}-findings.yaml)
31
+ ```
32
+
33
+ Report each directory created or already existing.
34
+
35
+ ## Step 2 — Copy Slash Commands
36
+
37
+ Tell the user:
38
+
39
+ > "Plugin này đã cài slash commands vào Claude tự động qua skill system.
40
+ > Nếu bạn muốn dùng commands trực tiếp trong Claude Code project (`.claude/commands/`), chạy lệnh sau:"
41
+
42
+ ```bash
43
+ # Copy all commands from plugin to project
44
+ mkdir -p {project-root}/.claude/commands
45
+ cp {plugin-dir}/commands/*.md {project-root}/.claude/commands/
46
+ ```
47
+
48
+ Note: The `.claude/commands/` copies are optional. Skills in this plugin work without them.
49
+
50
+ ## Step 3 — Create CLAUDE.md
51
+
52
+ Check if `{project-root}/CLAUDE.md` exists:
53
+ - If yes: ask "CLAUDE.md đã tồn tại. Merge template vào hay bỏ qua?"
54
+ - If no: create from template in `templates/architecture.template.md`
55
+
56
+ After creating, instruct:
57
+ > "Mở CLAUDE.md và điền vào các placeholder `{{...}}` với thông tin dự án của bạn.
58
+ > Đặc biệt quan trọng: §1 (project overview) và §3 (coding standards)."
59
+
60
+ ## Step 4 — Create project-context.yaml
61
+
62
+ Create `{project-root}/.agent/project-context.yaml`:
63
+
64
+ ```yaml
65
+ # Project context for AI-First workflow
66
+ # Fill in all fields before starting
67
+
68
+ project:
69
+ name: "{{PROJECT_NAME}}"
70
+ description: "{{ONE_LINE_DESCRIPTION}}"
71
+
72
+ tech_stack:
73
+ language: "{{LANGUAGE}}" # e.g. Java 21, Python 3.12, Node.js 20
74
+ framework: "{{FRAMEWORK}}" # e.g. Spring Boot 3.x, FastAPI, NestJS
75
+ build_tool: "{{BUILD_TOOL}}" # e.g. Gradle, Maven, npm
76
+ test_framework: "{{TEST_FW}}" # e.g. JUnit 5, pytest, Jest
77
+ orm: "{{ORM}}" # e.g. Hibernate/JPA, SQLAlchemy, Prisma
78
+ database: "{{DATABASE}}" # e.g. PostgreSQL, MySQL, MongoDB
79
+
80
+ conventions:
81
+ build_command: "{{BUILD_COMMAND}}" # e.g. ./gradlew build -x test
82
+ test_command: "{{TEST_COMMAND}}" # e.g. ./gradlew test
83
+ service_run: "{{RUN_COMMAND}}" # e.g. ./gradlew bootRun
84
+ ticket_prefix: "{{TICKET_PREFIX}}" # e.g. PROJ, FEAT, PD
85
+
86
+ domains: [] # List your business domains, e.g. [rental, payment, user]
87
+ ```
88
+
89
+ ## Step 5 — Verify Setup
90
+
91
+ Run a quick check:
92
+ - [ ] `specs/` directory exists
93
+ - [ ] `.trace/` directory exists
94
+ - [ ] `.agent/project-context.yaml` exists
95
+ - [ ] `CLAUDE.md` exists
96
+
97
+ Report:
98
+ ```
99
+ /setup-ai-first Complete ✅
100
+
101
+ Directories created: {N}
102
+ Files created:
103
+ ✅ CLAUDE.md (needs customization)
104
+ ✅ .agent/project-context.yaml (needs customization)
105
+ ```
106
+
107
+ # Report Footer — Standard Command Output Format
108
+
109
+ Every command report must end with this standard footer section.
110
+
111
+ ## Status Badge
112
+
113
+ Choose one based on outcome:
114
+ - `✅ Complete` — all steps succeeded, no issues found
115
+ - `❌ Failed` — command could not complete due to a blocking error
116
+ - `⚠️ Warnings` — completed with non-blocking issues that should be reviewed
117
+
118
+ ## Output Artifacts
119
+
120
+ List every file created or modified by this command:
121
+ ```
122
+ Output Artifacts:
123
+ {created|updated} {file-path} ({brief description})
124
+ {created|updated} {file-path} ({brief description})
125
+ ```
126
+
127
+ If no files were written (e.g., review or analysis commands) → write `Output Artifacts: none (read-only)`.
128
+
129
+ ## Next Command Suggestion
130
+
131
+ Suggest the logical next command based on workflow phase:
132
+
133
+ | Current command | Suggest next |
134
+ |-------------------------|-----------------------------------------------|
135
+ | /define-product | `/generate-prd {product-definition-file}` |
136
+ | /generate-prd | `/refine-prd {prd-file}` then `/review-context {prd-file}` |
137
+ | /refine-prd | Open Review Board → update PRD → `/review-context {prd-file}` |
138
+ | /review-context (PRD) | `/generate-bdd {prd-file}` if APPROVED; fix PRD if NEEDS_FIX |
139
+ | /generate-bdd | `/review-context {feature-file}` to verify coverage |
140
+ | /review-context (BDD) | `/generate-tech-docs {UC-ID}` if APPROVED; regenerate if NEEDS_FIX |
141
+ | /generate-tech-docs | `/review-tech-docs {tech-design-file}` |
142
+ | /review-tech-docs | `/generate-code {feature-file}` if APPROVED; fix doc if NEEDS_FIX |
143
+ | /generate-code | `/generate-tests {UC-ID}` |
144
+ | /generate-tests | `/run-tests {UC-ID}` |
145
+ | /run-tests (passing) | `/review-code {UC-ID}` |
146
+ | /run-tests (failing) | `/fix-bug {ticket-id}` or `/debug {error}` |
147
+ | /review-code | `/smoke-test {UC-ID}` or create PR |
148
+ | /smoke-test | Create PR and link to ticket |
149
+ | /validate-traces | `/generate-code {UC-ID}` for gaps |
150
+ | /fix-bug | Create PR and link to ticket |
151
+ | /debug | `/fix-bug {ticket-id}` if fix needed |
152
+
153
+ Format the footer as:
154
+ ```
155
+ ---
156
+ Status : {badge}
157
+ {Output Artifacts block}
158
+ Next : {suggested command with example arguments}
159
+ ```
160
+