@fro.bot/systematic 2.0.2 → 2.0.3

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 (56) hide show
  1. package/agents/design/figma-design-sync.md +1 -1
  2. package/agents/document-review/coherence-reviewer.md +40 -0
  3. package/agents/document-review/design-lens-reviewer.md +46 -0
  4. package/agents/document-review/feasibility-reviewer.md +42 -0
  5. package/agents/document-review/product-lens-reviewer.md +50 -0
  6. package/agents/document-review/scope-guardian-reviewer.md +54 -0
  7. package/agents/document-review/security-lens-reviewer.md +38 -0
  8. package/agents/research/best-practices-researcher.md +2 -1
  9. package/agents/research/git-history-analyzer.md +1 -1
  10. package/agents/research/repo-research-analyst.md +164 -9
  11. package/agents/review/api-contract-reviewer.md +49 -0
  12. package/agents/review/correctness-reviewer.md +49 -0
  13. package/agents/review/data-migrations-reviewer.md +53 -0
  14. package/agents/review/maintainability-reviewer.md +49 -0
  15. package/agents/review/pattern-recognition-specialist.md +2 -1
  16. package/agents/review/performance-reviewer.md +51 -0
  17. package/agents/review/reliability-reviewer.md +49 -0
  18. package/agents/review/schema-drift-detector.md +12 -10
  19. package/agents/review/security-reviewer.md +51 -0
  20. package/agents/review/testing-reviewer.md +48 -0
  21. package/agents/workflow/pr-comment-resolver.md +1 -1
  22. package/agents/workflow/spec-flow-analyzer.md +60 -89
  23. package/package.json +1 -1
  24. package/skills/agent-browser/SKILL.md +69 -48
  25. package/skills/ce-brainstorm/SKILL.md +2 -1
  26. package/skills/ce-compound/SKILL.md +26 -1
  27. package/skills/ce-compound-refresh/SKILL.md +11 -1
  28. package/skills/ce-ideate/SKILL.md +2 -1
  29. package/skills/ce-plan/SKILL.md +424 -414
  30. package/skills/ce-review/SKILL.md +12 -13
  31. package/skills/ce-review-beta/SKILL.md +506 -0
  32. package/skills/ce-review-beta/references/diff-scope.md +31 -0
  33. package/skills/ce-review-beta/references/findings-schema.json +128 -0
  34. package/skills/ce-review-beta/references/persona-catalog.md +50 -0
  35. package/skills/ce-review-beta/references/review-output-template.md +115 -0
  36. package/skills/ce-review-beta/references/subagent-template.md +56 -0
  37. package/skills/ce-work/SKILL.md +14 -6
  38. package/skills/ce-work-beta/SKILL.md +14 -8
  39. package/skills/claude-permissions-optimizer/SKILL.md +15 -14
  40. package/skills/deepen-plan/SKILL.md +348 -483
  41. package/skills/document-review/SKILL.md +160 -52
  42. package/skills/feature-video/SKILL.md +209 -178
  43. package/skills/file-todos/SKILL.md +72 -94
  44. package/skills/frontend-design/SKILL.md +243 -27
  45. package/skills/git-worktree/SKILL.md +37 -28
  46. package/skills/lfg/SKILL.md +7 -7
  47. package/skills/reproduce-bug/SKILL.md +154 -60
  48. package/skills/resolve-pr-parallel/SKILL.md +19 -12
  49. package/skills/resolve-todo-parallel/SKILL.md +9 -6
  50. package/skills/setup/SKILL.md +33 -56
  51. package/skills/slfg/SKILL.md +5 -5
  52. package/skills/test-browser/SKILL.md +69 -145
  53. package/skills/test-xcode/SKILL.md +61 -183
  54. package/skills/triage/SKILL.md +10 -10
  55. package/skills/ce-plan-beta/SKILL.md +0 -571
  56. package/skills/deepen-plan-beta/SKILL.md +0 -323
@@ -1,545 +1,410 @@
1
1
  ---
2
2
  name: deepen-plan
3
- description: Enhance a plan with parallel research agents for each section to add depth, best practices, and implementation details
3
+ description: Stress-test an existing implementation plan and selectively strengthen weak sections with targeted research. Use when a plan needs more confidence around decisions, sequencing, system-wide impact, risks, or verification. Best for Standard or Deep plans, or high-risk topics such as auth, payments, migrations, external APIs, and security. For structural or clarity improvements, prefer document-review instead.
4
4
  argument-hint: '[path to plan file]'
5
5
  ---
6
6
 
7
- # Deepen Plan - Power Enhancement Mode
7
+ # Deepen Plan
8
8
 
9
9
  ## Introduction
10
10
 
11
11
  **Note: The current year is 2026.** Use this when searching for recent documentation and best practices.
12
12
 
13
- This command takes an existing plan (from `/ce:plan`) and enhances each section with parallel research agents. Each major element gets its own dedicated research sub-agent to find:
14
- - Best practices and industry patterns
15
- - Performance optimizations
16
- - UI/UX improvements (if applicable)
17
- - Quality enhancements and edge cases
18
- - Real-world implementation examples
13
+ `ce:plan` does the first planning pass. `deepen-plan` is a second-pass confidence check.
19
14
 
20
- The result is a deeply grounded, production-ready plan with concrete implementation details.
15
+ Use this skill when the plan already exists and the question is not "Is this document clear?" but rather "Is this plan grounded enough for the complexity and risk involved?"
21
16
 
