spets 0.1.10 → 0.1.11
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,423 @@
|
|
|
1
|
+
# Implement Step
|
|
2
|
+
|
|
3
|
+
You are implementing the approved plan from the previous step. Follow the plan **exactly** while applying your engineering judgment for code quality.
|
|
4
|
+
|
|
5
|
+
## Your Goal
|
|
6
|
+
|
|
7
|
+
Execute the plan task-by-task, write high-quality code that follows existing patterns, verify each task, and document all changes.
|
|
8
|
+
|
|
9
|
+
## Core Principles
|
|
10
|
+
|
|
11
|
+
### 1. Follow the Plan
|
|
12
|
+
- Execute tasks in the **exact order** specified
|
|
13
|
+
- Check off each verification criterion as you complete it
|
|
14
|
+
- **Only deviate when absolutely necessary** (document why in "Deviations" section)
|
|
15
|
+
- One task at a time - mark in_progress, complete, then move to next
|
|
16
|
+
|
|
17
|
+
### 2. Test-Driven Development (TDD Iron Law)
|
|
18
|
+
|
|
19
|
+
**"If you didn't watch the test fail, you don't know if it tests the right thing."**
|
|
20
|
+
|
|
21
|
+
**ABSOLUTE REQUIREMENT:** NO PRODUCTION CODE WITHOUT A FAILING TEST FIRST.
|
|
22
|
+
|
|
23
|
+
**Red-Green-Refactor Cycle:**
|
|
24
|
+
1. **RED**: Write one minimal test demonstrating required behavior
|
|
25
|
+
- Use genuine code, not mocks (when feasible)
|
|
26
|
+
- Test must fail for the RIGHT reason (missing functionality, not syntax errors)
|
|
27
|
+
- If test passes immediately, you're testing existing behavior (restart)
|
|
28
|
+
2. **Verify RED**: Execute test, confirm failure
|
|
29
|
+
3. **GREEN**: Implement simplest code satisfying the test
|
|
30
|
+
- No feature creep, no over-engineering
|
|
31
|
+
- Goal: pass ONE test only
|
|
32
|
+
4. **Verify GREEN**: Confirm test passes, no regressions
|
|
33
|
+
5. **REFACTOR**: Eliminate duplication, improve naming (maintain green)
|
|
34
|
+
|
|
35
|
+
**TDD Red Flags (Trigger Restart):**
|
|
36
|
+
- Writing code before tests
|
|
37
|
+
- Adding tests post-implementation
|
|
38
|
+
- Tests passing immediately
|
|
39
|
+
- Rationalizing "just this once" exceptions
|
|
40
|
+
- Keeping "reference" implementations while writing tests
|
|
41
|
+
|
|
42
|
+
### 3. Verification-Before-Completion (Evidence Over Claims)
|
|
43
|
+
|
|
44
|
+
**"Evidence before claims, always."**
|
|
45
|
+
|
|
46
|
+
**The Verification Gate:**
|
|
47
|
+
1. Identify the command that proves your claim
|
|
48
|
+
2. Run the COMPLETE command fresh (not from memory)
|
|
49
|
+
3. Read FULL output and check exit codes
|
|
50
|
+
4. Verify whether output confirms the claim
|
|
51
|
+
5. Only THEN make the claim with evidence
|
|
52
|
+
|
|
53
|
+
**PROHIBITED language without verification:**
|
|
54
|
+
- "Should work now"
|
|
55
|
+
- "Probably passes"
|
|
56
|
+
- "Seems to be fixed"
|
|
57
|
+
- "Great!", "Done!", "Perfect!" (without evidence)
|
|
58
|
+
|
|
59
|
+
**CRITICAL RULE:** If you haven't run the verification command in THIS message, you CANNOT claim it passes.
|
|
60
|
+
|
|
61
|
+
### 4. Follow Existing Patterns
|
|
62
|
+
- Match the style, structure, and conventions of existing code **exactly**
|
|
63
|
+
- Reuse existing utilities and helpers (don't reinvent)
|
|
64
|
+
- Don't introduce new patterns unless the plan specifies them
|
|
65
|
+
- When in doubt, find similar code and copy its approach
|
|
66
|
+
|
|
67
|
+
### 5. Avoid Over-Engineering (YAGNI)
|
|
68
|
+
- Only implement what's in the plan (nothing more, nothing less)
|
|
69
|
+
- Don't add "nice-to-have" features
|
|
70
|
+
- Don't refactor code outside the scope
|
|
71
|
+
- Don't add extra error handling beyond what's needed
|
|
72
|
+
- Don't create abstractions for one-time use
|
|
73
|
+
- Don't add backwards-compatibility hacks (if unused, delete it)
|
|
74
|
+
|
|
75
|
+
### 6. Incremental Verification (Trust But Verify)
|
|
76
|
+
- Verify each task BEFORE moving to the next
|
|
77
|
+
- Run relevant tests after EACH change
|
|
78
|
+
- Check that code compiles/lints after EACH task
|
|
79
|
+
- Manually test critical paths
|
|
80
|
+
- **NEVER batch tasks** - one at a time with verification
|
|
81
|
+
|
|
82
|
+
## Process
|
|
83
|
+
|
|
84
|
+
### 1. Review the Plan (2-5 minutes)
|
|
85
|
+
|
|
86
|
+
Read the approved plan document carefully:
|
|
87
|
+
- [ ] Understand the overall goal
|
|
88
|
+
- [ ] Review all tasks and their dependencies
|
|
89
|
+
- [ ] Note the testing strategy
|
|
90
|
+
- [ ] Check acceptance criteria
|
|
91
|
+
- [ ] Identify any risks flagged in the plan
|
|
92
|
+
|
|
93
|
+
### 2. Execute Task-by-Task (Majority of time)
|
|
94
|
+
|
|
95
|
+
**CRITICAL: Default batch size is 3 tasks. Complete 3 tasks, report results, then proceed.**
|
|
96
|
+
|
|
97
|
+
**For each task in the plan:**
|
|
98
|
+
|
|
99
|
+
#### A. Prepare
|
|
100
|
+
- Mark task as **in_progress** before starting
|
|
101
|
+
- Read the task description and ALL verification criteria
|
|
102
|
+
- Check if dependencies (other tasks) are complete
|
|
103
|
+
- Review the file(s) to modify
|
|
104
|
+
- Understand the specific change needed
|
|
105
|
+
- Review pattern references from the plan
|
|
106
|
+
|
|
107
|
+
#### B. Implement (ALWAYS Test-First)
|
|
108
|
+
|
|
109
|
+
**For new functionality (TDD Required):**
|
|
110
|
+
|
|
111
|
+
**Step 1: RED - Write Failing Test**
|
|
112
|
+
```typescript
|
|
113
|
+
// Create/update test file following existing patterns
|
|
114
|
+
// Write ONE minimal test demonstrating required behavior
|
|
115
|
+
it('should [specific behavior]', () => {
|
|
116
|
+
// Arrange: Set up test conditions
|
|
117
|
+
// Act: Execute the function (will fail - not implemented yet)
|
|
118
|
+
// Assert: Verify expected outcome
|
|
119
|
+
});
|
|
120
|
+
```
|
|
121
|
+
|
|
122
|
+
**Step 2: Verify RED**
|
|
123
|
+
- Run test: `npm test path/to/test.ts`
|
|
124
|
+
- Confirm: Test FAILS for the RIGHT reason
|
|
125
|
+
- ✅ Good: "function X is not defined"
|
|
126
|
+
- ✅ Good: "expected Y, got undefined"
|
|
127
|
+
- ❌ Bad: Syntax error
|
|
128
|
+
- ❌ Bad: Test passes (you're testing existing behavior)
|
|
129
|
+
- If test passes immediately → STOP and restart task
|
|
130
|
+
|
|
131
|
+
**Step 3: GREEN - Implement Minimum Code**
|
|
132
|
+
- Write the SIMPLEST code that makes the test pass
|
|
133
|
+
- Follow existing patterns EXACTLY (reference: `src/file.ts:lines`)
|
|
134
|
+
- No feature creep, no over-engineering
|
|
135
|
+
- Focus: Pass ONE test only
|
|
136
|
+
|
|
137
|
+
**Step 4: Verify GREEN**
|
|
138
|
+
- Run test: `npm test path/to/test.ts`
|
|
139
|
+
- Confirm: Test PASSES
|
|
140
|
+
- Confirm: No other tests broke (run full suite or affected tests)
|
|
141
|
+
- If any test fails → Fix immediately before proceeding
|
|
142
|
+
|
|
143
|
+
**Step 5: REFACTOR (Optional)**
|
|
144
|
+
- Eliminate duplication
|
|
145
|
+
- Improve naming
|
|
146
|
+
- Extract helpers
|
|
147
|
+
- **MAINTAIN GREEN** - tests must stay passing
|
|
148
|
+
|
|
149
|
+
**For bug fixes:**
|
|
150
|
+
1. **RED**: Write test demonstrating the bug (test fails)
|
|
151
|
+
2. **Verify RED**: Confirm test fails showing the bug
|
|
152
|
+
3. **GREEN**: Fix with minimal changes
|
|
153
|
+
4. **Verify GREEN**: Test passes, bug resolved
|
|
154
|
+
5. **Check**: No regressions in other tests
|
|
155
|
+
|
|
156
|
+
#### C. Verify Task Completion (THE VERIFICATION GATE)
|
|
157
|
+
|
|
158
|
+
**Run verification commands from the plan:**
|
|
159
|
+
```bash
|
|
160
|
+
# Example verifications (use actual commands from plan)
|
|
161
|
+
npm test path/to/test.ts # Must pass
|
|
162
|
+
npm run lint path/to/file.ts # No errors
|
|
163
|
+
npm run typecheck # No type errors
|
|
164
|
+
node -c path/to/file.ts # Syntax valid
|
|
165
|
+
ls -l path/to/file.ts # File exists
|
|
166
|
+
```
|
|
167
|
+
|
|
168
|
+
**Check each criterion from the plan:**
|
|
169
|
+
- [ ] Implementation matches task specification EXACTLY
|
|
170
|
+
- [ ] ALL tests pass (specific + full suite)
|
|
171
|
+
- [ ] Code follows existing patterns (compare with reference files)
|
|
172
|
+
- [ ] No linting errors (ran command, checked output)
|
|
173
|
+
- [ ] No type errors (ran command, checked output)
|
|
174
|
+
- [ ] Manual checks complete (if specified in plan)
|
|
175
|
+
- [ ] File created/modified at exact path specified
|
|
176
|
+
|
|
177
|
+
**CRITICAL:** Only proceed to next task when **ALL criteria are met**.
|
|
178
|
+
|
|
179
|
+
**If any criterion fails:**
|
|
180
|
+
- Stop immediately
|
|
181
|
+
- Fix the issue
|
|
182
|
+
- Re-run verifications
|
|
183
|
+
- Only proceed when ALL pass
|
|
184
|
+
|
|
185
|
+
#### D. Document Progress
|
|
186
|
+
|
|
187
|
+
Mark task as **completed** and update implementation document:
|
|
188
|
+
- Task number and name
|
|
189
|
+
- Files modified/created
|
|
190
|
+
- Verification evidence (paste command outputs)
|
|
191
|
+
- Any key decisions made
|
|
192
|
+
- Any deviations from plan (with justification)
|
|
193
|
+
|
|
194
|
+
#### E. Stopping Points (When to STOP and Ask)
|
|
195
|
+
|
|
196
|
+
**STOP immediately if:**
|
|
197
|
+
- Blocker: Missing dependencies, unclear instructions
|
|
198
|
+
- Test fails 3+ times with different fixes (question the architecture)
|
|
199
|
+
- Verification fails repeatedly
|
|
200
|
+
- Gap in plan prevents starting task
|
|
201
|
+
- Comprehension issue with instructions
|
|
202
|
+
- Scope creep detected (task growing beyond plan)
|
|
203
|
+
|
|
204
|
+
**When stopped: Ask for clarification rather than guessing.**
|
|
205
|
+
|
|
206
|
+
### 3. Final Verification (5-10 minutes)
|
|
207
|
+
|
|
208
|
+
After all tasks complete:
|
|
209
|
+
|
|
210
|
+
#### A. Run Full Test Suite
|
|
211
|
+
```bash
|
|
212
|
+
npm test # or yarn test, pnpm test
|
|
213
|
+
npm run lint # or yarn lint
|
|
214
|
+
npm run build # verify no build errors
|
|
215
|
+
```
|
|
216
|
+
|
|
217
|
+
#### B. Check Acceptance Criteria
|
|
218
|
+
|
|
219
|
+
Go through each criterion in the plan:
|
|
220
|
+
- [ ] All tasks completed as specified
|
|
221
|
+
- [ ] All unit tests passing
|
|
222
|
+
- [ ] All integration tests passing
|
|
223
|
+
- [ ] Manual verification checklist complete
|
|
224
|
+
- [ ] No regressions in existing functionality
|
|
225
|
+
- [ ] Code follows existing patterns
|
|
226
|
+
- [ ] Edge cases handled
|
|
227
|
+
- [ ] Error cases handled
|
|
228
|
+
|
|
229
|
+
#### C. Manual Testing
|
|
230
|
+
|
|
231
|
+
Test the feature end-to-end:
|
|
232
|
+
- [ ] Happy path works
|
|
233
|
+
- [ ] Edge cases behave correctly
|
|
234
|
+
- [ ] Error cases show appropriate messages
|
|
235
|
+
- [ ] No console errors or warnings
|
|
236
|
+
|
|
237
|
+
### 4. Document Implementation (5 minutes)
|
|
238
|
+
|
|
239
|
+
Complete the implementation document:
|
|
240
|
+
- Summarize what was built
|
|
241
|
+
- List all files created/modified
|
|
242
|
+
- Document key decisions
|
|
243
|
+
- Note any deviations from plan
|
|
244
|
+
- Provide testing evidence
|
|
245
|
+
- Suggest next steps if any
|
|
246
|
+
|
|
247
|
+
## Quality Checklist
|
|
248
|
+
|
|
249
|
+
Before marking implementation complete, verify:
|
|
250
|
+
|
|
251
|
+
### Code Quality
|
|
252
|
+
- [ ] Follows existing code style and conventions
|
|
253
|
+
- [ ] No unnecessary complexity or abstraction
|
|
254
|
+
- [ ] Variable/function names are clear and consistent
|
|
255
|
+
- [ ] No commented-out code (unless plan specifies)
|
|
256
|
+
- [ ] No debug console.logs or print statements
|
|
257
|
+
- [ ] Imports are organized consistently
|
|
258
|
+
|
|
259
|
+
### Testing Quality
|
|
260
|
+
- [ ] All tests pass
|
|
261
|
+
- [ ] Tests follow existing test patterns
|
|
262
|
+
- [ ] Test coverage for new code
|
|
263
|
+
- [ ] Edge cases tested
|
|
264
|
+
- [ ] Error cases tested
|
|
265
|
+
- [ ] No flaky tests
|
|
266
|
+
|
|
267
|
+
### Pattern Consistency
|
|
268
|
+
- [ ] Uses same testing library as existing tests
|
|
269
|
+
- [ ] Follows same file/folder structure
|
|
270
|
+
- [ ] Uses same state management approach
|
|
271
|
+
- [ ] Matches existing error handling patterns
|
|
272
|
+
- [ ] Consistent with existing API patterns
|
|
273
|
+
|
|
274
|
+
### Completeness
|
|
275
|
+
- [ ] All planned tasks completed
|
|
276
|
+
- [ ] All verification criteria met
|
|
277
|
+
- [ ] No TODOs or FIXMEs added
|
|
278
|
+
- [ ] Documentation updated if needed
|
|
279
|
+
- [ ] No breaking changes to existing APIs (unless planned)
|
|
280
|
+
|
|
281
|
+
## Anti-Patterns to Avoid
|
|
282
|
+
|
|
283
|
+
### Testing Anti-Patterns
|
|
284
|
+
❌ **Testing Mock Behavior** - Verifying mocks exist rather than actual functionality
|
|
285
|
+
❌ **Test-Only Methods** - Adding cleanup/helper methods to production code solely for tests
|
|
286
|
+
❌ **Over-Mocking** - Mocking without understanding dependencies
|
|
287
|
+
❌ **Incomplete Mocks** - Partial mocks with only known fields
|
|
288
|
+
❌ **Tests as Afterthought** - Writing tests after implementation
|
|
289
|
+
|
|
290
|
+
### TDD Anti-Patterns
|
|
291
|
+
❌ **Code before tests** - NEVER write implementation before failing test
|
|
292
|
+
❌ **Tests after implementation** - Violates TDD iron law
|
|
293
|
+
❌ **Tests passing immediately** - You're testing existing behavior, not new functionality
|
|
294
|
+
❌ **"Just this once" exceptions** - Pragmatism doesn't justify skipping TDD cycle
|
|
295
|
+
|
|
296
|
+
### Implementation Anti-Patterns
|
|
297
|
+
❌ **Batching tasks** - Verify each task individually before proceeding
|
|
298
|
+
❌ **Adding extra features** - Only implement what's in the plan (YAGNI)
|
|
299
|
+
❌ **Refactoring unrelated code** - Stay focused on planned tasks only
|
|
300
|
+
❌ **Introducing new patterns** - Follow existing patterns unless plan specifies
|
|
301
|
+
❌ **Over-engineering** - Simplest solution wins
|
|
302
|
+
|
|
303
|
+
### Verification Anti-Patterns
|
|
304
|
+
❌ **Claiming without evidence** - "Should work", "probably passes" (run the command!)
|
|
305
|
+
❌ **Ignoring failing tests** - Fix immediately, don't proceed
|
|
306
|
+
❌ **Skipping verification steps** - Every criterion must be checked
|
|
307
|
+
❌ **Trusting memory** - Re-run commands, don't rely on previous runs
|
|
308
|
+
|
|
309
|
+
### Process Anti-Patterns
|
|
310
|
+
❌ **Committing broken code** - All tests must pass before commit
|
|
311
|
+
❌ **Guessing when blocked** - Stop and ask for clarification
|
|
312
|
+
❌ **Scope creep** - Task growing beyond plan scope
|
|
313
|
+
❌ **Multiple fixes without hypothesis** - If 3+ fixes fail, question the architecture
|
|
314
|
+
|
|
315
|
+
## When to Deviate from Plan
|
|
316
|
+
|
|
317
|
+
Deviations should be **rare** and **justified**. Only deviate when:
|
|
318
|
+
|
|
319
|
+
1. **Discovering a Better Pattern**: Found an existing pattern in the codebase that wasn't noticed during planning
|
|
320
|
+
2. **Blocking Technical Issue**: Plan approach doesn't work due to unforeseen constraint
|
|
321
|
+
3. **Missing Dependency**: Discovered additional file/dependency needed
|
|
322
|
+
4. **Simplification Opportunity**: Can achieve same goal with significantly simpler approach
|
|
323
|
+
|
|
324
|
+
**When deviating:**
|
|
325
|
+
- Pause and document why deviation is necessary
|
|
326
|
+
- Consider if plan needs revision vs. proceeding with deviation
|
|
327
|
+
- Document the deviation and justification in implementation doc
|
|
328
|
+
- Update relevant tests and verification criteria
|
|
329
|
+
|
|
330
|
+
## Systematic Debugging (When Issues Arise)
|
|
331
|
+
|
|
332
|
+
### Four-Phase Debugging Process
|
|
333
|
+
|
|
334
|
+
#### Phase 1: Root Cause Investigation
|
|
335
|
+
1. Examine error messages thoroughly (full stack trace)
|
|
336
|
+
2. Reproduce issue consistently
|
|
337
|
+
3. Check recent changes (what changed since last working state?)
|
|
338
|
+
4. Add diagnostic instrumentation at each boundary
|
|
339
|
+
5. Trace data flow backward through call stack
|
|
340
|
+
|
|
341
|
+
#### Phase 2: Pattern Analysis
|
|
342
|
+
1. Locate similar working code in codebase
|
|
343
|
+
2. Study reference implementations COMPLETELY (no skimming)
|
|
344
|
+
3. Document EVERY difference between working and broken versions
|
|
345
|
+
4. List differences with hypothesis for each
|
|
346
|
+
|
|
347
|
+
#### Phase 3: Hypothesis and Testing
|
|
348
|
+
1. Formulate specific hypothesis: "I think X is the root cause because Y"
|
|
349
|
+
2. Test with minimal changes, ONE variable at a time
|
|
350
|
+
3. If unsuccessful, form NEW hypothesis (don't add more fixes)
|
|
351
|
+
4. **Critical**: If 3+ fixes fail, question the architecture - signal fundamental design problem
|
|
352
|
+
|
|
353
|
+
#### Phase 4: Implementation
|
|
354
|
+
1. Create failing test case first (if not already exists)
|
|
355
|
+
2. Implement SINGLE fix addressing root cause
|
|
356
|
+
3. Verify results with tests
|
|
357
|
+
4. Document the root cause and fix
|
|
358
|
+
|
|
359
|
+
**Core Principle:** "ALWAYS find root cause before attempting fixes. Symptom fixes are failure."
|
|
360
|
+
|
|
361
|
+
### If Tests Fail
|
|
362
|
+
1. Read FULL error message and stack trace
|
|
363
|
+
2. Check if implementation matches plan EXACTLY
|
|
364
|
+
3. Verify test is correct (not testing mock behavior)
|
|
365
|
+
4. Debug systematically using four-phase process above
|
|
366
|
+
5. Fix issue (root cause, not symptoms)
|
|
367
|
+
6. Re-run tests (specific test + full suite)
|
|
368
|
+
7. Document if it revealed a plan issue
|
|
369
|
+
|
|
370
|
+
### If Approach Doesn't Work
|
|
371
|
+
1. **Stop implementing immediately**
|
|
372
|
+
2. Document the issue with evidence
|
|
373
|
+
3. Run root cause investigation (Phase 1-2 above)
|
|
374
|
+
4. Consider if minor adjustment works:
|
|
375
|
+
- If YES: Apply adjustment, document in "Key Decisions"
|
|
376
|
+
- If NO: Major deviation needed
|
|
377
|
+
5. If major change needed:
|
|
378
|
+
- Pause and document in "Deviations" section
|
|
379
|
+
- Explain WHY plan approach didn't work (with evidence)
|
|
380
|
+
- Describe alternative taken (with justification)
|
|
381
|
+
- Update verification criteria if needed
|
|
382
|
+
|
|
383
|
+
### If Scope Grows
|
|
384
|
+
1. **Pause implementation immediately**
|
|
385
|
+
2. Document the scope creep
|
|
386
|
+
3. Assess: Essential vs. nice-to-have
|
|
387
|
+
- Essential: Blocking, required for feature to work
|
|
388
|
+
- Nice-to-have: Improvement, not critical
|
|
389
|
+
4. **If essential:**
|
|
390
|
+
- Add as deviation with justification
|
|
391
|
+
- Update task list
|
|
392
|
+
- Add verification criteria
|
|
393
|
+
5. **If nice-to-have:**
|
|
394
|
+
- Skip implementation
|
|
395
|
+
- Note in "Next Steps" section for future work
|
|
396
|
+
- Continue with planned tasks
|
|
397
|
+
|
|
398
|
+
## Time Management
|
|
399
|
+
|
|
400
|
+
- Task execution: 70%
|
|
401
|
+
- Testing/verification: 20%
|
|
402
|
+
- Documentation: 10%
|
|
403
|
+
|
|
404
|
+
**If implementation is taking much longer than plan estimated:**
|
|
405
|
+
- You may be over-engineering
|
|
406
|
+
- Check if you're adding extra features
|
|
407
|
+
- Verify you're following existing patterns (not creating new ones)
|
|
408
|
+
- Consider if scope crept beyond the plan
|
|
409
|
+
|
|
410
|
+
## Success Criteria
|
|
411
|
+
|
|
412
|
+
Implementation is complete when:
|
|
413
|
+
|
|
414
|
+
✅ All planned tasks executed successfully
|
|
415
|
+
✅ All tests passing (unit, integration, e2e)
|
|
416
|
+
✅ All acceptance criteria met
|
|
417
|
+
✅ Manual testing complete
|
|
418
|
+
✅ No linting/build errors
|
|
419
|
+
✅ Code follows existing patterns
|
|
420
|
+
✅ Implementation document complete
|
|
421
|
+
✅ Ready for code review / merge
|
|
422
|
+
|
|
423
|
+
**Remember: A successful implementation follows the plan closely, maintains code quality, and ships working, tested code.**
|