planflow-ai 1.3.2 → 1.3.5

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.
@@ -7,7 +7,7 @@ Automatic model selection at phase boundaries during `/execute-plan`. Each phase
7
7
 
8
8
  **Scope**: `/execute-plan` only. Other skills (discovery, review, brainstorm) do not have pre-defined complexity scores and are not routed.
9
9
 
10
- **Config**: Controlled by `model_routing` key in `flow/.flowconfig` (default: `true`). Set `model_routing: false` to disable.
10
+ **Config**: Controlled by `model_routing` key in `flow/.flowconfig` (default: `false`). Set `model_routing: true` to enable.
11
11
 
12
12
  ---
13
13
 
@@ -23,12 +23,16 @@ Automatic model selection at phase boundaries during `/execute-plan`. Each phase
23
23
 
24
24
  ## Platform Mappings
25
25
 
26
+ Always use the **latest and most capable model** from each provider. Model names below are examples — always prefer the most recent version available at runtime.
27
+
26
28
  | Tier | Claude Code | Codex (OpenAI) | Cursor |
27
29
  |------|------------|----------------|--------|
28
30
  | Fast | `haiku` | `gpt-4.1-mini` | auto (fast) |
29
31
  | Standard | `sonnet` | `gpt-4.1` | auto (normal) |
30
32
  | Powerful | `opus` | `o3` | auto (max) |
31
33
 
34
+ **Default model (when routing is OFF)**: Always use the most capable/recent model from the active provider — e.g., `opus` for Anthropic, `o3` for OpenAI. This is the default behavior.
35
+
32
36
  **Fallback rule**: If a platform doesn't support a tier, fall back to the next tier up (e.g., if no haiku equivalent, use Standard).
33
37
 
34
38
  ---
@@ -37,7 +41,7 @@ Automatic model selection at phase boundaries during `/execute-plan`. Each phase
37
41
 
38
42
  ### At Each Phase Boundary
39
43
 
40
- 1. **Check config**: Read `model_routing` from `flow/.flowconfig`. If `false` or missing key, skip routing (use session default).
44
+ 1. **Check config**: Read `model_routing` from `flow/.flowconfig`. If `false`, missing key, or not set, skip routing (use the most capable session model — this is the default).
41
45
  2. **Read complexity**: Get the phase's complexity score from the plan file.
42
46
  3. **Look up tier**: Map score to tier using the table above.
43
47
  4. **Spawn subagent**: Use the Agent tool with `model={tier_model}` to implement the phase.