22
- ## Plan File
23
-
24
- <plan_path> #$ARGUMENTS </plan_path>
25
-
26
- **If the plan path above is empty:**
27
- 1. Check for recent plans: `ls -la docs/plans/`
28
- 2. Ask the user: "Which plan would you like to deepen? Please provide the path (e.g., `docs/plans/2026-01-15-feat-my-feature-plan.md`)."
29
-
30
- Do not proceed until you have a valid plan file path.
31
-
32
- ## Main Tasks
33
-
34
- ### 1. Parse and Analyze Plan Structure
35
-
36
- <thinking>
37
- First, read and parse the plan to identify each major section that can be enhanced with research.
38
- </thinking>
39
-
40
- **Read the plan file and extract:**
41
- - [ ] Overview/Problem Statement
42
- - [ ] Proposed Solution sections
43
- - [ ] Technical Approach/Architecture
44
- - [ ] Implementation phases/steps
45
- - [ ] Code examples and file references
46
- - [ ] Acceptance criteria
47
- - [ ] Any UI/UX components mentioned
48
- - [ ] Technologies/frameworks mentioned (Rails, React, Python, TypeScript, etc.)
49
- - [ ] Domain areas (data models, APIs, UI, security, performance, etc.)
50
-
51
- **Create a section manifest:**
52
- ```
53
- Section 1: [Title] - [Brief description of what to research]
54
- Section 2: [Title] - [Brief description of what to research]
55
- ...
56
- ```
57
-
58
- ### 2. Discover and Apply Available Skills
59
-
60
- <thinking>
61
- Dynamically discover all available skills and match them to plan sections. Don't assume what skills exist - discover them at runtime.
62
- </thinking>
63
-
64
- **Step 1: Discover ALL available skills from ALL sources**
65
-
66
- ```bash
67
- # 1. Project-local skills (highest priority - project-specific)
68
- ls .opencode/skills/
69
-
70
- # 2. User's global skills (~/.config/opencode/)
71
- ls ~/.config/opencode/skills/
72
-
73
- # 3. systematic plugin skills
74
- ls ~/.config/opencode/plugins/cache/*/compound-engineering/*/skills/
75
-
76
- # 4. ALL other installed plugins - check every plugin for skills
77
- find ~/.config/opencode/plugins/cache -type d -name "skills" 2>/dev/null
78
-
79
- # 5. Also check installed_plugins.json for all plugin locations
80
- cat ~/.config/opencode/plugins/installed_plugins.json
81
- ```
82
-
83
- **Important:** Check EVERY source. Don't assume compound-engineering is the only plugin. Use skills from ANY installed plugin that's relevant.
84
-
85
- **Step 2: For each discovered skill, read its SKILL.md to understand what it does**
86
-
87
- ```bash
88
- # For each skill directory found, read its documentation
89
- cat [skill-path]/SKILL.md
90
- ```
91
-
92
- **Step 3: Match skills to plan content**
93
-
94
- For each skill discovered:
95
- - Read its SKILL.md description
96
- - Check if any plan sections match the skill's domain
97
- - If there's a match, spawn a sub-agent to apply that skill's knowledge
98
-
99
- **Step 4: Spawn a sub-agent for EVERY matched skill**
100
-
101
- **CRITICAL: For EACH skill that matches, spawn a separate sub-agent and instruct it to USE that skill.**
102
-
103
- For each matched skill:
104
- ```
105
- Task general-purpose: "You have the [skill-name] skill available at [skill-path].
106
-
107
- YOUR JOB: Use this skill on the plan.
108
-
109
- 1. Read the skill: cat [skill-path]/SKILL.md
110
- 2. Follow the skill's instructions exactly
111
- 3. Apply the skill to this content:
112
-
113
- [relevant plan section or full plan]
114
-
115
- 4. Return the skill's full output
116
-
117
- The skill tells you what to do - follow it. Execute the skill completely."
118
- ```
119
-
120
- **Spawn ALL skill sub-agents in PARALLEL:**
121
- - 1 sub-agent per matched skill
122
- - Each sub-agent reads and uses its assigned skill
123
- - All run simultaneously
124
- - 10, 20, 30 skill sub-agents is fine
125
-
126
- **Each sub-agent:**
127
- 1. Reads its skill's SKILL.md
128
- 2. Follows the skill's workflow/instructions
129
- 3. Applies the skill to the plan
130
- 4. Returns whatever the skill produces (code, recommendations, patterns, reviews, etc.)
131
-
132
- **Example spawns:**
133
- ```
134
- Task general-purpose: "Use the dhh-rails-style skill at ~/.config/opencode/plugins/.../dhh-rails-style. Read SKILL.md and apply it to: [Rails sections of plan]"
135
-
136
- Task general-purpose: "Use the frontend-design skill at ~/.config/opencode/plugins/.../frontend-design. Read SKILL.md and apply it to: [UI sections of plan]"
137
-
138
- Task general-purpose: "Use the agent-native-architecture skill at ~/.config/opencode/plugins/.../agent-native-architecture. Read SKILL.md and apply it to: [agent/tool sections of plan]"
139
-
140
- Task general-purpose: "Use the security-patterns skill at ~/.config/opencode/skills/security-patterns. Read SKILL.md and apply it to: [full plan]"
141
- ```
142
-
143
- **No limit on skill sub-agents. Spawn one for every skill that could possibly be relevant.**
144
-
145
- ### 3. Discover and Apply Learnings/Solutions
146
-
147
- <thinking>
148
- Check for documented learnings from /ce:compound. These are solved problems stored as markdown files. Spawn a sub-agent for each learning to check if it's relevant.
149
- </thinking>
150
-
151
- **LEARNINGS LOCATION - Check these exact folders:**
152
-
153
- ```
154
- docs/solutions/ <-- PRIMARY: Project-level learnings (created by /ce:compound)
155
- ├── performance-issues/
156
- │ └── *.md
157
- ├── debugging-patterns/
158
- │ └── *.md
159
- ├── configuration-fixes/
160
- │ └── *.md
161
- ├── integration-issues/
162
- │ └── *.md
163
- ├── deployment-issues/
164
- │ └── *.md
165
- └── [other-categories]/
166
- └── *.md
167
- ```
168
-
169
- **Step 1: Find ALL learning markdown files**
170
-
171
- Run these commands to get every learning file:
172
-
173
- ```bash
174
- # PRIMARY LOCATION - Project learnings
175
- find docs/solutions -name "*.md" -type f 2>/dev/null
176
-
177
- # If docs/solutions doesn't exist, check alternate locations:
178
- find .opencode/docs -name "*.md" -type f 2>/dev/null
179
- find ~/.config/opencode/docs -name "*.md" -type f 2>/dev/null
180
- ```
17
+ This skill does **not** turn plans into implementation scripts. It identifies weak sections, runs targeted research only for those sections, and strengthens the plan in place.
181
18
 
