plan-flow-skill 1.0.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/.claude/commands/create-contract.md +468 -0
- package/.claude/commands/create-plan.md +512 -0
- package/.claude/commands/discovery-plan.md +561 -0
- package/.claude/commands/execute-plan.md +682 -0
- package/.claude/commands/review-code.md +459 -0
- package/.claude/commands/review-pr.md +651 -0
- package/.claude/commands/setup.md +1609 -0
- package/.claude/commands/write-tests.md +543 -0
- package/.claude/rules/core/allowed-patterns.md +175 -0
- package/.claude/rules/core/complexity-scoring.md +225 -0
- package/.claude/rules/core/forbidden-patterns.md +253 -0
- package/.claude/rules/languages/python-patterns.md +6 -0
- package/.claude/rules/languages/typescript-patterns.md +7 -0
- package/.claude/rules/patterns/contract-patterns.md +332 -0
- package/.claude/rules/patterns/discovery-patterns.md +342 -0
- package/.claude/rules/patterns/discovery-templates.md +319 -0
- package/.claude/rules/patterns/jest-patterns.md +482 -0
- package/.claude/rules/patterns/plans-patterns.md +225 -0
- package/.claude/rules/patterns/plans-templates.md +227 -0
- package/.claude/rules/patterns/pytest-patterns.md +457 -0
- package/.claude/rules/patterns/review-code-templates.md +305 -0
- package/.claude/rules/patterns/review-pr-patterns.md +360 -0
- package/.claude/rules/tools/auth-pr-tool.md +30 -0
- package/.claude/rules/tools/interactive-questions-tool.md +235 -0
- package/.claude/rules/tools/jest-testing-tool.md +73 -0
- package/.claude/rules/tools/plan-mode-tool.md +164 -0
- package/.claude/rules/tools/pytest-testing-tool.md +121 -0
- package/.claude/rules/tools/reference-expansion-tool.md +326 -0
- package/LICENSE +21 -0
- package/README.md +167 -0
- package/dist/cli/commands/init.d.ts +6 -0
- package/dist/cli/commands/init.d.ts.map +1 -0
- package/dist/cli/commands/init.js +139 -0
- package/dist/cli/commands/init.js.map +1 -0
- package/dist/cli/handlers/claude.d.ts +9 -0
- package/dist/cli/handlers/claude.d.ts.map +1 -0
- package/dist/cli/handlers/claude.js +119 -0
- package/dist/cli/handlers/claude.js.map +1 -0
- package/dist/cli/handlers/codex.d.ts +9 -0
- package/dist/cli/handlers/codex.d.ts.map +1 -0
- package/dist/cli/handlers/codex.js +100 -0
- package/dist/cli/handlers/codex.js.map +1 -0
- package/dist/cli/handlers/cursor.d.ts +8 -0
- package/dist/cli/handlers/cursor.d.ts.map +1 -0
- package/dist/cli/handlers/cursor.js +34 -0
- package/dist/cli/handlers/cursor.js.map +1 -0
- package/dist/cli/handlers/openclaw.d.ts +8 -0
- package/dist/cli/handlers/openclaw.d.ts.map +1 -0
- package/dist/cli/handlers/openclaw.js +34 -0
- package/dist/cli/handlers/openclaw.js.map +1 -0
- package/dist/cli/handlers/shared.d.ts +9 -0
- package/dist/cli/handlers/shared.d.ts.map +1 -0
- package/dist/cli/handlers/shared.js +44 -0
- package/dist/cli/handlers/shared.js.map +1 -0
- package/dist/cli/index.d.ts +8 -0
- package/dist/cli/index.d.ts.map +1 -0
- package/dist/cli/index.js +43 -0
- package/dist/cli/index.js.map +1 -0
- package/dist/cli/types.d.ts +26 -0
- package/dist/cli/types.d.ts.map +1 -0
- package/dist/cli/types.js +5 -0
- package/dist/cli/types.js.map +1 -0
- package/dist/cli/utils/files.d.ts +37 -0
- package/dist/cli/utils/files.d.ts.map +1 -0
- package/dist/cli/utils/files.js +122 -0
- package/dist/cli/utils/files.js.map +1 -0
- package/dist/cli/utils/logger.d.ts +11 -0
- package/dist/cli/utils/logger.d.ts.map +1 -0
- package/dist/cli/utils/logger.js +34 -0
- package/dist/cli/utils/logger.js.map +1 -0
- package/dist/cli/utils/prompts.d.ts +10 -0
- package/dist/cli/utils/prompts.d.ts.map +1 -0
- package/dist/cli/utils/prompts.js +65 -0
- package/dist/cli/utils/prompts.js.map +1 -0
- package/dist/test/setup.d.ts +5 -0
- package/dist/test/setup.d.ts.map +1 -0
- package/dist/test/setup.js +7 -0
- package/dist/test/setup.js.map +1 -0
- package/package.json +63 -0
- package/rules/core/_index.mdc +89 -0
- package/rules/core/allowed-patterns.mdc +185 -0
- package/rules/core/complexity-scoring.mdc +235 -0
- package/rules/core/forbidden-patterns.mdc +263 -0
- package/rules/languages/_index.mdc +80 -0
- package/rules/languages/python-patterns.mdc +188 -0
- package/rules/languages/typescript-patterns.mdc +128 -0
- package/rules/patterns/_index.mdc +185 -0
- package/rules/patterns/contract-patterns.mdc +344 -0
- package/rules/patterns/discovery-patterns.mdc +354 -0
- package/rules/patterns/discovery-templates.mdc +329 -0
- package/rules/patterns/jest-patterns.mdc +492 -0
- package/rules/patterns/plans-patterns.mdc +237 -0
- package/rules/patterns/plans-templates.mdc +237 -0
- package/rules/patterns/pytest-patterns.mdc +467 -0
- package/rules/patterns/review-code-templates.mdc +315 -0
- package/rules/patterns/review-pr-patterns.mdc +370 -0
- package/rules/skills/_index.mdc +174 -0
- package/rules/skills/create-contract-skill.mdc +239 -0
- package/rules/skills/create-plan-skill.mdc +271 -0
- package/rules/skills/discovery-skill.mdc +295 -0
- package/rules/skills/execute-plan-skill.mdc +388 -0
- package/rules/skills/review-code-skill.mdc +308 -0
- package/rules/skills/review-pr-skill.mdc +496 -0
- package/rules/skills/setup-skill.mdc +923 -0
- package/rules/skills/write-tests-skill.mdc +294 -0
- package/rules/templates/index-template.mdc +126 -0
- package/rules/tools/_index.mdc +114 -0
- package/rules/tools/auth-pr-tool.mdc +362 -0
- package/rules/tools/interactive-questions-tool.mdc +337 -0
- package/rules/tools/jest-testing-tool.mdc +96 -0
- package/rules/tools/plan-mode-tool.mdc +229 -0
- package/rules/tools/pytest-testing-tool.mdc +144 -0
- package/rules/tools/reference-expansion-tool.mdc +338 -0
- package/skills/plan-flow/SKILL.md +109 -0
- package/skills/plan-flow/create-contract/SKILL.md +139 -0
- package/skills/plan-flow/create-plan/SKILL.md +93 -0
- package/skills/plan-flow/discovery/SKILL.md +85 -0
- package/skills/plan-flow/execute-plan/SKILL.md +89 -0
- package/skills/plan-flow/review-code/SKILL.md +100 -0
- package/skills/plan-flow/review-pr/SKILL.md +122 -0
- package/skills/plan-flow/setup/SKILL.md +73 -0
- package/skills/plan-flow/write-tests/SKILL.md +115 -0
- package/templates/shared/AGENTS.md.template +60 -0
- package/templates/shared/CLAUDE.md.template +62 -0
|
@@ -0,0 +1,682 @@
|
|
|
1
|
+
---
|
|
2
|
+
description: This command executes an implementation plan phase by phase, using complexity scores to determine ex
|
|
3
|
+
---
|
|
4
|
+
|
|
5
|
+
# Execute Implementation Plan
|
|
6
|
+
|
|
7
|
+
## Command Description
|
|
8
|
+
|
|
9
|
+
This command executes an implementation plan phase by phase, using complexity scores to determine execution strategy. The command validates inputs and orchestrates the execution process by invoking the `execute-plan` skill.
|
|
10
|
+
|
|
11
|
+
**Output**: Implements all phases from the plan, updates progress, and optionally archives the completed plan.
|
|
12
|
+
|
|
13
|
+
---
|
|
14
|
+
|
|
15
|
+
|
|
16
|
+
## Help
|
|
17
|
+
|
|
18
|
+
**If the user invokes this command with `-help`, display only this section and stop:**
|
|
19
|
+
|
|
20
|
+
```
|
|
21
|
+
/execute-plan - Execute Implementation Plan
|
|
22
|
+
|
|
23
|
+
DESCRIPTION:
|
|
24
|
+
Executes an implementation plan phase by phase, using complexity scores
|
|
25
|
+
to determine execution strategy. Switches to Plan mode for each phase.
|
|
26
|
+
|
|
27
|
+
USAGE:
|
|
28
|
+
/execute-plan <plan_file>
|
|
29
|
+
/execute-plan -help
|
|
30
|
+
|
|
31
|
+
ARGUMENTS:
|
|
32
|
+
plan_file Path to the plan file in flow/plans/
|
|
33
|
+
|
|
34
|
+
EXAMPLES:
|
|
35
|
+
/execute-plan @flow/plans/plan_user_auth_v1.md
|
|
36
|
+
/execute-plan @flow/plans/plan_dark_mode_v2.md
|
|
37
|
+
|
|
38
|
+
OUTPUT:
|
|
39
|
+
- Implements all phases from the plan
|
|
40
|
+
- Updates plan file with completed tasks
|
|
41
|
+
- Runs build/test verification at the end
|
|
42
|
+
- Optionally archives completed plan
|
|
43
|
+
|
|
44
|
+
WORKFLOW:
|
|
45
|
+
1. Reads and parses the plan file
|
|
46
|
+
2. Groups phases by complexity score
|
|
47
|
+
3. For EACH phase:
|
|
48
|
+
- Auto-switches to Plan mode
|
|
49
|
+
- Presents phase details for approval
|
|
50
|
+
- Implements after approval
|
|
51
|
+
- Updates progress in plan file
|
|
52
|
+
4. Runs npm run build && npm run test (ONLY at the end)
|
|
53
|
+
5. Archives plan if requested
|
|
54
|
+
|
|
55
|
+
EXECUTION STRATEGIES:
|
|
56
|
+
Combined Score <= 6 Aggregate phases together
|
|
57
|
+
Combined Score 7-10 Cautious, 1-2 phases at a time
|
|
58
|
+
Combined Score > 10 Sequential, one phase at a time
|
|
59
|
+
Tests Phase Always executed separately
|
|
60
|
+
|
|
61
|
+
SAFETY:
|
|
62
|
+
- Database/ORM commands are NEVER run directly
|
|
63
|
+
- User is asked to execute migrations manually
|
|
64
|
+
- Prevents accidental data loss
|
|
65
|
+
|
|
66
|
+
RECOMMENDED MODEL:
|
|
67
|
+
Claude Opus 4.5 or Sonnet 4.5 for best results
|
|
68
|
+
|
|
69
|
+
RELATED COMMANDS:
|
|
70
|
+
/create-plan Create a plan first
|
|
71
|
+
/discovery-plan Run discovery before planning
|
|
72
|
+
```
|
|
73
|
+
|
|
74
|
+
---
|
|
75
|
+
|
|
76
|
+
## Critical Rules
|
|
77
|
+
|
|
78
|
+
| Rule | Description |
|
|
79
|
+
| ------------------------ | -------------------------------------------------------- |
|
|
80
|
+
| **Build ONLY at End** | Do NOT run build after each phase - only at the very end |
|
|
81
|
+
| **No Direct DB/ORM** | NEVER run ORM or database commands directly |
|
|
82
|
+
| **Complete and Stop** | After execution, STOP and wait for user |
|
|
83
|
+
|
|
84
|
+
---
|
|
85
|
+
|
|
86
|
+
## CRITICAL RULE: No Direct Database or ORM Commands
|
|
87
|
+
|
|
88
|
+
**NEVER execute any of the following commands directly:**
|
|
89
|
+
|
|
90
|
+
- `prisma migrate`
|
|
91
|
+
- `prisma db push`
|
|
92
|
+
- `prisma db seed`
|
|
93
|
+
- `prisma generate` (allowed - this is safe)
|
|
94
|
+
- `npx prisma ...` (except generate)
|
|
95
|
+
- `python manage.py migrate`
|
|
96
|
+
- `alembic upgrade`
|
|
97
|
+
- `sequelize db:migrate`
|
|
98
|
+
- `typeorm migration:run`
|
|
99
|
+
- `drizzle-kit push`
|
|
100
|
+
- Any direct SQL execution
|
|
101
|
+
- Any database connection/query commands
|
|
102
|
+
|
|
103
|
+
**ALWAYS ask the user to execute these commands manually:**
|
|
104
|
+
|
|
105
|
+
```markdown
|
|
106
|
+
## Action Required: Database Migration
|
|
107
|
+
|
|
108
|
+
The following command needs to be executed manually:
|
|
109
|
+
|
|
110
|
+
\`\`\`bash
|
|
111
|
+
npx prisma migrate dev --name add_user_table
|
|
112
|
+
\`\`\`
|
|
113
|
+
|
|
114
|
+
**Why manual execution is required:**
|
|
115
|
+
- Database operations can be destructive
|
|
116
|
+
- User should verify the migration before applying
|
|
117
|
+
- Prevents accidental data loss
|
|
118
|
+
|
|
119
|
+
Please run this command and let me know when it's complete.
|
|
120
|
+
```
|
|
121
|
+
|
|
122
|
+
**Safe commands (can be executed directly):**
|
|
123
|
+
- `prisma generate` - Only generates client, no DB changes
|
|
124
|
+
- `prisma format` - Only formats schema file
|
|
125
|
+
- Reading schema files
|
|
126
|
+
|
|
127
|
+
---
|
|
128
|
+
|
|
129
|
+
## CRITICAL RULE: Build Verification ONLY at the End
|
|
130
|
+
|
|
131
|
+
**DO NOT run `npm run build` after each phase or group.**
|
|
132
|
+
|
|
133
|
+
**`npm run build` and `npm run test` MUST ONLY be executed at the very end, after ALL phases (including Tests) are complete.**
|
|
134
|
+
|
|
135
|
+
---
|
|
136
|
+
|
|
137
|
+
## Instructions
|
|
138
|
+
|
|
139
|
+
### Step 1: Validate Inputs
|
|
140
|
+
|
|
141
|
+
| Input | Required | Description |
|
|
142
|
+
| ----------- | -------- | ---------------------------------- |
|
|
143
|
+
| `plan_file` | Yes | Path to plan file in `flow/plans/` |
|
|
144
|
+
|
|
145
|
+
If no plan is specified, list available plans in `flow/plans/` and ask user to select one.
|
|
146
|
+
|
|
147
|
+
**Important**: NEVER read or reference files in `flow/archive/` - these are outdated plans.
|
|
148
|
+
|
|
149
|
+
---
|
|
150
|
+
|
|
151
|
+
### Step 2: Validate Plan File
|
|
152
|
+
|
|
153
|
+
1. Read the specified plan file
|
|
154
|
+
2. Verify it contains phases with complexity scores
|
|
155
|
+
3. If complexity scores are missing, prompt user to add them
|
|
156
|
+
|
|
157
|
+
---
|
|
158
|
+
|
|
159
|
+
### Step 3: Invoke Execute Plan Skill
|
|
160
|
+
|
|
161
|
+
The skill will:
|
|
162
|
+
|
|
163
|
+
1. Parse the plan and extract phases
|
|
164
|
+
2. Analyze complexity and determine execution strategy
|
|
165
|
+
3. Present execution plan summary
|
|
166
|
+
4. For each phase:
|
|
167
|
+
- Auto-switch to Plan mode
|
|
168
|
+
- Present phase details
|
|
169
|
+
- Get user approval
|
|
170
|
+
- Implement the phase
|
|
171
|
+
- Update progress
|
|
172
|
+
5. Run final build and test verification
|
|
173
|
+
6. Present completion summary
|
|
174
|
+
|
|
175
|
+
See: `.claude/rules/skills/execute-plan-skill.md`
|
|
176
|
+
|
|
177
|
+
---
|
|
178
|
+
|
|
179
|
+
### Step 4: Handle Completion
|
|
180
|
+
|
|
181
|
+
After the skill completes:
|
|
182
|
+
|
|
183
|
+
1. Present summary of all changes made
|
|
184
|
+
2. Confirm all tests pass
|
|
185
|
+
3. Ask if the plan should be archived:
|
|
186
|
+
|
|
187
|
+
```markdown
|
|
188
|
+
Execution Complete!
|
|
189
|
+
|
|
190
|
+
**Summary**:
|
|
191
|
+
- X phases completed
|
|
192
|
+
- All tests passing
|
|
193
|
+
- Build successful
|
|
194
|
+
|
|
195
|
+
**Archive the plan?**
|
|
196
|
+
This will move the plan to `flow/archive/`:
|
|
197
|
+
```bash
|
|
198
|
+
mv flow/plans/plan_<feature>_v1.md flow/archive/
|
|
199
|
+
```
|
|
200
|
+
|
|
201
|
+
Would you like to archive this plan?
|
|
202
|
+
```
|
|
203
|
+
|
|
204
|
+
---
|
|
205
|
+
|
|
206
|
+
## Flow Diagram
|
|
207
|
+
|
|
208
|
+
```
|
|
209
|
+
+------------------------------------------+
|
|
210
|
+
| /execute-plan COMMAND |
|
|
211
|
+
+------------------------------------------+
|
|
212
|
+
|
|
|
213
|
+
v
|
|
214
|
+
+------------------------------------------+
|
|
215
|
+
| Step 1: Validate Inputs |
|
|
216
|
+
| - Check for plan file |
|
|
217
|
+
| - List available plans if needed |
|
|
218
|
+
+------------------------------------------+
|
|
219
|
+
|
|
|
220
|
+
v
|
|
221
|
+
+------------------------------------------+
|
|
222
|
+
| Step 2: Validate Plan File |
|
|
223
|
+
| - Verify phases have complexity scores |
|
|
224
|
+
+------------------------------------------+
|
|
225
|
+
|
|
|
226
|
+
v
|
|
227
|
+
+------------------------------------------+
|
|
228
|
+
| Step 3: Invoke Execute Plan Skill |
|
|
229
|
+
| - Skill handles all execution logic |
|
|
230
|
+
| - See execute-plan-skill.md |
|
|
231
|
+
+------------------------------------------+
|
|
232
|
+
|
|
|
233
|
+
v
|
|
234
|
+
+------------------------------------------+
|
|
235
|
+
| Step 4: Handle Completion |
|
|
236
|
+
| - Present summary |
|
|
237
|
+
| - Offer to archive plan |
|
|
238
|
+
+------------------------------------------+
|
|
239
|
+
```
|
|
240
|
+
|
|
241
|
+
---
|
|
242
|
+
|
|
243
|
+
## Example Usage
|
|
244
|
+
|
|
245
|
+
**User**: `/execute-plan @flow/plans/plan_realtime_notifications_v1.md`
|
|
246
|
+
|
|
247
|
+
**Execution**:
|
|
248
|
+
|
|
249
|
+
1. Validate input: plan file provided
|
|
250
|
+
2. Verify plan has complexity scores
|
|
251
|
+
3. Invoke execute-plan skill
|
|
252
|
+
4. Skill executes all phases with Plan mode
|
|
253
|
+
5. Final build and test verification
|
|
254
|
+
6. Present summary and archive prompt
|
|
255
|
+
|
|
256
|
+
---
|
|
257
|
+
|
|
258
|
+
## Context Optimization
|
|
259
|
+
|
|
260
|
+
This command uses hierarchical context loading to reduce context consumption. Instead of loading full files, load indexes first and expand specific sections on-demand.
|
|
261
|
+
|
|
262
|
+
### Recommended Loading Order
|
|
263
|
+
|
|
264
|
+
1. **Always load first**: This command file (`commands/execute-plan.md`)
|
|
265
|
+
2. **Load indexes**: Load `_index.md` files for relevant folders
|
|
266
|
+
3. **Expand on-demand**: Use reference codes to load specific sections when needed
|
|
267
|
+
|
|
268
|
+
### Index Files for Plan Execution
|
|
269
|
+
|
|
270
|
+
| Index | When to Load |
|
|
271
|
+
|-------|--------------|
|
|
272
|
+
| `rules/skills/_index.md` | To understand execution workflow |
|
|
273
|
+
| `rules/core/_index.md` | For complexity scoring reference |
|
|
274
|
+
| `rules/tools/_index.md` | When switching to Plan mode |
|
|
275
|
+
|
|
276
|
+
### Reference Codes for Plan Execution
|
|
277
|
+
|
|
278
|
+
| Code | Description | When to Expand |
|
|
279
|
+
|------|-------------|----------------|
|
|
280
|
+
| SKL-EXEC-1 | Execution workflow | Understanding full process |
|
|
281
|
+
| SKL-EXEC-2 | Complexity-based grouping | Determining execution strategy |
|
|
282
|
+
| COR-CS-1 | Complexity scoring table | Interpreting phase complexity |
|
|
283
|
+
| TLS-PLN-1 | Plan mode switching | Before each phase |
|
|
284
|
+
| TLS-PLN-2 | Plan mode workflow | Presenting phase details |
|
|
285
|
+
|
|
286
|
+
### Expansion Instructions
|
|
287
|
+
|
|
288
|
+
When executing this command:
|
|
289
|
+
|
|
290
|
+
1. **Start with indexes**: Read `rules/skills/_index.md` and `rules/core/_index.md`
|
|
291
|
+
2. **Identify needed codes**: Based on current phase, identify which codes are relevant
|
|
292
|
+
3. **Expand as needed**: Use the Read tool with specific line ranges from the index
|
|
293
|
+
4. **Don't expand everything**: Only load content required for the current phase
|
|
294
|
+
|
|
295
|
+
---
|
|
296
|
+
|
|
297
|
+
## Related Resources
|
|
298
|
+
|
|
299
|
+
| Resource | Purpose |
|
|
300
|
+
| -------------------------- | --------------------------------- |
|
|
301
|
+
| `rules/skills/_index.md` | Index of skills with reference codes |
|
|
302
|
+
| `rules/core/_index.md` | Index of core rules with reference codes |
|
|
303
|
+
| `rules/tools/_index.md` | Index of tools with reference codes |
|
|
304
|
+
| `execute-plan-skill.md` | Skill that executes the plan |
|
|
305
|
+
| `plans-patterns.md` | Rules and patterns for plans |
|
|
306
|
+
| `complexity-scoring.md` | Complexity scoring system |
|
|
307
|
+
| `plan-mode-tool.md` | Plan mode switching instructions |
|
|
308
|
+
| `/create-plan` command | Create a plan first |
|
|
309
|
+
| `/discovery-plan` command | Run discovery before planning |
|
|
310
|
+
|
|
311
|
+
---
|
|
312
|
+
|
|
313
|
+
# Implementation Details
|
|
314
|
+
|
|
315
|
+
|
|
316
|
+
## CRITICAL RULE: Build Verification ONLY at the End
|
|
317
|
+
|
|
318
|
+
**DO NOT run `npm run build` after each phase or group.**
|
|
319
|
+
|
|
320
|
+
**`npm run build` and `npm run test` MUST ONLY be executed at the very end, after ALL phases (including Tests) are complete.**
|
|
321
|
+
|
|
322
|
+
**Why**:
|
|
323
|
+
|
|
324
|
+
- Running build after each phase wastes time and breaks flow
|
|
325
|
+
- Intermediate phases may have temporary type errors that get resolved in later phases
|
|
326
|
+
- The final build verification ensures everything works together
|
|
327
|
+
|
|
328
|
+
**The ONLY time to run build/test**:
|
|
329
|
+
|
|
330
|
+
- After ALL phases are complete → `npm run build && npm run test`
|
|
331
|
+
|
|
332
|
+
---
|
|
333
|
+
|
|
334
|
+
## CRITICAL RULE: No Direct Database or ORM Commands
|
|
335
|
+
|
|
336
|
+
**NEVER execute any ORM or database commands directly. ALWAYS ask the user to run them manually.**
|
|
337
|
+
|
|
338
|
+
### Forbidden Commands (NEVER execute directly)
|
|
339
|
+
|
|
340
|
+
| Category | Commands |
|
|
341
|
+
| --------------- | ----------------------------------------------------- |
|
|
342
|
+
| **Prisma** | `prisma migrate`, `prisma db push`, `prisma db seed` |
|
|
343
|
+
| **Django** | `python manage.py migrate`, `python manage.py dbshell`|
|
|
344
|
+
| **Alembic** | `alembic upgrade`, `alembic downgrade` |
|
|
345
|
+
| **Sequelize** | `sequelize db:migrate`, `sequelize db:seed` |
|
|
346
|
+
| **TypeORM** | `typeorm migration:run`, `typeorm migration:revert` |
|
|
347
|
+
| **Drizzle** | `drizzle-kit push`, `drizzle-kit drop` |
|
|
348
|
+
| **Raw SQL** | Any direct SQL execution, psql, mysql, sqlite3 |
|
|
349
|
+
| **Connections** | Any database connection or query commands |
|
|
350
|
+
|
|
351
|
+
### When Database Commands Are Needed
|
|
352
|
+
|
|
353
|
+
**ALWAYS present the command to the user and wait for confirmation:**
|
|
354
|
+
|
|
355
|
+
```markdown
|
|
356
|
+
## Action Required: Database Migration
|
|
357
|
+
|
|
358
|
+
The following command needs to be executed manually:
|
|
359
|
+
|
|
360
|
+
\`\`\`bash
|
|
361
|
+
[command here]
|
|
362
|
+
\`\`\`
|
|
363
|
+
|
|
364
|
+
**Why manual execution is required:**
|
|
365
|
+
- Database operations can be destructive and irreversible
|
|
366
|
+
- User should review the migration before applying
|
|
367
|
+
- Prevents accidental data loss in development/production
|
|
368
|
+
|
|
369
|
+
Please run this command and let me know when it's complete, or if you encounter any issues.
|
|
370
|
+
```
|
|
371
|
+
|
|
372
|
+
### Safe Commands (CAN be executed directly)
|
|
373
|
+
|
|
374
|
+
| Command | Why It's Safe |
|
|
375
|
+
| --------------------- | ------------------------------------------ |
|
|
376
|
+
| `prisma generate` | Only generates client code, no DB changes |
|
|
377
|
+
| `prisma format` | Only formats schema file |
|
|
378
|
+
| `prisma validate` | Only validates schema |
|
|
379
|
+
| Reading schema files | Read-only operation |
|
|
380
|
+
|
|
381
|
+
### Why This Rule Exists
|
|
382
|
+
|
|
383
|
+
1. **Data Safety**: Database migrations can delete or modify data
|
|
384
|
+
2. **Reversibility**: Some operations cannot be undone
|
|
385
|
+
3. **Environment Awareness**: User knows if this is dev/staging/prod
|
|
386
|
+
4. **Verification**: User can review the migration before applying
|
|
387
|
+
5. **Error Handling**: User can handle errors appropriately
|
|
388
|
+
|
|
389
|
+
---
|
|
390
|
+
|
|
391
|
+
## Inputs
|
|
392
|
+
|
|
393
|
+
| Input | Required | Description |
|
|
394
|
+
| ----------- | -------- | ------------------------------------ |
|
|
395
|
+
| `plan_file` | Yes | Path to plan file in `flow/plans/` |
|
|
396
|
+
|
|
397
|
+
---
|
|
398
|
+
|
|
399
|
+
## Workflow
|
|
400
|
+
|
|
401
|
+
### Step 1: Parse the Plan
|
|
402
|
+
|
|
403
|
+
1. Read the specified plan file
|
|
404
|
+
2. Parse all phases with their complexity scores and tasks
|
|
405
|
+
3. Validate that all phases have complexity scores
|
|
406
|
+
|
|
407
|
+
**Important**: NEVER read or reference files in `flow/archive/` - these are outdated plans.
|
|
408
|
+
|
|
409
|
+
---
|
|
410
|
+
|
|
411
|
+
### Step 2: Analyze Complexity and Determine Execution Strategy
|
|
412
|
+
|
|
413
|
+
Parse each phase and calculate execution groups based on complexity scores:
|
|
414
|
+
|
|
415
|
+
**Execution Strategy Rules**:
|
|
416
|
+
|
|
417
|
+
| Total Adjacent Score | Execution Strategy |
|
|
418
|
+
| -------------------- | ----------------------------------------------------------- |
|
|
419
|
+
| ≤ 6 | **Aggregate**: Execute multiple phases together in one pass |
|
|
420
|
+
| 7-10 | **Cautious**: Execute 1-2 phases, then continue |
|
|
421
|
+
| > 10 | **Sequential**: Execute one phase at a time |
|
|
422
|
+
|
|
423
|
+
**Aggregation Rules**:
|
|
424
|
+
|
|
425
|
+
1. **Can aggregate** phases when their combined complexity ≤ 6
|
|
426
|
+
2. **Never aggregate** across a phase with complexity ≥ 8
|
|
427
|
+
3. **Always execute separately**: Tests phase (regardless of score)
|
|
428
|
+
4. **Prefer aggregation** for trivial consecutive phases (0-2 each)
|
|
429
|
+
|
|
430
|
+
**Example Analysis**:
|
|
431
|
+
|
|
432
|
+
```
|
|
433
|
+
Phase 1: Types and Schemas - Complexity: 3/10
|
|
434
|
+
Phase 2: Utility Functions - Complexity: 2/10
|
|
435
|
+
Phase 3: API Route - Complexity: 7/10
|
|
436
|
+
Phase 4: UI Components - Complexity: 6/10
|
|
437
|
+
Phase 5: Integration - Complexity: 4/10
|
|
438
|
+
Phase 6: Tests - Complexity: 5/10
|
|
439
|
+
|
|
440
|
+
Execution Groups:
|
|
441
|
+
|
|
442
|
+
- Group 1: Phase 1 + Phase 2 (combined: 5) → Aggregate
|
|
443
|
+
- Group 2: Phase 3 (7) → Execute alone
|
|
444
|
+
- Group 3: Phase 4 + Phase 5 (combined: 10) → Execute together
|
|
445
|
+
- Group 4: Phase 6 (Tests) → Always separate
|
|
446
|
+
```
|
|
447
|
+
|
|
448
|
+
---
|
|
449
|
+
|
|
450
|
+
### Step 3: Present Execution Plan Summary
|
|
451
|
+
|
|
452
|
+
Before starting, present the execution plan to the user:
|
|
453
|
+
|
|
454
|
+
```markdown
|
|
455
|
+
## Execution Plan Summary
|
|
456
|
+
|
|
457
|
+
**Plan**: [Plan Name]
|
|
458
|
+
**Total Phases**: X
|
|
459
|
+
**Total Complexity**: XX/XX
|
|
460
|
+
|
|
461
|
+
### Execution Groups:
|
|
462
|
+
|
|
463
|
+
| Group | Phases | Combined Complexity | Strategy |
|
|
464
|
+
| ----- | ---------------- | ------------------- | ---------- |
|
|
465
|
+
| 1 | Phase 1, Phase 2 | 5/10 | Aggregate |
|
|
466
|
+
| 2 | Phase 3 | 7/10 | Sequential |
|
|
467
|
+
| 3 | Phase 4, Phase 5 | 10/10 | Cautious |
|
|
468
|
+
| 4 | Phase 6 (Tests) | 5/10 | Sequential |
|
|
469
|
+
|
|
470
|
+
**Build Verification**: Only at the end, after ALL phases complete
|
|
471
|
+
|
|
472
|
+
Ready to begin execution?
|
|
473
|
+
```
|
|
474
|
+
|
|
475
|
+
Wait for user confirmation before proceeding.
|
|
476
|
+
|
|
477
|
+
---
|
|
478
|
+
|
|
479
|
+
### Step 4: Execute Each Phase with Plan Mode
|
|
480
|
+
|
|
481
|
+
**CRITICAL RULE**: Use the [Plan Mode Tool](../tools/plan-mode-tool.md) to switch to Plan mode for **EACH individual phase**.
|
|
482
|
+
|
|
483
|
+
**REMINDER**: Do NOT run `npm run build` between phases.
|
|
484
|
+
|
|
485
|
+
**For Each Phase**:
|
|
486
|
+
|
|
487
|
+
1. **Auto-switch to Plan mode** - Call `SwitchMode` tool
|
|
488
|
+
2. **Present phase details** - Show scope, tasks, and approach
|
|
489
|
+
3. **Wait for approval** - Get user confirmation
|
|
490
|
+
4. **Implement** - Execute the phase following approved approach
|
|
491
|
+
5. **Update progress** - Mark tasks complete in plan file
|
|
492
|
+
6. **Continue to next phase** - NO BUILD between phases
|
|
493
|
+
|
|
494
|
+
**Phase Presentation Template**:
|
|
495
|
+
|
|
496
|
+
```markdown
|
|
497
|
+
## Phase Execution: Phase X - [Phase Name]
|
|
498
|
+
|
|
499
|
+
**Complexity**: X/10
|
|
500
|
+
**Scope**: [Phase scope description]
|
|
501
|
+
|
|
502
|
+
### Tasks to Complete:
|
|
503
|
+
- [ ] Task 1
|
|
504
|
+
- [ ] Task 2
|
|
505
|
+
- [ ] Task 3
|
|
506
|
+
|
|
507
|
+
### Implementation Approach:
|
|
508
|
+
[Discuss the approach, patterns to follow, and any decisions needed]
|
|
509
|
+
|
|
510
|
+
### Cursor Rules Checklist:
|
|
511
|
+
- [ ] Following allowed patterns
|
|
512
|
+
- [ ] Avoiding forbidden patterns
|
|
513
|
+
- [ ] Using appropriate language patterns
|
|
514
|
+
|
|
515
|
+
---
|
|
516
|
+
|
|
517
|
+
**Ready to implement this phase?**
|
|
518
|
+
```
|
|
519
|
+
|
|
520
|
+
---
|
|
521
|
+
|
|
522
|
+
### Step 5: Update Progress After Each Phase
|
|
523
|
+
|
|
524
|
+
Mark completed tasks in the plan file:
|
|
525
|
+
|
|
526
|
+
```markdown
|
|
527
|
+
- [x] Task 1
|
|
528
|
+
- [x] Task 2
|
|
529
|
+
```
|
|
530
|
+
|
|
531
|
+
Then continue to the next phase (NO BUILD HERE).
|
|
532
|
+
|
|
533
|
+
---
|
|
534
|
+
|
|
535
|
+
### Step 6: Handle Tests Phase
|
|
536
|
+
|
|
537
|
+
The Tests phase is **always executed separately**, regardless of complexity score:
|
|
538
|
+
|
|
539
|
+
1. Switch to Plan mode
|
|
540
|
+
2. Present the testing strategy
|
|
541
|
+
3. Discuss test coverage and edge cases
|
|
542
|
+
4. Get user approval
|
|
543
|
+
5. Implement tests
|
|
544
|
+
6. **DO NOT run tests yet** - Continue to Step 7
|
|
545
|
+
|
|
546
|
+
---
|
|
547
|
+
|
|
548
|
+
### Step 7: Completion - Build and Test Verification
|
|
549
|
+
|
|
550
|
+
**This is the ONLY place where build and tests are run.**
|
|
551
|
+
|
|
552
|
+
After ALL phases are complete (including Tests phase):
|
|
553
|
+
|
|
554
|
+
1. **Run final verification**:
|
|
555
|
+
|
|
556
|
+
```bash
|
|
557
|
+
npm run build && npm run test
|
|
558
|
+
```
|
|
559
|
+
|
|
560
|
+
2. **Handle failures**:
|
|
561
|
+
- If build fails: Fix the issue, re-run verification
|
|
562
|
+
- If tests fail: Fix the issue, re-run verification
|
|
563
|
+
- Only proceed after everything passes
|
|
564
|
+
|
|
565
|
+
3. **Present summary** of completed work
|
|
566
|
+
|
|
567
|
+
4. **List all key changes** made
|
|
568
|
+
|
|
569
|
+
5. **Ask if the plan should be archived**:
|
|
570
|
+
|
|
571
|
+
```bash
|
|
572
|
+
mv flow/plans/plan_feature_name_v1.md flow/archive/
|
|
573
|
+
```
|
|
574
|
+
|
|
575
|
+
---
|
|
576
|
+
|
|
577
|
+
## Execution Flow Within a Group
|
|
578
|
+
|
|
579
|
+
```
|
|
580
|
+
Group 1: Phase 1 + Phase 2 (combined complexity: 5)
|
|
581
|
+
│
|
|
582
|
+
├── AUTO-SWITCH to Plan Mode for Phase 1
|
|
583
|
+
├── Present Phase 1 details
|
|
584
|
+
├── Get user approval
|
|
585
|
+
├── Implement Phase 1
|
|
586
|
+
├── Update Phase 1 progress in plan file
|
|
587
|
+
│
|
|
588
|
+
├── AUTO-SWITCH to Plan Mode for Phase 2
|
|
589
|
+
├── Present Phase 2 details
|
|
590
|
+
├── Get user approval
|
|
591
|
+
├── Implement Phase 2
|
|
592
|
+
├── Update Phase 2 progress in plan file
|
|
593
|
+
│
|
|
594
|
+
└── Continue to next group (NO BUILD HERE)
|
|
595
|
+
```
|
|
596
|
+
|
|
597
|
+
---
|
|
598
|
+
|
|
599
|
+
## Complexity-Based Behavior
|
|
600
|
+
|
|
601
|
+
### Low Complexity Phases (0-4)
|
|
602
|
+
|
|
603
|
+
- Can be grouped with adjacent low-complexity phases
|
|
604
|
+
- Still requires Plan mode for each individual phase
|
|
605
|
+
- Quick planning discussion
|
|
606
|
+
- Focus on consistency with existing patterns
|
|
607
|
+
|
|
608
|
+
### Medium Complexity Phases (5-6)
|
|
609
|
+
|
|
610
|
+
- May be grouped if combined score ≤ 6
|
|
611
|
+
- Moderate planning discussion
|
|
612
|
+
- Review key decisions and patterns
|
|
613
|
+
|
|
614
|
+
### High Complexity Phases (7-8)
|
|
615
|
+
|
|
616
|
+
- Execute alone or with one adjacent phase if combined ≤ 10
|
|
617
|
+
- Detailed planning discussion
|
|
618
|
+
- Consider multiple approaches
|
|
619
|
+
|
|
620
|
+
### Very High Complexity Phases (9-10)
|
|
621
|
+
|
|
622
|
+
- **Always execute alone**
|
|
623
|
+
- Extensive planning discussion
|
|
624
|
+
- Break down into sub-tasks if needed
|
|
625
|
+
- Consider spikes or prototypes first
|
|
626
|
+
|
|
627
|
+
---
|
|
628
|
+
|
|
629
|
+
## Error Handling
|
|
630
|
+
|
|
631
|
+
### Build Failures (at Completion)
|
|
632
|
+
|
|
633
|
+
If `npm run build` fails at Step 7:
|
|
634
|
+
|
|
635
|
+
1. Analyze the error
|
|
636
|
+
2. Determine which phase introduced the issue
|
|
637
|
+
3. Fix the issue
|
|
638
|
+
4. Re-run build verification
|
|
639
|
+
5. Only complete after successful build
|
|
640
|
+
|
|
641
|
+
### Test Failures (at Completion)
|
|
642
|
+
|
|
643
|
+
If `npm run test` fails at Step 7:
|
|
644
|
+
|
|
645
|
+
1. Analyze failing tests
|
|
646
|
+
2. Determine if it's a test issue or implementation bug
|
|
647
|
+
3. Fix the issue
|
|
648
|
+
4. Re-run tests
|
|
649
|
+
5. Only complete after all tests pass
|
|
650
|
+
|
|
651
|
+
### User Cancellation
|
|
652
|
+
|
|
653
|
+
If the user wants to stop execution:
|
|
654
|
+
|
|
655
|
+
1. Save current progress in the plan file
|
|
656
|
+
2. Note which phases are complete
|
|
657
|
+
3. The plan can be resumed later from the last completed phase
|
|
658
|
+
4. When resuming, run build verification first
|
|
659
|
+
|
|
660
|
+
---
|
|
661
|
+
|
|
662
|
+
## Summary of Key Rules
|
|
663
|
+
|
|
664
|
+
| Rule | Description |
|
|
665
|
+
| ---------------------------- | ----------------------------------------------------------- |
|
|
666
|
+
| **Auto-switch to Plan mode** | Switch immediately for each phase, no asking |
|
|
667
|
+
| **Build ONLY at end** | `npm run build && npm run test` runs once, after ALL phases |
|
|
668
|
+
| **No intermediate builds** | Never run build between phases or groups |
|
|
669
|
+
| **Tests phase separate** | Always execute Tests phase individually |
|
|
670
|
+
| **Update progress** | Mark tasks complete in plan file after each phase |
|
|
671
|
+
|
|
672
|
+
---
|
|
673
|
+
|
|
674
|
+
## Related Files
|
|
675
|
+
|
|
676
|
+
| File | Purpose |
|
|
677
|
+
| ------------------------------------------- | -------------------------------- |
|
|
678
|
+
| `.claude/rules/patterns/plans-patterns.md` | Plan patterns and rules |
|
|
679
|
+
| `.claude/rules/core/complexity-scoring.md` | Complexity scoring system |
|
|
680
|
+
| `.claude/rules/tools/plan-mode-tool.md` | Plan mode switching instructions |
|
|
681
|
+
| `flow/plans/` | Input plan documents |
|
|
682
|
+
| `flow/archive/` | Completed plans destination |
|