@@ -0,0 +1,222 @@
1
+
2
+ # Phase Isolation
3
+
4
+ ## Purpose
5
+
6
+ When `phase_isolation: true` in `flow/.flowconfig` (default), each `/execute-plan` phase implementation runs in an **isolated Agent sub-agent** with a clean context window. The sub-agent receives only the context it needs and returns a structured JSON summary. This eliminates context rot — phase 7 has the same quality as phase 1.
7
+
8
+ **Core principle**: Clean context in, structured summary out.
9
+
10
+ ---
11
+
12
+ ## Architecture
13
+
14
+ ```
15
+ Coordinator (main session)
16
+
17
+ ├─ Present phase in Plan Mode → User approves
18
+
19
+ ├─ Prepare isolated context (see Context Template below)
20
+
21
+ ├─ Spawn Agent sub-agent:
22
+ │ model: [tier from model routing]
23
+ │ mode: "auto"
24
+ │ prompt: [focused context + instructions + return format]
25
+
26
+ ├─ Receive structured JSON summary (1-2K tokens)
27
+
28
+ ├─ Process summary:
29
+ │ ├─ Update plan file (mark tasks [x])
30
+ │ ├─ Accumulate files_modified list
31
+ │ ├─ Append patterns to pending-patterns.md
32
+ │ ├─ Git commit (if enabled)
33
+ │ └─ Handle errors (present to user if status != success)
34
+
35
+ └─ Next phase...
36
+ ```
37
+
38
+ Planning and user approval always happen in the **main session** (full context). Only the **implementation step** is isolated.
39
+
40
+ ---
41
+
42
+ ## Context Template
43
+
44
+ The Agent sub-agent prompt must include exactly these sections:
45
+
46
+ ```markdown
47
+ # Phase Implementation: {Phase N — Phase Name}
48
+
49
+ ## Plan
50
+ **Feature**: {feature name}
51
+ **Plan file**: {path to plan file}
52
+
53
+ ## Phase Scope
54
+ {Scope description from plan}
55
+
56
+ ## Tasks
57
+ {Task list from plan, as checklist}
58
+
59
+ ## Files Modified in Previous Phases
60
+ {List of file paths created/modified so far, or "None — this is Phase 1"}
61
+
62
+ ## Project Patterns
63
+ Read these files before implementing:
64
+ - `.claude/rules/core/allowed-patterns.md`
65
+ - `.claude/rules/core/forbidden-patterns.md`
66
+
67
+ ## Design Context
68
+ {Only if UI phase — include design tokens from discovery doc}
69
+ {Otherwise omit this section entirely}
70
+
71
+ ## Instructions
72
+ 1. Read the plan file to understand the full feature context
73
+ 2. Implement all tasks listed above
74
+ 3. Follow the project patterns from the files listed
75
+ 4. Return a JSON summary in the exact format below — do NOT return markdown
76
+
77
+ ## Return Format
78
+ Return ONLY a JSON object (no markdown fences, no explanation):
79
+ {see Return Format Schema below}
80
+ ```
81
+
82
+ ### Context Size Target
83
+
84
+ The prompt should be **under 2K tokens** (excluding files the sub-agent reads itself via the Read tool). Keep it focused — the sub-agent will read project files as needed during implementation.
85
+
86
+ ---
87
+
88
+ ## Return Format Schema
89
+
90
+ The sub-agent must return a JSON object with this structure:
91
+
92
+ ```json
93
+ {
94
+ "status": "success",
95
+ "phase": "Phase 1: Create Core Resource",
96
+ "summary": "One-paragraph description of what was implemented and any notable decisions.",
97
+ "files_created": [
98
+ "src/types/auth.ts"
99
+ ],
100
+ "files_modified": [
101
+ "src/api/routes.ts",
102
+ "src/utils/helpers.ts"
103
+ ],
104
+ "decisions": [
105
+ "Chose JWT over sessions because discovery DR-4 specified stateless auth"
106
+ ],
107
+ "deviations": [
108
+ "Task 3 deferred — requires database migration first"
109
+ ],
110
+ "errors": [],
111
+ "patterns_captured": [
112
+ {
113
+ "category": "allowed",
114
+ "name": "Zod schema co-location",
115
+ "description": "All Zod schemas live next to their type definitions",
116
+ "confidence": "high"
117
+ }
118
+ ]
119
+ }
120
+ ```
121
+
122
+ ### Field Descriptions
123
+
124
+ | Field | Type | Required | Description |
125
+ |-------|------|----------|-------------|
126
+ | `status` | `"success" \| "failure" \| "partial"` | Yes | Overall phase outcome |
127
+ | `phase` | string | Yes | Phase number and name |
128
+ | `summary` | string | Yes | 1-3 sentence description of what was done |
129
+ | `files_created` | string[] | Yes | Paths of new files created (empty array if none) |
130
+ | `files_modified` | string[] | Yes | Paths of existing files modified (empty array if none) |
131
+ | `decisions` | string[] | No | Architecture/design decisions made during implementation |
132
+ | `deviations` | string[] | No | Tasks skipped or changed from plan |
133
+ | `errors` | string[] | No | Errors encountered (even if resolved) |
134
+ | `patterns_captured` | object[] | No | Patterns observed during implementation |
135
+
136
+ ### Failure Return Example
137
+
138
+ ```json
139
+ {
140
+ "status": "failure",
141
+ "phase": "Phase 3: API Integration",
142
+ "summary": "Failed to implement API routes. Missing dependency '@auth/core' not in package.json.",
143
+ "files_created": [],
144
+ "files_modified": ["src/api/auth.ts"],
145
+ "decisions": [],
146
+ "deviations": [],
147
+ "errors": [
148
+ "Cannot find module '@auth/core' — dependency not installed",
149
+ "Partial implementation in src/api/auth.ts — needs cleanup"
150
+ ],
151
+ "patterns_captured": []
152
+ }
153
+ ```
154
+
155
+ ---
156
+
157
+ ## Coordinator Processing
158
+
159
+ After receiving the sub-agent's JSON summary, the coordinator:
160
+
161
+ ### On Success (`status: "success"`)
162
+
163
+ 1. **Update plan file**: Mark all phase tasks as `[x]`
164
+ 2. **Accumulate file list**: Merge `files_created` and `files_modified` into running list
165
+ 3. **Buffer patterns**: Append `patterns_captured` entries to `flow/resources/pending-patterns.md`
166
+ 4. **Git commit**: If `commit: true`, run `git add -A && git commit -m "Phase N: {name} — {feature}"`
167
+ 5. **Log decisions**: Include `decisions` in phase completion message
168
+ 6. **Proceed**: Move to next phase
169
+
170
+ ### On Failure (`status: "failure"`)
171
+
172
+ 1. **Present error**: Show `errors` array to user
173
+ 2. **Show partial work**: List `files_modified` so user knows what was touched
174
+ 3. **Ask user**: "Phase failed. Options: (1) Retry phase, (2) Skip and continue, (3) Stop execution"
175
+ 4. **Do NOT auto-retry**: Let user decide
176
+
177
+ ### On Partial (`status: "partial"`)
178
+
179
+ 1. **Present summary**: Show what was completed and what wasn't
180
+ 2. **Show deviations**: List `deviations` explaining what was skipped
181
+ 3. **Ask user**: "Phase partially complete. Continue to next phase or retry remaining tasks?"
182
+
183
+ ---
184
+
185
+ ## Aggregated Phases
186
+
187
+ When phases are aggregated (combined complexity ≤ 6), they run as **one sub-agent call** with all tasks from all aggregated phases. The context template lists all phases and tasks together. The return uses the highest phase number as the `phase` field.
188
+
189
+ ---
190
+
191
+ ## Configuration
192
+
193
+ ### `.flowconfig` Setting
194
+
195
+ ```yaml
196
+ phase_isolation: true # Run phases in isolated sub-agents (default: true)
197
+ ```
198
+
199
+ - `true` (default): Each phase runs in an isolated Agent sub-agent
200
+ - `false`: Phases execute inline in the main session (legacy behavior, useful for debugging)
201
+
202
+ ### Interaction with Model Routing
203
+
204
+ Phase isolation **enhances** model routing — it doesn't replace it:
205
+
206
+ | Setting | Behavior |
207
+ |---------|----------|
208
+ | `model_routing: true` + `phase_isolation: true` | Sub-agent spawned with correct tier model AND clean context |
209
+ | `model_routing: true` + `phase_isolation: false` | Sub-agent spawned with correct tier model, inherits session context |
210
+ | `model_routing: false` + `phase_isolation: true` | Sub-agent spawned with session model, clean context |
211
+ | `model_routing: false` + `phase_isolation: false` | Inline execution, no sub-agents (original behavior) |
212
+
213
+ ---
214
+
215
+ ## Rules
216
+
217
+ 1. **Planning stays in session** — only implementation is isolated
218
+ 2. **Under 2K token prompts** — keep context focused, let sub-agent read files
219
+ 3. **JSON return only** — no markdown in the return, pure JSON
220
+ 4. **Coordinator validates** — check status field before proceeding
221
+ 5. **Never auto-retry** — on failure, present to user and ask
222
+ 6. **Pass paths, not content** — give file paths, sub-agent reads them
@@ -0,0 +1,105 @@
1
+
2
+ # Session Scratchpad
3
+
4
+ ## Purpose
5
+
6
+ The session scratchpad (`flow/.scratchpad.md`) is an ephemeral per-session file for raw notes, temporary analysis, and in-progress observations. It bridges the gap between transient session work and permanent artifacts (ledger, brain, memory).
7
+
8
+ **Core principle**: Write things down so they survive compaction; promote the valuable ones before session ends.
9
+
10
+ ---
11
+
12
+ ## Session Start Behavior
13
+
14
+ On session start:
15
+ 1. If `flow/.scratchpad.md` exists and has content, read it silently
16
+ 2. If entries look stale (from a previous session), scan for promotable items:
17
+ - Learnings → promote to `flow/ledger.md`
18
+ - Error patterns → promote to `flow/brain/errors/`
19
+ - Feature context → promote to `flow/brain/features/`
20
+ - User preferences → promote to `flow/ledger.md` (User Preferences section)
21
+ 3. After promotion, clear the file (reset to empty template)
22
+ 4. If the file is empty or doesn't exist, skip — no action needed
23
+
24
+ ---
25
+
26
+ ## Write Triggers
27
+
28
+ Write to the scratchpad when you encounter:
29
+
30
+ | Trigger | Example Entry |
31
+ |---------|---------------|
32
+ | **Non-obvious error resolution** | "Fixed ESM import issue — need `type: module` in package.json AND `moduleResolution: node16` in tsconfig" |
33
+ | **Architectural insight** | "This project uses barrel exports everywhere — new files need re-export in index.ts" |
34
+ | **Dead-end approach** | "Tried using `fs.watch` for file monitoring — unreliable on Linux, switched to chokidar" |
35
+ | **User preference discovered** | "User prefers terse responses, no trailing summaries" |
36
+ | **Open question** | "Need to verify: does the CI pipeline run on Node 18 or 20?" |
37
+ | **Mid-task context** | "Reviewing auth module — found 3 unused imports, will clean up after main task" |
38
+
39
+ ### What NOT to Write
40
+
41
+ - Routine file reads or grep results (re-readable)
42
+ - Build/test output (captured in logs)
43
+ - Things already captured by brain-capture blocks
44
+ - Obvious facts derivable from the code
45
+ - Full code snippets (reference file:line instead)
46
+
47
+ ---
48
+
49
+ ## File Format
50
+
51
+ ```markdown
52
+ # Session Scratchpad
53
+
54
+ ## Notes
55
+
56
+ - [{timestamp}] {note}
57
+ - [{timestamp}] {note}
58
+
59
+ ## Open Questions
60
+
61
+ - {question}
62
+
63
+ ## Promote Before Session End
64
+
65
+ - [ ] {item to promote} → {target: ledger/brain/memory}
66
+ ```
67
+
68
+ Keep under **50 lines**. When approaching the limit, promote older entries or discard low-value ones.
69
+
70
+ ---
71
+
72
+ ## Promotion Rules
73
+
74
+ Before session ends (or when the scratchpad is getting full):
75
+
76
+ 1. **Scan each entry** and classify:
77
+ - **Promote**: Valuable insight that should persist → move to appropriate target
78
+ - **Discard**: Transient note, already acted on, or no future value → delete
79
+ 2. **Promotion targets**:
80
+ | Content Type | Target | Section |
81
+ |-------------|--------|---------|
82
+ | Project learning / workaround | `flow/ledger.md` | What Works / What Didn't Work |
83
+ | User preference | `flow/ledger.md` | User Preferences |
84
+ | Error pattern | `flow/brain/errors/{name}.md` | New or updated entry |
85
+ | Feature context | `flow/brain/features/{name}.md` | Timeline update |
86
+ | Reusable pattern | `flow/resources/pending-patterns.md` | Pattern capture buffer |
87
+ 3. **After promotion**, clear the scratchpad (leave just the empty template headers)
88
+
89
+ ---
90
+
91
+ ## Compaction Integration
92
+
93
+ During `/compact`, the scratchpad is in the **preserve** list — its contents survive compaction summaries. This is critical because scratchpad notes often contain context that would otherwise be lost.
94
+
95
+ After compaction, the model should re-read `flow/.scratchpad.md` to restore any notes written before compaction.
96
+
97
+ ---
98
+
99
+ ## Rules
100
+
101
+ 1. **Lightweight writes** — single-line entries, not paragraphs
102
+ 2. **No duplication** — don't write what brain-capture already captures
103
+ 3. **Self-manage size** — promote or discard when approaching 50 lines
104
+ 4. **Promote before ending** — always scan for promotable items before session ends
105
+ 5. **Not a task list** — use `flow/tasklist.md` for tasks, scratchpad is for observations
@@ -23,6 +23,10 @@ Skills implement the workflow logic for commands. Each skill orchestrates a spec
23
23
  > **Note**: The review-code and review-pr skills include **Severity Re-Ranking**. After verification, findings are re-ranked by severity → confidence → fix complexity, related findings across files are grouped, and an executive summary is added when ≥ 5 findings. See `.claude/resources/core/review-severity-ranking.md` for full rules.