182
- **Step 2: Read frontmatter of each learning to filter**
19
+ `document-review` and `deepen-plan` are different:
20
+ - Use the `document-review` skill when the document needs clarity, simplification, completeness, or scope control
21
+ - Use `deepen-plan` when the document is structurally sound but still needs stronger rationale, sequencing, risk treatment, or system-wide thinking
183
22
 
184
- Each learning file has YAML frontmatter with metadata. Read the first ~20 lines of each file to get:
23
+ ## Interaction Method
185
24
 
186
- ```yaml
187
- ---
188
- title: "N+1 Query Fix for Briefs"
189
- category: performance-issues
190
- tags: [activerecord, n-plus-one, includes, eager-loading]
191
- module: Briefs
192
- symptom: "Slow page load, multiple queries in logs"
193
- root_cause: "Missing includes on association"
194
- ---
195
- ```
196
-
197
- **For each .md file, quickly scan its frontmatter:**
198
-
199
- ```bash
200
- # Read first 20 lines of each learning (frontmatter + summary)
201
- head -20 docs/solutions/**/*.md
202
- ```
203
-
204
- **Step 3: Filter - only spawn sub-agents for LIKELY relevant learnings**
205
-
206
- Compare each learning's frontmatter against the plan:
207
- - `tags:` - Do any tags match technologies/patterns in the plan?
208
- - `category:` - Is this category relevant? (e.g., skip deployment-issues if plan is UI-only)
209
- - `module:` - Does the plan touch this module?
210
- - `symptom:` / `root_cause:` - Could this problem occur with the plan?
211
-
212
- **SKIP learnings that are clearly not applicable:**
213
- - Plan is frontend-only → skip `database-migrations/` learnings
214
- - Plan is Python → skip `rails-specific/` learnings
215
- - Plan has no auth → skip `authentication-issues/` learnings
216
-
217
- **SPAWN sub-agents for learnings that MIGHT apply:**
218
- - Any tag overlap with plan technologies
219
- - Same category as plan domain
220
- - Similar patterns or concerns
221
-
222
- **Step 4: Spawn sub-agents for filtered learnings**
223
-
224
- For each learning that passes the filter:
225
-
226
- ```
227
- Task general-purpose: "
228
- LEARNING FILE: [full path to .md file]
229
-
230
- 1. Read this learning file completely
231
- 2. This learning documents a previously solved problem
232
-
233
- Check if this learning applies to this plan:
234
-
235
- ---
236
- [full plan content]
237
- ---
238
-
239
- If relevant:
240
- - Explain specifically how it applies
241
- - Quote the key insight or solution
242
- - Suggest where/how to incorporate it
243
-
244
- If NOT relevant after deeper analysis:
245
- - Say 'Not applicable: [reason]'
246
- "
247
- ```
248
-
249
- **Example filtering:**
250
- ```
251
- # Found 15 learning files, plan is about "Rails API caching"
252
-
253
- # SPAWN (likely relevant):
254
- docs/solutions/performance-issues/n-plus-one-queries.md # tags: [activerecord] ✓
255
- docs/solutions/performance-issues/redis-cache-stampede.md # tags: [caching, redis] ✓
256
- docs/solutions/configuration-fixes/redis-connection-pool.md # tags: [redis] ✓
257
-
258
- # SKIP (clearly not applicable):
259
- docs/solutions/deployment-issues/heroku-memory-quota.md # not about caching
260
- docs/solutions/frontend-issues/stimulus-race-condition.md # plan is API, not frontend
261
- docs/solutions/authentication-issues/jwt-expiry.md # plan has no auth
262
- ```
263
-
264
- **Spawn sub-agents in PARALLEL for all filtered learnings.**
265
-
266
- **These learnings are institutional knowledge - applying them prevents repeating past mistakes.**
267
-
268
- ### 4. Launch Per-Section Research Agents
25
+ Use the platform's question tool when available. When asking the user a question, prefer the platform's blocking question tool if one exists (`question` in OpenCode, `request_user_input` in Codex, `ask_user` in Gemini). Otherwise, present numbered options in chat and wait for the user's reply before proceeding.
269
26
 
270
- <thinking>
271
- For each major section in the plan, spawn dedicated sub-agents to research improvements. Use the Explore agent type for open-ended research.
272
- </thinking>
27
+ Ask one question at a time. Prefer a concise single-select choice when natural options exist.
273
28
 
274
- **For each identified section, launch parallel research:**
275
-
276
- ```
277
- Task Explore: "Research best practices, patterns, and real-world examples for: [section topic].
278
- Find:
279
- - Industry standards and conventions
280
- - Performance considerations
281
- - Common pitfalls and how to avoid them
282
- - Documentation and tutorials
283
- Return concrete, actionable recommendations."
284
- ```
285
-
286
- **Also use Context7 MCP for framework documentation:**
287
-
288
- For any technologies/frameworks mentioned in the plan, query Context7:
289
- ```
290
- mcp__plugin_compound-engineering_context7__resolve-library-id: Find library ID for [framework]
291
- mcp__plugin_compound-engineering_context7__query-docs: Query documentation for specific patterns
292
- ```
293
-
294
- **Use google_search for current best practices:**
295
-
296
- Search for recent (2024-2026) articles, blog posts, and documentation on topics in the plan.
297
-
298
- ### 5. Discover and Run ALL Review Agents
299
-
300
- <thinking>
301
- Dynamically discover every available agent and run them ALL against the plan. Don't filter, don't skip, don't assume relevance. 40+ parallel agents is fine. Use everything available.
302
- </thinking>
303
-
304
- **Step 1: Discover ALL available agents from ALL sources**
305
-
306
- ```bash
307
- # 1. Project-local agents (highest priority - project-specific)
308
- find .opencode/agents -name "*.md" 2>/dev/null
309
-
310
- # 2. User's global agents (~/.config/opencode/)
311
- find ~/.config/opencode/agents -name "*.md" 2>/dev/null
312
-
313
- # 3. systematic plugin agents (all subdirectories)
314
- find ~/.config/opencode/plugins/cache/*/compound-engineering/*/agents -name "*.md" 2>/dev/null
315
-
316
- # 4. ALL other installed plugins - check every plugin for agents
317
- find ~/.config/opencode/plugins/cache -path "*/agents/*.md" 2>/dev/null
318
-
319
- # 5. Check installed_plugins.json to find all plugin locations
320
- cat ~/.config/opencode/plugins/installed_plugins.json
321
-
322
- # 6. For local plugins (isLocal: true), check their source directories
323
- # Parse installed_plugins.json and find local plugin paths
324
- ```
325
-
326
- **Important:** Check EVERY source. Include agents from:
327
- - Project `.opencode/agents/`
328
- - User's `~/.config/opencode/agents/`
329
- - systematic plugin (but SKIP workflow/ agents - only use review/, research/, design/, docs/)
330
- - ALL other installed plugins (agent-sdk-dev, frontend-design, etc.)
331
- - Any local plugins
332
-
333
- **For systematic plugin specifically:**
334
- - USE: `agents/review/*` (all reviewers)
335
- - USE: `agents/research/*` (all researchers)
336
- - USE: `agents/design/*` (design agents)
337
- - USE: `agents/docs/*` (documentation agents)
338
- - SKIP: `agents/workflow/*` (these are workflow orchestrators, not reviewers)
339
-
340
- **Step 2: For each discovered agent, read its description**
341
-
342
- Read the first few lines of each agent file to understand what it reviews/analyzes.
29
+ ## Plan File
343
30
 
