@panuwatbas/spec-driven-dev 1.0.2
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/README.md +378 -0
- package/bin/cli.js +289 -0
- package/package.json +39 -0
- package/skill/README.md +346 -0
- package/skill/SKILL.md +195 -0
- package/skill/examples/example-design.md +287 -0
- package/skill/examples/example-requirements.md +151 -0
- package/skill/examples/example-tasks.md +189 -0
- package/skill/scripts/init-spec.bat +70 -0
- package/skill/scripts/init-spec.sh +159 -0
- package/skill/templates/design.template.md +248 -0
- package/skill/templates/requirements.template.md +116 -0
- package/skill/templates/tasks.template.md +127 -0
package/package.json
ADDED
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@panuwatbas/spec-driven-dev",
|
|
3
|
+
"version": "1.0.2",
|
|
4
|
+
"description": "Spec-Driven Development skill inspired by Kiro IDE. Plan first, then build. Requirements -> Design -> Tasks workflow for AI agents.",
|
|
5
|
+
"keywords": [
|
|
6
|
+
"spec-driven-development",
|
|
7
|
+
"kiro",
|
|
8
|
+
"ai-skill",
|
|
9
|
+
"requirements",
|
|
10
|
+
"design",
|
|
11
|
+
"tasks",
|
|
12
|
+
"gemini",
|
|
13
|
+
"cursor",
|
|
14
|
+
"windsurf",
|
|
15
|
+
"copilot",
|
|
16
|
+
"ai-agent",
|
|
17
|
+
"planning",
|
|
18
|
+
"spec"
|
|
19
|
+
],
|
|
20
|
+
"author": "",
|
|
21
|
+
"license": "MIT",
|
|
22
|
+
"bin": {
|
|
23
|
+
"spec-driven-dev": "./bin/cli.js"
|
|
24
|
+
},
|
|
25
|
+
"files": [
|
|
26
|
+
"bin/",
|
|
27
|
+
"skill/",
|
|
28
|
+
"README.md",
|
|
29
|
+
"LICENSE"
|
|
30
|
+
],
|
|
31
|
+
"repository": {
|
|
32
|
+
"type": "git",
|
|
33
|
+
"url": ""
|
|
34
|
+
},
|
|
35
|
+
"homepage": "",
|
|
36
|
+
"engines": {
|
|
37
|
+
"node": ">=16.0.0"
|
|
38
|
+
}
|
|
39
|
+
}
|
package/skill/README.md
ADDED
|
@@ -0,0 +1,346 @@
|
|
|
1
|
+
# Spec-Driven Development Skill
|
|
2
|
+
|
|
3
|
+
> **Plan first, then build.** สร้าง Requirements → Design → Tasks ก่อน แล้วค่อย Code
|
|
4
|
+
|
|
5
|
+
Skill นี้เลียนแบบ workflow ของ **Kiro IDE** ที่เน้นการวางแผนอย่างเป็นระบบ
|
|
6
|
+
ก่อนเขียน code ทุกครั้ง ลดความผิดพลาด ลดการทำซ้ำ และสร้าง documentation ที่มีชีวิต
|
|
7
|
+
|
|
8
|
+
---
|
|
9
|
+
|
|
10
|
+
## Features
|
|
11
|
+
|
|
12
|
+
- **Structured Planning** — 3 เฟสชัดเจน: Requirements → Design → Tasks
|
|
13
|
+
- **GIVEN/WHEN/THEN** — Acceptance criteria แบบ Gherkin ที่ทดสอบได้
|
|
14
|
+
- **Mermaid Diagrams** — Architecture และ Sequence diagrams อัตโนมัติ
|
|
15
|
+
- **Traceability** — ทุก task อ้างอิงกลับไปหา requirement
|
|
16
|
+
- **Progress Tracking** — `[ ]` `[/]` `[x]` สำหรับ track progress
|
|
17
|
+
- **Human-in-the-Loop** — ต้อง approve ก่อนไปเฟสถัดไป
|
|
18
|
+
- **3 Workflow Variants** — Requirements-First, Design-First, Bugfix Mode
|
|
19
|
+
- **Agent-Compatible** — ใช้ได้กับ AI agent ทุกตัว
|
|
20
|
+
|
|
21
|
+
---
|
|
22
|
+
|
|
23
|
+
## โครงสร้าง Skill
|
|
24
|
+
|
|
25
|
+
```
|
|
26
|
+
spec-driven-dev/
|
|
27
|
+
├── SKILL.md # คำสั่งหลัก (AI Agent อ่านไฟล์นี้)
|
|
28
|
+
├── README.md # คู่มือนี้
|
|
29
|
+
├── templates/
|
|
30
|
+
│ ├── requirements.template.md # เทมเพลต: กำหนดว่า "ทำอะไร"
|
|
31
|
+
│ ├── design.template.md # เทมเพลต: กำหนดว่า "ทำยังไง"
|
|
32
|
+
│ └── tasks.template.md # เทมเพลต: แผนการทำงาน
|
|
33
|
+
├── examples/
|
|
34
|
+
│ ├── example-requirements.md # ตัวอย่าง: Shopping Cart requirements
|
|
35
|
+
│ ├── example-design.md # ตัวอย่าง: Shopping Cart design
|
|
36
|
+
│ └── example-tasks.md # ตัวอย่าง: Shopping Cart tasks
|
|
37
|
+
└── scripts/
|
|
38
|
+
├── init-spec.sh # Script สร้าง spec ใหม่ (Linux/Mac)
|
|
39
|
+
└── init-spec.bat # Script สร้าง spec ใหม่ (Windows)
|
|
40
|
+
```
|
|
41
|
+
|
|
42
|
+
---
|
|
43
|
+
|
|
44
|
+
## การติดตั้ง
|
|
45
|
+
|
|
46
|
+
คัดลอกโฟลเดอร์ `spec-driven-dev` ไปวางในโฟลเดอร์ skills ของเครื่องมือที่ใช้:
|
|
47
|
+
|
|
48
|
+
### Gemini CLI / Google Antigravity
|
|
49
|
+
|
|
50
|
+
```powershell
|
|
51
|
+
Copy-Item -Recurse "spec-driven-dev" ".gemini\skills\spec-driven-dev"
|
|
52
|
+
```
|
|
53
|
+
|
|
54
|
+
### Cursor
|
|
55
|
+
|
|
56
|
+
```powershell
|
|
57
|
+
Copy-Item -Recurse "spec-driven-dev" ".cursor\skills\spec-driven-dev"
|
|
58
|
+
```
|
|
59
|
+
|
|
60
|
+
### Windsurf
|
|
61
|
+
|
|
62
|
+
```powershell
|
|
63
|
+
Copy-Item -Recurse "spec-driven-dev" ".windsurf\skills\spec-driven-dev"
|
|
64
|
+
```
|
|
65
|
+
|
|
66
|
+
### เครื่องมืออื่นๆ
|
|
67
|
+
|
|
68
|
+
ชี้ให้ AI agent อ่านไฟล์ `SKILL.md` โดยตรง หรือ copy เนื้อหาเข้า system prompt
|
|
69
|
+
|
|
70
|
+
---
|
|
71
|
+
|
|
72
|
+
## วิธีใช้งาน
|
|
73
|
+
|
|
74
|
+
### วิธีที่ 1: บอก AI Agent โดยตรง
|
|
75
|
+
|
|
76
|
+
พิมพ์ประโยคแบบนี้ใน chat:
|
|
77
|
+
|
|
78
|
+
```
|
|
79
|
+
สร้าง spec สำหรับ feature ระบบ login
|
|
80
|
+
```
|
|
81
|
+
|
|
82
|
+
```
|
|
83
|
+
ช่วย spec feature ตะกร้าสินค้า ตาม spec-driven-dev skill
|
|
84
|
+
```
|
|
85
|
+
|
|
86
|
+
```
|
|
87
|
+
Start a spec for user-authentication using the spec-driven-dev skill
|
|
88
|
+
```
|
|
89
|
+
|
|
90
|
+
Agent จะเริ่มทำตาม workflow 3 เฟสอัตโนมัติ
|
|
91
|
+
|
|
92
|
+
---
|
|
93
|
+
|
|
94
|
+
### วิธีที่ 2: ใช้ Script สร้างโครงสร้างก่อน
|
|
95
|
+
|
|
96
|
+
```powershell
|
|
97
|
+
# Windows
|
|
98
|
+
.\scripts\init-spec.bat user-authentication
|
|
99
|
+
|
|
100
|
+
# Linux / Mac
|
|
101
|
+
bash scripts/init-spec.sh user-authentication
|
|
102
|
+
```
|
|
103
|
+
|
|
104
|
+
จะได้โครงสร้าง:
|
|
105
|
+
|
|
106
|
+
```
|
|
107
|
+
.specs/user-authentication/
|
|
108
|
+
├── requirements.md <- เทมเพลตพร้อมแก้ไข
|
|
109
|
+
├── design.md <- เทมเพลตพร้อมแก้ไข
|
|
110
|
+
└── tasks.md <- เทมเพลตพร้อมแก้ไข
|
|
111
|
+
```
|
|
112
|
+
|
|
113
|
+
แล้วบอก agent: `"ช่วยเติม spec ใน .specs/user-authentication/"`
|
|
114
|
+
|
|
115
|
+
---
|
|
116
|
+
|
|
117
|
+
## Workflow 3 เฟส
|
|
118
|
+
|
|
119
|
+
```
|
|
120
|
+
┌─────────────────┐ ┌─────────────────┐ ┌─────────────────┐
|
|
121
|
+
│ Phase 1 │ │ Phase 2 │ │ Phase 3 │
|
|
122
|
+
│ REQUIREMENTS │ --> │ DESIGN │ --> │ TASKS │
|
|
123
|
+
│ │ │ │ │ │
|
|
124
|
+
│ กำหนดว่า │ │ กำหนดว่า │ │ แผนการทำงาน │
|
|
125
|
+
│ "ทำอะไร" │ │ "ทำยังไง" │ │ ทีละขั้นตอน │
|
|
126
|
+
│ │ │ │ │ │
|
|
127
|
+
│ - User Stories │ │ - Architecture │ │ - Task List │
|
|
128
|
+
│ - GIVEN/WHEN/ │ │ - Components │ │ - Phases │
|
|
129
|
+
│ THEN │ │ - Data Models │ │ - Verification │
|
|
130
|
+
│ - Edge Cases │ │ - API Contracts│ │ - Status [x] │
|
|
131
|
+
└────────┬────────┘ └────────┬────────┘ └────────┬────────┘
|
|
132
|
+
│ │ │
|
|
133
|
+
คุณ approve คุณ approve คุณ approve
|
|
134
|
+
│
|
|
135
|
+
เริ่ม code!
|
|
136
|
+
```
|
|
137
|
+
|
|
138
|
+
### เฟส 1 — Requirements (`requirements.md`)
|
|
139
|
+
|
|
140
|
+
กำหนด **"ทำอะไร"** จากมุมมองผู้ใช้
|
|
141
|
+
|
|
142
|
+
```markdown
|
|
143
|
+
# Feature: ระบบ Login
|
|
144
|
+
|
|
145
|
+
## User Story
|
|
146
|
+
**As a** ผู้ใช้ทั่วไป,
|
|
147
|
+
**I want to** เข้าสู่ระบบด้วย email และ password,
|
|
148
|
+
**so that** ฉันสามารถเข้าถึงข้อมูลส่วนตัวของฉันได้.
|
|
149
|
+
|
|
150
|
+
## Acceptance Criteria
|
|
151
|
+
|
|
152
|
+
### AC-1.1: เข้าสู่ระบบสำเร็จ
|
|
153
|
+
**Given** ผู้ใช้อยู่ที่หน้า login
|
|
154
|
+
**And** มีบัญชีอยู่แล้วในระบบ
|
|
155
|
+
**When** กรอก email และ password ที่ถูกต้อง แล้วกดปุ่ม "Login"
|
|
156
|
+
**Then** ระบบพาไปหน้า dashboard
|
|
157
|
+
**And** แสดงชื่อผู้ใช้ที่มุมบนขวา
|
|
158
|
+
|
|
159
|
+
### AC-1.2: กรอก password ผิด
|
|
160
|
+
**Given** ผู้ใช้อยู่ที่หน้า login
|
|
161
|
+
**When** กรอก email ถูกต้อง แต่ password ผิด
|
|
162
|
+
**Then** แสดงข้อความ "อีเมลหรือรหัสผ่านไม่ถูกต้อง"
|
|
163
|
+
**And** ไม่บอกว่าผิดอันไหน (เพื่อความปลอดภัย)
|
|
164
|
+
```
|
|
165
|
+
|
|
166
|
+
**คุณรีวิว -> แก้ไข -> approve** -> ไปเฟส 2
|
|
167
|
+
|
|
168
|
+
---
|
|
169
|
+
|
|
170
|
+
### เฟส 2 — Design (`design.md`)
|
|
171
|
+
|
|
172
|
+
กำหนด **"ทำยังไง"** ในเชิงเทคนิค
|
|
173
|
+
|
|
174
|
+
```markdown
|
|
175
|
+
## Architecture
|
|
176
|
+
┌──────────┐ ┌──────────┐ ┌──────────┐
|
|
177
|
+
│ React │ --> │ Express │ --> │ Postgres │
|
|
178
|
+
│ Frontend│ │ API │ │ Database │
|
|
179
|
+
└──────────┘ └──────────┘ └──────────┘
|
|
180
|
+
|
|
181
|
+
## Component: AuthService
|
|
182
|
+
- Responsibility: จัดการ login, logout, token refresh
|
|
183
|
+
- Location: src/server/services/AuthService.ts
|
|
184
|
+
|
|
185
|
+
## API Contract
|
|
186
|
+
POST /api/auth/login
|
|
187
|
+
Request: { "email": "string", "password": "string" }
|
|
188
|
+
Response: { "token": "jwt", "user": { "id", "name" } }
|
|
189
|
+
```
|
|
190
|
+
|
|
191
|
+
**คุณรีวิว -> แก้ไข -> approve** -> ไปเฟส 3
|
|
192
|
+
|
|
193
|
+
---
|
|
194
|
+
|
|
195
|
+
### เฟส 3 — Tasks (`tasks.md`)
|
|
196
|
+
|
|
197
|
+
แผนการทำงานเป็น **checklist**
|
|
198
|
+
|
|
199
|
+
```markdown
|
|
200
|
+
## Phase 1: Database
|
|
201
|
+
- [x] Task 1.1: สร้าง users table migration
|
|
202
|
+
- [x] Task 1.2: สร้าง User model
|
|
203
|
+
|
|
204
|
+
## Phase 2: Backend API
|
|
205
|
+
- [/] Task 2.1: สร้าง POST /api/auth/login <- กำลังทำ
|
|
206
|
+
- [ ] Task 2.2: สร้าง JWT middleware
|
|
207
|
+
- [ ] Task 2.3: สร้าง rate limiting
|
|
208
|
+
|
|
209
|
+
## Phase 3: Frontend
|
|
210
|
+
- [ ] Task 3.1: สร้าง LoginForm component
|
|
211
|
+
- [ ] Task 3.2: สร้าง auth context/store
|
|
212
|
+
- [ ] Task 3.3: สร้าง protected route
|
|
213
|
+
|
|
214
|
+
## Phase 4: Testing
|
|
215
|
+
- [ ] Task 4.1: Unit tests สำหรับ AuthService
|
|
216
|
+
- [ ] Task 4.2: E2E test login flow
|
|
217
|
+
```
|
|
218
|
+
|
|
219
|
+
**คุณ approve -> Agent เริ่ม code ทีละ task**
|
|
220
|
+
|
|
221
|
+
---
|
|
222
|
+
|
|
223
|
+
## Workflow Variants
|
|
224
|
+
|
|
225
|
+
### 1. Requirements-First (ค่าเริ่มต้น)
|
|
226
|
+
|
|
227
|
+
เหมาะกับ **feature ใหม่** ที่เน้น business logic
|
|
228
|
+
|
|
229
|
+
```
|
|
230
|
+
requirements.md -> design.md -> tasks.md
|
|
231
|
+
```
|
|
232
|
+
|
|
233
|
+
**ใช้เมื่อ:** สร้างฟีเจอร์ใหม่ตั้งแต่ต้น
|
|
234
|
+
|
|
235
|
+
---
|
|
236
|
+
|
|
237
|
+
### 2. Design-First
|
|
238
|
+
|
|
239
|
+
เหมาะกับ **ระบบซับซ้อน** ที่มีข้อจำกัดทางเทคนิค
|
|
240
|
+
|
|
241
|
+
```
|
|
242
|
+
design.md -> requirements.md (derived) -> tasks.md
|
|
243
|
+
```
|
|
244
|
+
|
|
245
|
+
**ใช้เมื่อ:** มี architecture constraints, performance requirements, หรือต้อง integrate กับระบบเดิม
|
|
246
|
+
|
|
247
|
+
---
|
|
248
|
+
|
|
249
|
+
### 3. Bugfix Mode
|
|
250
|
+
|
|
251
|
+
เหมาะกับ **bug ที่ซับซ้อน** ต้องวิเคราะห์ root cause
|
|
252
|
+
|
|
253
|
+
```
|
|
254
|
+
bugfix.md -> design.md (root cause + fix) -> tasks.md
|
|
255
|
+
```
|
|
256
|
+
|
|
257
|
+
**ใช้เมื่อ:** Bug ที่ reproduce ยาก หรือเกี่ยวข้องหลาย component
|
|
258
|
+
|
|
259
|
+
---
|
|
260
|
+
|
|
261
|
+
## ตัวอย่างคำสั่งสำหรับ AI Agent
|
|
262
|
+
|
|
263
|
+
| สถานการณ์ | พูดกับ Agent ว่า |
|
|
264
|
+
|----------|-----------------|
|
|
265
|
+
| เริ่ม feature ใหม่ | `"สร้าง spec สำหรับ feature [ชื่อ]"` |
|
|
266
|
+
| Fix bug ซับซ้อน | `"สร้าง bugfix spec สำหรับ [ปัญหา]"` |
|
|
267
|
+
| มี design อยู่แล้ว | `"เริ่มจาก design-first สำหรับ [ชื่อ]"` |
|
|
268
|
+
| Approve เฟส | `"approve แล้ว ไปเฟสถัดไป"` |
|
|
269
|
+
| เริ่ม code | `"approve tasks แล้ว เริ่ม execute ได้เลย"` |
|
|
270
|
+
| แก้ requirement | `"แก้ AC-1.2 เป็น... แล้ว sync ลง tasks"` |
|
|
271
|
+
| ดูตัวอย่าง | `"ดูตัวอย่าง requirements จาก examples"` |
|
|
272
|
+
| สร้างจากเทมเพลต | `"สร้าง requirements จาก template"` |
|
|
273
|
+
|
|
274
|
+
---
|
|
275
|
+
|
|
276
|
+
## Output ที่ได้
|
|
277
|
+
|
|
278
|
+
เมื่อใช้ skill นี้กับ project จะได้โครงสร้าง:
|
|
279
|
+
|
|
280
|
+
```
|
|
281
|
+
your-project/
|
|
282
|
+
├── .specs/
|
|
283
|
+
│ ├── user-authentication/
|
|
284
|
+
│ │ ├── requirements.md <- Approved
|
|
285
|
+
│ │ ├── design.md <- Approved
|
|
286
|
+
│ │ └── tasks.md <- In Progress (12/15 tasks done)
|
|
287
|
+
│ │
|
|
288
|
+
│ ├── shopping-cart/
|
|
289
|
+
│ │ ├── requirements.md <- Approved
|
|
290
|
+
│ │ ├── design.md <- Draft
|
|
291
|
+
│ │ └── tasks.md <- Not Started
|
|
292
|
+
│ │
|
|
293
|
+
│ └── payment-integration/
|
|
294
|
+
│ └── requirements.md <- Draft
|
|
295
|
+
│
|
|
296
|
+
├── src/
|
|
297
|
+
│ └── ... <- code ที่สร้างจาก tasks
|
|
298
|
+
└── ...
|
|
299
|
+
```
|
|
300
|
+
|
|
301
|
+
---
|
|
302
|
+
|
|
303
|
+
## หลักการสำคัญ
|
|
304
|
+
|
|
305
|
+
| หลักการ | คำอธิบาย |
|
|
306
|
+
|---------|---------|
|
|
307
|
+
| **Plan First** | วางแผนก่อน code เสมอ |
|
|
308
|
+
| **Traceability** | ทุก task อ้างอิงกลับไป requirement |
|
|
309
|
+
| **Human-in-the-Loop** | คนต้อง approve ก่อนทุกเฟส |
|
|
310
|
+
| **Small Tasks** | แต่ละ task เล็กพอทำจบได้ในรอบเดียว |
|
|
311
|
+
| **Living Documentation** | Spec อัปเดตตาม code ที่เปลี่ยน |
|
|
312
|
+
| **Verify Often** | ทุกเฟสมี verification step |
|
|
313
|
+
|
|
314
|
+
---
|
|
315
|
+
|
|
316
|
+
## ไฟล์ Reference
|
|
317
|
+
|
|
318
|
+
| ไฟล์ | คำอธิบาย |
|
|
319
|
+
|------|---------|
|
|
320
|
+
| [`SKILL.md`](./SKILL.md) | คำสั่งหลักที่ AI Agent อ่าน |
|
|
321
|
+
| [`templates/requirements.template.md`](./templates/requirements.template.md) | เทมเพลต requirements |
|
|
322
|
+
| [`templates/design.template.md`](./templates/design.template.md) | เทมเพลต design |
|
|
323
|
+
| [`templates/tasks.template.md`](./templates/tasks.template.md) | เทมเพลต tasks |
|
|
324
|
+
| [`examples/example-requirements.md`](./examples/example-requirements.md) | ตัวอย่าง requirements (Shopping Cart) |
|
|
325
|
+
| [`examples/example-design.md`](./examples/example-design.md) | ตัวอย่าง design (Shopping Cart) |
|
|
326
|
+
| [`examples/example-tasks.md`](./examples/example-tasks.md) | ตัวอย่าง tasks (Shopping Cart) |
|
|
327
|
+
|
|
328
|
+
---
|
|
329
|
+
|
|
330
|
+
## Compatibility
|
|
331
|
+
|
|
332
|
+
| เครื่องมือ | รองรับ | วิธีติดตั้ง |
|
|
333
|
+
|-----------|-------|-----------|
|
|
334
|
+
| Google Antigravity / Gemini CLI | Yes | `.gemini/skills/` |
|
|
335
|
+
| Cursor | Yes | `.cursor/skills/` |
|
|
336
|
+
| Windsurf | Yes | `.windsurf/skills/` |
|
|
337
|
+
| Claude (Anthropic) | Yes | ใส่ SKILL.md ใน system prompt |
|
|
338
|
+
| ChatGPT / GPT-4 | Yes | ใส่ SKILL.md ใน system prompt |
|
|
339
|
+
| GitHub Copilot | Yes | `.github/copilot/skills/` |
|
|
340
|
+
| อื่นๆ | Yes | อ้างอิง SKILL.md โดยตรง |
|
|
341
|
+
|
|
342
|
+
---
|
|
343
|
+
|
|
344
|
+
<p align="center">
|
|
345
|
+
<b>Spec-Driven Development</b> — Stop vibe coding. Start spec coding.
|
|
346
|
+
</p>
|
package/skill/SKILL.md
ADDED
|
@@ -0,0 +1,195 @@
|
|
|
1
|
+
---
|
|
2
|
+
name: spec-driven-dev
|
|
3
|
+
description: >
|
|
4
|
+
Spec-Driven Development (SDD) skill inspired by Kiro IDE.
|
|
5
|
+
Enforces a structured 3-phase workflow: Requirements → Design → Tasks.
|
|
6
|
+
Use this skill when starting a new feature, refactoring, or fixing a complex bug.
|
|
7
|
+
It ensures AI agents plan first, then build — reducing ambiguity, improving code quality,
|
|
8
|
+
and creating living documentation that stays in sync with the codebase.
|
|
9
|
+
---
|
|
10
|
+
|
|
11
|
+
# Spec-Driven Development (SDD)
|
|
12
|
+
|
|
13
|
+
> **Philosophy:** Plan first, then build. Create requirements and design before coding starts.
|
|
14
|
+
|
|
15
|
+
This skill implements a structured, spec-driven development workflow inspired by Kiro IDE.
|
|
16
|
+
Every feature, refactor, or complex bugfix follows **three phases**, each producing a
|
|
17
|
+
living Markdown document that serves as the source of truth for AI agents and human developers alike.
|
|
18
|
+
|
|
19
|
+
---
|
|
20
|
+
|
|
21
|
+
## When to Use This Skill
|
|
22
|
+
|
|
23
|
+
- Thinking through features in-depth
|
|
24
|
+
- Projects needing upfront planning
|
|
25
|
+
- Building features in a structured way
|
|
26
|
+
- Complex bug fixes requiring root-cause analysis
|
|
27
|
+
- Refactoring with clear scope and success criteria
|
|
28
|
+
|
|
29
|
+
---
|
|
30
|
+
|
|
31
|
+
## Directory Structure
|
|
32
|
+
|
|
33
|
+
All spec documents live under a `.specs/` directory at the project root, organized by feature:
|
|
34
|
+
|
|
35
|
+
```
|
|
36
|
+
.specs/
|
|
37
|
+
└── <feature-name>/
|
|
38
|
+
├── requirements.md # Phase 1: WHAT to build
|
|
39
|
+
├── design.md # Phase 2: HOW to build it
|
|
40
|
+
└── tasks.md # Phase 3: Execution plan
|
|
41
|
+
```
|
|
42
|
+
|
|
43
|
+
---
|
|
44
|
+
|
|
45
|
+
## The 3-Phase Workflow
|
|
46
|
+
|
|
47
|
+
### Phase 1 → Requirements (`requirements.md`)
|
|
48
|
+
|
|
49
|
+
**Goal:** Define *what* needs to be built or fixed.
|
|
50
|
+
|
|
51
|
+
1. Read the template: [templates/requirements.template.md](templates/requirements.template.md)
|
|
52
|
+
2. Gather the user's high-level intent and translate it into structured **User Stories** and **Acceptance Criteria**.
|
|
53
|
+
3. Use the **GIVEN / WHEN / THEN** format (Gherkin-style) for every acceptance criterion.
|
|
54
|
+
4. Keep language **non-technical** — focus on behavior from the user's perspective.
|
|
55
|
+
5. Cover **happy paths**, **edge cases**, and **error scenarios**.
|
|
56
|
+
|
|
57
|
+
**Transition Rule:** Do NOT proceed to Phase 2 until the user has reviewed and approved the requirements.
|
|
58
|
+
|
|
59
|
+
---
|
|
60
|
+
|
|
61
|
+
### Phase 2 → Design (`design.md`)
|
|
62
|
+
|
|
63
|
+
**Goal:** Define *how* to build it.
|
|
64
|
+
|
|
65
|
+
1. Read the template: [templates/design.template.md](templates/design.template.md)
|
|
66
|
+
2. Map each requirement to a **technical solution**.
|
|
67
|
+
3. Define: architecture, components, data models, API contracts, and error-handling strategies.
|
|
68
|
+
4. Use **Mermaid diagrams** for system architecture and sequence diagrams where applicable.
|
|
69
|
+
5. List **constraints**, **forbidden patterns**, and **naming conventions**.
|
|
70
|
+
6. Identify **technical risks** and **open questions**.
|
|
71
|
+
|
|
72
|
+
**Transition Rule:** Do NOT proceed to Phase 3 until the user has reviewed and approved the design.
|
|
73
|
+
|
|
74
|
+
---
|
|
75
|
+
|
|
76
|
+
### Phase 3 → Tasks (`tasks.md`)
|
|
77
|
+
|
|
78
|
+
**Goal:** Define the step-by-step execution plan.
|
|
79
|
+
|
|
80
|
+
1. Read the template: [templates/tasks.template.md](templates/tasks.template.md)
|
|
81
|
+
2. Break the design into **discrete, trackable, executable tasks**.
|
|
82
|
+
3. Group tasks into **logical phases** (e.g., Database → Backend → Frontend → Testing).
|
|
83
|
+
4. Use checkbox syntax for status tracking:
|
|
84
|
+
- `- [ ]` → Not started
|
|
85
|
+
- `- [/]` → In progress
|
|
86
|
+
- `- [x]` → Completed
|
|
87
|
+
5. Each task should be **small enough to complete in one focused session**.
|
|
88
|
+
6. Include **sub-tasks** for complex items.
|
|
89
|
+
7. Add **verification steps** at the end of each phase.
|
|
90
|
+
|
|
91
|
+
**Transition Rule:** Execute tasks one at a time (or in approved parallel batches). Update status as you go.
|
|
92
|
+
|
|
93
|
+
---
|
|
94
|
+
|
|
95
|
+
## Workflow Variants
|
|
96
|
+
|
|
97
|
+
### 🔹 Requirements-First (Default)
|
|
98
|
+
Best for **new features** where business logic is the priority.
|
|
99
|
+
Flow: `requirements.md` → `design.md` → `tasks.md`
|
|
100
|
+
|
|
101
|
+
### 🔹 Design-First
|
|
102
|
+
Best for **complex systems** or scenarios with strict technical constraints.
|
|
103
|
+
Flow: `design.md` → `requirements.md` (derived) → `tasks.md`
|
|
104
|
+
|
|
105
|
+
### 🔹 Bugfix Mode
|
|
106
|
+
For **complex bugs** requiring root-cause analysis.
|
|
107
|
+
Use `requirements.md` as a `bugfix.md` with:
|
|
108
|
+
- **Bug Description** instead of User Story
|
|
109
|
+
- **Reproduction Steps** in GIVEN/WHEN/THEN format
|
|
110
|
+
- **Expected vs Actual Behavior**
|
|
111
|
+
- **Root Cause Analysis** section in `design.md`
|
|
112
|
+
|
|
113
|
+
---
|
|
114
|
+
|
|
115
|
+
## Agent Instructions
|
|
116
|
+
|
|
117
|
+
When activated, follow this exact sequence:
|
|
118
|
+
|
|
119
|
+
### Step 1: Initialize
|
|
120
|
+
```
|
|
121
|
+
1. Ask the user: "What feature/fix would you like to spec out?"
|
|
122
|
+
2. Determine the workflow variant (Requirements-First, Design-First, or Bugfix)
|
|
123
|
+
3. Create the `.specs/<feature-name>/` directory
|
|
124
|
+
```
|
|
125
|
+
|
|
126
|
+
### Step 2: Requirements Phase
|
|
127
|
+
```
|
|
128
|
+
1. Generate `requirements.md` using the template
|
|
129
|
+
2. Present to user for review
|
|
130
|
+
3. Iterate until user approves
|
|
131
|
+
4. Mark phase as complete
|
|
132
|
+
```
|
|
133
|
+
|
|
134
|
+
### Step 3: Design Phase
|
|
135
|
+
```
|
|
136
|
+
1. Generate `design.md` using the template, referencing approved requirements
|
|
137
|
+
2. Include architecture diagrams (Mermaid)
|
|
138
|
+
3. Present to user for review
|
|
139
|
+
4. Iterate until user approves
|
|
140
|
+
5. Mark phase as complete
|
|
141
|
+
```
|
|
142
|
+
|
|
143
|
+
### Step 4: Tasks Phase
|
|
144
|
+
```
|
|
145
|
+
1. Generate `tasks.md` using the template, referencing approved design
|
|
146
|
+
2. Break into small, actionable items with clear acceptance
|
|
147
|
+
3. Present to user for review
|
|
148
|
+
4. Iterate until user approves
|
|
149
|
+
5. Begin execution when user says "go" or "start"
|
|
150
|
+
```
|
|
151
|
+
|
|
152
|
+
### Step 5: Execution
|
|
153
|
+
```
|
|
154
|
+
1. Pick the next uncompleted task
|
|
155
|
+
2. Update its status to [/] (in progress)
|
|
156
|
+
3. Implement the task
|
|
157
|
+
4. Run verification (tests, build, lint)
|
|
158
|
+
5. Update status to [x] (completed)
|
|
159
|
+
6. Repeat until all tasks are done
|
|
160
|
+
```
|
|
161
|
+
|
|
162
|
+
### Step 6: Sync (When Changes Occur)
|
|
163
|
+
```
|
|
164
|
+
If requirements or design change mid-development:
|
|
165
|
+
1. Update the changed document
|
|
166
|
+
2. Cascade changes to downstream documents
|
|
167
|
+
3. Re-verify affected completed tasks
|
|
168
|
+
4. Get user approval before continuing
|
|
169
|
+
```
|
|
170
|
+
|
|
171
|
+
---
|
|
172
|
+
|
|
173
|
+
## Key Principles
|
|
174
|
+
|
|
175
|
+
| Principle | Description |
|
|
176
|
+
|-----------|-------------|
|
|
177
|
+
| **Traceability** | Every task links back to a requirement and design element |
|
|
178
|
+
| **Living Docs** | Spec files are updated as the project evolves |
|
|
179
|
+
| **Human-in-the-Loop** | User approves each phase before the next begins |
|
|
180
|
+
| **Small Tasks** | Each task is completable in one focused session |
|
|
181
|
+
| **Verify Often** | Every phase includes verification steps |
|
|
182
|
+
|
|
183
|
+
---
|
|
184
|
+
|
|
185
|
+
## File Reference
|
|
186
|
+
|
|
187
|
+
| File | Purpose |
|
|
188
|
+
|------|---------|
|
|
189
|
+
| [templates/requirements.template.md](templates/requirements.template.md) | Requirements template with GIVEN/WHEN/THEN format |
|
|
190
|
+
| [templates/design.template.md](templates/design.template.md) | Technical design template with architecture diagrams |
|
|
191
|
+
| [templates/tasks.template.md](templates/tasks.template.md) | Task breakdown template with status tracking |
|
|
192
|
+
| [examples/example-requirements.md](examples/example-requirements.md) | Complete example: E-commerce cart requirements |
|
|
193
|
+
| [examples/example-design.md](examples/example-design.md) | Complete example: E-commerce cart design |
|
|
194
|
+
| [examples/example-tasks.md](examples/example-tasks.md) | Complete example: E-commerce cart tasks |
|
|
195
|
+
|