24
24
  >
25
25
  > **Note**: The review-code and review-pr skills include **Adaptive Depth**. Review depth scales automatically based on changeset size: < 50 lines → Lightweight (quick-scan), 50–500 → Standard (no change), 500+ → Deep (multi-pass with executive summary). See `.claude/resources/core/review-adaptive-depth.md` for full rules.
26
+ >
27
+ > **Note**: All long-running skills (execute-plan, review-code, discovery) support **Context Compaction**. When compacting mid-skill, load `.claude/resources/core/compaction-guide.md` for preserve/discard rules and the compact summary template. See `COR-CG-1` through `COR-CG-4`.
28
+ >
29
+ > **Note**: The discovery skill uses **Discovery Sub-Agents** for parallel codebase exploration. Three haiku sub-agents (similar features, API/data patterns, schema/types) run in parallel after reading referenced docs, returning condensed JSON findings merged into a Codebase Analysis section. See `.claude/resources/core/discovery-sub-agents.md` for full rules.
26
30
 
27
31
  ---
28
32
 
@@ -93,44 +97,68 @@ Skills implement the workflow logic for commands. Each skill orchestrates a spec
93
97
 
94
98
  | Code | Description | Source | Lines |
95
99
  |------|-------------|--------|-------|
96
- | SKL-EXEC-1 | Critical rules (build only at end, no DB commands) | execute-plan-skill.md | 22-95 |
97
- | SKL-EXEC-2 | Workflow steps 1-3 (parse, analyze complexity, present summary) | execute-plan-skill.md | 105-182 |
98
- | SKL-EXEC-3 | Workflow steps 4-5 (execute phases with Plan mode, update progress) | execute-plan-skill.md | 184-238 |
99
- | SKL-EXEC-4 | Workflow steps 6-7 (tests phase, completion/verification) | execute-plan-skill.md | 240-281 |
100
- | SKL-EXEC-5 | Complexity-based behavior (low, medium, high, very high) | execute-plan-skill.md | 303-332 |
101
- | SKL-EXEC-6 | Error handling (build failures, test failures, cancellation) | execute-plan-skill.md | 334-366 |
100
+ | SKL-EXEC-1 | Purpose and inputs | execute-plan-skill.md | 4-100 |
101
+ | SKL-EXEC-2 | Critical rules (build only at end, no DB commands) | execute-plan-skill.md | 18-92 |
102
+ | SKL-EXEC-3 | Step 1: Parse the plan | execute-plan-skill.md | 103-112 |
103
+ | SKL-EXEC-4 | Step 2: Analyze complexity and determine execution strategy | execute-plan-skill.md | 113-151 |
104
+ | SKL-EXEC-5 | Step 3: Present execution plan summary | execute-plan-skill.md | 152-180 |
105
+ | SKL-EXEC-6 | Step 4: Execute each phase with Plan mode | execute-plan-skill.md | 181-236 |
106
+ | SKL-EXEC-7 | Step 5: Update progress after each phase | execute-plan-skill.md | 237-249 |
107
+ | SKL-EXEC-8 | Step 5b: Phase-boundary context check (compaction) | execute-plan-skill.md | 250-275 |
108
+ | SKL-EXEC-9 | Step 6: Handle tests phase | execute-plan-skill.md | 277-302 |
109
+ | SKL-EXEC-10 | Step 7: Completion — build and test verification | execute-plan-skill.md | 303-364 |
110
+ | SKL-EXEC-11 | Complexity-based behavior (low, medium, high, very high) | execute-plan-skill.md | 365-393 |
111
+ | SKL-EXEC-12 | Error handling (build failures, test failures, cancellation) | execute-plan-skill.md | 395-427 |
102
112
 