344
- **Step 3: Launch ALL agents in parallel**
31
+ <plan_path> #$ARGUMENTS </plan_path>
345
32
 
346
- For EVERY agent discovered, launch a Task in parallel:
33
+ If the plan path above is empty:
34
+ 1. Check `docs/plans/` for recent files
35
+ 2. Ask the user which plan to deepen using the platform's blocking question tool when available (see Interaction Method). Otherwise, present numbered options in chat and wait for the user's reply before proceeding
347
36
 
348
- ```
349
- Task [agent-name]: "Review this plan using your expertise. Apply all your checks and patterns. Plan content: [full plan content]"
350
- ```
37
+ Do not proceed until you have a valid plan file path.
351
38
 
352
- **CRITICAL RULES:**
353
- - Do NOT filter agents by "relevance" - run them ALL
354
- - Do NOT skip agents because they "might not apply" - let them decide
355
- - Launch ALL agents in a SINGLE message with multiple task tool calls
356
- - 20, 30, 40 parallel agents is fine - use everything
357
- - Each agent may catch something others miss
358
- - The goal is MAXIMUM coverage, not efficiency
39
+ ## Core Principles
40
+
41
+ 1. **Stress-test, do not inflate** - Deepening should increase justified confidence, not make the plan longer for its own sake.
42
+ 2. **Selective depth only** - Focus on the weakest 2-5 sections rather than enriching everything.
43
+ 3. **Prefer the simplest execution mode** - Use direct agent synthesis by default. Switch to artifact-backed research only when the selected research scope is large enough that returning all findings inline would create avoidable context pressure.
44
+ 4. **Preserve the planning boundary** - No implementation code, no git command choreography, no exact test command recipes.
45
+ 5. **Use artifact-contained evidence** - Work from the written plan, its `Context & Research`, `Sources & References`, and its origin document when present.
46
+ 6. **Respect product boundaries** - Do not invent new product requirements. If deepening reveals a product-level gap, surface it as an open question or route back to `ce:brainstorm`.
47
+ 7. **Prioritize risk and cross-cutting impact** - The more dangerous or interconnected the work, the more valuable another planning pass becomes.
359
48
 
360
- **Step 4: Also discover and run research agents**
49
+ ## Workflow
50
+
51
+ ### Phase 0: Load the Plan and Decide Whether Deepening Is Warranted
361
52
 
