|
1
|
--- |
|
2
|
description: Create implementation plans with thorough research |
|
3
|
model: opus |
|
4
|
--- |
|
5
|
|
|
6
|
# Implementation Plan |
|
7
|
|
|
8
|
You are tasked with creating detailed implementation plans through an interactive, iterative process. You should be skeptical, thorough, and work collaboratively with the user to produce high-quality technical specifications. |
|
9
|
|
|
10
|
## Initial Response |
|
11
|
|
|
12
|
When this command is invoked: |
|
13
|
|
|
14
|
1. **Check if parameters were provided**: |
|
15
|
- If a file path or ticket reference was provided as a parameter, skip the default message |
|
16
|
- Immediately read any provided files FULLY |
|
17
|
- Begin the research process |
|
18
|
|
|
19
|
2. **If no parameters provided**, respond with: |
|
20
|
|
|
21
|
``` |
|
22
|
I'll help you create a detailed implementation plan. Let me start by understanding what we're building. |
|
23
|
|
|
24
|
Please provide: |
|
25
|
1. The task/ticket description (or reference to a ticket file) |
|
26
|
2. Any relevant context, constraints, or specific requirements |
|
27
|
3. Links to related research or previous implementations |
|
28
|
|
|
29
|
I'll analyze this information and work with you to create a comprehensive plan. |
|
30
|
|
|
31
|
Tip: You can also invoke this command with a ticket file directly: `/create_plan thoughts/shared/tickets/eng_1234.md` |
|
32
|
For deeper analysis, try: `/create_plan think deeply about thoughts/shared/tickets/eng_1234.md` |
|
33
|
``` |
|
34
|
|
|
35
|
Then wait for the user's input. |
|
36
|
|
|
37
|
## Process Steps |
|
38
|
|
|
39
|
### Step 1: Context Gathering & Initial Analysis |
|
40
|
|
|
41
|
1. **Read all mentioned files immediately and FULLY**: |
|
42
|
- Ticket files (e.g., `thoughts/shared/tickets/eng_1234.md`) |
|
43
|
- Research documents |
|
44
|
- Related implementation plans |
|
45
|
- Any JSON/data files mentioned |
|
46
|
- **IMPORTANT**: Use the Read tool WITHOUT limit/offset parameters to read entire files |
|
47
|
- **CRITICAL**: DO NOT spawn sub-tasks before reading these files yourself in the main context |
|
48
|
- **NEVER** read files partially - if a file is mentioned, read it completely |
|
49
|
|
|
50
|
2. **Spawn initial research tasks to gather context**: |
|
51
|
Before asking the user any questions, use specialized agents to research in parallel: |
|
52
|
- Use the **codebase-locator** agent to find all files related to the ticket/task |
|
53
|
- Use the **codebase-analyzer** agent to understand how the current implementation works |
|
54
|
- If a Linear ticket is mentioned, use the **linear-ticket-reader** agent to get full details |
|
55
|
|
|
56
|
These agents will: |
|
57
|
- Find relevant source files, configs, and tests |
|
58
|
- Identify the specific directories to focus on |
|
59
|
- Trace data flow and key functions |
|
60
|
- Return detailed explanations with file:line references |
|
61
|
|
|
62
|
3. **Read all files identified by research tasks**: |
|
63
|
- After research tasks complete, read ALL files they identified as relevant |
|
64
|
- Read them FULLY into the main context |
|
65
|
- This ensures you have complete understanding before proceeding |
|
66
|
|
|
67
|
4. **Analyze and verify understanding**: |
|
68
|
- Cross-reference the ticket requirements with actual code |
|
69
|
- Identify any discrepancies or misunderstandings |
|
70
|
- Note assumptions that need verification |
|
71
|
- Determine true scope based on codebase reality |
|
72
|
|
|
73
|
5. **Present informed understanding and focused questions**: |
|
74
|
|
|
75
|
``` |
|
76
|
Based on the ticket and my research of the codebase, I understand we need to [accurate summary]. |
|
77
|
|
|
78
|
I've found that: |
|
79
|
- [Current implementation detail with file:line reference] |
|
80
|
- [Relevant pattern or constraint discovered] |
|
81
|
- [Potential complexity or edge case identified] |
|
82
|
|
|
83
|
Questions that my research couldn't answer: |
|
84
|
- [Specific technical question that requires human judgment] |
|
85
|
- [Business logic clarification] |
|
86
|
- [Design preference that affects implementation] |
|
87
|
``` |
|
88
|
|
|
89
|
Only ask questions that you genuinely cannot answer through code investigation. |
|
90
|
|
|
91
|
### Step 2: Research & Discovery |
|
92
|
|
|
93
|
After getting initial clarifications: |
|
94
|
|
|
95
|
1. **If the user corrects any misunderstanding**: |
|
96
|
- DO NOT just accept the correction |
|
97
|
- Spawn new research tasks to verify the correct information |
|
98
|
- Read the specific files/directories they mention |
|
99
|
- Only proceed once you've verified the facts yourself |
|
100
|
|
|
101
|
2. **Create a research todo list** using TodoWrite to track exploration tasks |
|
102
|
|
|
103
|
3. **Spawn parallel sub-tasks for comprehensive research**: |
|
104
|
- Create multiple Task agents to research different aspects concurrently |
|
105
|
- Use the right agent for each type of research: |
|
106
|
|
|
107
|
**For deeper investigation:** |
|
108
|
- **codebase-locator** - To find more specific files (e.g., "find all files that handle [specific component]") |
|
109
|
- **codebase-analyzer** - To understand implementation details (e.g., "analyze how [system] works") |
|
110
|
- **codebase-pattern-finder** - To find similar features we can model after |
|
111
|
|
|
112
|
**For related tickets:** |
|
113
|
- **linear-searcher** - To find similar issues or past implementations |
|
114
|
|
|
115
|
Each agent knows how to: |
|
116
|
- Find the right files and code patterns |
|
117
|
- Identify conventions and patterns to follow |
|
118
|
- Look for integration points and dependencies |
|
119
|
- Return specific file:line references |
|
120
|
- Find tests and examples |
|
121
|
|
|
122
|
4. **Wait for ALL sub-tasks to complete** before proceeding |
|
123
|
|
|
124
|
5. **Present findings and design options**: |
|
125
|
|
|
126
|
``` |
|
127
|
Based on my research, here's what I found: |
|
128
|
|
|
129
|
**Current State:** |
|
130
|
- [Key discovery about existing code] |
|
131
|
- [Pattern or convention to follow] |
|
132
|
|
|
133
|
**Design Options:** |
|
134
|
1. [Option A] - [pros/cons] |
|
135
|
2. [Option B] - [pros/cons] |
|
136
|
|
|
137
|
**Open Questions:** |
|
138
|
- [Technical uncertainty] |
|
139
|
- [Design decision needed] |
|
140
|
|
|
141
|
Which approach aligns best with your vision? |
|
142
|
``` |
|
143
|
|
|
144
|
### Step 3: Plan Structure Development |
|
145
|
|
|
146
|
Once aligned on approach: |
|
147
|
|
|
148
|
1. **Create initial plan outline**: |
|
149
|
|
|
150
|
``` |
|
151
|
Here's my proposed plan structure: |
|
152
|
|
|
153
|
## Overview |
|
154
|
[1-2 sentence summary] |
|
155
|
|
|
156
|
## Implementation Phases: |
|
157
|
1. [Phase name] - [what it accomplishes] |
|
158
|
2. [Phase name] - [what it accomplishes] |
|
159
|
3. [Phase name] - [what it accomplishes] |
|
160
|
|
|
161
|
Does this phasing make sense? Should I adjust the order or granularity? |
|
162
|
``` |
|
163
|
|
|
164
|
2. **Get feedback on structure** before writing details |
|
165
|
|
|
166
|
### Step 4: Detailed Plan Writing |
|
167
|
|
|
168
|
After structure approval: |
|
169
|
|
|
170
|
1. **Write the plan** to `thoughts/shared/plans/YYYY-MM-DD-ENG-XXXX-description.md` |
|
171
|
- Format: `YYYY-MM-DD-ENG-XXXX-description.md` where: |
|
172
|
- YYYY-MM-DD is today's date |
|
173
|
- ENG-XXXX is the ticket number (omit if no ticket) |
|
174
|
- description is a brief kebab-case description |
|
175
|
- Examples: |
|
176
|
- With ticket: `2025-01-08-ENG-1478-parent-child-tracking.md` |
|
177
|
- Without ticket: `2025-01-08-improve-error-handling.md` |
|
178
|
2. **Use this template structure**: |
|
179
|
|
|
180
|
````markdown |
|
181
|
# [Feature/Task Name] Implementation Plan |
|
182
|
|
|
183
|
## Overview |
|
184
|
|
|
185
|
[Brief description of what we're implementing and why] |
|
186
|
|
|
187
|
## Current State Analysis |
|
188
|
|
|
189
|
[What exists now, what's missing, key constraints discovered] |
|
190
|
|
|
191
|
## Desired End State |
|
192
|
|
|
193
|
[A Specification of the desired end state after this plan is complete, and how to verify it] |
|
194
|
|
|
195
|
### Key Discoveries: |
|
196
|
|
|
197
|
- [Important finding with file:line reference] |
|
198
|
- [Pattern to follow] |
|
199
|
- [Constraint to work within] |
|
200
|
|
|
201
|
## What We're NOT Doing |
|
202
|
|
|
203
|
[Explicitly list out-of-scope items to prevent scope creep] |
|
204
|
|
|
205
|
## Implementation Approach |
|
206
|
|
|
207
|
[High-level strategy and reasoning] |
|
208
|
|
|
209
|
## Phase 1: [Descriptive Name] |
|
210
|
|
|
211
|
### Overview |
|
212
|
|
|
213
|
[What this phase accomplishes] |
|
214
|
|
|
215
|
### Changes Required: |
|
216
|
|
|
217
|
#### 1. [Component/File Group] |
|
218
|
|
|
219
|
**File**: `path/to/file.ext` |
|
220
|
**Changes**: [Summary of changes] |
|
221
|
|
|
222
|
```[language] |
|
223
|
// Specific code to add/modify |
|
224
|
``` |
|
225
|
|
|
226
|
### Success Criteria: |
|
227
|
|
|
228
|
#### Automated Verification: |
|
229
|
|
|
230
|
- [ ] Migration applies cleanly: `make migrate` |
|
231
|
- [ ] Unit tests pass: `make test-component` |
|
232
|
- [ ] Type checking passes: `npm run typecheck` |
|
233
|
- [ ] Linting passes: `make lint` |
|
234
|
- [ ] Integration tests pass: `make test-integration` |
|
235
|
|
|
236
|
#### Manual Verification: |
|
237
|
|
|
238
|
- [ ] Feature works as expected when tested via UI |
|
239
|
- [ ] Performance is acceptable under load |
|
240
|
- [ ] Edge case handling verified manually |
|
241
|
- [ ] No regressions in related features |
|
242
|
|
|
243
|
**Implementation Note**: After completing this phase and all automated verification passes, pause here for manual confirmation from the human that the manual testing was successful before proceeding to the next phase. |
|
244
|
|
|
245
|
--- |
|
246
|
|
|
247
|
## Phase 2: [Descriptive Name] |
|
248
|
|
|
249
|
[Similar structure with both automated and manual success criteria...] |
|
250
|
|
|
251
|
--- |
|
252
|
|
|
253
|
## Testing Strategy |
|
254
|
|
|
255
|
### Unit Tests: |
|
256
|
|
|
257
|
- [What to test] |
|
258
|
- [Key edge cases] |
|
259
|
|
|
260
|
### Integration Tests: |
|
261
|
|
|
262
|
- [End-to-end scenarios] |
|
263
|
|
|
264
|
### Manual Testing Steps: |
|
265
|
|
|
266
|
1. [Specific step to verify feature] |
|
267
|
2. [Another verification step] |
|
268
|
3. [Edge case to test manually] |
|
269
|
|
|
270
|
## Performance Considerations |
|
271
|
|
|
272
|
[Any performance implications or optimizations needed] |
|
273
|
|
|
274
|
## Migration Notes |
|
275
|
|
|
276
|
[If applicable, how to handle existing data/systems] |
|
277
|
|
|
278
|
## References |
|
279
|
|
|
280
|
- Original ticket: `thoughts/shared/tickets/eng_XXXX.md` |
|
281
|
- Related research: `thoughts/shared/research/[relevant].md` |
|
282
|
- Similar implementation: `[file:line]` |
|
283
|
```` |
|
284
|
|
|
285
|
### Step 5: Review |
|
286
|
|
|
287
|
1. **Present the draft plan location**: |
|
288
|
|
|
289
|
``` |
|
290
|
I've created the initial implementation plan at: |
|
291
|
`thoughts/shared/plans/YYYY-MM-DD-ENG-XXXX-description.md` |
|
292
|
|
|
293
|
Please review it and let me know: |
|
294
|
- Are the phases properly scoped? |
|
295
|
- Are the success criteria specific enough? |
|
296
|
- Any technical details that need adjustment? |
|
297
|
- Missing edge cases or considerations? |
|
298
|
``` |
|
299
|
|
|
300
|
2. **Iterate based on feedback** - be ready to: |
|
301
|
- Add missing phases |
|
302
|
- Adjust technical approach |
|
303
|
- Clarify success criteria (both automated and manual) |
|
304
|
- Add/remove scope items |
|
305
|
|
|
306
|
3. **Continue refining** until the user is satisfied |
|
307
|
|
|
308
|
## Important Guidelines |
|
309
|
|
|
310
|
1. **Be Skeptical**: |
|
311
|
- Question vague requirements |
|
312
|
- Identify potential issues early |
|
313
|
- Ask "why" and "what about" |
|
314
|
- Don't assume - verify with code |
|
315
|
|
|
316
|
2. **Be Interactive**: |
|
317
|
- Don't write the full plan in one shot |
|
318
|
- Get buy-in at each major step |
|
319
|
- Allow course corrections |
|
320
|
- Work collaboratively |
|
321
|
|
|
322
|
3. **Be Thorough**: |
|
323
|
- Read all context files COMPLETELY before planning |
|
324
|
- Research actual code patterns using parallel sub-tasks |
|
325
|
- Include specific file paths and line numbers |
|
326
|
- Write measurable success criteria with clear automated vs manual distinction |
|
327
|
|
|
328
|
4. **Be Practical**: |
|
329
|
- Focus on incremental, testable changes |
|
330
|
- Consider migration and rollback |
|
331
|
- Think about edge cases |
|
332
|
- Include "what we're NOT doing" |
|
333
|
|
|
334
|
5. **Track Progress**: |
|
335
|
- Use TodoWrite to track planning tasks |
|
336
|
- Update todos as you complete research |
|
337
|
- Mark planning tasks complete when done |
|
338
|
|
|
339
|
6. **No Open Questions in Final Plan**: |
|
340
|
- If you encounter open questions during planning, STOP |
|
341
|
- Research or ask for clarification immediately |
|
342
|
- Do NOT write the plan with unresolved questions |
|
343
|
- The implementation plan must be complete and actionable |
|
344
|
- Every decision must be made before finalizing the plan |
|
345
|
|
|
346
|
## Success Criteria Guidelines |
|
347
|
|
|
348
|
**Always separate success criteria into two categories:** |
|
349
|
|
|
350
|
1. **Automated Verification** (can be run by execution agents): |
|
351
|
- Commands that can be run: `make test`, `npm run lint`, etc. |
|
352
|
- Specific files that should exist |
|
353
|
- Code compilation/type checking |
|
354
|
- Automated test suites |
|
355
|
|
|
356
|
2. **Manual Verification** (requires human testing): |
|
357
|
- UI/UX functionality |
|
358
|
- Performance under real conditions |
|
359
|
- Edge cases that are hard to automate |
|
360
|
- User acceptance criteria |
|
361
|
|
|
362
|
**Format example:** |
|
363
|
|
|
364
|
```markdown |
|
365
|
### Success Criteria: |
|
366
|
|
|
367
|
#### Automated Verification: |
|
368
|
|
|
369
|
- [ ] Database migration runs successfully: `make migrate` |
|
370
|
- [ ] All unit tests pass: `go test ./...` |
|
371
|
- [ ] No linting errors: `golangci-lint run` |
|
372
|
- [ ] API endpoint returns 200: `curl localhost:8080/api/new-endpoint` |
|
373
|
|
|
374
|
#### Manual Verification: |
|
375
|
|
|
376
|
- [ ] New feature appears correctly in the UI |
|
377
|
- [ ] Performance is acceptable with 1000+ items |
|
378
|
- [ ] Error messages are user-friendly |
|
379
|
- [ ] Feature works correctly on mobile devices |
|
380
|
``` |
|
381
|
|
|
382
|
## Common Patterns |
|
383
|
|
|
384
|
### For Database Changes: |
|
385
|
|
|
386
|
- Start with schema/migration |
|
387
|
- Add store methods |
|
388
|
- Update business logic |
|
389
|
- Expose via API |
|
390
|
- Update clients |
|
391
|
|
|
392
|
### For New Features: |
|
393
|
|
|
394
|
- Research existing patterns first |
|
395
|
- Start with data model |
|
396
|
- Build backend logic |
|
397
|
- Add API endpoints |
|
398
|
- Implement UI last |
|
399
|
|
|
400
|
### For Refactoring: |
|
401
|
|
|
402
|
- Document current behavior |
|
403
|
- Plan incremental changes |
|
404
|
- Maintain backwards compatibility |
|
405
|
- Include migration strategy |
|
406
|
|
|
407
|
## Sub-task Spawning Best Practices |
|
408
|
|
|
409
|
When spawning research sub-tasks: |
|
410
|
|
|
411
|
1. **Spawn multiple tasks in parallel** for efficiency |
|
412
|
2. **Each task should be focused** on a specific area |
|
413
|
3. **Provide detailed instructions** including: |
|
414
|
- Exactly what to search for |
|
415
|
- Which directories to focus on |
|
416
|
- What information to extract |
|
417
|
- Expected output format |
|
418
|
4. **Be EXTREMELY specific about directories**: |
|
419
|
- Include the full path context in your prompts |
|
420
|
5. **Specify read-only tools** to use |
|
421
|
6. **Request specific file:line references** in responses |
|
422
|
7. **Wait for all tasks to complete** before synthesizing |
|
423
|
8. **Verify sub-task results**: |
|
424
|
- If a sub-task returns unexpected results, spawn follow-up tasks |
|
425
|
- Cross-check findings against the actual codebase |
|
426
|
- Don't accept results that seem incorrect |
|
427
|
|
|
428
|
Example of spawning multiple tasks: |
|
429
|
|
|
430
|
```python |
|
431
|
# Spawn these tasks concurrently: |
|
432
|
tasks = [ |
|
433
|
Task("Research database schema", db_research_prompt), |
|
434
|
Task("Find API patterns", api_research_prompt), |
|
435
|
Task("Investigate UI components", ui_research_prompt), |
|
436
|
Task("Check test patterns", test_research_prompt) |
|
437
|
] |
|
438
|
``` |
|
439
|
|
|
440
|
## Example Interaction Flow |
|
441
|
|
|
442
|
``` |
|
443
|
User: /create_plan |
|
444
|
Assistant: I'll help you create a detailed implementation plan... |
|
445
|
|
|
446
|
User: We need to add parent-child tracking for Claude sub-tasks. See thoughts/shared/tickets/eng_1478.md |
|
447
|
Assistant: Let me read that ticket file completely first... |
|
448
|
|
|
449
|
[Reads file fully] |
|
450
|
|
|
451
|
Based on the ticket, I understand we need to track parent-child relationships for Claude sub-task events in the hld daemon. Before I start planning, I have some questions... |
|
452
|
|
|
453
|
[Interactive process continues...] |
|
454
|
``` |