103
113
  ### Review Code Skill (`review-code-skill.md`)
104
114
 
105
115
  | Code | Description | Source | Lines |
106
116
  |------|-------------|--------|-------|
107
- | SKL-REV-1 | Purpose and restrictions (read-only analysis) | review-code-skill.md | 8-58 |
108
- | SKL-REV-2 | Workflow steps 1-3 (identify files, load patterns, find similar) | review-code-skill.md | 72-130 |
109
- | SKL-REV-3 | Workflow steps 4-6 (analyze, pattern conflicts, generate doc) | review-code-skill.md | 131-180 |
110
- | SKL-REV-4 | Severity levels and conflict resolution | review-code-skill.md | 182-231 |
111
- | SKL-REV-5 | Finding similar implementations (search strategies) | review-code-skill.md | 233-259 |
117
+ | SKL-REV-1 | Purpose and restrictions (read-only, allowed actions) | review-code-skill.md | 4-58 |
118
+ | SKL-REV-2 | Step 1: Identify changed files | review-code-skill.md | 70-77 |
119
+ | SKL-REV-3 | Step 1b: Determine review depth (adaptive depth) | review-code-skill.md | 78-97 |
120
+ | SKL-REV-4 | Step 2: Load review patterns | review-code-skill.md | 98-107 |
121
+ | SKL-REV-5 | Step 3: Find similar implementations in codebase | review-code-skill.md | 108-146 |
122
+ | SKL-REV-6 | Step 4: Analyze code changes | review-code-skill.md | 147-158 |
123
+ | SKL-REV-7 | Step 5: Pattern conflicts + 5b verify + 5c re-rank | review-code-skill.md | 159-231 |
124
+ | SKL-REV-8 | Step 6: Generate review document | review-code-skill.md | 232-260 |
125
+ | SKL-REV-9 | Severity levels and conflict resolution | review-code-skill.md | 252-301 |
126
+ | SKL-REV-10 | Finding similar implementations (search strategies) | review-code-skill.md | 303-330 |
127
+ | SKL-REV-11 | Validation checklist | review-code-skill.md | 379-392 |
112
128
 
