aiblueprint-cli 1.4.41 → 1.4.42

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.
Files changed (81) hide show
  1. package/claude-code-config/skills/apex/SKILL.md +116 -0
  2. package/claude-code-config/skills/{workflow-apex → apex}/scripts/setup-templates.sh +12 -2
  3. package/claude-code-config/skills/{workflow-apex → apex}/steps/step-00-init.md +19 -34
  4. package/claude-code-config/skills/{workflow-apex → apex}/steps/step-00b-interactive.md +13 -1
  5. package/claude-code-config/skills/apex/steps/step-00b-save.md +123 -0
  6. package/claude-code-config/skills/{workflow-apex → apex}/steps/step-01-analyze.md +36 -17
  7. package/claude-code-config/skills/apex/steps/step-02-plan.md +593 -0
  8. package/claude-code-config/skills/apex/steps/step-02b-tasks.md +301 -0
  9. package/claude-code-config/skills/apex/steps/step-03-execute-teams.md +296 -0
  10. package/claude-code-config/skills/{workflow-apex → apex}/steps/step-03-execute.md +1 -0
  11. package/claude-code-config/skills/{workflow-apex → apex}/steps/step-04-validate.md +3 -1
  12. package/claude-code-config/skills/{workflow-apex → apex}/steps/step-05-examine.md +92 -35
  13. package/claude-code-config/skills/{workflow-apex → apex}/steps/step-06-resolve.md +1 -0
  14. package/claude-code-config/skills/{workflow-apex → apex}/steps/step-09-finish.md +32 -2
  15. package/claude-code-config/skills/{workflow-apex → apex}/templates/00-context.md +2 -0
  16. package/claude-code-config/skills/{meta-claude-memory → claude-memory}/SKILL.md +59 -1
  17. package/package.json +1 -1
  18. package/claude-code-config/skills/workflow-apex/SKILL.md +0 -303
  19. package/claude-code-config/skills/workflow-apex/steps/step-02-plan.md +0 -264
  20. /package/claude-code-config/skills/{workflow-apex → apex}/scripts/update-progress.sh +0 -0
  21. /package/claude-code-config/skills/{workflow-apex → apex}/steps/step-00b-branch.md +0 -0
  22. /package/claude-code-config/skills/{workflow-apex → apex}/steps/step-00b-economy.md +0 -0
  23. /package/claude-code-config/skills/{workflow-apex → apex}/steps/step-07-tests.md +0 -0
  24. /package/claude-code-config/skills/{workflow-apex → apex}/steps/step-08-run-tests.md +0 -0
  25. /package/claude-code-config/skills/{workflow-apex → apex}/templates/01-analyze.md +0 -0
  26. /package/claude-code-config/skills/{workflow-apex → apex}/templates/02-plan.md +0 -0
  27. /package/claude-code-config/skills/{workflow-apex → apex}/templates/03-execute.md +0 -0
  28. /package/claude-code-config/skills/{workflow-apex → apex}/templates/04-validate.md +0 -0
  29. /package/claude-code-config/skills/{workflow-apex → apex}/templates/05-examine.md +0 -0
  30. /package/claude-code-config/skills/{workflow-apex → apex}/templates/06-resolve.md +0 -0
  31. /package/claude-code-config/skills/{workflow-apex → apex}/templates/07-tests.md +0 -0
  32. /package/claude-code-config/skills/{workflow-apex → apex}/templates/08-run-tests.md +0 -0
  33. /package/claude-code-config/skills/{workflow-apex → apex}/templates/09-finish.md +0 -0
  34. /package/claude-code-config/skills/{workflow-apex → apex}/templates/README.md +0 -0
  35. /package/claude-code-config/skills/{workflow-apex → apex}/templates/step-complete.md +0 -0
  36. /package/claude-code-config/skills/{meta-claude-memory → claude-memory}/references/comprehensive-example.md +0 -0
  37. /package/claude-code-config/skills/{meta-claude-memory → claude-memory}/references/optimize-guide.md +0 -0
  38. /package/claude-code-config/skills/{meta-claude-memory → claude-memory}/references/project-patterns.md +0 -0
  39. /package/claude-code-config/skills/{meta-claude-memory → claude-memory}/references/prompting-techniques.md +0 -0
  40. /package/claude-code-config/skills/{meta-claude-memory → claude-memory}/references/rules-directory-guide.md +0 -0
  41. /package/claude-code-config/skills/{meta-claude-memory → claude-memory}/references/section-templates.md +0 -0
  42. /package/claude-code-config/skills/{git-commit → commit}/SKILL.md +0 -0
  43. /package/claude-code-config/skills/{git-create-pr → create-pr}/SKILL.md +0 -0
  44. /package/claude-code-config/skills/{utils-fix-errors → fix-errors}/SKILL.md +0 -0
  45. /package/claude-code-config/skills/{utils-fix-grammar → fix-grammar}/SKILL.md +0 -0
  46. /package/claude-code-config/skills/{git-fix-pr-comments → fix-pr-comments}/SKILL.md +0 -0
  47. /package/claude-code-config/skills/{git-merge → merge}/SKILL.md +0 -0
  48. /package/claude-code-config/skills/{utils-oneshot → oneshot}/SKILL.md +0 -0
  49. /package/claude-code-config/skills/{meta-prompt-creator → prompt-creator}/SKILL.md +0 -0
  50. /package/claude-code-config/skills/{meta-prompt-creator → prompt-creator}/references/anthropic-best-practices.md +0 -0
  51. /package/claude-code-config/skills/{meta-prompt-creator → prompt-creator}/references/anti-patterns.md +0 -0
  52. /package/claude-code-config/skills/{meta-prompt-creator → prompt-creator}/references/clarity-principles.md +0 -0
  53. /package/claude-code-config/skills/{meta-prompt-creator → prompt-creator}/references/context-management.md +0 -0
  54. /package/claude-code-config/skills/{meta-prompt-creator → prompt-creator}/references/few-shot-patterns.md +0 -0
  55. /package/claude-code-config/skills/{meta-prompt-creator → prompt-creator}/references/openai-best-practices.md +0 -0
  56. /package/claude-code-config/skills/{meta-prompt-creator → prompt-creator}/references/prompt-templates.md +0 -0
  57. /package/claude-code-config/skills/{meta-prompt-creator → prompt-creator}/references/reasoning-techniques.md +0 -0
  58. /package/claude-code-config/skills/{meta-prompt-creator → prompt-creator}/references/system-prompt-patterns.md +0 -0
  59. /package/claude-code-config/skills/{meta-prompt-creator → prompt-creator}/references/xml-structure.md +0 -0
  60. /package/claude-code-config/skills/{meta-skill-creator → skill-creator}/LICENSE.txt +0 -0
  61. /package/claude-code-config/skills/{meta-skill-creator → skill-creator}/SKILL.md +0 -0
  62. /package/claude-code-config/skills/{meta-skill-creator → skill-creator}/package.json +0 -0
  63. /package/claude-code-config/skills/{meta-skill-creator → skill-creator}/references/output-patterns.md +0 -0
  64. /package/claude-code-config/skills/{meta-skill-creator → skill-creator}/references/progressive-disclosure-patterns.md +0 -0
  65. /package/claude-code-config/skills/{meta-skill-creator → skill-creator}/references/prompting-integration.md +0 -0
  66. /package/claude-code-config/skills/{meta-skill-creator → skill-creator}/references/real-world-examples.md +0 -0
  67. /package/claude-code-config/skills/{meta-skill-creator → skill-creator}/references/script-patterns.md +0 -0
  68. /package/claude-code-config/skills/{meta-skill-creator → skill-creator}/references/workflows.md +0 -0
  69. /package/claude-code-config/skills/{meta-skill-creator → skill-creator}/references/xml-tag-guide.md +0 -0
  70. /package/claude-code-config/skills/{meta-skill-creator → skill-creator}/scripts/init-skill.ts +0 -0
  71. /package/claude-code-config/skills/{meta-skill-creator → skill-creator}/scripts/package-skill.ts +0 -0
  72. /package/claude-code-config/skills/{meta-skill-creator → skill-creator}/scripts/validate.ts +0 -0
  73. /package/claude-code-config/skills/{meta-subagent-creator → subagent-creator}/SKILL.md +0 -0
  74. /package/claude-code-config/skills/{meta-subagent-creator → subagent-creator}/references/context-management.md +0 -0
  75. /package/claude-code-config/skills/{meta-subagent-creator → subagent-creator}/references/debugging-agents.md +0 -0
  76. /package/claude-code-config/skills/{meta-subagent-creator → subagent-creator}/references/error-handling-and-recovery.md +0 -0
  77. /package/claude-code-config/skills/{meta-subagent-creator → subagent-creator}/references/evaluation-and-testing.md +0 -0
  78. /package/claude-code-config/skills/{meta-subagent-creator → subagent-creator}/references/orchestration-patterns.md +0 -0
  79. /package/claude-code-config/skills/{meta-subagent-creator → subagent-creator}/references/subagents.md +0 -0
  80. /package/claude-code-config/skills/{meta-subagent-creator → subagent-creator}/references/writing-subagent-prompts.md +0 -0
  81. /package/claude-code-config/skills/{utils-ultrathink → ultrathink}/SKILL.md +0 -0
