@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.
- package/ARCHITECTURE.md +243 -0
- package/bin/build.js +230 -0
- package/bin/index.js +311 -0
- package/commands/debug.md +374 -0
- package/commands/debug.tmpl +77 -0
- package/commands/define-product.md +451 -0
- package/commands/define-product.tmpl +154 -0
- package/commands/fix-bug.md +379 -0
- package/commands/fix-bug.tmpl +82 -0
- package/commands/generate-bdd.md +591 -0
- package/commands/generate-bdd.tmpl +294 -0
- package/commands/generate-code.md +395 -0
- package/commands/generate-code.tmpl +98 -0
- package/commands/generate-prd.md +488 -0
- package/commands/generate-prd.tmpl +191 -0
- package/commands/generate-tech-docs.md +362 -0
- package/commands/generate-tech-docs.tmpl +65 -0
- package/commands/generate-tests.md +377 -0
- package/commands/generate-tests.tmpl +80 -0
- package/commands/refine-prd.md +408 -0
- package/commands/refine-prd.tmpl +111 -0
- package/commands/review-code.md +354 -0
- package/commands/review-code.tmpl +57 -0
- package/commands/review-context.md +646 -0
- package/commands/review-context.tmpl +349 -0
- package/commands/review-tech-docs.md +518 -0
- package/commands/review-tech-docs.tmpl +221 -0
- package/commands/run-tests.md +343 -0
- package/commands/run-tests.tmpl +46 -0
- package/commands/setup-ai-first.md +278 -0
- package/commands/setup-ai-first.tmpl +197 -0
- package/commands/smoke-test.md +366 -0
- package/commands/smoke-test.tmpl +69 -0
- package/commands/validate-traces.md +529 -0
- package/commands/validate-traces.tmpl +232 -0
- package/core/FRAMEWORK_VERSION +1 -0
- package/core/commands/debug.md +374 -0
- package/core/commands/define-product.md +451 -0
- package/core/commands/fix-bug.md +379 -0
- package/core/commands/generate-bdd.md +591 -0
- package/core/commands/generate-code.md +395 -0
- package/core/commands/generate-prd.md +488 -0
- package/core/commands/generate-tech-docs.md +362 -0
- package/core/commands/generate-tests.md +377 -0
- package/core/commands/refine-prd.md +408 -0
- package/core/commands/review-code.md +354 -0
- package/core/commands/review-context.md +646 -0
- package/core/commands/review-tech-docs.md +518 -0
- package/core/commands/run-tests.md +343 -0
- package/core/commands/setup-ai-first.md +278 -0
- package/core/commands/smoke-test.md +366 -0
- package/core/commands/validate-traces.md +529 -0
- package/core/hooks/data-guard.js +141 -0
- package/core/hooks/settings.json +18 -0
- package/core/modules/angular/architecture-snippets/component-patterns.md +187 -0
- package/core/modules/angular/module.yaml +6 -0
- package/core/modules/angular/stack-profile.yaml +38 -0
- package/core/modules/context-engineering/architecture-snippets/context-design.md +119 -0
- package/core/modules/context-engineering/module.yaml +9 -0
- package/core/modules/context-engineering/stack-profile.yaml +61 -0
- package/core/modules/dotnet/architecture-snippets/clean-arch.md +160 -0
- package/core/modules/dotnet/module.yaml +6 -0
- package/core/modules/dotnet/stack-profile.yaml +50 -0
- package/core/modules/golang/architecture-snippets/domain-layout.md +283 -0
- package/core/modules/golang/module.yaml +6 -0
- package/core/modules/golang/stack-profile.yaml +40 -0
- package/core/modules/java-spring/architecture-snippets/layered-arch.md +201 -0
- package/core/modules/java-spring/module.yaml +15 -0
- package/core/modules/java-spring/stack-profile.yaml +28 -0
- package/core/modules/nextjs/architecture-snippets/app-router-patterns.md +269 -0
- package/core/modules/nextjs/module.yaml +14 -0
- package/core/modules/nextjs/stack-profile.yaml +74 -0
- package/core/modules/php-laravel/architecture-snippets/service-repository.md +302 -0
- package/core/modules/php-laravel/module.yaml +15 -0
- package/core/modules/php-laravel/stack-profile.yaml +56 -0
- package/core/modules/react/architecture-snippets/hooks-query-patterns.md +254 -0
- package/core/modules/react/module.yaml +14 -0
- package/core/modules/react/stack-profile.yaml +63 -0
- package/core/rules/data-protection.md +80 -0
- package/core/rules/workflow.md +44 -0
- package/core/skills/code/SKILL.md +526 -0
- package/core/skills/debug/SKILL.md +584 -0
- package/core/skills/discovery/SKILL.md +363 -0
- package/core/skills/prd/SKILL.md +456 -0
- package/core/skills/setup-ai-first/SKILL.md +160 -0
- package/core/skills/spec/SKILL.md +361 -0
- package/core/skills/test/SKILL.md +862 -0
- package/core/steps/context-loader.md +163 -0
- package/core/steps/gate.md +81 -0
- package/core/steps/report-footer.md +53 -0
- package/core/steps/spawn-agent.md +123 -0
- package/core/templates/architecture.template.md +113 -0
- package/core/templates/feature.template +259 -0
- package/core/templates/platform-guide.template.md +145 -0
- package/core/templates/prd.template.md +312 -0
- package/core/templates/product-definition.template.md +168 -0
- package/core/templates/project-context.yaml +78 -0
- package/hooks/data-guard.js +141 -0
- package/hooks/settings.json +18 -0
- package/modules/angular/architecture-snippets/component-patterns.md +187 -0
- package/modules/angular/module.yaml +6 -0
- package/modules/angular/stack-profile.yaml +38 -0
- package/modules/context-engineering/architecture-snippets/context-design.md +119 -0
- package/modules/context-engineering/module.yaml +9 -0
- package/modules/context-engineering/stack-profile.yaml +61 -0
- package/modules/dotnet/architecture-snippets/clean-arch.md +160 -0
- package/modules/dotnet/module.yaml +6 -0
- package/modules/dotnet/stack-profile.yaml +50 -0
- package/modules/golang/architecture-snippets/domain-layout.md +283 -0
- package/modules/golang/module.yaml +6 -0
- package/modules/golang/stack-profile.yaml +40 -0
- package/modules/java-spring/architecture-snippets/layered-arch.md +201 -0
- package/modules/java-spring/module.yaml +15 -0
- package/modules/java-spring/stack-profile.yaml +28 -0
- package/modules/nextjs/architecture-snippets/app-router-patterns.md +269 -0
- package/modules/nextjs/module.yaml +14 -0
- package/modules/nextjs/stack-profile.yaml +74 -0
- package/modules/php-laravel/architecture-snippets/service-repository.md +302 -0
- package/modules/php-laravel/module.yaml +15 -0
- package/modules/php-laravel/stack-profile.yaml +56 -0
- package/modules/react/architecture-snippets/hooks-query-patterns.md +254 -0
- package/modules/react/module.yaml +14 -0
- package/modules/react/stack-profile.yaml +63 -0
- package/package.json +42 -0
- package/rules/data-protection.md +80 -0
- package/rules/workflow.md +44 -0
- package/scripts/init.sh +49 -0
- package/scripts/upgrade.sh +94 -0
- package/skills/code/SKILL.md +526 -0
- package/skills/code/SKILL.tmpl +176 -0
- package/skills/debug/SKILL.md +584 -0
- package/skills/debug/SKILL.tmpl +262 -0
- package/skills/discovery/SKILL.md +363 -0
- package/skills/discovery/SKILL.tmpl +147 -0
- package/skills/prd/SKILL.md +456 -0
- package/skills/prd/SKILL.tmpl +188 -0
- package/skills/setup-ai-first/SKILL.md +160 -0
- package/skills/setup-ai-first/SKILL.tmpl +107 -0
- package/skills/spec/SKILL.md +361 -0
- package/skills/spec/SKILL.tmpl +174 -0
- package/skills/test/SKILL.md +862 -0
- package/skills/test/SKILL.tmpl +296 -0
- package/steps/context-loader.md +163 -0
- package/steps/gate.md +81 -0
- package/steps/report-footer.md +53 -0
- package/steps/spawn-agent.md +123 -0
- package/templates/architecture.template.md +113 -0
- package/templates/feature.template +259 -0
- package/templates/platform-guide.template.md +145 -0
- package/templates/prd.template.md +312 -0
- package/templates/product-definition.template.md +168 -0
- 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
|
+
|
|
@@ -0,0 +1,174 @@
|
|
|
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
|
+
{{include:steps/gate.md}}
|
|
17
|
+
|
|
18
|
+
Also verify: Check that the PRD `Status` is `approved` (not `draft`).
|
|
19
|
+
- If `draft`: warn "PRD is still draft. Proceed anyway? Findings from /refine-prd may not be addressed yet."
|
|
20
|
+
|
|
21
|
+
### UC Decomposition
|
|
22
|
+
|
|
23
|
+
For each Use Case in the PRD, derive scenarios. Present outline:
|
|
24
|
+
|
|
25
|
+
```
|
|
26
|
+
{DOMAIN}-UC1: {Name}
|
|
27
|
+
SC1: Happy path — {client/role type} — {success scenario}
|
|
28
|
+
SC2: Happy path — {other client/role type} (if applicable)
|
|
29
|
+
SC3: Validation error — {invalid input}
|
|
30
|
+
SC4: Not found / resource missing
|
|
31
|
+
BRs covered: BR-1, BR-2
|
|
32
|
+
|
|
33
|
+
{DOMAIN}-UC2: {Name}
|
|
34
|
+
...
|
|
35
|
+
```
|
|
36
|
+
|
|
37
|
+
**CHECKPOINT** — Ask: "Does this outline look correct? Any missing scenarios?"
|
|
38
|
+
Wait for confirmation before generating files.
|
|
39
|
+
|
|
40
|
+
### Generate
|
|
41
|
+
|
|
42
|
+
For each UC, write `specs/bdd/{domain}/{UC-ID}-{slug}.feature`:
|
|
43
|
+
|
|
44
|
+
```gherkin
|
|
45
|
+
# @trace.source=specs/prd/{domain}/{slug}.md
|
|
46
|
+
# @trace.uc={UC-ID}
|
|
47
|
+
Feature: {UC Name}
|
|
48
|
+
|
|
49
|
+
Background:
|
|
50
|
+
Given the system is running
|
|
51
|
+
And a {persona} is authenticated
|
|
52
|
+
|
|
53
|
+
Scenario: SC1 — {Happy path description}
|
|
54
|
+
Given {precondition}
|
|
55
|
+
When {action}
|
|
56
|
+
Then {expected outcome}
|
|
57
|
+
And {secondary outcome if any}
|
|
58
|
+
|
|
59
|
+
Scenario: SC2 — {Another happy path}
|
|
60
|
+
Given {precondition}
|
|
61
|
+
When {action}
|
|
62
|
+
Then {expected outcome}
|
|
63
|
+
|
|
64
|
+
Scenario: SC3 — Validation error
|
|
65
|
+
Given {precondition}
|
|
66
|
+
When {invalid action}
|
|
67
|
+
Then the system returns a validation error
|
|
68
|
+
And the error message mentions "{field}"
|
|
69
|
+
|
|
70
|
+
Scenario: SC4 — Resource not found
|
|
71
|
+
Given no {resource} exists with id {id}
|
|
72
|
+
When {action}
|
|
73
|
+
Then the system returns a not-found error
|
|
74
|
+
```
|
|
75
|
+
|
|
76
|
+
### Quality Check
|
|
77
|
+
|
|
78
|
+
After generating, self-evaluate:
|
|
79
|
+
- [ ] Every acceptance criteria from PRD has at least one scenario
|
|
80
|
+
- [ ] Every business rule is covered by at least one scenario
|
|
81
|
+
- [ ] Error scenarios are present (validation, not-found, unauthorized)
|
|
82
|
+
- [ ] Scenarios are atomic (one behavior per scenario)
|
|
83
|
+
- [ ] No implementation details in feature files (no SQL, no class names)
|
|
84
|
+
|
|
85
|
+
### Output
|
|
86
|
+
|
|
87
|
+
```
|
|
88
|
+
/generate-bdd Complete — {domain}
|
|
89
|
+
|
|
90
|
+
Files created:
|
|
91
|
+
✅ specs/bdd/{domain}/{UC-ID}-{slug}.feature ({N} scenarios)
|
|
92
|
+
...
|
|
93
|
+
|
|
94
|
+
Quality: {score}%
|
|
95
|
+
```
|
|
96
|
+
|
|
97
|
+
{{include:steps/report-footer.md}}
|
|
98
|
+
|
|
99
|
+
---
|
|
100
|
+
|
|
101
|
+
## /generate-tech-docs — Generate Technical Design Document
|
|
102
|
+
|
|
103
|
+
### Gate
|
|
104
|
+
|
|
105
|
+
Check BDD quality (read .feature files, verify scenarios are well-formed).
|
|
106
|
+
If quality < 80%, halt and report: "BDD quality insufficient. Fix these issues first: [list]"
|
|
107
|
+
|
|
108
|
+
### Generate
|
|
109
|
+
|
|
110
|
+
Write `tech-docs/{domain}/{UC-ID}-tech-design.md`:
|
|
111
|
+
|
|
112
|
+
```markdown
|
|
113
|
+
# Technical Design — {UC-ID}: {Feature}
|
|
114
|
+
|
|
115
|
+
**Domain**: {domain}
|
|
116
|
+
**Date**: {date}
|
|
117
|
+
**Spec**: specs/bdd/{domain}/{UC-ID}.feature
|
|
118
|
+
|
|
119
|
+
## §1. Overview
|
|
120
|
+
{Brief description of what this UC implements}
|
|
121
|
+
|
|
122
|
+
## §2. API Endpoints
|
|
123
|
+
|
|
124
|
+
| Method | Path | Auth/Role | Request Body | Response |
|
|
125
|
+
|--------|------|-----------|--------------|----------|
|
|
126
|
+
| GET | /v1/{resource} | {role} | — | {ResponseDTO} |
|
|
127
|
+
| POST | /v1/{resource} | {role} | {RequestDTO} | {ResponseDTO} |
|
|
128
|
+
|
|
129
|
+
## §3. Data Model
|
|
130
|
+
|
|
131
|
+
{Entity diagram or table structure}
|
|
132
|
+
|
|
133
|
+
Key entities:
|
|
134
|
+
- `{Entity}`: {description, key fields}
|
|
135
|
+
|
|
136
|
+
## §4. Service Flow
|
|
137
|
+
|
|
138
|
+
Sequence for each UC:
|
|
139
|
+
```
|
|
140
|
+
{Client} → Controller → {Facade} → {Service} → {Repository}
|
|
141
|
+
↓
|
|
142
|
+
{OtherService} (if cross-service)
|
|
143
|
+
```
|
|
144
|
+
|
|
145
|
+
## §5. Business Rules Implementation
|
|
146
|
+
|
|
147
|
+
| BR-ID | Rule | Implementation approach |
|
|
148
|
+
|-------|------|------------------------|
|
|
149
|
+
| BR-1 | {rule} | {how to implement} |
|
|
150
|
+
|
|
151
|
+
## §6. Error Handling
|
|
152
|
+
|
|
153
|
+
| Scenario | Exception | HTTP Status |
|
|
154
|
+
|----------|-----------|-------------|
|
|
155
|
+
| {resource} not found | {NotFoundException} | 404 |
|
|
156
|
+
| Validation failure | {ValidationException} | 400 |
|
|
157
|
+
| Unauthorized | {AuthException} | 403 |
|
|
158
|
+
|
|
159
|
+
## §7. Database Changes
|
|
160
|
+
|
|
161
|
+
{Migration script or schema changes needed}
|
|
162
|
+
|
|
163
|
+
## §8. Caching Strategy
|
|
164
|
+
|
|
165
|
+
{Which data to cache, TTL, invalidation triggers — or "N/A"}
|
|
166
|
+
|
|
167
|
+
## §9. Cross-Service Dependencies
|
|
168
|
+
|
|
169
|
+
{List external service calls, event producers/consumers}
|
|
170
|
+
```
|
|
171
|
+
|
|
172
|
+
Instruct: "SA/Lead should review and approve before running /generate-code."
|
|
173
|
+
|
|
174
|
+
{{include:steps/report-footer.md}}
|