113
129
  ### Review PR Skill (`review-pr-skill.md`)
114
130
 
115
131
  | Code | Description | Source | Lines |
116
132
  |------|-------------|--------|-------|
117
- | SKL-PR-1 | Purpose and restrictions (GitHub/Azure DevOps commands) | review-pr-skill.md | 8-122 |
118
- | SKL-PR-2 | Workflow (authenticate, fetch, analyze, generate) | review-pr-skill.md | 132-217 |
119
- | SKL-PR-3 | Output format template with review history | review-pr-skill.md | 219-318 |
120
- | SKL-PR-4 | Severity levels and fix complexity scoring | review-pr-skill.md | 320-370 |
121
- | SKL-PR-5 | Link format for GitHub and Azure DevOps | review-pr-skill.md | 372-420 |
133
+ | SKL-PR-1 | Purpose and restrictions (read-only, GitHub/Azure DevOps) | review-pr-skill.md | 4-120 |
134
+ | SKL-PR-2 | Step 0: Authenticate for PR access | review-pr-skill.md | 132-158 |
135
+ | SKL-PR-3 | Step 1: Fetch PR information + 1b determine review depth | review-pr-skill.md | 159-184 |
136
+ | SKL-PR-4 | Step 2: Load review patterns | review-pr-skill.md | 185-194 |
137
+ | SKL-PR-5 | Step 3: Analyze code changes + 3b verify + 3c re-rank | review-pr-skill.md | 195-240 |
138
+ | SKL-PR-6 | Step 4: Generate or update review document | review-pr-skill.md | 241-320 |
139
+ | SKL-PR-7 | Output format template (findings, severity, recommendations) | review-pr-skill.md | 322-376 |
140
+ | SKL-PR-8 | Fix complexity scoring (scale, modifiers, examples) | review-pr-skill.md | 388-426 |
141
+ | SKL-PR-9 | Link format for GitHub and Azure DevOps | review-pr-skill.md | 428-477 |
142
+ | SKL-PR-10 | Example finding and quick reference commands | review-pr-skill.md | 479-552 |
122
143
 