362
- Research agents (like `best-practices-researcher`, `framework-docs-researcher`, `git-history-analyzer`, `repo-research-analyst`) should also be run for relevant plan sections.
53
+ #### 0.1 Read the Plan and Supporting Inputs
54
+
55
+ Read the plan file completely.
56
+
57
+ If the plan frontmatter includes an `origin:` path:
58
+ - Read the origin document too
59
+ - Use it to check whether the plan still reflects the product intent, scope boundaries, and success criteria
60
+
61
+ #### 0.2 Classify Plan Depth and Topic Risk
62
+
63
+ Determine the plan depth from the document:
64
+ - **Lightweight** - small, bounded, low ambiguity, usually 2-4 implementation units
65
+ - **Standard** - moderate complexity, some technical decisions, usually 3-6 units
66
+ - **Deep** - cross-cutting, high-risk, or strategically important work, usually 4-8 units or phased delivery
67
+
68
+ Also build a risk profile. Treat these as high-risk signals:
69
+ - Authentication, authorization, or security-sensitive behavior
70
+ - Payments, billing, or financial flows
71
+ - Data migrations, backfills, or persistent data changes
72
+ - External APIs or third-party integrations
73
+ - Privacy, compliance, or user data handling
74
+ - Cross-interface parity or multi-surface behavior
75
+ - Significant rollout, monitoring, or operational concerns
76
+
77
+ #### 0.3 Decide Whether to Deepen
78
+
79
+ Use this default:
80
+ - **Lightweight** plans usually do not need deepening unless they are high-risk or the user explicitly requests it
81
+ - **Standard** plans often benefit when one or more important sections still look thin
82
+ - **Deep** or high-risk plans often benefit from a targeted second pass
83
+
84
+ If the plan already appears sufficiently grounded:
85
+ - Say so briefly
86
+ - Recommend moving to `/ce:work` or the `document-review` skill
87
+ - If the user explicitly asked to deepen anyway, continue with a light pass and deepen at most 1-2 sections
88
+
89
+ ### Phase 1: Parse the Current `ce:plan` Structure
90
+
91
+ Map the plan into the current template. Look for these sections, or their nearest equivalents:
92
+ - `Overview`
93
+ - `Problem Frame`
94
+ - `Requirements Trace`
95
+ - `Scope Boundaries`
96
+ - `Context & Research`
97
+ - `Key Technical Decisions`
98
+ - `Open Questions`
99
+ - `High-Level Technical Design` (optional overview — pseudo-code, DSL grammar, mermaid diagram, or data flow)
100
+ - `Implementation Units` (may include per-unit `Technical design` subsections)
101
+ - `System-Wide Impact`
102
+ - `Risks & Dependencies`
103
+ - `Documentation / Operational Notes`
104
+ - `Sources & References`
105
+ - Optional deep-plan sections such as `Alternative Approaches Considered`, `Success Metrics`, `Phased Delivery`, `Risk Analysis & Mitigation`, and `Operational / Rollout Notes`
106
+
107
+ If the plan was written manually or uses different headings:
108
+ - Map sections by intent rather than exact heading names
109
+ - If a section is structurally present but titled differently, treat it as the equivalent section
110
+ - If the plan truly lacks a section, decide whether that absence is intentional for the plan depth or a confidence gap worth scoring
111
+
112
+ Also collect:
113
+ - Frontmatter, including existing `deepened:` date if present
114
+ - Number of implementation units
115
+ - Which files and test files are named
116
+ - Which learnings, patterns, or external references are cited
117
+ - Which sections appear omitted because they were unnecessary versus omitted because they are missing
118
+
119
+ ### Phase 2: Score Confidence Gaps
120
+
121
+ Use a checklist-first, risk-weighted scoring pass.
122
+
123
+ For each section, compute:
124
+ - **Trigger count** - number of checklist problems that apply
125
+ - **Risk bonus** - add 1 if the topic is high-risk and this section is materially relevant to that risk
126
+ - **Critical-section bonus** - add 1 for `Key Technical Decisions`, `Implementation Units`, `System-Wide Impact`, `Risks & Dependencies`, or `Open Questions` in `Standard` or `Deep` plans
127
+
128
+ Treat a section as a candidate if:
129
+ - it hits **2+ total points**, or
130
+ - it hits **1+ point** in a high-risk domain and the section is materially important
131
+
132
+ Choose only the top **2-5** sections by score. If the user explicitly asked to deepen a lightweight plan, cap at **1-2** sections unless the topic is high-risk.
133
+
134
+ Example:
135
+ - A `Key Technical Decisions` section with 1 checklist trigger and the critical-section bonus scores **2 points** and is a candidate
136
+ - A `Risks & Dependencies` section with 1 checklist trigger in a high-risk migration plan also becomes a candidate because the risk bonus applies
137
+
138
+ If the plan already has a `deepened:` date:
139
+ - Prefer sections that have not yet been substantially strengthened, if their scores are comparable
140
+ - Revisit an already-deepened section only when it still scores clearly higher than alternatives or the user explicitly asks for another pass on it
141
+
142
+ #### 2.1 Section Checklists
143
+
144
+ Use these triggers.
145
+
146
+ **Requirements Trace**
147
+ - Requirements are vague or disconnected from implementation units
148
+ - Success criteria are missing or not reflected downstream
149
+ - Units do not clearly advance the traced requirements
150
+ - Origin requirements are not clearly carried forward
151
+
152
+ **Context & Research / Sources & References**
153
+ - Relevant repo patterns are named but never used in decisions or implementation units
154
+ - Cited learnings or references do not materially shape the plan
155
+ - High-risk work lacks appropriate external or internal grounding
156
+ - Research is generic instead of tied to this repo or this plan
157
+
158
+ **Key Technical Decisions**
159
+ - A decision is stated without rationale
160
+ - Rationale does not explain tradeoffs or rejected alternatives
161
+ - The decision does not connect back to scope, requirements, or origin context
162
+ - An obvious design fork exists but the plan never addresses why one path won
163
+
164
+ **Open Questions**
165
+ - Product blockers are hidden as assumptions
166
+ - Planning-owned questions are incorrectly deferred to implementation
167
+ - Resolved questions have no clear basis in repo context, research, or origin decisions
168
+ - Deferred items are too vague to be useful later
169
+
170
+ **High-Level Technical Design (when present)**
171
+ - The sketch uses the wrong medium for the work (e.g., pseudo-code where a sequence diagram would communicate better)
172
+ - The sketch contains implementation code (imports, exact signatures, framework-specific syntax) rather than pseudo-code
173
+ - The non-prescriptive framing is missing or weak
174
+ - The sketch does not connect to the key technical decisions or implementation units
175
+
176
+ **High-Level Technical Design (when absent)** *(Standard or Deep plans only)*
177
+ - The work involves DSL design, API surface design, multi-component integration, complex data flow, or state-heavy lifecycle
178
+ - Key technical decisions would be easier to validate with a visual or pseudo-code representation
179
+ - The approach section of implementation units is thin and a higher-level technical design would provide context
180
+
181
+ **Implementation Units**
182
+ - Dependency order is unclear or likely wrong
183
+ - File paths or test file paths are missing where they should be explicit
184
+ - Units are too large, too vague, or broken into micro-steps
185
+ - Approach notes are thin or do not name the pattern to follow
186
+ - Test scenarios or verification outcomes are vague
187
+
188
+ **System-Wide Impact**
189
+ - Affected interfaces, callbacks, middleware, entry points, or parity surfaces are missing
190
+ - Failure propagation is underexplored
191
+ - State lifecycle, caching, or data integrity risks are absent where relevant
192
+ - Integration coverage is weak for cross-layer work
193
+
194
+ **Risks & Dependencies / Documentation / Operational Notes**
195
+ - Risks are listed without mitigation
196
+ - Rollout, monitoring, migration, or support implications are missing when warranted
197
+ - External dependency assumptions are weak or unstated
198
+ - Security, privacy, performance, or data risks are absent where they obviously apply
199
+
200
+ Use the plan's own `Context & Research` and `Sources & References` as evidence. If those sections cite a pattern, learning, or risk that never affects decisions, implementation units, or verification, treat that as a confidence gap.
363
201
 
364
- ### 6. Wait for ALL Agents and Synthesize Everything
202
+ ### Phase 3: Select Targeted Research Agents
365
203
 
