specweave 0.1.7 → 0.1.9

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.
@@ -0,0 +1,474 @@
1
+ ---
2
+ name: build
3
+ description: Execute increment implementation following spec and plan - hooks run after EVERY task
4
+ ---
5
+
6
+ # Build Increment
7
+
8
+ **Implementation Execution**: Following spec.md and plan.md to build the increment.
9
+
10
+ You are helping the user implement a SpecWeave increment by executing tasks from tasks.md with automatic documentation updates after EVERY task completion.
11
+
12
+ ## Usage
13
+
14
+ ```bash
15
+ # Auto-resumes from last incomplete task
16
+ /build <increment-id>
17
+
18
+ # Or let it find active increment automatically
19
+ /build
20
+ ```
21
+
22
+ ## Arguments
23
+
24
+ - `<increment-id>`: Optional. Increment ID (e.g., "001", "0001", "1", "0042")
25
+ - If omitted, finds the active in-progress increment automatically
26
+ - **Smart resume**: Automatically starts from next incomplete task
27
+
28
+ ---
29
+
30
+ ## Workflow
31
+
32
+ ### Step 1: Load Context
33
+
34
+ 1. **Find increment directory**:
35
+ - Normalize ID to 4-digit format (e.g., "1" → "0001")
36
+ - Find `.specweave/increments/0001-name/`
37
+ - Verify increment exists
38
+
39
+ 2. **Load specification and plan**:
40
+ - Read `spec.md` - Understand WHAT and WHY
41
+ - Read `plan.md` - Understand HOW
42
+ - Read `tasks.md` - Understand implementation steps
43
+ - Read `tests.md` - Understand test strategy
44
+
45
+ 3. **Verify readiness**:
46
+ - Check status is "planned" (not already in-progress or completed)
47
+ - Check no blocking dependencies
48
+ - Check tasks.md has tasks to execute
49
+
50
+ **Example output**:
51
+ ```
52
+ 📂 Loading increment 0001-user-authentication...
53
+
54
+ ✅ Loaded context:
55
+ • spec.md (6 user stories, 15 requirements)
56
+ • plan.md (Architecture: JWT + PostgreSQL)
57
+ • tasks.md (42 tasks, estimated 3-4 weeks)
58
+ • tests.md (12 test cases, 85% coverage)
59
+
60
+ 🎯 Ready to build!
61
+ ```
62
+
63
+ ### Step 2: Smart Resume - Find Next Incomplete Task
64
+
65
+ **🎯 CRITICAL: Auto-resume functionality** - no need to remember which task you were on!
66
+
67
+ 1. **Parse tasks.md**:
68
+ - Scan all tasks in order
69
+ - Check completion status (`[x]` = complete, `[ ]` = incomplete)
70
+ - Find first incomplete task
71
+
72
+ 2. **Determine starting point**:
73
+ - If all tasks complete → Show completion message
74
+ - If tasks incomplete → Resume from first incomplete task
75
+ - If no tasks started → Start from T001
76
+
77
+ 3. **Show resume context**:
78
+ ```
79
+ 📊 Resume Context:
80
+
81
+ Completed: 3/12 tasks (25%)
82
+ ├─ [✅] T001: Setup auth module (P1)
83
+ ├─ [✅] T002: Create user model (P1)
84
+ ├─ [✅] T003: Implement JWT tokens (P1)
85
+ └─ [⏳] T004: Add password hashing (P1) ← RESUMING HERE
86
+
87
+ Remaining: 9 tasks (estimated 2 weeks)
88
+ ```
89
+
90
+ **Why smart resume?**
91
+ - ✅ No manual tracking needed
92
+ - ✅ Seamlessly continue after breaks
93
+ - ✅ Prevents duplicate work
94
+ - ✅ Shows progress at a glance
95
+
96
+ ### Step 3: Update Status to In-Progress (if needed)
97
+
98
+ If status is "planned", update `spec.md` frontmatter:
99
+
100
+ ```yaml
101
+ ---
102
+ increment: 0001-user-authentication
103
+ status: in-progress # ← Changed from "planned"
104
+ started: 2025-10-28 # ← Start date
105
+ ---
106
+ ```
107
+
108
+ If already "in-progress", keep existing metadata.
109
+
110
+ ### Step 4: Execute Tasks Sequentially
111
+
112
+ **For each task in tasks.md**:
113
+
114
+ 1. **Read task details**:
115
+ - Task ID (T001, T002, etc.)
116
+ - Description
117
+ - Acceptance criteria
118
+ - File paths affected
119
+ - Implementation notes
120
+
121
+ 2. **Execute task**:
122
+ - Follow plan.md architecture
123
+ - Implement using detected tech stack
124
+ - Write clean, maintainable code
125
+ - Add inline documentation
126
+
127
+ 3. **Mark task complete** in tasks.md:
128
+ - Change `[ ]` → `[x]`
129
+ - Add completion timestamp
130
+ - Note any deviations from plan
131
+
132
+ 4. **🔥 CRITICAL: Run hooks after EVERY task**:
133
+ - Hook: `post-task-completion`
134
+ - Actions:
135
+ - Update documentation (CLAUDE.md, README.md)
136
+ - Update CHANGELOG.md if needed
137
+ - Verify docs reflect new code
138
+ - Check for doc/code drift
139
+
140
+ **Example task execution**:
141
+ ```
142
+ ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
143
+ TASK T001: Create User model (PostgreSQL)
144
+ ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
145
+
146
+ 📋 Task details:
147
+ • File: src/models/User.ts
148
+ • Description: Create User model with Prisma
149
+ • Acceptance: Model has id, email, passwordHash, createdAt fields
150
+
151
+ 🔨 Implementing...
152
+ ✓ Created src/models/User.ts
153
+ ✓ Added Prisma schema definition
154
+ ✓ Generated migration file
155
+ ✓ Added inline documentation
156
+
157
+ ✅ Task T001 completed
158
+
159
+ 🪝 Running post-task hooks...
160
+ ✓ Updated CLAUDE.md (added User model to schema)
161
+ ✓ Updated README.md (added database section)
162
+ ✓ Verified documentation consistency
163
+
164
+ ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
165
+
166
+ Progress: 1/42 tasks (2%) | Estimated remaining: 3.9 weeks
167
+ ```
168
+
169
+ ### Step 4: Handle Blockers
170
+
171
+ If a task cannot be completed:
172
+
173
+ 1. **Document blocker**:
174
+ - Add to tasks.md as note
175
+ - Explain reason (missing dependency, unclear requirement, etc.)
176
+
177
+ 2. **Ask user for clarification**:
178
+ - Present blocker clearly
179
+ - Offer solutions or alternatives
180
+ - Wait for user decision
181
+
182
+ 3. **Continue or pause**:
183
+ - Skip to next task if blocker is non-blocking
184
+ - Pause if blocker is critical
185
+
186
+ **Example blocker**:
187
+ ```
188
+ ⚠️ Blocker on Task T012: "Add email verification"
189
+
190
+ Issue: Email service provider not specified in plan.md
191
+
192
+ Options:
193
+ A) Use SendGrid (recommended, $15/month)
194
+ B) Use AWS SES (cheaper, $1/1000 emails)
195
+ C) Use SMTP (self-hosted, free but complex)
196
+ D) Skip for now, add as new task later
197
+
198
+ Your choice? [A/B/C/D]: _
199
+ ```
200
+
201
+ ### Step 5: Run Tests Continuously
202
+
203
+ **After completing tasks that affect testable functionality**:
204
+
205
+ 1. **Run relevant tests**:
206
+ - Unit tests for the module
207
+ - Integration tests if applicable
208
+ - Show pass/fail status
209
+
210
+ 2. **If tests fail**:
211
+ - Show error details
212
+ - Fix immediately
213
+ - Re-run tests
214
+ - Continue only when tests pass
215
+
216
+ **Example test run**:
217
+ ```
218
+ 🧪 Running tests for auth module...
219
+
220
+ ✓ User model validation
221
+ ✓ Password hashing
222
+ ✗ JWT token generation (FAILED)
223
+ Expected token to expire in 24h, got 1h
224
+
225
+ 🔧 Fixing test failure...
226
+ • Updated JWT expiry config in plan.md
227
+ • Fixed token generation in src/auth/jwt.ts
228
+
229
+ Re-running tests...
230
+
231
+ ✓ JWT token generation
232
+
233
+ ✅ All tests passing (3/3)
234
+ ```
235
+
236
+ ### Step 6: Progress Tracking
237
+
238
+ **Show progress regularly**:
239
+
240
+ ```
241
+ 📊 Increment Progress: 0001-user-authentication
242
+
243
+ Tasks completed: 15/42 (36%)
244
+ Time elapsed: 1.2 weeks
245
+ Estimated remaining: 2.1 weeks
246
+ On track: ✅ Yes
247
+
248
+ Current phase: Backend Implementation
249
+ Next phase: Frontend Integration
250
+
251
+ Recent completions:
252
+ ✓ T012: Add email verification (2h ago)
253
+ ✓ T013: Implement password reset (1h ago)
254
+ ✓ T014: Add rate limiting (30m ago)
255
+
256
+ Up next:
257
+ [ ] T015: Create login API endpoint
258
+ [ ] T016: Add JWT middleware
259
+ ```
260
+
261
+ ### Step 7: Completion Check
262
+
263
+ **When all tasks marked complete**:
264
+
265
+ ```
266
+ 🎉 All tasks completed!
267
+
268
+ ✅ Tasks: 42/42 (100%)
269
+ ⏱️ Time taken: 3.2 weeks (vs estimated 3-4 weeks)
270
+
271
+ Next steps:
272
+ 1. Run full test suite: npm test
273
+ 2. Validate increment: /validate 0001 --quality
274
+ 3. Close increment: /done 0001 (PM validates before closing)
275
+ ```
276
+
277
+ ---
278
+
279
+ ## Hook Integration (CRITICAL!)
280
+
281
+ **Post-Task Completion Hook** runs after EVERY task:
282
+
283
+ ### Configuration
284
+
285
+ **File**: `.specweave/config.yaml`
286
+
287
+ ```yaml
288
+ hooks:
289
+ enabled: true
290
+ post_task_completion:
291
+ enabled: true # ← MUST be true
292
+ actions:
293
+ - update_documentation # Update CLAUDE.md, README.md
294
+ - update_changelog # Update CHANGELOG.md if public API changes
295
+ - verify_consistency # Check docs match code
296
+ ```
297
+
298
+ ### Hook Behavior
299
+
300
+ **After EVERY task completion**:
301
+
302
+ 1. **Scan changed files**:
303
+ - Detect new functions, classes, APIs
304
+ - Detect changed behavior
305
+ - Detect new configuration
306
+
307
+ 2. **Update documentation**:
308
+ - CLAUDE.md: Add to quick reference tables
309
+ - README.md: Update examples if needed
310
+ - API docs: Regenerate if API changed
311
+
312
+ 3. **Verify consistency**:
313
+ - Check docs mention new features
314
+ - Check no stale references
315
+ - Check examples still work
316
+
317
+ 4. **Report**:
318
+ ```
319
+ 🪝 Post-task documentation update:
320
+
321
+ Files updated:
322
+ • CLAUDE.md (+3 lines: Added User model to schema reference)
323
+ • README.md (+12 lines: Added authentication example)
324
+
325
+ Consistency checks:
326
+ ✓ All code references up to date
327
+ ✓ Examples tested and working
328
+ ✓ No stale documentation
329
+
330
+ Documentation drift: 0% (perfect sync)
331
+ ```
332
+
333
+ ---
334
+
335
+ ## Examples
336
+
337
+ ### Example 1: Build Complete Increment
338
+
339
+ ```bash
340
+ /build 0001
341
+ ```
342
+
343
+ **Output**:
344
+ ```
345
+ 📂 Loading increment 0001-user-authentication...
346
+
347
+ ✅ Context loaded (spec.md, plan.md, tasks.md, tests.md)
348
+
349
+ 🔨 Starting implementation (42 tasks)...
350
+
351
+ ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
352
+ Task T001: Create User model
353
+ ✅ Completed | 🪝 Docs updated
354
+ ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
355
+
356
+ [... continues for all 42 tasks ...]
357
+
358
+ 🎉 All tasks completed (42/42)
359
+
360
+ Next: /validate 0001 --quality
361
+ ```
362
+
363
+ ### Example 2: Build with Blocker
364
+
365
+ ```bash
366
+ /build 0002
367
+ ```
368
+
369
+ **Output**:
370
+ ```
371
+ 📂 Loading increment 0002-payment-processing...
372
+
373
+ 🔨 Implementing tasks...
374
+
375
+ Task T005: Integrate Stripe payment
376
+ ⚠️ Blocker: Stripe API key not in .env
377
+
378
+ Options:
379
+ A) Add API key now (provide test key)
380
+ B) Skip for now, add as separate task
381
+ C) Use mock payment provider
382
+
383
+ Your choice? [A/B/C]: _
384
+ ```
385
+
386
+ ### Example 3: Build with Test Failure
387
+
388
+ ```bash
389
+ /build 0003
390
+ ```
391
+
392
+ **Output**:
393
+ ```
394
+ 📂 Loading increment 0003-reporting-dashboard...
395
+
396
+ Task T008: Add CSV export
397
+ ✅ Completed
398
+
399
+ 🧪 Running tests...
400
+ ✗ CSV export test failed
401
+ Expected: 1000 rows
402
+ Got: 999 rows (off-by-one error)
403
+
404
+ 🔧 Fixing test failure...
405
+ • Fixed loop boundary in src/reports/csv.ts
406
+
407
+ ✅ Tests now passing (12/12)
408
+
409
+ 🪝 Docs updated
410
+
411
+ Next task: T009
412
+ ```
413
+
414
+ ---
415
+
416
+ ## Error Handling
417
+
418
+ ### Increment Not Found
419
+ ```
420
+ ❌ Error: Increment 0001 not found
421
+
422
+ Available increments:
423
+ • 0002-core-enhancements (planned)
424
+ • 0003-payment-processing (in-progress)
425
+
426
+ Usage: /build <increment-id>
427
+ ```
428
+
429
+ ### Increment Not Planned
430
+ ```
431
+ ❌ Error: Cannot build increment 0001 (status: backlog)
432
+
433
+ Increment must be "planned" before building.
434
+
435
+ Run: /increment "User authentication" to plan this increment first.
436
+ ```
437
+
438
+ ### No Tasks to Execute
439
+ ```
440
+ ⚠️ Warning: No tasks found in tasks.md
441
+
442
+ This usually means:
443
+ 1. Tasks weren't auto-generated from plan.md
444
+ 2. Tasks.md is empty or missing
445
+
446
+ Options:
447
+ 1. Re-plan increment: /increment 0001 (regenerate tasks)
448
+ 2. Add tasks manually: Edit .specweave/increments/0001-name/tasks.md
449
+ ```
450
+
451
+ ---
452
+
453
+ ## Related Commands
454
+
455
+ - `/increment`: Plan increment (creates spec.md, plan.md, tasks.md)
456
+ - `/validate`: Validate quality before building
457
+ - `/done`: Close increment (PM validates completion)
458
+ - `/list-increments`: List all increments with status
459
+
460
+ ---
461
+
462
+ ## Related Skills
463
+
464
+ - `context-loader`: Loads relevant context (70% token reduction)
465
+ - `nodejs-backend`: Node.js implementation knowledge
466
+ - `python-backend`: Python implementation knowledge
467
+ - `nextjs`: Next.js implementation knowledge
468
+ - `frontend`: React/Vue/Angular implementation knowledge
469
+
470
+ ---
471
+
472
+ **Important**: This command is designed for continuous execution. It's normal to run `/build` and let it execute multiple tasks sequentially with documentation updates after each one.
473
+
474
+ **Best Practice**: Always run `/validate 0001 --quality` after building to ensure quality before closing with `/done`.