123
144
  ### Setup Skill (`setup-skill.md`)
124
145
 
125
146
  | Code | Description | Source | Lines |
126
147
  |------|-------------|--------|-------|
127
- | SKL-SETUP-1 | Purpose and critical approach | setup-skill.md | 8-30 |
128
- | SKL-SETUP-2 | Steps 1-2 (scan project structure, dependency analysis) | setup-skill.md | 34-106 |
129
- | SKL-SETUP-3 | Step 3 (deep code analysis, sample files, extract patterns) | setup-skill.md | 108-200 |
130
- | SKL-SETUP-4 | Steps 4-5 (research best practices, check existing rules) | setup-skill.md | 202-252 |
131
- | SKL-SETUP-5 | Step 6 (confirming questions via Plan mode) | setup-skill.md | 254-334 |
132
- | SKL-SETUP-6 | Step 7 (generate framework and library pattern files) | setup-skill.md | 336-493 |
133
- | SKL-SETUP-7 | Steps 8-11 (update core, create analysis doc, create flow folder, summary) | setup-skill.md | 595-797 |
148
+ | SKL-SETUP-1 | Purpose and critical approach | setup-skill.md | 4-28 |
149
+ | SKL-SETUP-2 | Step 1: Scan project structure | setup-skill.md | 31-57 |
150
+ | SKL-SETUP-3 | Step 2: Deep dependency analysis | setup-skill.md | 58-103 |
151
+ | SKL-SETUP-4 | Step 3: Deep code analysis | setup-skill.md | 104-199 |
152
+ | SKL-SETUP-5 | Step 4: Research best practices | setup-skill.md | 200-222 |
153
+ | SKL-SETUP-6 | Step 5: Check existing rules | setup-skill.md | 223-249 |
154
+ | SKL-SETUP-7 | Step 6: Ask confirming questions (Plan mode) | setup-skill.md | 250-332 |
155
+ | SKL-SETUP-8 | Step 7: Generate pattern files (templates + examples) | setup-skill.md | 333-574 |
156
+ | SKL-SETUP-9 | Step 8: Update core pattern files | setup-skill.md | 575-605 |
157
+ | SKL-SETUP-10 | Step 9: Sync generic patterns to global brain | setup-skill.md | 606-654 |
158
+ | SKL-SETUP-11 | Step 10: Create project analysis document | setup-skill.md | 655-727 |
159
+ | SKL-SETUP-12 | Step 11: Index documentation files | setup-skill.md | 728-816 |
160
+ | SKL-SETUP-13 | Step 12: Create flow folder structure | setup-skill.md | 817-860 |
161
+ | SKL-SETUP-14 | Step 13: Present setup summary | setup-skill.md | 861-955 |
134
162
 
135
163
  ### Write Tests Skill (`write-tests-skill.md`)
136
164
 
@@ -159,26 +187,56 @@ Skills implement the workflow logic for commands. Each skill orchestrates a spec
159
187
 
160
188
  | Code | Expand When |
161
189
  |------|-------------|
162
- | SKL-EXEC-1 | Need critical rules (build timing, DB commands) |
163
- | SKL-EXEC-2 | Need complexity analysis and grouping logic |
164
- | SKL-EXEC-3 | Need phase execution workflow with Plan mode |
165
- | SKL-EXEC-5 | Need complexity-based behavior details |
190
+ | SKL-EXEC-2 | Need critical rules (build timing, DB commands) |
191
+ | SKL-EXEC-3 | Parsing plan file structure |
192
+ | SKL-EXEC-4 | Analyzing complexity and determining execution strategy |
193
+ | SKL-EXEC-5 | Presenting execution plan summary to user |
194
+ | SKL-EXEC-6 | Executing a phase with Plan mode |
195
+ | SKL-EXEC-7 | Updating progress after a phase |
196
+ | SKL-EXEC-8 | Compacting at phase boundaries |
197
+ | SKL-EXEC-9 | Handling the tests phase |
198
+ | SKL-EXEC-10 | Final build and test verification |
199
+ | SKL-EXEC-11 | Need complexity-based behavior details |
200
+ | SKL-EXEC-12 | Handling build/test failures or cancellation |
166
201
 
167
202
  ### Code Review