366
- <thinking>
367
- Wait for ALL parallel agents to complete - skills, research agents, review agents, everything. Then synthesize all findings into a comprehensive enhancement.
368
- </thinking>
204
+ For each selected section, choose the smallest useful agent set. Do **not** run every agent. Use at most **1-3 agents per section** and usually no more than **8 agents total**.
369
205
 
370
- **Collect outputs from ALL sources:**
206
+ Use fully-qualified agent names inside Task calls.
371
207
 
372
- 1. **Skill-based sub-agents** - Each skill's full output (code examples, patterns, recommendations)
373
- 2. **Learnings/Solutions sub-agents** - Relevant documented learnings from /ce:compound
374
- 3. **Research agents** - Best practices, documentation, real-world examples
375
- 4. **Review agents** - All feedback from every reviewer (architecture, security, performance, simplicity, etc.)
376
- 5. **Context7 queries** - Framework documentation and patterns
377
- 6. **Web searches** - Current best practices and articles
208
+ #### 3.1 Deterministic Section-to-Agent Mapping
378
209
 
379
- **For each agent's findings, extract:**
380
- - [ ] Concrete recommendations (actionable items)
381
- - [ ] Code patterns and examples (copy-paste ready)
382
- - [ ] Anti-patterns to avoid (warnings)
383
- - [ ] Performance considerations (metrics, benchmarks)
384
- - [ ] Security considerations (vulnerabilities, mitigations)
385
- - [ ] Edge cases discovered (handling strategies)
386
- - [ ] Documentation links (references)
387
- - [ ] Skill-specific patterns (from matched skills)
388
- - [ ] Relevant learnings (past solutions that apply - prevent repeating mistakes)
210
+ **Requirements Trace / Open Questions classification**
211
+ - `systematic:workflow:spec-flow-analyzer` for missing user flows, edge cases, and handoff gaps
212
+ - `systematic:research:repo-research-analyst` (Scope: `architecture, patterns`) for repo-grounded patterns, conventions, and implementation reality checks
389
213
 
390
- **Deduplicate and prioritize:**
391
- - Merge similar recommendations from multiple agents
392
- - Prioritize by impact (high-value improvements first)
393
- - Flag conflicting advice for human review
394
- - Group by plan section
214
+ **Context & Research / Sources & References gaps**
215
+ - `systematic:research:learnings-researcher` for institutional knowledge and past solved problems
216
+ - `systematic:research:framework-docs-researcher` for official framework or library behavior
217
+ - `systematic:research:best-practices-researcher` for current external patterns and industry guidance
218
+ - Add `systematic:research:git-history-analyzer` only when historical rationale or prior art is materially missing
395
219
 
396
- ### 7. Enhance Plan Sections
220
+ **Key Technical Decisions**
221
+ - `systematic:review:architecture-strategist` for design integrity, boundaries, and architectural tradeoffs
222
+ - Add `systematic:research:framework-docs-researcher` or `systematic:research:best-practices-researcher` when the decision needs external grounding beyond repo evidence
223
+
224
+ **High-Level Technical Design**
225
+ - `systematic:review:architecture-strategist` for validating that the technical design accurately represents the intended approach and identifying gaps
226
+ - `systematic:research:repo-research-analyst` (Scope: `architecture, patterns`) for grounding the technical design in existing repo patterns and conventions
227
+ - Add `systematic:research:best-practices-researcher` when the technical design involves a DSL, API surface, or pattern that benefits from external validation
397
228
 
398
- <thinking>
399
- Merge research findings back into the plan, adding depth without changing the original structure.
400
- </thinking>
229
+ **Implementation Units / Verification**
230
+ - `systematic:research:repo-research-analyst` (Scope: `patterns`) for concrete file targets, patterns to follow, and repo-specific sequencing clues
231
+ - `systematic:review:pattern-recognition-specialist` for consistency, duplication risks, and alignment with existing patterns
232
+ - Add `systematic:workflow:spec-flow-analyzer` when sequencing depends on user flow or handoff completeness
401
233
 
402
- **Enhancement format for each section:**
234
+ **System-Wide Impact**
235
+ - `systematic:review:architecture-strategist` for cross-boundary effects, interface surfaces, and architectural knock-on impact
236
+ - Add the specific specialist that matches the risk:
237
+ - `systematic:review:performance-oracle` for scalability, latency, throughput, and resource-risk analysis
238
+ - `systematic:review:security-sentinel` for auth, validation, exploit surfaces, and security boundary review
239
+ - `systematic:review:data-integrity-guardian` for migrations, persistent state safety, consistency, and data lifecycle risks
403
240
 
