@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,361 @@
1
+ ---
2
+ description: Generates BDD .feature files from an approved PRD, or generates technical design documents. Trigger when: "/generate-bdd", "/generate-tech-docs", "tạo BDD", "tạo spec", "generate feature file", "write BDD scenarios", "tạo technical design", "tech design", "sinh tech docs", "API design", "sinh .feature".
3
+ ---
4
+
5
+ # Spec Skills — BDD & Technical Design
6
+
7
+ This skill handles two commands: `/generate-bdd` to create BDD feature files, and `/generate-tech-docs` to create technical design documents.
8
+
9
+ ---
10
+
11
+ ## /generate-bdd — Generate BDD Feature Files
12
+
13
+ ### Gate
14
+
15
+ <!-- Directory: specs/prd/**/*.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
+ Also verify: Check that the PRD `Status` is `approved` (not `draft`).
100
+ - If `draft`: warn "PRD is still draft. Proceed anyway? Findings from /refine-prd may not be addressed yet."
101
+
102
+ ### UC Decomposition
103
+
104
+ For each Use Case in the PRD, derive scenarios. Present outline:
105
+
106
+ ```
107
+ {DOMAIN}-UC1: {Name}
108
+ SC1: Happy path — {client/role type} — {success scenario}
109
+ SC2: Happy path — {other client/role type} (if applicable)
110
+ SC3: Validation error — {invalid input}
111
+ SC4: Not found / resource missing
112
+ BRs covered: BR-1, BR-2
113
+
114
+ {DOMAIN}-UC2: {Name}
115
+ ...
116
+ ```
117
+
118
+ **CHECKPOINT** — Ask: "Does this outline look correct? Any missing scenarios?"
119
+ Wait for confirmation before generating files.
120
+
121
+ ### Generate
122
+
123
+ For each UC, write `specs/bdd/{domain}/{UC-ID}-{slug}.feature`:
124
+
125
+ ```gherkin
126
+ # @trace.source=specs/prd/{domain}/{slug}.md
127
+ # @trace.uc={UC-ID}
128
+ Feature: {UC Name}
129
+
130
+ Background:
131
+ Given the system is running
132
+ And a {persona} is authenticated
133
+
134
+ Scenario: SC1 — {Happy path description}
135
+ Given {precondition}
136
+ When {action}
137
+ Then {expected outcome}
138
+ And {secondary outcome if any}
139
+
140
+ Scenario: SC2 — {Another happy path}
141
+ Given {precondition}
142
+ When {action}
143
+ Then {expected outcome}
144
+
145
+ Scenario: SC3 — Validation error
146
+ Given {precondition}
147
+ When {invalid action}
148
+ Then the system returns a validation error
149
+ And the error message mentions "{field}"
150
+
151
+ Scenario: SC4 — Resource not found
152
+ Given no {resource} exists with id {id}
153
+ When {action}
154
+ Then the system returns a not-found error
155
+ ```
156
+
157
+ ### Quality Check
158
+
159
+ After generating, self-evaluate:
160
+ - [ ] Every acceptance criteria from PRD has at least one scenario
161
+ - [ ] Every business rule is covered by at least one scenario
162
+ - [ ] Error scenarios are present (validation, not-found, unauthorized)
163
+ - [ ] Scenarios are atomic (one behavior per scenario)
164
+ - [ ] No implementation details in feature files (no SQL, no class names)
165
+
166
+ ### Output
167
+
168
+ ```
169
+ /generate-bdd Complete — {domain}
170
+
171
+ Files created:
172
+ ✅ specs/bdd/{domain}/{UC-ID}-{slug}.feature ({N} scenarios)
173
+ ...
174
+
175
+ Quality: {score}%
176
+ ```
177
+
178
+ # Report Footer — Standard Command Output Format
179
+
180
+ Every command report must end with this standard footer section.
181
+
182
+ ## Status Badge
183
+
184
+ Choose one based on outcome:
185
+ - `✅ Complete` — all steps succeeded, no issues found
186
+ - `❌ Failed` — command could not complete due to a blocking error
187
+ - `⚠️ Warnings` — completed with non-blocking issues that should be reviewed
188
+
189
+ ## Output Artifacts
190
+
191
+ List every file created or modified by this command:
192
+ ```
193
+ Output Artifacts:
194
+ {created|updated} {file-path} ({brief description})
195
+ {created|updated} {file-path} ({brief description})
196
+ ```
197
+
198
+ If no files were written (e.g., review or analysis commands) → write `Output Artifacts: none (read-only)`.
199
+
200
+ ## Next Command Suggestion
201
+
202
+ Suggest the logical next command based on workflow phase:
203
+
204
+ | Current command | Suggest next |
205
+ |-------------------------|-----------------------------------------------|
206
+ | /define-product | `/generate-prd {product-definition-file}` |
207
+ | /generate-prd | `/refine-prd {prd-file}` then `/review-context {prd-file}` |
208
+ | /refine-prd | Open Review Board → update PRD → `/review-context {prd-file}` |
209
+ | /review-context (PRD) | `/generate-bdd {prd-file}` if APPROVED; fix PRD if NEEDS_FIX |
210
+ | /generate-bdd | `/review-context {feature-file}` to verify coverage |
211
+ | /review-context (BDD) | `/generate-tech-docs {UC-ID}` if APPROVED; regenerate if NEEDS_FIX |
212
+ | /generate-tech-docs | `/review-tech-docs {tech-design-file}` |
213
+ | /review-tech-docs | `/generate-code {feature-file}` if APPROVED; fix doc if NEEDS_FIX |
214
+ | /generate-code | `/generate-tests {UC-ID}` |
215
+ | /generate-tests | `/run-tests {UC-ID}` |
216
+ | /run-tests (passing) | `/review-code {UC-ID}` |
217
+ | /run-tests (failing) | `/fix-bug {ticket-id}` or `/debug {error}` |
218
+ | /review-code | `/smoke-test {UC-ID}` or create PR |
219
+ | /smoke-test | Create PR and link to ticket |
220
+ | /validate-traces | `/generate-code {UC-ID}` for gaps |
221
+ | /fix-bug | Create PR and link to ticket |
222
+ | /debug | `/fix-bug {ticket-id}` if fix needed |
223
+
224
+ Format the footer as:
225
+ ```
226
+ ---
227
+ Status : {badge}
228
+ {Output Artifacts block}
229
+ Next : {suggested command with example arguments}
230
+ ```
231
+
232
+
233
+ ---
234
+
235
+ ## /generate-tech-docs — Generate Technical Design Document
236
+
237
+ ### Gate
238
+
239
+ Check BDD quality (read .feature files, verify scenarios are well-formed).
240
+ If quality < 80%, halt and report: "BDD quality insufficient. Fix these issues first: [list]"
241
+
242
+ ### Generate
243
+
244
+ Write `tech-docs/{domain}/{UC-ID}-tech-design.md`:
245
+
246
+ ```markdown
247
+ # Technical Design — {UC-ID}: {Feature}
248
+
249
+ **Domain**: {domain}
250
+ **Date**: {date}
251
+ **Spec**: specs/bdd/{domain}/{UC-ID}.feature
252
+
253
+ ## §1. Overview
254
+ {Brief description of what this UC implements}
255
+
256
+ ## §2. API Endpoints
257
+
258
+ | Method | Path | Auth/Role | Request Body | Response |
259
+ |--------|------|-----------|--------------|----------|
260
+ | GET | /v1/{resource} | {role} | — | {ResponseDTO} |
261
+ | POST | /v1/{resource} | {role} | {RequestDTO} | {ResponseDTO} |
262
+
263
+ ## §3. Data Model
264
+
265
+ {Entity diagram or table structure}
266
+
267
+ Key entities:
268
+ - `{Entity}`: {description, key fields}
269
+
270
+ ## §4. Service Flow
271
+
272
+ Sequence for each UC:
273
+ ```
274
+ {Client} → Controller → {Facade} → {Service} → {Repository}
275
+
276
+ {OtherService} (if cross-service)
277
+ ```
278
+
279
+ ## §5. Business Rules Implementation
280
+
281
+ | BR-ID | Rule | Implementation approach |
282
+ |-------|------|------------------------|
283
+ | BR-1 | {rule} | {how to implement} |
284
+
285
+ ## §6. Error Handling
286
+
287
+ | Scenario | Exception | HTTP Status |
288
+ |----------|-----------|-------------|
289
+ | {resource} not found | {NotFoundException} | 404 |
290
+ | Validation failure | {ValidationException} | 400 |
291
+ | Unauthorized | {AuthException} | 403 |
292
+
293
+ ## §7. Database Changes
294
+
295
+ {Migration script or schema changes needed}
296
+
297
+ ## §8. Caching Strategy
298
+
299
+ {Which data to cache, TTL, invalidation triggers — or "N/A"}
300
+
301
+ ## §9. Cross-Service Dependencies
302
+
303
+ {List external service calls, event producers/consumers}
304
+ ```
305
+
306
+ Instruct: "SA/Lead should review and approve before running /generate-code."
307
+
308
+ # Report Footer — Standard Command Output Format
309
+
310
+ Every command report must end with this standard footer section.
311
+
312
+ ## Status Badge
313
+
314
+ Choose one based on outcome:
315
+ - `✅ Complete` — all steps succeeded, no issues found
316
+ - `❌ Failed` — command could not complete due to a blocking error
317
+ - `⚠️ Warnings` — completed with non-blocking issues that should be reviewed
318
+
319
+ ## Output Artifacts
320
+
321
+ List every file created or modified by this command:
322
+ ```
323
+ Output Artifacts:
324
+ {created|updated} {file-path} ({brief description})
325
+ {created|updated} {file-path} ({brief description})
326
+ ```
327
+
328
+ If no files were written (e.g., review or analysis commands) → write `Output Artifacts: none (read-only)`.
329
+
330
+ ## Next Command Suggestion
331
+
332
+ Suggest the logical next command based on workflow phase:
333
+
334
+ | Current command | Suggest next |
335
+ |-------------------------|-----------------------------------------------|
336
+ | /define-product | `/generate-prd {product-definition-file}` |
337
+ | /generate-prd | `/refine-prd {prd-file}` then `/review-context {prd-file}` |
338
+ | /refine-prd | Open Review Board → update PRD → `/review-context {prd-file}` |
339
+ | /review-context (PRD) | `/generate-bdd {prd-file}` if APPROVED; fix PRD if NEEDS_FIX |
340
+ | /generate-bdd | `/review-context {feature-file}` to verify coverage |
341
+ | /review-context (BDD) | `/generate-tech-docs {UC-ID}` if APPROVED; regenerate if NEEDS_FIX |
342
+ | /generate-tech-docs | `/review-tech-docs {tech-design-file}` |
343
+ | /review-tech-docs | `/generate-code {feature-file}` if APPROVED; fix doc if NEEDS_FIX |
344
+ | /generate-code | `/generate-tests {UC-ID}` |
345
+ | /generate-tests | `/run-tests {UC-ID}` |
346
+ | /run-tests (passing) | `/review-code {UC-ID}` |
347
+ | /run-tests (failing) | `/fix-bug {ticket-id}` or `/debug {error}` |
348
+ | /review-code | `/smoke-test {UC-ID}` or create PR |
349
+ | /smoke-test | Create PR and link to ticket |
350
+ | /validate-traces | `/generate-code {UC-ID}` for gaps |
351
+ | /fix-bug | Create PR and link to ticket |
352
+ | /debug | `/fix-bug {ticket-id}` if fix needed |
353
+
354
+ Format the footer as:
355
+ ```
356
+ ---
357
+ Status : {badge}
358
+ {Output Artifacts block}
359
+ Next : {suggested command with example arguments}
360
+ ```
361
+