planflow-ai 1.2.0 → 1.3.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/.claude/commands/brainstorm.md +228 -0
- package/.claude/commands/discovery-plan.md +25 -1
- package/.claude/commands/execute-plan.md +35 -0
- package/.claude/commands/flow.md +36 -3
- package/.claude/commands/review-code.md +10 -0
- package/.claude/resources/core/_index.md +37 -2
- package/.claude/resources/core/design-awareness.md +400 -0
- package/.claude/resources/core/model-routing.md +116 -0
- package/.claude/resources/core/pattern-capture.md +227 -0
- package/.claude/resources/patterns/_index.md +11 -1
- package/.claude/resources/patterns/brainstorm-templates.md +132 -0
- package/.claude/resources/patterns/discovery-templates.md +44 -0
- package/.claude/resources/skills/_index.md +28 -1
- package/.claude/resources/skills/brainstorm-skill.md +284 -0
- package/.claude/resources/skills/discovery-skill.md +38 -4
- package/.claude/resources/skills/execute-plan-skill.md +66 -4
- package/.claude/resources/skills/flow-cost.md +153 -0
- package/.claude/resources/skills/review-code-skill.md +16 -1
- package/.claude/rules/core/allowed-patterns.md +6 -0
- package/.claude/rules/core/forbidden-patterns.md +6 -0
- package/dist/cli/daemon/heartbeat-daemon.js +7 -2
- package/dist/cli/daemon/heartbeat-daemon.js.map +1 -1
- package/dist/cli/handlers/claude.d.ts.map +1 -1
- package/dist/cli/handlers/claude.js +130 -2
- package/dist/cli/handlers/claude.js.map +1 -1
- package/dist/cli/handlers/shared.d.ts.map +1 -1
- package/dist/cli/handlers/shared.js +2 -1
- package/dist/cli/handlers/shared.js.map +1 -1
- package/dist/cli/index.js +0 -0
- package/package.json +1 -1
- package/templates/shared/CLAUDE.md.template +27 -10
|
@@ -0,0 +1,400 @@
|
|
|
1
|
+
|
|
2
|
+
# Design Awareness
|
|
3
|
+
|
|
4
|
+
## Purpose
|
|
5
|
+
|
|
6
|
+
Makes plan-flow design-aware by capturing design context during `/discovery-plan` and injecting it into UI phases during `/execute-plan`. When a feature involves UI work, the discovery document is extended with a **Design Context** section containing structured design tokens (colors, typography, spacing, component patterns). During execution, those tokens are automatically prepended to UI phase prompts so implementations are consistent with the project's visual design.
|
|
7
|
+
|
|
8
|
+
**Scope**: `/discovery-plan` (capture) and `/execute-plan` (injection). Other skills are not affected.
|
|
9
|
+
|
|
10
|
+
**Plugin integration**: If `.interface-design/system.md` exists in the project root, offer to use the plugin's design system as the token source. If absent, use the built-in personality picker and token extraction described here — do NOT suggest installing the plugin.
|
|
11
|
+
|
|
12
|
+
---
|
|
13
|
+
|
|
14
|
+
## Design Context Section Template
|
|
15
|
+
|
|
16
|
+
When UI work is detected during discovery, append the following section to the discovery document after all other sections:
|
|
17
|
+
|
|
18
|
+
```markdown
|
|
19
|
+
## Design Context
|
|
20
|
+
|
|
21
|
+
### Design Personality
|
|
22
|
+
{personality name} — {brief description}
|
|
23
|
+
|
|
24
|
+
### Color Palette
|
|
25
|
+
| Token | Value | Usage |
|
|
26
|
+
|-------|-------|-------|
|
|
27
|
+
| Primary | #XXXXXX | Main actions, CTAs |
|
|
28
|
+
| Secondary | #XXXXXX | Supporting elements |
|
|
29
|
+
| Background | #XXXXXX | Page/card backgrounds |
|
|
30
|
+
| Surface | #XXXXXX | Elevated surfaces |
|
|
31
|
+
| Text Primary | #XXXXXX | Main body text |
|
|
32
|
+
| Text Secondary | #XXXXXX | Secondary/muted text |
|
|
33
|
+
| Error | #XXXXXX | Error states |
|
|
34
|
+
| Success | #XXXXXX | Success states |
|
|
35
|
+
|
|
36
|
+
### Typography
|
|
37
|
+
| Element | Font | Size | Weight |
|
|
38
|
+
|---------|------|------|--------|
|
|
39
|
+
| Heading 1 | {font} | {size} | {weight} |
|
|
40
|
+
| Heading 2 | {font} | {size} | {weight} |
|
|
41
|
+
| Body | {font} | {size} | {weight} |
|
|
42
|
+
| Caption | {font} | {size} | {weight} |
|
|
43
|
+
|
|
44
|
+
### Spacing Scale
|
|
45
|
+
| Token | Value |
|
|
46
|
+
|-------|-------|
|
|
47
|
+
| xs | {value} |
|
|
48
|
+
| sm | {value} |
|
|
49
|
+
| md | {value} |
|
|
50
|
+
| lg | {value} |
|
|
51
|
+
| xl | {value} |
|
|
52
|
+
|
|
53
|
+
### Component Patterns
|
|
54
|
+
- {Pattern 1}: {description}
|
|
55
|
+
- {Pattern 2}: {description}
|
|
56
|
+
|
|
57
|
+
### Design Source
|
|
58
|
+
- **Source**: {screenshots / Figma export / design personality / existing system.md}
|
|
59
|
+
- **Files**: {list of provided design files, if any}
|
|
60
|
+
```
|
|
61
|
+
|
|
62
|
+
**Filling in the template**: Use the Token Extraction Rules (Section 4) when the source is screenshots. Use the Design Personalities (Section 3) when no existing design is provided. Use the plugin's `system.md` when the Interface Design plugin is detected.
|
|
63
|
+
|
|
64
|
+
---
|
|
65
|
+
|
|
66
|
+
## Design Personalities
|
|
67
|
+
|
|
68
|
+
Six built-in personalities cover the most common UI directions. Each provides default token values to seed the Design Context template when no existing design is available.
|
|
69
|
+
|
|
70
|
+
---
|
|
71
|
+
|
|
72
|
+
### 1. Stark
|
|
73
|
+
|
|
74
|
+
**Character**: Clean, minimal, high-contrast. Think Apple / Stripe. Monochrome palette with a single accent color. Generous whitespace, sharp edges (0–4px radius), system fonts.
|
|
75
|
+
|
|
76
|
+
| Token | Default Value |
|
|
77
|
+
|-------|--------------|
|
|
78
|
+
| Primary | #0066FF |
|
|
79
|
+
| Secondary | #666666 |
|
|
80
|
+
| Background | #FFFFFF |
|
|
81
|
+
| Surface | #F5F5F5 |
|
|
82
|
+
| Text Primary | #111111 |
|
|
83
|
+
| Text Secondary | #666666 |
|
|
84
|
+
| Error | #FF3B30 |
|
|
85
|
+
| Success | #34C759 |
|
|
86
|
+
|
|
87
|
+
**Typography**: System UI stack (`-apple-system, BlinkMacSystemFont, "Segoe UI"`) — Heading 1: 32px/700, Heading 2: 24px/600, Body: 16px/400, Caption: 12px/400.
|
|
88
|
+
|
|
89
|
+
**Spacing**: xs=4px, sm=8px, md=16px, lg=32px, xl=64px.
|
|
90
|
+
|
|
91
|
+
---
|
|
92
|
+
|
|
93
|
+
### 2. Aura
|
|
94
|
+
|
|
95
|
+
**Character**: Warm, organic, approachable. Think Notion / Linear. Soft shadows, rounded corners (8–12px), warm neutrals, friendly sans-serif fonts.
|
|
96
|
+
|
|
97
|
+
| Token | Default Value |
|
|
98
|
+
|-------|--------------|
|
|
99
|
+
| Primary | #5B6AF0 |
|
|
100
|
+
| Secondary | #B8BAC8 |
|
|
101
|
+
| Background | #FAFAF8 |
|
|
102
|
+
| Surface | #FFFFFF |
|
|
103
|
+
| Text Primary | #1A1A2E |
|
|
104
|
+
| Text Secondary | #6B7280 |
|
|
105
|
+
| Error | #EF4444 |
|
|
106
|
+
| Success | #10B981 |
|
|
107
|
+
|
|
108
|
+
**Typography**: Inter — Heading 1: 30px/700, Heading 2: 22px/600, Body: 15px/400, Caption: 13px/400. Line-height 1.6 on body.
|
|
109
|
+
|
|
110
|
+
**Spacing**: xs=4px, sm=8px, md=16px, lg=24px, xl=48px.
|
|
111
|
+
|
|
112
|
+
---
|
|
113
|
+
|
|
114
|
+
### 3. Neo
|
|
115
|
+
|
|
116
|
+
**Character**: Bold, vibrant, modern. Think Vercel / Figma. Dark backgrounds, saturated accent colors, geometric shapes, tight spacing.
|
|
117
|
+
|
|
118
|
+
| Token | Default Value |
|
|
119
|
+
|-------|--------------|
|
|
120
|
+
| Primary | #7C3AED |
|
|
121
|
+
| Secondary | #06B6D4 |
|
|
122
|
+
| Background | #0A0A0A |
|
|
123
|
+
| Surface | #18181B |
|
|
124
|
+
| Text Primary | #FAFAFA |
|
|
125
|
+
| Text Secondary | #A1A1AA |
|
|
126
|
+
| Error | #F87171 |
|
|
127
|
+
| Success | #4ADE80 |
|
|
128
|
+
|
|
129
|
+
**Typography**: Inter or Geist — Heading 1: 36px/800, Heading 2: 24px/700, Body: 14px/400, Caption: 12px/400. Tight tracking on headings (−0.02em).
|
|
130
|
+
|
|
131
|
+
**Spacing**: xs=2px, sm=6px, md=12px, lg=24px, xl=48px.
|
|
132
|
+
|
|
133
|
+
---
|
|
134
|
+
|
|
135
|
+
### 4. Zen
|
|
136
|
+
|
|
137
|
+
**Character**: Calm, balanced, content-first. Think Medium / iA Writer. Neutral palette, serif for headings, generous line-height, minimal decoration.
|
|
138
|
+
|
|
139
|
+
| Token | Default Value |
|
|
140
|
+
|-------|--------------|
|
|
141
|
+
| Primary | #2563EB |
|
|
142
|
+
| Secondary | #9CA3AF |
|
|
143
|
+
| Background | #FFFFFF |
|
|
144
|
+
| Surface | #F9FAFB |
|
|
145
|
+
| Text Primary | #111827 |
|
|
146
|
+
| Text Secondary | #6B7280 |
|
|
147
|
+
| Error | #DC2626 |
|
|
148
|
+
| Success | #16A34A |
|
|
149
|
+
|
|
150
|
+
**Typography**: Headings in Georgia or Lora (serif), body in `ui-sans-serif` — Heading 1: 34px/700, Heading 2: 26px/600, Body: 18px/400, Caption: 14px/400. Line-height 1.75 on body.
|
|
151
|
+
|
|
152
|
+
**Spacing**: xs=4px, sm=8px, md=20px, lg=40px, xl=80px.
|
|
153
|
+
|
|
154
|
+
---
|
|
155
|
+
|
|
156
|
+
### 5. Flux
|
|
157
|
+
|
|
158
|
+
**Character**: Dynamic, playful, expressive. Think Spotify / Discord. Gradients, bold typography, dark mode by default, vibrant accent pops.
|
|
159
|
+
|
|
160
|
+
| Token | Default Value |
|
|
161
|
+
|-------|--------------|
|
|
162
|
+
| Primary | #FF6B6B |
|
|
163
|
+
| Secondary | #4ECDC4 |
|
|
164
|
+
| Background | #1A1A2E |
|
|
165
|
+
| Surface | #16213E |
|
|
166
|
+
| Text Primary | #EAEAEA |
|
|
167
|
+
| Text Secondary | #A8A8B3 |
|
|
168
|
+
| Error | #FF6B6B |
|
|
169
|
+
| Success | #4ECDC4 |
|
|
170
|
+
|
|
171
|
+
**Typography**: Plus Jakarta Sans or Nunito — Heading 1: 40px/800, Heading 2: 28px/700, Body: 16px/400, Caption: 13px/400. Tracking: 0.01em on headings.
|
|
172
|
+
|
|
173
|
+
**Spacing**: xs=4px, sm=8px, md=16px, lg=32px, xl=64px.
|
|
174
|
+
|
|
175
|
+
---
|
|
176
|
+
|
|
177
|
+
### 6. Terra
|
|
178
|
+
|
|
179
|
+
**Character**: Grounded, professional, trustworthy. Think GitHub / Basecamp. Muted earth tones, clear hierarchy, functional over decorative.
|
|
180
|
+
|
|
181
|
+
| Token | Default Value |
|
|
182
|
+
|-------|--------------|
|
|
183
|
+
| Primary | #347D39 |
|
|
184
|
+
| Secondary | #6E7781 |
|
|
185
|
+
| Background | #FFFFFF |
|
|
186
|
+
| Surface | #F6F8FA |
|
|
187
|
+
| Text Primary | #24292F |
|
|
188
|
+
| Text Secondary | #57606A |
|
|
189
|
+
| Error | #CF222E |
|
|
190
|
+
| Success | #2DA44E |
|
|
191
|
+
|
|
192
|
+
**Typography**: `-apple-system` or Roboto — Heading 1: 28px/600, Heading 2: 20px/600, Body: 14px/400, Caption: 12px/400. Line-height 1.5 on body.
|
|
193
|
+
|
|
194
|
+
**Spacing**: xs=4px, sm=8px, md=16px, lg=24px, xl=40px.
|
|
195
|
+
|
|
196
|
+
---
|
|
197
|
+
|
|
198
|
+
## Token Extraction Rules
|
|
199
|
+
|
|
200
|
+
When the user provides screenshots, Figma exports, or any visual design artifact, extract structured tokens using the following process:
|
|
201
|
+
|
|
202
|
+
### Color Extraction
|
|
203
|
+
|
|
204
|
+
1. **Primary**: The most prominent interactive color — buttons, links, active states
|
|
205
|
+
2. **Secondary**: Supporting color — secondary buttons, tags, less prominent accents
|
|
206
|
+
3. **Background**: The base page/app background (typically the largest area)
|
|
207
|
+
4. **Surface**: Elevated elements — cards, modals, sidebars (often slightly different from Background)
|
|
208
|
+
5. **Text Primary**: The main body text color
|
|
209
|
+
6. **Text Secondary**: Muted/caption text color
|
|
210
|
+
7. **Error**: Red-family color used in error messages or destructive actions
|
|
211
|
+
8. **Success**: Green-family color used in confirmations or success states
|
|
212
|
+
|
|
213
|
+
**Confidence notes**: When a value is estimated (not pixel-sampled), append `*` to the hex value and add a note: `*estimated from screenshot`.
|
|
214
|
+
|
|
215
|
+
### Typography Extraction
|
|
216
|
+
|
|
217
|
+
1. Identify visible font families (check for recognizable typefaces — Inter, Roboto, SF Pro, etc.)
|
|
218
|
+
2. If the font cannot be identified with confidence, describe the style: `"clean sans-serif (likely Inter or similar)"`
|
|
219
|
+
3. Estimate size in px based on visual hierarchy (H1 typically 28–40px, Body 14–18px)
|
|
220
|
+
4. Identify weight from stroke thickness (400=regular, 600=semibold, 700=bold, 800=extrabold)
|
|
221
|
+
|
|
222
|
+
### Spacing Extraction
|
|
223
|
+
|
|
224
|
+
1. Estimate the base grid unit from gaps between elements (4px, 8px, or 12px are most common)
|
|
225
|
+
2. Describe density: tight (base=4px), normal (base=8px), generous (base=16px)
|
|
226
|
+
3. Map to scale: `xs = 1×base`, `sm = 2×base`, `md = 4×base`, `lg = 8×base`, `xl = 16×base`
|
|
227
|
+
|
|
228
|
+
### Component Pattern Extraction
|
|
229
|
+
|
|
230
|
+
Identify recurring visual patterns present in the design:
|
|
231
|
+
- Card style (flat, elevated, bordered, ghost)
|
|
232
|
+
- Button style (rounded/pill, sharp, outlined, filled)
|
|
233
|
+
- Input style (underline, outlined, filled)
|
|
234
|
+
- Navigation style (top bar, sidebar, bottom tabs)
|
|
235
|
+
- Data presentation (tables, list rows, tiles, kanban)
|
|
236
|
+
|
|
237
|
+
### Output Format
|
|
238
|
+
|
|
239
|
+
Always output extracted tokens using the **Design Context Section Template** (Section 2). Never output raw color lists without the table structure. Add a confidence note at the end of the Design Context block when values are estimated:
|
|
240
|
+
|
|
241
|
+
```markdown
|
|
242
|
+
> **Note**: Token values marked `*` are estimated from visual inspection of screenshots, not pixel-sampled. Adjust to match your exact design specs.
|
|
243
|
+
```
|
|
244
|
+
|
|
245
|
+
---
|
|
246
|
+
|
|
247
|
+
## UI Phase Detection Heuristics
|
|
248
|
+
|
|
249
|
+
Used by `/execute-plan` to determine whether to inject Design Context into a phase prompt.
|
|
250
|
+
|
|
251
|
+
### Phase Name Keywords
|
|
252
|
+
|
|
253
|
+
A phase involves UI work if its name contains any of:
|
|
254
|
+
|
|
255
|
+
`component`, `page`, `UI`, `layout`, `form`, `modal`, `dialog`, `sidebar`, `navigation`, `header`, `footer`, `dashboard`, `widget`, `view`, `screen`, `frontend`, `interface`, `button`, `card`, `table`, `list`, `menu`, `panel`, `toolbar`, `tooltip`, `popup`, `dropdown`, `tab`, `accordion`, `carousel`, `toast`, `notification`, `badge`, `avatar`, `icon`
|
|
256
|
+
|
|
257
|
+
### Task Description Keywords
|
|
258
|
+
|
|
259
|
+
A phase involves UI work if any task description contains any of:
|
|
260
|
+
|
|
261
|
+
`create component`, `build page`, `implement view`, `style`, `CSS`, `responsive`, `layout`, `render`, `display`, `user interface`
|
|
262
|
+
|
|
263
|
+
### Injection Rule
|
|
264
|
+
|
|
265
|
+
> If ANY keyword appears in the phase name **OR** ANY task description within the phase, inject the Design Context. If neither condition matches, skip injection — no overhead, no noise.
|
|
266
|
+
|
|
267
|
+
Matching is case-insensitive.
|
|
268
|
+
|
|
269
|
+
---
|
|
270
|
+
|
|
271
|
+
## Discovery Question Flow
|
|
272
|
+
|
|
273
|
+
Add design awareness questions to the standard discovery question sequence. Ask **Question 1** for every feature; only ask subsequent questions if the answer indicates UI work.
|
|
274
|
+
|
|
275
|
+
### Question 1 — UI Detection (always ask)
|
|
276
|
+
|
|
277
|
+
> "Does this feature involve any UI or visual interface work?"
|
|
278
|
+
|
|
279
|
+
| Option | Value |
|
|
280
|
+
|--------|-------|
|
|
281
|
+
| Yes — has UI components *(Recommended if unclear)* | → proceed to Question Batch 2 |
|
|
282
|
+
| No — backend/infrastructure only | → skip design questions entirely |
|
|
283
|
+
| Partially — minor UI changes | → proceed to Question Batch 2 |
|
|
284
|
+
|
|
285
|
+
---
|
|
286
|
+
|
|
287
|
+
### Question Batch 2 — Design Source (ask when Q1 = Yes or Partially)
|
|
288
|
+
|
|
289
|
+
Ask these questions together or in sequence as appropriate for the tool:
|
|
290
|
+
|
|
291
|
+
**Q2a — Existing design?**
|
|
292
|
+
|
|
293
|
+
> "Do you have an existing design to follow?"
|
|
294
|
+
|
|
295
|
+
| Option | Next Step |
|
|
296
|
+
|--------|-----------|
|
|
297
|
+
| Yes — I have screenshots/mockups *(Recommended)* | Ask user to share files; use Token Extraction Rules |
|
|
298
|
+
| Yes — existing design system in project | Read project design files (e.g., `tokens.ts`, `theme.ts`, `system.md`); extract tokens |
|
|
299
|
+
| No — need to establish design direction | Ask Q2b (personality picker) |
|
|
300
|
+
|
|
301
|
+
---
|
|
302
|
+
|
|
303
|
+
**Q2b — Design personality** (only when no existing design)
|
|
304
|
+
|
|
305
|
+
> "What design personality fits this feature?"
|
|
306
|
+
|
|
307
|
+
| Option | Personality |
|
|
308
|
+
|--------|------------|
|
|
309
|
+
| Stark — Clean & minimal *(Recommended)* | Section 3.1 defaults |
|
|
310
|
+
| Aura — Warm & approachable | Section 3.2 defaults |
|
|
311
|
+
| Neo — Bold & modern | Section 3.3 defaults |
|
|
312
|
+
| Zen — Calm & content-first | Section 3.4 defaults |
|
|
313
|
+
| Other (Flux / Terra / describe your own) | Section 3.5–3.6 defaults, or prompt for description |
|
|
314
|
+
|
|
315
|
+
---
|
|
316
|
+
|
|
317
|
+
**Q2c — Primary layout pattern** (always ask when Q1 = Yes or Partially)
|
|
318
|
+
|
|
319
|
+
> "What's the primary layout pattern for this feature?"
|
|
320
|
+
|
|
321
|
+
| Option | Component Patterns hint |
|
|
322
|
+
|--------|------------------------|
|
|
323
|
+
| Dashboard with cards/panels *(Recommended)* | Cards (elevated), stat widgets, grid layout |
|
|
324
|
+
| Content page with sidebar | Sidebar nav, content area, breadcrumbs |
|
|
325
|
+
| Form-heavy workflow | Input fields, validation states, multi-step |
|
|
326
|
+
| Data table/list view | Table rows, sort/filter controls, pagination |
|
|
327
|
+
|
|
328
|
+
---
|
|
329
|
+
|
|
330
|
+
### After Gathering Answers
|
|
331
|
+
|
|
332
|
+
1. **Screenshots provided**: Run Token Extraction (Section 4) → populate Design Context template → append to discovery doc
|
|
333
|
+
2. **Personality selected**: Use personality defaults (Section 3) as starting values → populate Design Context template → append to discovery doc
|
|
334
|
+
3. **Existing design system found**: Parse project design files → map to Design Context tokens → append to discovery doc
|
|
335
|
+
4. **Plugin detected** (`.interface-design/system.md` exists): Offer to use it as source; if accepted, read and map to Design Context template
|
|
336
|
+
|
|
337
|
+
---
|
|
338
|
+
|
|
339
|
+
## Execution Injection Rules
|
|
340
|
+
|
|
341
|
+
How `/execute-plan` uses the Design Context section from a discovery document.
|
|
342
|
+
|
|
343
|
+
### Step-by-Step Injection
|
|
344
|
+
|
|
345
|
+
At each phase boundary (Step 4 of the execute-plan skill):
|
|
346
|
+
|
|
347
|
+
1. **Locate the discovery doc**: Read the plan's "Based on Discovery" field to find the discovery document path
|
|
348
|
+
2. **Check for Design Context**: Scan the discovery doc for a `## Design Context` section
|
|
349
|
+
3. **Check phase relevance**: Apply UI Phase Detection Heuristics (Section 5) to the current phase name and task list
|
|
350
|
+
4. **Inject if both conditions met**:
|
|
351
|
+
- Prepend the full `## Design Context` section content to the phase implementation prompt
|
|
352
|
+
- Add the following instruction header before the Design Context block:
|
|
353
|
+
|
|
354
|
+
```
|
|
355
|
+
## Design Tokens (apply to all UI in this phase)
|
|
356
|
+
|
|
357
|
+
Follow these design tokens when implementing UI elements.
|
|
358
|
+
Use the exact color values, typography, and spacing from the Design Context.
|
|
359
|
+
Do not introduce colors, fonts, or spacing values outside this system.
|
|
360
|
+
```
|
|
361
|
+
- Add to the phase Rules Checklist: `- [ ] Following design tokens from Design Context`
|
|
362
|
+
|
|
363
|
+
5. **Skip if phase is not UI-related**: If heuristics return no match, do not inject Design Context. No message, no overhead.
|
|
364
|
+
6. **Skip if no Design Context exists**: If the discovery doc has no `## Design Context` section, proceed normally without injection.
|
|
365
|
+
|
|
366
|
+
### Injection Position in Phase Prompt
|
|
367
|
+
|
|
368
|
+
```
|
|
369
|
+
[Design Tokens block — if UI phase]
|
|
370
|
+
[Phase title and objective]
|
|
371
|
+
[Tasks list]
|
|
372
|
+
[Files to create/modify]
|
|
373
|
+
[Rules checklist]
|
|
374
|
+
[Context from previous phases]
|
|
375
|
+
```
|
|
376
|
+
|
|
377
|
+
The Design Tokens block comes first so the model internalizes constraints before reading the task list.
|
|
378
|
+
|
|
379
|
+
---
|
|
380
|
+
|
|
381
|
+
## Plugin Detection and Fallback
|
|
382
|
+
|
|
383
|
+
| Condition | Behavior |
|
|
384
|
+
|-----------|----------|
|
|
385
|
+
| `.interface-design/system.md` **found** in project root | Offer it as a token source option during Q2a. If accepted, read the file and map its tokens to the Design Context template. |
|
|
386
|
+
| `.interface-design/system.md` **not found** | Use built-in design awareness (personality picker + token extraction). Do NOT suggest installing the plugin. |
|
|
387
|
+
|
|
388
|
+
The built-in fallback produces the same `## Design Context` template structure as the plugin path. The plugin adds richer tooling and persistent design files; the built-in path is sufficient for feature-level design awareness.
|
|
389
|
+
|
|
390
|
+
---
|
|
391
|
+
|
|
392
|
+
## Related Files
|
|
393
|
+
|
|
394
|
+
| File | Purpose |
|
|
395
|
+
|------|---------|
|
|
396
|
+
| `.claude/resources/skills/discovery-plan-skill.md` | Discovery workflow where design questions are asked |
|
|
397
|
+
| `.claude/resources/skills/execute-plan-skill.md` | Phase execution workflow where injection happens |
|
|
398
|
+
| `.claude/resources/core/complexity-scoring.md` | Phase complexity model referenced by execute-plan |
|
|
399
|
+
| `.claude/commands/discovery-plan.md` | Discovery command definition |
|
|
400
|
+
| `.claude/commands/execute-plan.md` | Execute-plan command definition |
|
|
@@ -0,0 +1,116 @@
|
|
|
1
|
+
|
|
2
|
+
# Model Routing
|
|
3
|
+
|
|
4
|
+
## Purpose
|
|
5
|
+
|
|
6
|
+
Automatic model selection at phase boundaries during `/execute-plan`. Each phase is routed to the most cost-effective model tier based on its complexity score, using the Agent tool's `model` parameter to spawn implementation subagents.
|
|
7
|
+
|
|
8
|
+
**Scope**: `/execute-plan` only. Other skills (discovery, review, brainstorm) do not have pre-defined complexity scores and are not routed.
|
|
9
|
+
|
|
10
|
+
**Config**: Controlled by `model_routing` key in `flow/.flowconfig` (default: `true`). Set `model_routing: false` to disable.
|
|
11
|
+
|
|
12
|
+
---
|
|
13
|
+
|
|
14
|
+
## Model Tiers
|
|
15
|
+
|
|
16
|
+
| Tier | Complexity Score | Description | When to Use |
|
|
17
|
+
|------|-----------------|-------------|-------------|
|
|
18
|
+
| **Fast** | 0-3 | Trivial/low tasks: type aliases, config changes, boilerplate, simple wiring | Mechanical changes following clear patterns |
|
|
19
|
+
| **Standard** | 4-5 | Medium tasks: moderate logic, straightforward implementation with some decisions | Standard implementation work |
|
|
20
|
+
| **Powerful** | 6-10 | High/complex tasks: multi-file coordination, architectural decisions, complex logic | Tasks requiring deep reasoning or careful design |
|
|
21
|
+
|
|
22
|
+
---
|
|
23
|
+
|
|
24
|
+
## Platform Mappings
|
|
25
|
+
|
|
26
|
+
| Tier | Claude Code | Codex (OpenAI) | Cursor |
|
|
27
|
+
|------|------------|----------------|--------|
|
|
28
|
+
| Fast | `haiku` | `gpt-4.1-mini` | auto (fast) |
|
|
29
|
+
| Standard | `sonnet` | `gpt-4.1` | auto (normal) |
|
|
30
|
+
| Powerful | `opus` | `o3` | auto (max) |
|
|
31
|
+
|
|
32
|
+
**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
|
+
|
|
34
|
+
---
|
|
35
|
+
|
|
36
|
+
## Routing Rules
|
|
37
|
+
|
|
38
|
+
### At Each Phase Boundary
|
|
39
|
+
|
|
40
|
+
1. **Check config**: Read `model_routing` from `flow/.flowconfig`. If `false` or missing key, skip routing (use session default).
|
|
41
|
+
2. **Read complexity**: Get the phase's complexity score from the plan file.
|
|
42
|
+
3. **Look up tier**: Map score to tier using the table above.
|
|
43
|
+
4. **Spawn subagent**: Use the Agent tool with `model={tier_model}` to implement the phase.
|
|
44
|
+
|
|
45
|
+
### Agent Tool Usage
|
|
46
|
+
|
|
47
|
+
```
|
|
48
|
+
Agent tool call:
|
|
49
|
+
model: "haiku" | "sonnet" | "opus"
|
|
50
|
+
prompt: [comprehensive phase context — see below]
|
|
51
|
+
```
|
|
52
|
+
|
|
53
|
+
**Required context in Agent prompt**:
|
|
54
|
+
- Plan file path and current phase details (scope, tasks, approach)
|
|
55
|
+
- List of files modified in previous phases
|
|
56
|
+
- Key project patterns and constraints
|
|
57
|
+
- Reference to allowed/forbidden patterns
|
|
58
|
+
|
|
59
|
+
### Plan Mode Exception
|
|
60
|
+
|
|
61
|
+
The **planning step** (Phase presentation → user approval) always uses the current session model. Only the **implementation step** gets routed to the tier model. Planning is lightweight and benefits from the session model's full context.
|
|
62
|
+
|
|
63
|
+
---
|
|
64
|
+
|
|
65
|
+
## Aggregation Behavior
|
|
66
|
+
|
|
67
|
+
When multiple phases are aggregated (combined complexity <= 6):
|
|
68
|
+
|
|
69
|
+
- Use the **highest individual phase complexity** to determine the model tier
|
|
70
|
+
- Example: Phase 1 (complexity 2) + Phase 2 (complexity 3) aggregated → highest is 3 → Fast tier (haiku)
|
|
71
|
+
- Example: Phase 3 (complexity 3) + Phase 4 (complexity 5) aggregated → highest is 5 → Standard tier (sonnet)
|
|
72
|
+
|
|
73
|
+
**Rationale**: The aggregated group is only as easy as its hardest phase. Routing to a weaker model than the hardest phase could cause failures.
|
|
74
|
+
|
|
75
|
+
---
|
|
76
|
+
|
|
77
|
+
## Cost Impact
|
|
78
|
+
|
|
79
|
+
Assuming a typical 6-phase plan with mixed complexity:
|
|
80
|
+
|
|
81
|
+
| Phase Type | Count | Without Routing | With Routing | Savings |
|
|
82
|
+
|-----------|-------|----------------|--------------|---------|
|
|
83
|
+
| Trivial (0-3) | 2 | opus ($15/$75) | haiku ($0.80/$4) | ~95% |
|
|
84
|
+
| Medium (4-5) | 2 | opus ($15/$75) | sonnet ($3/$15) | ~80% |
|
|
85
|
+
| Complex (6+) | 2 | opus ($15/$75) | opus ($15/$75) | 0% |
|
|
86
|
+
|
|
87
|
+
**Estimated overall cost reduction**: 50-70% per plan execution.
|
|
88
|
+
|
|
89
|
+
---
|
|
90
|
+
|
|
91
|
+
## Execution Summary Format
|
|
92
|
+
|
|
93
|
+
After all phases complete, include model routing info in the completion summary:
|
|
94
|
+
|
|
95
|
+
```markdown
|
|
96
|
+
| Phase | Complexity | Model | Status |
|
|
97
|
+
|-------|-----------|-------|--------|
|
|
98
|
+
| 1. Setup types | 2/10 | haiku | Done |
|
|
99
|
+
| 2. Core logic | 5/10 | sonnet | Done |
|
|
100
|
+
| 3. Integration | 7/10 | opus | Done |
|
|
101
|
+
| 4. Tests | 4/10 | sonnet | Done |
|
|
102
|
+
|
|
103
|
+
**Model routing**: Saved ~65% vs all-opus execution
|
|
104
|
+
```
|
|
105
|
+
|
|
106
|
+
---
|
|
107
|
+
|
|
108
|
+
## Related Files
|
|
109
|
+
|
|
110
|
+
| File | Purpose |
|
|
111
|
+
|------|---------|
|
|
112
|
+
| `.claude/resources/core/complexity-scoring.md` | Scoring system that drives routing |
|
|
113
|
+
| `.claude/resources/skills/execute-plan-skill.md` | Phase execution workflow with routing injection |
|
|
114
|
+
| `.claude/commands/execute-plan.md` | Command-level routing documentation |
|
|
115
|
+
| `.claude/commands/flow.md` | `model_routing` config setting |
|
|
116
|
+
| `flow/.flowconfig` | Runtime config with `model_routing` key |
|