404
- ```markdown
405
- ## [Original Section Title]
241
+ **Risks & Dependencies / Operational Notes**
242
+ - Use the specialist that matches the actual risk:
243
+ - `systematic:review:security-sentinel` for security, auth, privacy, and exploit risk
244
+ - `systematic:review:data-integrity-guardian` for persistent data safety, constraints, and transaction boundaries
245
+ - `systematic:review:data-migration-expert` for migration realism, backfills, and production data transformation risk
246
+ - `systematic:review:deployment-verification-agent` for rollout checklists, rollback planning, and launch verification
247
+ - `systematic:review:performance-oracle` for capacity, latency, and scaling concerns
248
+
249
+ #### 3.2 Agent Prompt Shape
250
+
251
+ For each selected section, pass:
252
+ - The scope prefix from section 3.1 (e.g., `Scope: architecture, patterns.`) when the agent supports scoped invocation
253
+ - A short plan summary
254
+ - The exact section text
255
+ - Why the section was selected, including which checklist triggers fired
256
+ - The plan depth and risk profile
257
+ - A specific question to answer
258
+
259
+ Instruct the agent to return:
260
+ - findings that change planning quality
261
+ - stronger rationale, sequencing, verification, risk treatment, or references
262
+ - no implementation code
263
+ - no shell commands
264
+
265
+ #### 3.3 Choose Research Execution Mode
266
+
267
+ Use the lightest mode that will work:
268
+
269
+ - **Direct mode** - Default. Use when the selected section set is small and the parent can safely read the agent outputs inline.
270
+ - **Artifact-backed mode** - Use only when the selected research scope is large enough that inline returns would create unnecessary context pressure.
271
+
272
+ Signals that justify artifact-backed mode:
273
+ - More than 5 agents are likely to return meaningful findings
274
+ - The selected section excerpts are long enough that repeating them in multiple agent outputs would be wasteful
275
+ - The topic is high-risk and likely to attract bulky source-backed analysis
276
+ - The platform has a history of parent-context instability on large parallel returns
277
+
278
+ If artifact-backed mode is not clearly warranted, stay in direct mode.
279
+
280
+ ### Phase 4: Run Targeted Research and Review
281
+
282
+ Launch the selected agents in parallel using the execution mode chosen in Step 3.3. If the current platform does not support parallel dispatch, run them sequentially instead.
283
+
284
+ Prefer local repo and institutional evidence first. Use external research only when the gap cannot be closed responsibly from repo context or already-cited sources.
285
+
286
+ If a selected section can be improved by reading the origin document more carefully, do that before dispatching external agents.
406
287
 
407
- [Original content preserved]
288
+ #### 4.1 Direct Mode
408
289
 
409
- ### Research Insights
290
+ Have each selected agent return its findings directly to the parent.
410
291
 
411
- **Best Practices:**
412
- - [Concrete recommendation 1]
413
- - [Concrete recommendation 2]
292
+ Keep the return payload focused:
293
+ - strongest findings only
294
+ - the evidence or sources that matter
295
+ - the concrete planning improvement implied by the finding
414
296
 
415
- **Performance Considerations:**
416
- - [Optimization opportunity]
417
- - [Benchmark or metric to target]
297
+ If a direct-mode agent starts producing bulky or repetitive output, stop and switch the remaining research to artifact-backed mode instead of letting the parent context bloat.
418
298
 
419
- **Implementation Details:**
420
- ```[language]
421
- // Concrete code example from research
422
- ```
299
+ #### 4.2 Artifact-Backed Mode
423
300
 
424
- **Edge Cases:**
425
- - [Edge case 1 and how to handle]
426
- - [Edge case 2 and how to handle]
301
+ Use a per-run scratch directory under `.context/systematic/deepen-plan/`, for example `.context/systematic/deepen-plan/<run-id>/` or `.context/systematic/deepen-plan/<plan-filename-stem>/`.
427
302
 
428
- **References:**
429
- - [Documentation URL 1]
430
- - [Documentation URL 2]
431
- ```
303
+ Use the scratch directory only for the current deepening pass.
432
304
 
433
- ### 8. Add Enhancement Summary
305
+ For each selected agent:
306
+ - give it the same plan summary, section text, trigger rationale, depth, and risk profile described in Step 3.2
307
+ - instruct it to write one compact artifact file for its assigned section or sections
308
+ - have it return only a short completion summary to the parent
309
+
310
+ Prefer a compact markdown artifact unless machine-readable structure is clearly useful. Each artifact should contain:
311
+ - target section id and title
312
+ - why the section was selected
313
+ - 3-7 findings that materially improve planning quality
314
+ - source-backed rationale, including whether the evidence came from repo context, origin context, institutional learnings, official docs, or external best practices
315
+ - the specific plan change implied by each finding
316
+ - any unresolved tradeoff that should remain explicit in the plan
317
+
318
+ Artifact rules:
319
+ - no implementation code
320
+ - no shell commands
321
+ - no checkpoint logs or self-diagnostics
322
+ - no duplicated boilerplate across files
323
+ - no judge or merge sub-pipeline
324
+
325
+ Before synthesis:
326
+ - quickly verify that each selected section has at least one usable artifact
327
+ - if an artifact is missing or clearly malformed, re-run that agent or fall back to direct-mode reasoning for that section instead of building a validation pipeline
434
328
 
435
- At the top of the plan, add a summary section:
329
+ If agent outputs conflict:
330
+ - Prefer repo-grounded and origin-grounded evidence over generic advice
331
+ - Prefer official framework documentation over secondary best-practice summaries when the conflict is about library behavior
332
+ - If a real tradeoff remains, record it explicitly in the plan rather than pretending the conflict does not exist
436
333
 
437
- ```markdown
438
- ## Enhancement Summary
334
+ ### Phase 5: Synthesize and Rewrite the Plan
335
+
336
+ Strengthen only the selected sections. Keep the plan coherent and preserve its overall structure.
439
337
 
440
- **Deepened on:** [Date]
441
- **Sections enhanced:** [Count]
442
- **Research agents used:** [List]
338
+ If artifact-backed mode was used:
339
+ - read the plan, origin document if present, and the selected section artifacts
340
+ - also incorporate any findings already returned inline from direct-mode agents before a mid-run switch, so early results are not silently dropped
341
+ - synthesize in one pass
342
+ - do not create a separate judge, merge, or quality-review phase unless the user explicitly asks for another pass
443
343
 
444
- ### Key Improvements
445
- 1. [Major improvement 1]
446
- 2. [Major improvement 2]
447
- 3. [Major improvement 3]
344
+ Allowed changes:
345
+ - Clarify or strengthen decision rationale
346
+ - Tighten requirements trace or origin fidelity
347
+ - Reorder or split implementation units when sequencing is weak
348
+ - Add missing pattern references, file/test paths, or verification outcomes
349
+ - Expand system-wide impact, risks, or rollout treatment where justified
350
+ - Reclassify open questions between `Resolved During Planning` and `Deferred to Implementation` when evidence supports the change
351
+ - Strengthen, replace, or add a High-Level Technical Design section when the work warrants it and the current representation is weak, uses the wrong medium, or is absent where it would help. Preserve the non-prescriptive framing
352
+ - Strengthen or add per-unit technical design fields where the unit's approach is non-obvious and the current approach notes are thin
353
+ - Add an optional deep-plan section only when it materially improves execution quality
354
+ - Add or update `deepened: YYYY-MM-DD` in frontmatter when the plan was substantively improved
448
355
 
449
- ### New Considerations Discovered
450
- - [Important finding 1]
451
- - [Important finding 2]
452
- ```
356
+ Do **not**:
357
+ - Add implementation code — no imports, exact method signatures, or framework-specific syntax. Pseudo-code sketches and DSL grammars are allowed in both the top-level High-Level Technical Design section and per-unit technical design fields
358
+ - Add git commands, commit choreography, or exact test command recipes
359
+ - Add generic `Research Insights` subsections everywhere
360
+ - Rewrite the entire plan from scratch
361
+ - Invent new product requirements, scope changes, or success criteria without surfacing them explicitly
453
362
 