168
203
 
169
204
  | Code | Expand When |
170
205
  |------|-------------|
171
- | SKL-REV-2 | Need pattern loading and similar implementation search |
172
- | SKL-REV-4 | Need severity levels and conflict resolution |
173
- | SKL-PR-3 | Need PR review output template |
174
- | SKL-PR-5 | Need link format for GitHub/Azure DevOps |
206
+ | SKL-REV-2 | Identifying changed files for review |
207
+ | SKL-REV-3 | Determining review depth (adaptive) |
208
+ | SKL-REV-4 | Loading review patterns |
209
+ | SKL-REV-5 | Finding similar implementations in codebase |
210
+ | SKL-REV-6 | Analyzing code changes |
211
+ | SKL-REV-7 | Pattern conflicts, verification, and re-ranking |
212
+ | SKL-REV-8 | Generating the review document |
213
+ | SKL-REV-9 | Need severity levels and conflict resolution |
214
+ | SKL-REV-10 | Need search strategies for similar code |
215
+ | SKL-PR-2 | Authenticating for PR access |
216
+ | SKL-PR-3 | Fetching PR info and determining depth |
217
+ | SKL-PR-5 | Analyzing PR changes, verification, re-ranking |
218
+ | SKL-PR-6 | Generating PR review document |
219
+ | SKL-PR-7 | Need PR review output template |
220
+ | SKL-PR-8 | Need fix complexity scoring |
221
+ | SKL-PR-9 | Need link format for GitHub/Azure DevOps |
175
222
 
176
223
  ### Setup and Testing
177
224
 
178
225
  | Code | Expand When |
179
226
  |------|-------------|
180
- | SKL-SETUP-2 | Need dependency detection tables |
181
- | SKL-SETUP-6 | Need pattern file generation templates |
227
+ | SKL-SETUP-2 | Scanning project structure |
228
+ | SKL-SETUP-3 | Deep dependency analysis |
229
+ | SKL-SETUP-4 | Deep code analysis |
230
+ | SKL-SETUP-5 | Researching best practices |
231
+ | SKL-SETUP-6 | Checking existing rules |
232
+ | SKL-SETUP-7 | Asking confirming questions via Plan mode |
233
+ | SKL-SETUP-8 | Generating pattern files |
234
+ | SKL-SETUP-9 | Updating core pattern files |
235
+ | SKL-SETUP-10 | Syncing to global brain |
236
+ | SKL-SETUP-11 | Creating project analysis document |
237
+ | SKL-SETUP-12 | Indexing documentation files |
238
+ | SKL-SETUP-13 | Creating flow folder structure |
239
+ | SKL-SETUP-14 | Presenting setup summary |
182
240
  | SKL-TEST-2 | Need coverage analysis workflow |
183
241
  | SKL-TEST-4 | Need test writing guidelines |
184
242
 
@@ -201,10 +259,10 @@ Skills implement the workflow logic for commands. Each skill orchestrates a spec
201
259
  | `/learn` | learn-skill | SKL-LRN-1 through SKL-LRN-4 |
202
260
  | `/discovery-plan` | discovery-skill | SKL-DIS-1 through SKL-DIS-4 |
203
261
  | `/create-plan` | create-plan-skill | SKL-PLN-1 through SKL-PLN-4 |
204
- | `/execute-plan` | execute-plan-skill | SKL-EXEC-1 through SKL-EXEC-6 |
205
- | `/review-code` | review-code-skill | SKL-REV-1 through SKL-REV-5 |
206
- | `/review-pr` | review-pr-skill | SKL-PR-1 through SKL-PR-5 |
207
- | `/setup` | setup-skill | SKL-SETUP-1 through SKL-SETUP-7 |
262
+ | `/execute-plan` | execute-plan-skill | SKL-EXEC-1 through SKL-EXEC-12 |
263
+ | `/review-code` | review-code-skill | SKL-REV-1 through SKL-REV-11 |
264
+ | `/review-pr` | review-pr-skill | SKL-PR-1 through SKL-PR-10 |
265
+ | `/setup` | setup-skill | SKL-SETUP-1 through SKL-SETUP-14 |
208
266
  | `/write-tests` | write-tests-skill | SKL-TEST-1 through SKL-TEST-5 |
209
267
  | `/create-contract` | create-contract-skill | SKL-CON-1 through SKL-CON-4 |
210
268
 
@@ -214,10 +272,10 @@ Skills implement the workflow logic for commands. Each skill orchestrates a spec
214
272
 
215
273
  | Skill | Lines | Sections | Complexity |
216
274
  |-------|-------|----------|------------|