@@ -0,0 +1,593 @@
1
+ ---
2
+ name: step-02-plan
3
+ description: Strategic planning - create detailed file-by-file implementation strategy
4
+ prev_step: steps/step-01-analyze.md
5
+ next_step: steps/step-03-execute.md
6
+ ---
7
+
8
+ # Step 2: Plan (Strategic Design)
9
+
10
+ ## MANDATORY EXECUTION RULES (READ FIRST):
11
+
12
+ - 🛑 NEVER start implementing - that's step 3
13
+ - 🛑 NEVER write or modify code in this step
14
+ - 🛑 NEVER mark plan as "complete" BEFORE writing plan to `{output_dir}/02-plan.md` (if save_mode)
15
+ - ✅ ALWAYS structure plan by FILE, not by feature
16
+ - ✅ ALWAYS include specific line numbers from analysis
17
+ - ✅ ALWAYS map acceptance criteria to file changes
18
+ - ✅ ALWAYS create a TaskList using TaskCreate tool to track all planned file changes
19
+ - ✅ IF save_mode: ALWAYS use Edit tool to write the full plan to `{output_dir}/02-plan.md` BEFORE showing summary
20
+ - 📋 YOU ARE A PLANNER, not an implementer
21
+ - 💬 FOCUS on "What changes need to be made where?"
22
+ - 🚫 FORBIDDEN to use Edit/Write on source code files (only on output files if save_mode)
23
+
24
+ ## EXECUTION PROTOCOLS:
25
+
26
+ - 🎯 ULTRA THINK before creating the plan
27
+ - 💾 IF save_mode: Use Edit tool to write the full plan to `{output_dir}/02-plan.md` AFTER creating the plan and BEFORE presenting summary
28
+ - 📖 Reference patterns from step-01 analysis
29
+ - 🚫 FORBIDDEN to proceed until user approves plan (unless auto_mode)
30
+ - 🚫 FORBIDDEN to proceed to step-03 without saving plan first (if save_mode)
31
+
32
+ ## CONTEXT BOUNDARIES:
33
+
34
+ - Context from step-01 (files, patterns, utilities) is available
35
+ - Implementation has NOT started
36
+ - User has NOT approved any changes yet
37
+ - Plan must be complete before execution
38
+
39
+ ## YOUR TASK:
40
+
41
+ Transform analysis findings into a comprehensive, executable, file-by-file implementation plan.
42
+
43
+ ---
44
+
45
+ <available_state>
46
+ From previous steps:
47
+
48
+ | Variable | Description |
49
+ |----------|-------------|
50
+ | `{task_description}` | What to implement |
51
+ | `{task_id}` | Kebab-case identifier |
52
+ | `{acceptance_criteria}` | Success criteria from step-01 |
53
+ | `{auto_mode}` | Skip confirmations |
54
+ | `{save_mode}` | Save outputs to files |
55
+ | `{output_dir}` | Path to output (if save_mode) |
56
+ | Files found | From step-01 codebase exploration |
57
+ | Patterns | From step-01 pattern analysis |
58
+ | Utilities | From step-01 utility discovery |
59
+ </available_state>
60
+
61
+ ---
62
+
63
+ ## EXECUTION SEQUENCE:
64
+
65
+ ### 1. Initialize Save Output (if save_mode)
66
+
67
+ **If `{save_mode}` = true:**
68
+
69
+ ```bash
70
+ bash {skill_dir}/scripts/update-progress.sh "{task_id}" "02" "plan" "in_progress"
71
+ ```
72
+
73
+ Append plan to `{output_dir}/02-plan.md` as you work.
74
+
75
+ ### 2. ULTRA THINK: Design Complete Strategy
76
+
77
+ **CRITICAL: Think through ENTIRE implementation before writing any plan.**
78
+
79
+ Mental simulation:
80
+ - Walk through the implementation step by step
81
+ - Identify all files that need changes
82
+ - Determine logical order (dependencies first)
83
+ - Consider edge cases and error handling
84
+ - Plan test coverage
85
+
86
+ ### 3. Clarify Ambiguities
87
+
88
+ **If `{auto_mode}` = true:**
89
+ → Use recommended option for any ambiguity, proceed automatically
90
+
91
+ **If `{auto_mode}` = false AND multiple valid approaches exist:**
92
+
93
+ ```yaml
94
+ questions:
95
+ - header: "Approach"
96
+ question: "Multiple approaches are possible. Which should we use?"
97
+ options:
98
+ - label: "Approach A (Recommended)"
99
+ description: "Description and tradeoffs of A"
100
+ - label: "Approach B"
101
+ description: "Description and tradeoffs of B"
102
+ - label: "Approach C"
103
+ description: "Description and tradeoffs of C"
104
+ multiSelect: false
105
+ ```
106
+
107
+ ### 4. Create Detailed Plan
108
+
109
+ **Structure by FILE, not by feature:**
110
+
111
+ ```markdown
112
+ ## Implementation Plan: {task_description}
113
+
114
+ ### Overview
115
+ [1-2 sentences: High-level strategy and approach]
116
+
117
+ ### Prerequisites
118
+ - [ ] Prerequisite 1 (if any)
119
+ - [ ] Prerequisite 2 (if any)
120
+
121
+ ---
122
+
123
+ ### File Changes
124
+
125
+ #### `src/path/file1.ts`
126
+ - Add `functionName` that handles X
127
+ - Extract logic from Y (follow pattern in `example.ts:45`)
128
+ - Handle error case: [specific scenario]
129
+ - Consider: [edge case or important context]
130
+
131
+ #### `src/path/file2.ts`
132
+ - Update imports to include new module
133
+ - Call `functionName` in existing flow at line ~42
134
+ - Update types: Add `NewType` interface
135
+
136
+ #### `src/path/file3.ts` (NEW FILE)
137
+ - Create utility for Z
138
+ - Export: `utilityFunction`, `HelperType`
139
+ - Pattern: Follow `similar-util.ts` structure
140
+
141
+ ---
142
+
143
+ ### Testing Strategy
144
+
145
+ **New tests:**
146
+ - `src/path/file1.test.ts` - Test functionName with:
147
+ - Happy path
148
+ - Error case
149
+ - Edge case
150
+
151
+ **Update existing:**
152
+ - `src/path/existing.test.ts` - Add test for new flow
153
+
154
+ ---
155
+
156
+ ### Acceptance Criteria Mapping
157
+ - [ ] AC1: Satisfied by changes in `file1.ts`
158
+ - [ ] AC2: Satisfied by changes in `file2.ts`
159
+
160
+ ---
161
+
162
+ ### Risks & Considerations
163
+ - Risk 1: [potential issue and mitigation]
164
+ ```
165
+
166
+ **IF `{save_mode}` = true (MANDATORY - DO THIS NOW):**
167
+
168
+ <critical>
169
+ Use the **Edit tool** to write the FULL plan to `{output_dir}/02-plan.md`. Replace the placeholder content with the complete plan including all file changes, testing strategy, acceptance criteria mapping, and risks.
170
+ </critical>
171
+
172
+ ### 5. Create Team (if teams_mode - BEFORE TaskList)
173
+
174
+ <critical>
175
+ If `{teams_mode}` = true, you MUST create the team BEFORE creating any tasks.
176
+ TeamCreate resets the task list — so the team must exist first, then tasks are added to it.
177
+ Do NOT spawn any agents yet — that happens in step-03-execute-teams.
178
+ </critical>
179
+
180
+ **If `{teams_mode}` = true:**
181
+
182
+ ```
183
+ TeamCreate:
184
+ team_name: "apex-{feature_name}"
185
+ description: "APEX: {task_description}"
186
+ ```
187
+
188
+ → This creates the team and its empty task list.
189
+ → All subsequent TaskCreate calls will use this team's task list.
190
+ → Agents are spawned later in step-03-execute-teams.
191
+
192
+ ### 6. Create Task List (MANDATORY)
193
+
194
+ <critical>
195
+ You MUST create a TaskList using TaskCreate for every planned change.
196
+ This is NOT optional - the task list tracks progress through execution.
197
+ If teams_mode is enabled, the team was already created in step 5 — tasks go into the team's task list.
198
+ </critical>
199
+
200
+ **Create one task per file change from the plan:**
201
+
202
+ For each file in the plan, call `TaskCreate` with:
203
+ - **subject**: `{action} {filepath}` (e.g., "Add validateToken to src/auth/handler.ts")
204
+ - **description**: The full details of what changes are needed for this file, including specific functions, patterns to follow, and line references
205
+ - **activeForm**: Present continuous form (e.g., "Adding validateToken to handler.ts")
206
+
207
+ **Then set up dependencies using `TaskUpdate`:**
208
+ - If file B depends on file A (e.g., B imports from A), use `addBlockedBy` to mark the dependency
209
+ - This ensures execution follows the correct order
210
+
211
+ **Example:**
212
+ ```
213
+ TaskCreate: "Create auth types in src/types/auth.ts"
214
+ → description: "Create AuthToken interface, ValidateResult type. Follow pattern from src/types/user.ts"
215
+ → activeForm: "Creating auth types"
216
+
217
+ TaskCreate: "Add validateToken to src/auth/handler.ts"
218
+ → description: "Add validateToken function that returns ValidateResult. Handle expired token error case."
219
+ → activeForm: "Adding validateToken to handler"
220
+ → Then: TaskUpdate with addBlockedBy: [auth-types-task-id]
221
+ ```
222
+
223
+ ### 7. Verify Plan Completeness
224
+
225
+ Checklist:
226
+ - [ ] All files identified - nothing missing
227
+ - [ ] Logical order - dependencies handled first
228
+ - [ ] Clear actions - every step specific and actionable
229
+ - [ ] Test coverage - all paths have test strategy
230
+ - [ ] In scope - no scope creep
231
+ - [ ] AC mapped - every criterion has implementation
232
+ - [ ] **TaskList created with all file changes**
233
+ - [ ] **Task dependencies set correctly**
234
+
235
+ ### 8. Brainstorm Uncertainty Points
236
+
237
+ <critical>
238
+ Before proceeding, THINK about what you're NOT 100% certain about.
239
+ DO NOT ask generic "is this plan good?" questions.
240
+ Instead, identify SPECIFIC uncertainties and ask TARGETED questions.
241
+ </critical>
242
+
243
+ **ULTRA THINK: Identify Uncertainties**
244
+
245
+ For each aspect of the plan, rate your confidence (High/Medium/Low):
246
+
247
+ ```markdown
248
+ ## Uncertainty Analysis
249
+
250
+ | Aspect | Confidence | Uncertainty |
251
+ |--------|------------|-------------|
252
+ | File locations correct? | High/Medium/Low | [What's unclear] |
253
+ | Patterns match codebase? | High/Medium/Low | [What's unclear] |
254
+ | Dependencies complete? | High/Medium/Low | [What's unclear] |
255
+ | Error handling approach? | High/Medium/Low | [What's unclear] |
256
+ | User expectations for X? | High/Medium/Low | [What's unclear] |
257
+ | Technical approach for Y? | High/Medium/Low | [What's unclear] |
258
+ ```
259
+
260
+ **Identify TOP 1-4 uncertainties with Low or Medium confidence.**
261
+
262
+ These are the ONLY things worth asking about.
263
+
264
+ ---
265
+
266
+ ### 9. Ask Smart Questions (if not auto_mode)
267
+
268
+ **If `{auto_mode}` = true:**
269
+ → Skip questions, use your best judgment, proceed directly
270
+
271
+ **If `{auto_mode}` = false AND you have uncertainties:**
272
+
273
+ <critical>
274
+ ONLY ask questions about things where:
275
+ 1. Multiple valid approaches exist AND the choice significantly impacts implementation
276
+ 2. User intent is genuinely ambiguous from the task description
277
+ 3. A wrong assumption could cause significant rework
278
+
279
+ DO NOT ask about:
280
+ - Implementation details you can decide yourself
281
+ - Things you're "slightly unsure" about (just decide)
282
+ - Generic plan approval (never ask "is this plan good?")
283
+ </critical>
284
+
285
+ **Question Types to Use:**
286
+
287
+ **Type 1: Behavior Clarification**
288
+ When user intent is genuinely unclear:
289
+ ```yaml
290
+ questions:
291
+ - header: "Behavior"
292
+ question: "When [specific scenario], should the system [option A] or [option B]?"
293
+ options:
294
+ - label: "[Option A] (Recommended)"
295
+ description: "[What A does and why it might be preferred]"
296
+ - label: "[Option B]"
297
+ description: "[What B does and when it's better]"
298
+ multiSelect: false
299
+ ```
300
+
301
+ **Type 2: Scope Clarification**
302
+ When scope boundaries are unclear:
303
+ ```yaml
304
+ questions:
305
+ - header: "Scope"
306
+ question: "Should we also [related thing] as part of this, or keep it focused on [core thing]?"
307
+ options:
308
+ - label: "Keep focused (Recommended)"
309
+ description: "Only do [core thing], faster implementation"
310
+ - label: "Include [related thing]"
311
+ description: "More complete but expands scope"
312
+ multiSelect: false
313
+ ```
314
+
315
+ **Type 3: Technical Choice**
316
+ When multiple valid technical approaches exist:
317
+ ```yaml
318
+ questions:
319
+ - header: "Approach"
320
+ question: "For [specific technical decision], we can use [approach A] or [approach B]. Which fits your needs?"
321
+ options:
322
+ - label: "[Approach A] (Recommended)"
323
+ description: "[Tradeoffs of A - e.g., simpler but less flexible]"
324
+ - label: "[Approach B]"
325
+ description: "[Tradeoffs of B - e.g., more complex but extensible]"
326
+ multiSelect: false
327
+ ```
328
+
329
+ **Type 4: Edge Case Handling**
330
+ When edge case behavior is unclear:
331
+ ```yaml
332
+ questions:
333
+ - header: "Edge case"
334
+ question: "If [edge case scenario] occurs, should we [behavior A] or [behavior B]?"
335
+ options:
336
+ - label: "[Behavior A] (Recommended)"
337
+ description: "[What happens with A]"
338
+ - label: "[Behavior B]"
339
+ description: "[What happens with B]"
340
+ multiSelect: false
341
+ ```
342
+
343
+ **If you have 0 uncertainties worth asking about:**
344
+ → Proceed directly to execution without asking anything
345
+
346
+ **Example of GOOD questions:**
347
+ - "When a user submits invalid email format, should we show inline validation or only validate on submit?"
348
+ - "Should the loading state show a spinner on the button or a full-page skeleton?"
349
+ - "For rate limiting, should we limit per user or per IP address?"
350
+
351
+ **Example of BAD questions (NEVER ask these):**
352
+ - ❌ "Does this plan look good to you?"
353
+ - ❌ "Ready to proceed with implementation?"
354
+ - ❌ "Should I use async/await or promises?" (just decide)
355
+ - ❌ "Is the file structure correct?" (you already verified)
356
+
357
+ ---
358
+
359
+ ### 10. Present Plan Summary & Approve
360
+
361
+ **Always show the full plan summary (both auto and non-auto):**
362
+
363
+ ```
364
+ **Implementation Plan Ready: {task_description}**
365
+
366
+ **Overview:** [1 sentence summary]
367
+
368
+ **Files to modify:** {count} files
369
+ **New files:** {count} files
370
+ **Tests:** {count} test files
371
+
372
+ **Key decisions made:**
373
+ - [Decision 1 from user responses or auto-decided]
374
+ - [Decision 2 from user responses or auto-decided]
375
+
376
+ **Estimated changes:**
377
+ - `file1.ts` - Major changes (add function, handle errors)
378
+ - `file2.ts` - Minor changes (imports, single call)
379
+ - `file1.test.ts` - New test file
380
+
381
+ **Acceptance Criteria Coverage:**
382
+ - [ ] AC1: Satisfied by changes in `file1.ts`
383
+ - [ ] AC2: Satisfied by changes in `file2.ts`
384
+
385
+ **Risks & Considerations:**
386
+ - [Risk 1 and mitigation]
387
+ ```
388
+
389
+ ---
390
+
391
+ **If `{auto_mode}` = true:**
392
+ → Show the full summary above, then proceed directly to next step
393
+
394
+ **If `{auto_mode}` = false:**
395
+
396
+ <critical>
397
+ Use EnterPlanMode / ExitPlanMode for plan approval — NOT AskUserQuestion.
398
+ This gives the user proper plan review UI and supports "Execute and clear context".
399
+ </critical>
400
+
401
+ **Step 10a: Call `EnterPlanMode`**
402
+
403
+ This transitions into plan mode so the user can review and approve.
404
+
405
+ **Step 10b: Write the plan to the plan file**
406
+
407
+ The system will provide a plan file path. Write the FULL plan to it, including APEX state for context survival.
408
+
409
+ <critical>
410
+ The plan file must contain ALL details from step 4 — do NOT strip sections.
411
+ Include everything: Overview, Prerequisites, File Changes, Testing Strategy, Acceptance Criteria Mapping, Risks & Considerations, Key Decisions.
412
+ </critical>
413
+
414
+ ```markdown
415
+ # APEX Implementation Plan: {task_description}
416
+
417
+ ## APEX Workflow Context
418
+
419
+ > **IMPORTANT:** This is an APEX workflow plan. If you are reading this after
420
+ > "Execute and clear context", continue the APEX workflow by loading the next
421
+ > step file listed below.
422
+
423
+ ### State Variables
424
+ | Variable | Value |
425
+ |----------|-------|
426
+ | task_description | {task_description} |
427
+ | task_id | {task_id} |
428
+ | feature_name | {feature_name} |
429
+ | auto_mode | {auto_mode} |
430
+ | examine_mode | {examine_mode} |
431
+ | save_mode | {save_mode} |
432
+ | test_mode | {test_mode} |
433
+ | economy_mode | {economy_mode} |
434
+ | branch_mode | {branch_mode} |
435
+ | pr_mode | {pr_mode} |
436
+ | tasks_mode | {tasks_mode} |
437
+ | teams_mode | {teams_mode} |
438
+ | output_dir | {output_dir} |
439
+ | branch_name | {branch_name} |
440
+
441
+ ### Next Step After Approval
442
+ {if tasks_mode or teams_mode:}
443
+ Load `skills/workflow-apex/steps/step-02b-tasks.md`
444
+ {else:}
445
+ Load `skills/workflow-apex/steps/step-03-execute.md`
446
+
447
+ ---
448
+
449
+ ## Plan Overview
450
+ [1-2 sentence high-level strategy and approach]
451
+
452
+ ## Prerequisites
453
+ - [ ] Prerequisite 1 (if any)
454
+ - [ ] Prerequisite 2 (if any)
455
+
456
+ ## File Changes
457
+
458
+ [Full file-by-file plan from step 4 — every file with specific actions, line references, patterns to follow, edge cases]
459
+
460
+ ## Testing Strategy
461
+
462
+ **New tests:**
463
+ - [test files to create with coverage details]
464
+
465
+ **Update existing:**
466
+ - [existing test files to modify]
467
+
468
+ ## Acceptance Criteria Mapping
469
+ - [ ] AC1: Satisfied by changes in `file1.ts`
470
+ - [ ] AC2: Satisfied by changes in `file2.ts`
471
+
472
+ ## Key Decisions
473
+ - [Decision 1 from user responses or auto-decided]
474
+ - [Decision 2 from user responses or auto-decided]
475
+
476
+ ## Risks & Considerations
477
+ - [Risk 1: potential issue and mitigation]
478
+ - [Risk 2: potential issue and mitigation]
479
+ ```
480
+
481
+ **Step 10c: Call `ExitPlanMode`**
482
+
483
+ Include appropriate allowedPrompts for execution:
484
+
485
+ ```yaml
486
+ allowedPrompts:
487
+ - tool: Bash
488
+ prompt: "run build, typecheck, lint, test, and format commands"
489
+ - tool: Bash
490
+ prompt: "run git operations for branch management and commits"
491
+ - tool: Bash
492
+ prompt: "run APEX workflow scripts for progress tracking"
493
+ ```
494
+
495
+ **Step 10d: Handle "Execute and clear context"**
496
+
497
+ If the user chooses "Execute and clear context":
498
+ - Context is cleared but the plan file survives
499
+ - The agent re-reads the plan file on the next turn
500
+ - The APEX Workflow Context section in the plan file tells the agent:
501
+ 1. This is an APEX workflow — restore all state variables from the table
502
+ 2. Load the next step file indicated in "Next Step After Approval"
503
+ 3. Continue the workflow as normal
504
+
505
+ <critical>
506
+ The plan file MUST contain ALL state variables, the next step path, AND the full detailed plan.
507
+ Without this, "Execute and clear context" breaks the APEX workflow.
508
+ Never strip sections from the plan file — it must be the complete implementation reference.
509
+ </critical>
510
+
511
+ ### 11. Complete Save Output (if save_mode)
512
+
513
+ **If `{save_mode}` = true:**
514
+
515
+ Append to `{output_dir}/02-plan.md`:
516
+ ```markdown
517
+ ---
518
+ ## Step Complete
519
+ **Status:** ✓ Complete
520
+ **Files planned:** {count}
521
+ **Tests planned:** {count}
522
+ **Uncertainties resolved:** {count}
523
+ **Next:** step-03-execute.md
524
+ **Timestamp:** {ISO timestamp}
525
+ ```
526
+
527
+ ---
528
+
529
+ ## SUCCESS METRICS:
530
+
531
+ ✅ Complete file-by-file plan created
532
+ ✅ Logical dependency order established
533
+ ✅ All acceptance criteria mapped to changes
534
+ ✅ Test strategy defined
535
+ ✅ **Team created with TeamCreate BEFORE TaskList (if teams_mode)**
536
+ ✅ **TaskList created with TaskCreate for every file change**
537
+ ✅ **Task dependencies set with TaskUpdate (addBlockedBy)**
538
+ ✅ Uncertainty points identified and addressed
539
+ ✅ Smart, targeted questions asked (if not auto_mode and uncertainties exist)
540
+ ✅ **Plan approved via EnterPlanMode/ExitPlanMode (if not auto_mode)**
541
+ ✅ **Plan file contains APEX state variables for "Execute and clear context" survival**
542
+ ✅ NO code written or modified
543
+ ✅ Output saved (if save_mode)
544
+
545
+ ## FAILURE MODES:
546
+
547
+ ❌ **CRITICAL**: Skipping file save when save_mode is true (proceeding without writing to 02-plan.md)
548
+ ❌ Organizing by feature instead of file
549
+ ❌ Vague actions like "add feature" or "fix issue"
550
+ ❌ Missing test strategy
551
+ ❌ Not mapping to acceptance criteria
552
+ ❌ Starting to write code (that's step 3!)
553
+ ❌ **CRITICAL**: Not creating a TaskList with TaskCreate
554
+ ❌ **CRITICAL**: Asking generic "is this plan good?" questions
555
+ ❌ **CRITICAL**: Asking about implementation details you can decide yourself
556
+ ❌ **CRITICAL**: Not brainstorming uncertainties before asking questions
557
+ ❌ **CRITICAL**: Using AskUserQuestion for plan approval instead of EnterPlanMode/ExitPlanMode (when auto_mode=false)
558
+ ❌ **CRITICAL**: Plan file missing APEX state variables (breaks "Execute and clear context")
559
+
560
+ ## PLANNING PROTOCOLS:
561
+
562
+ - Structure by FILE - each file is a section
563
+ - Include line number references from analysis
564
+ - Every action must be specific and actionable
565
+ - Map every AC to specific file changes
566
+ - Plan tests alongside implementation
567
+
568
+ ---
569
+
570
+ ## NEXT STEP:
571
+
572
+ **If `{auto_mode}` = true:** Proceed directly after plan summary.
573
+ **If `{auto_mode}` = false:** Proceed after user approves via ExitPlanMode.
574
+
575
+ **If "Execute and clear context" was chosen:**
576
+ → The agent re-reads the plan file, restores APEX state variables from the table, and loads the next step indicated in the plan file.
577
+
578
+ **Routing:**
579
+
580
+ **If `{tasks_mode}` = true OR `{teams_mode}` = true:**
581
+ → Load `./step-02b-tasks.md` to generate task breakdown with dependencies
582
+
583
+ **If `{teams_mode}` = true (after task breakdown):**
584
+ → Flow continues to `./step-03-execute-teams.md` for Agent Team parallel execution
585
+
586
+ **Otherwise:**
587
+ → Load `./step-03-execute.md` to start implementation
588
+
589
+ <critical>
590
+ Remember: Planning is ONLY about designing the approach - save all implementation for step-03!
591
+ When auto_mode=false, ALWAYS use EnterPlanMode/ExitPlanMode for approval — never AskUserQuestion.
592
+ The plan file MUST contain APEX state variables so "Execute and clear context" works.
593
+ </critical>