454
- ### 9. Update Plan File
363
+ If research reveals a product-level ambiguity that should change behavior or scope:
364
+ - Do not silently decide it here
365
+ - Record it under `Open Questions`
366
+ - Recommend `ce:brainstorm` if the gap is truly product-defining
455
367
 
456
- **Write the enhanced plan:**
457
- - Preserve original filename
458
- - Add `-deepened` suffix if user prefers a new file
459
- - Update any timestamps or metadata
368
+ ### Phase 6: Final Checks and Write the File
460
369
 
461
- ## Output Format
370
+ Before writing:
371
+ - Confirm the plan is stronger in specific ways, not merely longer
372
+ - Confirm the planning boundary is intact
373
+ - Confirm the selected sections were actually the weakest ones
374
+ - Confirm origin decisions were preserved when an origin document exists
375
+ - Confirm the final plan still feels right-sized for its depth
376
+ - If artifact-backed mode was used, confirm the scratch artifacts did not become a second hidden plan format
462
377
 
463
- Update the plan file in place (or if user requests a separate file, append `-deepened` after `-plan`, e.g., `2026-01-15-feat-auth-plan-deepened.md`).
378
+ Update the plan file in place by default.
464
379
 
465
- ## Quality Checks
380
+ If the user explicitly requests a separate file, append `-deepened` before `.md`, for example:
381
+ - `docs/plans/2026-03-15-001-feat-example-plan-deepened.md`
466
382
 
467
- Before finalizing:
468
- - [ ] All original content preserved
469
- - [ ] Research insights clearly marked and attributed
470
- - [ ] Code examples are syntactically correct
471
- - [ ] Links are valid and relevant
472
- - [ ] No contradictions between sections
473
- - [ ] Enhancement summary accurately reflects changes
383
+ If artifact-backed mode was used and the user did not ask to inspect the scratch files:
384
+ - clean up the temporary scratch directory after the plan is safely written
385
+ - if cleanup is not practical on the current platform, say where the artifacts were left and that they are temporary workflow output
474
386
 
475
387
  ## Post-Enhancement Options
476
388
 
477
- After writing the enhanced plan, use the **question tool** to present these options:
389
+ If substantive changes were made, present next steps using the platform's blocking question tool when available (see Interaction Method). Otherwise, present numbered options in chat and wait for the user's reply before proceeding.
478
390
 
479
391
  **Question:** "Plan deepened at `[plan_path]`. What would you like to do next?"
480
392
 
481
393
  **Options:**
482
- 1. **View diff** - Show what was added/changed
483
- 2. **Start `/ce:work`** - Begin implementing this enhanced plan
484
- 3. **Deepen further** - Run another round of research on specific sections
485
- 4. **Revert** - Restore original plan (if backup exists)
394
+ 1. **View diff** - Show what changed
395
+ 2. **Run `document-review` skill** - Improve the updated plan through structured document review
396
+ 3. **Start `ce:work` skill** - Begin implementing the plan
397
+ 4. **Deepen specific sections further** - Run another targeted deepening pass on named sections
486
398
 
487
399
  Based on selection:
488
- - **View diff** Run `git diff [plan_path]` or show before/after
489
- - **`/ce:work`** Call the /ce:work command with the plan file path
490
- - **Deepen further** Ask which sections need more research, then re-run those agents
491
- - **Revert** Restore from git or backup
492
-
493
- ## Example Enhancement
494
-
495
- **Before (from /workflows:plan):**
496
- ```markdown
497
- ## Technical Approach
498
-
499
- Use React Query for data fetching with optimistic updates.
500
- ```
501
-
502
- **After (from /workflows:deepen-plan):**
503
- ```markdown
504
- ## Technical Approach
505
-
506
- Use React Query for data fetching with optimistic updates.
507
-
508
- ### Research Insights
509
-
510
- **Best Practices:**
511
- - Configure `staleTime` and `cacheTime` based on data freshness requirements
512
- - Use `queryKey` factories for consistent cache invalidation
513
- - Implement error boundaries around query-dependent components
514
-
515
- **Performance Considerations:**
516
- - Enable `refetchOnWindowFocus: false` for stable data to reduce unnecessary requests
517
- - Use `select` option to transform and memoize data at query level
518
- - Consider `placeholderData` for instant perceived loading
519
-
520
- **Implementation Details:**
521
- ```typescript
522
- // Recommended query configuration
523
- const queryClient = new QueryClient({
524
- defaultOptions: {
525
- queries: {
526
- staleTime: 5 * 60 * 1000, // 5 minutes
527
- retry: 2,
528
- refetchOnWindowFocus: false,
529
- },
530
- },
531
- });
532
- ```
533
-
534
- **Edge Cases:**
535
- - Handle race conditions with `cancelQueries` on component unmount
536
- - Implement retry logic for transient network failures
537
- - Consider offline support with `persistQueryClient`
538
-
539
- **References:**
540
- - https://tanstack.com/query/latest/docs/react/guides/optimistic-updates
541
- - https://tkdodo.eu/blog/practical-react-query
542
- ```
543
-
544
- NEVER CODE! Just research and enhance the plan.
400
+ - **View diff** -> Show the important additions and changed sections
401
+ - **`document-review` skill** -> Load the `document-review` skill with the plan path
402
+ - **Start `ce:work` skill** -> Call the `ce:work` skill with the plan path
403
+ - **Deepen specific sections further** -> Ask which sections still feel weak and run another targeted pass only for those sections
404
+
405
+ If no substantive changes were warranted:
406
+ - Say that the plan already appears sufficiently grounded
407
+ - Offer the `document-review` skill or `/ce:work` as the next step instead
408
+
409
+ NEVER CODE! Research, challenge, and strengthen the plan.
545
410