@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,278 @@
|
|
|
1
|
+
# /setup-ai-first — Initialize Spec-Driven Dev in a Project
|
|
2
|
+
|
|
3
|
+
Walk the user through a one-time setup that creates all required directories, installs CLAUDE.md, and verifies the environment.
|
|
4
|
+
|
|
5
|
+
## Gate
|
|
6
|
+
# Gate — Universal Entry Procedure
|
|
7
|
+
|
|
8
|
+
Every command must execute this gate before proceeding with its specific logic.
|
|
9
|
+
|
|
10
|
+
## Step 0 — Sub-Agent Mode Check
|
|
11
|
+
|
|
12
|
+
Before anything else, check if `$ARGUMENTS` is a JSON payload from an orchestrator:
|
|
13
|
+
|
|
14
|
+
1. Attempt to parse `$ARGUMENTS` as JSON.
|
|
15
|
+
2. If it parses successfully **and** contains `"_agent_mode": true`:
|
|
16
|
+
- **Skip Steps 1, 2, and 3 of this Gate entirely.**
|
|
17
|
+
- Set target file = `payload.target_file`
|
|
18
|
+
- Set loaded context = `payload.context` (do NOT run context-loader.md)
|
|
19
|
+
- Set UC scope = `payload.uc_id` (process only this UC)
|
|
20
|
+
- Set line range = `payload.uc_section` (read only that PRD section)
|
|
21
|
+
- Proceed directly to the command-specific logic.
|
|
22
|
+
3. If `$ARGUMENTS` is not JSON or `_agent_mode` is absent → continue to Step 1 (normal mode).
|
|
23
|
+
|
|
24
|
+
## Step 0-B — Model Check
|
|
25
|
+
|
|
26
|
+
*Skip this step if `_agent_mode: true` (sub-agent — orchestrator already validated).*
|
|
27
|
+
|
|
28
|
+
Complex generation and review commands require strong reasoning.
|
|
29
|
+
Using a smaller model risks missed edge cases, incomplete spec analysis, and architecture violations.
|
|
30
|
+
|
|
31
|
+
Display and wait for response:
|
|
32
|
+
|
|
33
|
+
```
|
|
34
|
+
⚙️ MODEL CHECK
|
|
35
|
+
──────────────────────────────────────────────────────────────────
|
|
36
|
+
Recommended : claude-opus-4-5 (or claude-opus-4)
|
|
37
|
+
Why needed : Spec analysis, architecture review, code generation
|
|
38
|
+
require deep reasoning. Smaller models miss edge cases.
|
|
39
|
+
|
|
40
|
+
To switch in Claude Code:
|
|
41
|
+
• Settings → Model → select "claude-opus"
|
|
42
|
+
• or: /model → choose claude-opus
|
|
43
|
+
|
|
44
|
+
Running on claude-opus?
|
|
45
|
+
Y — yes, on claude-opus → proceed
|
|
46
|
+
S — skip check (I accept lower quality risk with current model)
|
|
47
|
+
──────────────────────────────────────────────────────────────────
|
|
48
|
+
```
|
|
49
|
+
|
|
50
|
+
- "Y" → proceed to Step 1.
|
|
51
|
+
- "S" → proceed to Step 1 (user accepts risk, add ⚠️ to final report).
|
|
52
|
+
- "N" or anything else → **STOP.** Output: "Please switch to claude-opus, then re-run this command."
|
|
53
|
+
|
|
54
|
+
## Step 1 — Resolve Target File
|
|
55
|
+
|
|
56
|
+
1. If `$ARGUMENTS` is provided and points to an existing file → use it directly as the target.
|
|
57
|
+
2. If `$ARGUMENTS` is a UC-ID, ticket ID, or partial name → search for matching files in the relevant directory.
|
|
58
|
+
3. If `$ARGUMENTS` is empty or no match found:
|
|
59
|
+
- List files in the relevant directory for this command (e.g., `specs/prd/**/*.md` for PRD commands, `specs/bdd/**/*.feature` for BDD commands).
|
|
60
|
+
- Present the list to the user and ask: "Which file do you want to work with? (Enter number or filename)"
|
|
61
|
+
- Wait for user selection before continuing.
|
|
62
|
+
|
|
63
|
+
## Step 2 — Execute Context Loader
|
|
64
|
+
|
|
65
|
+
Load all project context by following the procedure in `steps/context-loader.md`.
|
|
66
|
+
Store all loaded context in memory for use throughout this command session.
|
|
67
|
+
|
|
68
|
+
## Step 3 — CHECKPOINT
|
|
69
|
+
|
|
70
|
+
After completing Steps 1 and 2, display a summary and wait for confirmation:
|
|
71
|
+
|
|
72
|
+
```
|
|
73
|
+
CHECKPOINT
|
|
74
|
+
-----------
|
|
75
|
+
Target : {resolved file path}
|
|
76
|
+
Project : {project.name from project-context.yaml}
|
|
77
|
+
Tech stack : {language} / {framework}
|
|
78
|
+
Module : {module if set, else "not configured"}
|
|
79
|
+
Domains : {comma-separated domain list}
|
|
80
|
+
|
|
81
|
+
Proceed? (Y/N)
|
|
82
|
+
```
|
|
83
|
+
|
|
84
|
+
Wait for explicit "Y" or "N" from the user before continuing.
|
|
85
|
+
- "Y" → proceed to the command-specific steps below.
|
|
86
|
+
- "N" → stop and ask what the user wants to change.
|
|
87
|
+
|
|
88
|
+
|
|
89
|
+
*Note: For this command, there is no input file. Skip Step 1 file discovery. In Step 2, skip project-context.yaml loading (it does not exist yet). Ask: "Which project are you setting up? Give me the root path of the project."*
|
|
90
|
+
|
|
91
|
+
---
|
|
92
|
+
|
|
93
|
+
## Precondition Check
|
|
94
|
+
|
|
95
|
+
Check if already set up:
|
|
96
|
+
- If `.claude/commands/` exists with `.md` files → report "Already set up."
|
|
97
|
+
- If `specs/` exists → offer to re-initialize or skip
|
|
98
|
+
|
|
99
|
+
## Step 1 — Create Directory Structure
|
|
100
|
+
|
|
101
|
+
Create these directories (skip if they exist):
|
|
102
|
+
|
|
103
|
+
```
|
|
104
|
+
{project-root}/
|
|
105
|
+
├── specs/
|
|
106
|
+
│ ├── product-definition/
|
|
107
|
+
│ ├── prd/
|
|
108
|
+
│ ├── bdd/
|
|
109
|
+
│ └── domain-knowledge/ ← business dictionary & domain context
|
|
110
|
+
├── tech-docs/
|
|
111
|
+
├── .trace/
|
|
112
|
+
└── .agent/
|
|
113
|
+
└── review/
|
|
114
|
+
```
|
|
115
|
+
|
|
116
|
+
## Step 2 — Create CLAUDE.md
|
|
117
|
+
|
|
118
|
+
Check if `CLAUDE.md` exists:
|
|
119
|
+
- Yes → ask "Merge template or skip?"
|
|
120
|
+
- No → create from the template below
|
|
121
|
+
|
|
122
|
+
After creating, instruct: "Open CLAUDE.md and fill in the `{{PLACEHOLDER}}` values with your project information."
|
|
123
|
+
|
|
124
|
+
### CLAUDE.md Template
|
|
125
|
+
|
|
126
|
+
```
|
|
127
|
+
# §1. Project Overview
|
|
128
|
+
Project: {{PROJECT_NAME}}
|
|
129
|
+
Language: {{LANGUAGE}}
|
|
130
|
+
Framework: {{FRAMEWORK}}
|
|
131
|
+
Build: {{BUILD_COMMAND}}
|
|
132
|
+
Test: {{TEST_COMMAND}}
|
|
133
|
+
Domains: {{COMMA_SEPARATED_DOMAINS}}
|
|
134
|
+
|
|
135
|
+
# §2. Architecture
|
|
136
|
+
layers: "{{LAYER_STACK}}"
|
|
137
|
+
# Example: Controller → Facade → Service → Repository
|
|
138
|
+
rules:
|
|
139
|
+
- "Controllers must not contain business logic"
|
|
140
|
+
- "Services own transaction boundaries"
|
|
141
|
+
|
|
142
|
+
# §3. Coding Standards
|
|
143
|
+
naming:
|
|
144
|
+
classes: "{{NAMING_CONVENTION}}"
|
|
145
|
+
methods: "{{METHOD_CONVENTION}}"
|
|
146
|
+
response_wrapper: "{{WRAPPER}}"
|
|
147
|
+
forbidden:
|
|
148
|
+
- "Magic numbers"
|
|
149
|
+
- "Debug print statements"
|
|
150
|
+
|
|
151
|
+
# §4. Traceability
|
|
152
|
+
# Every controller method must be tagged:
|
|
153
|
+
# @trace.implements={UC-ID}-{SC-ID}
|
|
154
|
+
# @trace.source=specs/bdd/{domain}/{UC-ID}.feature
|
|
155
|
+
# Tests must be tagged:
|
|
156
|
+
# @trace.verifies={UC-ID}
|
|
157
|
+
|
|
158
|
+
# §5. Error Handling
|
|
159
|
+
not_found: "{{NOT_FOUND_EXCEPTION}}"
|
|
160
|
+
http_codes: { get: 200, create: 201, not_found: 404, validation: 400 }
|
|
161
|
+
|
|
162
|
+
# §6. Build & Test
|
|
163
|
+
build_command: "{{BUILD_COMMAND}}"
|
|
164
|
+
test_command: "{{TEST_COMMAND}}"
|
|
165
|
+
run_command: "{{RUN_COMMAND}}"
|
|
166
|
+
|
|
167
|
+
# §7. Git Conventions
|
|
168
|
+
branch_feature: "feature/{{TICKET_PREFIX}}-{N}-{slug}"
|
|
169
|
+
commit_feature: "feat({{TICKET_PREFIX}}-{N}): {description}"
|
|
170
|
+
```
|
|
171
|
+
|
|
172
|
+
## Step 3 — Create project-context.yaml
|
|
173
|
+
|
|
174
|
+
Create `.agent/project-context.yaml` using `templates/project-context.yaml` as the source template.
|
|
175
|
+
|
|
176
|
+
Copy the template and instruct: "Open `.agent/project-context.yaml` and fill in all `{{PLACEHOLDER}}` values. The `paths` section is pre-configured with sensible defaults — adjust if your project uses different directory names."
|
|
177
|
+
|
|
178
|
+
## Step 4 — Create business-dictionary.md
|
|
179
|
+
|
|
180
|
+
Create `specs/domain-knowledge/business-dictionary.md` if it does not exist:
|
|
181
|
+
|
|
182
|
+
```markdown
|
|
183
|
+
# Business Dictionary — {{PROJECT_NAME}}
|
|
184
|
+
|
|
185
|
+
> Canonical terminology for this project. All PRDs, BDD specs, and code must follow these terms.
|
|
186
|
+
> Managed by: PO / SA team.
|
|
187
|
+
|
|
188
|
+
## Canonical Terms
|
|
189
|
+
|
|
190
|
+
| Canonical Term | Description / Context |
|
|
191
|
+
|----------------|----------------------|
|
|
192
|
+
| {Term} | {Short description, usage scope} |
|
|
193
|
+
|
|
194
|
+
## Banned Terms
|
|
195
|
+
|
|
196
|
+
| ❌ Do NOT use | ✅ Use instead | Reason |
|
|
197
|
+
|---------------|-------------------|--------|
|
|
198
|
+
| {banned} | {canonical} | {why} |
|
|
199
|
+
|
|
200
|
+
## Status / Enum Registry
|
|
201
|
+
|
|
202
|
+
| Entity | Field | Allowed Values |
|
|
203
|
+
|--------|---------|--------------------|
|
|
204
|
+
| {Entity} | status | {value1, value2} |
|
|
205
|
+
```
|
|
206
|
+
|
|
207
|
+
Instruct: "Open `specs/domain-knowledge/business-dictionary.md` and add your project terminology. This file will be read by all commands to enforce consistent naming."
|
|
208
|
+
|
|
209
|
+
## Step 5 — Create core-entities.md
|
|
210
|
+
|
|
211
|
+
Create `specs/domain-knowledge/core-entities.md` if it does not exist:
|
|
212
|
+
|
|
213
|
+
```markdown
|
|
214
|
+
# Core Entities — {{PROJECT_NAME}}
|
|
215
|
+
|
|
216
|
+
> Machine-readable entity glossary for AI-assisted development.
|
|
217
|
+
> Loaded by all commands so AI knows your domain model without reading source code.
|
|
218
|
+
> Managed by: Tech Lead / Architect.
|
|
219
|
+
>
|
|
220
|
+
> HOW TO USE:
|
|
221
|
+
> - Add one `## Entity: {Name}` section per domain entity (aggregate root, value object, etc.)
|
|
222
|
+
> - Keep field descriptions concise — this is a REFERENCE, not API docs
|
|
223
|
+
> - Update this file whenever you add/rename fields or change business invariants
|
|
224
|
+
|
|
225
|
+
---
|
|
226
|
+
|
|
227
|
+
## Entity: {EntityName}
|
|
228
|
+
|
|
229
|
+
**Purpose**: {1-2 sentences — what this entity represents and why it exists in the domain}
|
|
230
|
+
**Domain**: {domain}
|
|
231
|
+
**Storage**: {e.g., `orders` table in PostgreSQL | `orders` collection in MongoDB}
|
|
232
|
+
**Owner service**: {service/module that owns this entity}
|
|
233
|
+
|
|
234
|
+
| Field | Type | Nullable | Description |
|
|
235
|
+
|--------------|---------|----------|-------------------------------------|
|
|
236
|
+
| id | UUID | No | Primary key |
|
|
237
|
+
| {field_name} | {type} | Yes/No | {short description} |
|
|
238
|
+
| status | Enum | No | See Status Registry in business-dictionary.md |
|
|
239
|
+
|
|
240
|
+
**Business invariants:**
|
|
241
|
+
- {Rule 1: e.g., "status can only transition: PENDING → ACTIVE → CLOSED"}
|
|
242
|
+
- {Rule 2: e.g., "total must equal sum of line items"}
|
|
243
|
+
|
|
244
|
+
**Relationships:**
|
|
245
|
+
- `{EntityA}` 1:N `{EntityB}` — {one sentence description}
|
|
246
|
+
- `{EntityA}` N:N `{EntityC}` via `{junction_table}` — {description}
|
|
247
|
+
|
|
248
|
+
---
|
|
249
|
+
|
|
250
|
+
## Entity: {AnotherEntity}
|
|
251
|
+
|
|
252
|
+
*(Add more entities following the same pattern above)*
|
|
253
|
+
```
|
|
254
|
+
|
|
255
|
+
Instruct: "Open `specs/domain-knowledge/core-entities.md` and define your key domain entities. Start with aggregate roots. This file is loaded by every AI command — good definitions here save significant back-and-forth during code generation."
|
|
256
|
+
|
|
257
|
+
## Step 6 — Verify
|
|
258
|
+
|
|
259
|
+
- [ ] `specs/` exists
|
|
260
|
+
- [ ] `specs/domain-knowledge/` exists
|
|
261
|
+
- [ ] `.trace/` exists
|
|
262
|
+
- [ ] `.agent/project-context.yaml` exists
|
|
263
|
+
- [ ] `CLAUDE.md` exists
|
|
264
|
+
- [ ] `specs/domain-knowledge/business-dictionary.md` exists
|
|
265
|
+
- [ ] `specs/domain-knowledge/core-entities.md` exists
|
|
266
|
+
|
|
267
|
+
## Output
|
|
268
|
+
|
|
269
|
+
```
|
|
270
|
+
/setup-ai-first Complete ✅
|
|
271
|
+
Next:
|
|
272
|
+
1. Fill CLAUDE.md (replace {{PLACEHOLDER}} values)
|
|
273
|
+
2. Fill .agent/project-context.yaml
|
|
274
|
+
3. Fill specs/domain-knowledge/business-dictionary.md ← terminology rules
|
|
275
|
+
4. Fill specs/domain-knowledge/core-entities.md ← entity glossary for code gen
|
|
276
|
+
5. git add and commit those 4 files
|
|
277
|
+
6. /define-product to start your first feature
|
|
278
|
+
```
|
|
@@ -0,0 +1,197 @@
|
|
|
1
|
+
# /setup-ai-first — Initialize Spec-Driven Dev in a Project
|
|
2
|
+
|
|
3
|
+
Walk the user through a one-time setup that creates all required directories, installs CLAUDE.md, and verifies the environment.
|
|
4
|
+
|
|
5
|
+
## Gate
|
|
6
|
+
{{include:steps/gate.md}}
|
|
7
|
+
|
|
8
|
+
*Note: For this command, there is no input file. Skip Step 1 file discovery. In Step 2, skip project-context.yaml loading (it does not exist yet). Ask: "Which project are you setting up? Give me the root path of the project."*
|
|
9
|
+
|
|
10
|
+
---
|
|
11
|
+
|
|
12
|
+
## Precondition Check
|
|
13
|
+
|
|
14
|
+
Check if already set up:
|
|
15
|
+
- If `.claude/commands/` exists with `.md` files → report "Already set up."
|
|
16
|
+
- If `specs/` exists → offer to re-initialize or skip
|
|
17
|
+
|
|
18
|
+
## Step 1 — Create Directory Structure
|
|
19
|
+
|
|
20
|
+
Create these directories (skip if they exist):
|
|
21
|
+
|
|
22
|
+
```
|
|
23
|
+
{project-root}/
|
|
24
|
+
├── specs/
|
|
25
|
+
│ ├── product-definition/
|
|
26
|
+
│ ├── prd/
|
|
27
|
+
│ ├── bdd/
|
|
28
|
+
│ └── domain-knowledge/ ← business dictionary & domain context
|
|
29
|
+
├── tech-docs/
|
|
30
|
+
├── .trace/
|
|
31
|
+
└── .agent/
|
|
32
|
+
└── review/
|
|
33
|
+
```
|
|
34
|
+
|
|
35
|
+
## Step 2 — Create CLAUDE.md
|
|
36
|
+
|
|
37
|
+
Check if `CLAUDE.md` exists:
|
|
38
|
+
- Yes → ask "Merge template or skip?"
|
|
39
|
+
- No → create from the template below
|
|
40
|
+
|
|
41
|
+
After creating, instruct: "Open CLAUDE.md and fill in the `{{PLACEHOLDER}}` values with your project information."
|
|
42
|
+
|
|
43
|
+
### CLAUDE.md Template
|
|
44
|
+
|
|
45
|
+
```
|
|
46
|
+
# §1. Project Overview
|
|
47
|
+
Project: {{PROJECT_NAME}}
|
|
48
|
+
Language: {{LANGUAGE}}
|
|
49
|
+
Framework: {{FRAMEWORK}}
|
|
50
|
+
Build: {{BUILD_COMMAND}}
|
|
51
|
+
Test: {{TEST_COMMAND}}
|
|
52
|
+
Domains: {{COMMA_SEPARATED_DOMAINS}}
|
|
53
|
+
|
|
54
|
+
# §2. Architecture
|
|
55
|
+
layers: "{{LAYER_STACK}}"
|
|
56
|
+
# Example: Controller → Facade → Service → Repository
|
|
57
|
+
rules:
|
|
58
|
+
- "Controllers must not contain business logic"
|
|
59
|
+
- "Services own transaction boundaries"
|
|
60
|
+
|
|
61
|
+
# §3. Coding Standards
|
|
62
|
+
naming:
|
|
63
|
+
classes: "{{NAMING_CONVENTION}}"
|
|
64
|
+
methods: "{{METHOD_CONVENTION}}"
|
|
65
|
+
response_wrapper: "{{WRAPPER}}"
|
|
66
|
+
forbidden:
|
|
67
|
+
- "Magic numbers"
|
|
68
|
+
- "Debug print statements"
|
|
69
|
+
|
|
70
|
+
# §4. Traceability
|
|
71
|
+
# Every controller method must be tagged:
|
|
72
|
+
# @trace.implements={UC-ID}-{SC-ID}
|
|
73
|
+
# @trace.source=specs/bdd/{domain}/{UC-ID}.feature
|
|
74
|
+
# Tests must be tagged:
|
|
75
|
+
# @trace.verifies={UC-ID}
|
|
76
|
+
|
|
77
|
+
# §5. Error Handling
|
|
78
|
+
not_found: "{{NOT_FOUND_EXCEPTION}}"
|
|
79
|
+
http_codes: { get: 200, create: 201, not_found: 404, validation: 400 }
|
|
80
|
+
|
|
81
|
+
# §6. Build & Test
|
|
82
|
+
build_command: "{{BUILD_COMMAND}}"
|
|
83
|
+
test_command: "{{TEST_COMMAND}}"
|
|
84
|
+
run_command: "{{RUN_COMMAND}}"
|
|
85
|
+
|
|
86
|
+
# §7. Git Conventions
|
|
87
|
+
branch_feature: "feature/{{TICKET_PREFIX}}-{N}-{slug}"
|
|
88
|
+
commit_feature: "feat({{TICKET_PREFIX}}-{N}): {description}"
|
|
89
|
+
```
|
|
90
|
+
|
|
91
|
+
## Step 3 — Create project-context.yaml
|
|
92
|
+
|
|
93
|
+
Create `.agent/project-context.yaml` using `templates/project-context.yaml` as the source template.
|
|
94
|
+
|
|
95
|
+
Copy the template and instruct: "Open `.agent/project-context.yaml` and fill in all `{{PLACEHOLDER}}` values. The `paths` section is pre-configured with sensible defaults — adjust if your project uses different directory names."
|
|
96
|
+
|
|
97
|
+
## Step 4 — Create business-dictionary.md
|
|
98
|
+
|
|
99
|
+
Create `specs/domain-knowledge/business-dictionary.md` if it does not exist:
|
|
100
|
+
|
|
101
|
+
```markdown
|
|
102
|
+
# Business Dictionary — {{PROJECT_NAME}}
|
|
103
|
+
|
|
104
|
+
> Canonical terminology for this project. All PRDs, BDD specs, and code must follow these terms.
|
|
105
|
+
> Managed by: PO / SA team.
|
|
106
|
+
|
|
107
|
+
## Canonical Terms
|
|
108
|
+
|
|
109
|
+
| Canonical Term | Description / Context |
|
|
110
|
+
|----------------|----------------------|
|
|
111
|
+
| {Term} | {Short description, usage scope} |
|
|
112
|
+
|
|
113
|
+
## Banned Terms
|
|
114
|
+
|
|
115
|
+
| ❌ Do NOT use | ✅ Use instead | Reason |
|
|
116
|
+
|---------------|-------------------|--------|
|
|
117
|
+
| {banned} | {canonical} | {why} |
|
|
118
|
+
|
|
119
|
+
## Status / Enum Registry
|
|
120
|
+
|
|
121
|
+
| Entity | Field | Allowed Values |
|
|
122
|
+
|--------|---------|--------------------|
|
|
123
|
+
| {Entity} | status | {value1, value2} |
|
|
124
|
+
```
|
|
125
|
+
|
|
126
|
+
Instruct: "Open `specs/domain-knowledge/business-dictionary.md` and add your project terminology. This file will be read by all commands to enforce consistent naming."
|
|
127
|
+
|
|
128
|
+
## Step 5 — Create core-entities.md
|
|
129
|
+
|
|
130
|
+
Create `specs/domain-knowledge/core-entities.md` if it does not exist:
|
|
131
|
+
|
|
132
|
+
```markdown
|
|
133
|
+
# Core Entities — {{PROJECT_NAME}}
|
|
134
|
+
|
|
135
|
+
> Machine-readable entity glossary for AI-assisted development.
|
|
136
|
+
> Loaded by all commands so AI knows your domain model without reading source code.
|
|
137
|
+
> Managed by: Tech Lead / Architect.
|
|
138
|
+
>
|
|
139
|
+
> HOW TO USE:
|
|
140
|
+
> - Add one `## Entity: {Name}` section per domain entity (aggregate root, value object, etc.)
|
|
141
|
+
> - Keep field descriptions concise — this is a REFERENCE, not API docs
|
|
142
|
+
> - Update this file whenever you add/rename fields or change business invariants
|
|
143
|
+
|
|
144
|
+
---
|
|
145
|
+
|
|
146
|
+
## Entity: {EntityName}
|
|
147
|
+
|
|
148
|
+
**Purpose**: {1-2 sentences — what this entity represents and why it exists in the domain}
|
|
149
|
+
**Domain**: {domain}
|
|
150
|
+
**Storage**: {e.g., `orders` table in PostgreSQL | `orders` collection in MongoDB}
|
|
151
|
+
**Owner service**: {service/module that owns this entity}
|
|
152
|
+
|
|
153
|
+
| Field | Type | Nullable | Description |
|
|
154
|
+
|--------------|---------|----------|-------------------------------------|
|
|
155
|
+
| id | UUID | No | Primary key |
|
|
156
|
+
| {field_name} | {type} | Yes/No | {short description} |
|
|
157
|
+
| status | Enum | No | See Status Registry in business-dictionary.md |
|
|
158
|
+
|
|
159
|
+
**Business invariants:**
|
|
160
|
+
- {Rule 1: e.g., "status can only transition: PENDING → ACTIVE → CLOSED"}
|
|
161
|
+
- {Rule 2: e.g., "total must equal sum of line items"}
|
|
162
|
+
|
|
163
|
+
**Relationships:**
|
|
164
|
+
- `{EntityA}` 1:N `{EntityB}` — {one sentence description}
|
|
165
|
+
- `{EntityA}` N:N `{EntityC}` via `{junction_table}` — {description}
|
|
166
|
+
|
|
167
|
+
---
|
|
168
|
+
|
|
169
|
+
## Entity: {AnotherEntity}
|
|
170
|
+
|
|
171
|
+
*(Add more entities following the same pattern above)*
|
|
172
|
+
```
|
|
173
|
+
|
|
174
|
+
Instruct: "Open `specs/domain-knowledge/core-entities.md` and define your key domain entities. Start with aggregate roots. This file is loaded by every AI command — good definitions here save significant back-and-forth during code generation."
|
|
175
|
+
|
|
176
|
+
## Step 6 — Verify
|
|
177
|
+
|
|
178
|
+
- [ ] `specs/` exists
|
|
179
|
+
- [ ] `specs/domain-knowledge/` exists
|
|
180
|
+
- [ ] `.trace/` exists
|
|
181
|
+
- [ ] `.agent/project-context.yaml` exists
|
|
182
|
+
- [ ] `CLAUDE.md` exists
|
|
183
|
+
- [ ] `specs/domain-knowledge/business-dictionary.md` exists
|
|
184
|
+
- [ ] `specs/domain-knowledge/core-entities.md` exists
|
|
185
|
+
|
|
186
|
+
## Output
|
|
187
|
+
|
|
188
|
+
```
|
|
189
|
+
/setup-ai-first Complete ✅
|
|
190
|
+
Next:
|
|
191
|
+
1. Fill CLAUDE.md (replace {{PLACEHOLDER}} values)
|
|
192
|
+
2. Fill .agent/project-context.yaml
|
|
193
|
+
3. Fill specs/domain-knowledge/business-dictionary.md ← terminology rules
|
|
194
|
+
4. Fill specs/domain-knowledge/core-entities.md ← entity glossary for code gen
|
|
195
|
+
5. git add and commit those 4 files
|
|
196
|
+
6. /define-product to start your first feature
|
|
197
|
+
```
|