217
- | setup-skill | 821 | 7 | Highest - deep project analysis |
218
- | review-pr-skill | 496 | 5 | High - multi-platform support |
219
- | execute-plan-skill | 388 | 6 | High - phase execution logic |
220
- | review-code-skill | 308 | 5 | Medium - pattern matching |
275
+ | setup-skill | 955 | 14 | Highest - deep project analysis |
276
+ | review-pr-skill | 552 | 10 | High - multi-platform support |
277
+ | execute-plan-skill | 448 | 12 | High - phase execution logic |
278
+ | review-code-skill | 392 | 11 | Medium - pattern matching |
221
279
  | discovery-skill | 295 | 4 | Medium - requirements gathering |
222
280
  | brainstorm-skill | 280 | 3 | Medium - structured exploration with interactive questions |
223
281
  | write-tests-skill | 294 | 5 | Medium - iterative testing |
@@ -98,6 +98,47 @@ This skill is **strictly for gathering and documenting requirements**. The proce
98
98
 
99
99
  ---
100
100
 
101
+ ### Step 1b: Spawn Exploration Sub-Agents
102
+
103
+ After reading referenced documents, spawn three parallel Agent sub-agents to explore the codebase. These run in parallel and return condensed findings that inform the clarifying questions in Step 2.
104
+
105
+ **Actions**:
106
+
107
+ 1. **Prepare context summary**: Distill Step 1 findings into a brief context paragraph (feature name, key requirements, relevant technologies mentioned)
108
+ 2. **Spawn 3 sub-agents in parallel** using the Agent tool:
109
+ - **Similar Features** agent — finds existing code with related functionality
110
+ - **API/Data Patterns** agent — maps API endpoints, service patterns, data flow
111
+ - **Schema/Types** agent — explores type definitions, schemas, shared interfaces
112
+ 3. Each sub-agent uses `model: "haiku"` and `subagent_type: "Explore"`
113
+ 4. Each receives: feature name, context summary, and agent-specific exploration instructions
114
+
115
+ See `.claude/resources/core/discovery-sub-agents.md` for prompt templates, return format schema, and full agent definitions (`COR-DSA-1`).
116
+
117
+ **Spawning pattern**:
118
+ ```
119
+ Launch in parallel:
120
+ - Agent(model: "haiku", subagent_type: "Explore", prompt: similar_features_prompt)
121
+ - Agent(model: "haiku", subagent_type: "Explore", prompt: api_data_prompt)
122
+ - Agent(model: "haiku", subagent_type: "Explore", prompt: schema_types_prompt)
123
+ ```
124
+
125
+ ---
126
+
127
+ ### Step 1c: Collect and Merge Exploration Findings
128
+
129
+ After all sub-agents return, process their findings:
130
+
131
+ 1. **Parse returns**: Extract JSON from each sub-agent response
132
+ 2. **Handle failures**: If a sub-agent returns `status: "failure"` or invalid JSON, skip its findings and continue. Log the failure but do not block discovery.
133
+ 3. **Filter**: If more than 15 total findings, remove `relevance: "low"` entries
134
+ 4. **Merge patterns**: Collect all `patterns_noticed` entries, deduplicate, and append to `flow/resources/pending-patterns.md`
135
+ 5. **Build Codebase Analysis**: Format merged findings into a `## Codebase Analysis` section (see template in `COR-DSA-2`)
136
+ 6. **Inform Step 2**: Use findings to formulate better clarifying questions — reference specific existing code when asking about patterns to follow
137
+
138
+ If all sub-agents fail or return no findings, skip the Codebase Analysis section entirely. Discovery continues normally — findings are supplementary, not required.
139
+
140
+ ---
141
+
101
142
  ### Step 2: Ask Clarifying Questions
102
143
 
103
144
  Ask questions about gaps identified in documents and unclear requirements.
@@ -273,12 +314,15 @@ Create the discovery markdown file:
273
314
 
274
315
  1. Context
275
316
  2. Referenced Documents
276
- 3. Requirements Gathered (FR, NFR, Constraints)
277
- 4. Open Questions (all answered)
278
- 5. Technical Considerations
279
- 6. Proposed Approach
280
- 7. Risks and Unknowns
281
- 8. Next Steps
317
+ 3. Codebase Analysis (from Step 1c — omit if no findings)
318
+ 4. Requirements Gathered (FR, NFR, Constraints)
319
+ 5. Open Questions (all answered)
320
+ 6. Technical Considerations
321
+ 7. Proposed Approach
322
+ 8. Risks and Unknowns
323
+ 9. Next Steps
324
+
325
+ **Codebase Analysis**: Include the merged findings from Step 1c. Use the Codebase Analysis section format from `.claude/resources/core/discovery-sub-agents.md` (`COR-DSA-2`). Omit this section if all sub-agents failed or returned no findings.
282
326
 
283
327
  **Design Context**: If UI work was confirmed during questioning, append a `## Design Context` section to the discovery document using the template from `.claude/resources/core/design-awareness.md`. Populate with extracted tokens (from screenshots), personality defaults, or existing design system values.
284
328