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,284 @@
|
|
|
1
|
+
|
|
2
|
+
# Brainstorm Skill
|
|
3
|
+
|
|
4
|
+
## Purpose
|
|
5
|
+
|
|
6
|
+
Facilitate a **free-form, conversational exploration** of an idea through collaborative dialogue. The LLM acts as a sharp coworker at a whiteboard — asking one question at a time, challenging assumptions, suggesting angles, and silently tracking the emerging structure.
|
|
7
|
+
|
|
8
|
+
This skill is the **pre-discovery phase** — pure ideation before requirements formalization. It does NOT:
|
|
9
|
+
|
|
10
|
+
- Write any source code
|
|
11
|
+
- Modify any source files
|
|
12
|
+
- Create implementation plans
|
|
13
|
+
- Execute any implementation
|
|
14
|
+
- Scan the codebase (unless user explicitly asks)
|
|
15
|
+
- Write to `flow/brain/` or `flow/memory.md`
|
|
16
|
+
- Automatically update `flow/tasklist.md`
|
|
17
|
+
|
|
18
|
+
---
|
|
19
|
+
|
|
20
|
+
## Restrictions
|
|
21
|
+
|
|
22
|
+
### Allowed Actions
|
|
23
|
+
|
|
24
|
+
| Action | Purpose |
|
|
25
|
+
|--------|---------|
|
|
26
|
+
| Conversational dialogue | Core brainstorm interaction |
|
|
27
|
+
| Read codebase files | **Only when user explicitly asks** (e.g., "check how X works") |
|
|
28
|
+
| Write to `flow/brainstorms/` | Save brainstorm output document |
|
|
29
|
+
| Read `flow/brainstorms/` | Check for existing brainstorms on same topic |
|
|
30
|
+
| Edit `flow/tasklist.md` | **Only when user explicitly requests** at the end |
|
|
31
|
+
|
|
32
|
+
### Forbidden Actions
|
|
33
|
+
|
|
34
|
+
| Action | Reason |
|
|
35
|
+
|--------|--------|
|
|
36
|
+
| Write source code | Brainstorm is ideation only |
|
|
37
|
+
| Write to `flow/brain/` | No brain integration |
|
|
38
|
+
| Write to `flow/memory.md` | No memory integration |
|
|
39
|
+
| Auto-update `flow/tasklist.md` | Only on explicit user request |
|
|
40
|
+
| Deep codebase scanning | That's discovery's job — brainstorm stays in idea space |
|
|
41
|
+
| Create plans or discovery docs | Brainstorm only produces brainstorm files |
|
|
42
|
+
| Run build/test commands | No execution commands |
|
|
43
|
+
|
|
44
|
+
---
|
|
45
|
+
|
|
46
|
+
## Inputs
|
|
47
|
+
|
|
48
|
+
| Input | Required | Description |
|
|
49
|
+
|-------|----------|-------------|
|
|
50
|
+
| `idea` | Yes | Free-text description of the idea to explore |
|
|
51
|
+
| `topic_name` | Optional | Short name for the topic (derived from idea if not provided) |
|
|
52
|
+
|
|
53
|
+
---
|
|
54
|
+
|
|
55
|
+
## Workflow
|
|
56
|
+
|
|
57
|
+
### Step 1: Parse Idea and Open the Conversation
|
|
58
|
+
|
|
59
|
+
1. Read the user's idea
|
|
60
|
+
2. **Show understanding** — restate the core concept in your own words to confirm alignment
|
|
61
|
+
3. **Add an initial insight** — offer a first reaction, angle, or connection
|
|
62
|
+
4. **Ask one focused question** — the first question that would most help shape the idea
|
|
63
|
+
|
|
64
|
+
**Tone**: Casual, collaborative, curious. Like a coworker who just heard your idea and is genuinely interested.
|
|
65
|
+
|
|
66
|
+
**Example**:
|
|
67
|
+
|
|
68
|
+
```
|
|
69
|
+
User: /brainstorm I want to add a plugin system to plan-flow
|
|
70
|
+
|
|
71
|
+
LLM: A plugin system — so users could extend plan-flow with custom skills
|
|
72
|
+
or hooks without forking the repo. That could unlock a whole ecosystem.
|
|
73
|
+
|
|
74
|
+
The first thing I'd want to understand: are you thinking plugins that
|
|
75
|
+
add new slash commands, or something lower-level like middleware that
|
|
76
|
+
hooks into the existing skill execution pipeline?
|
|
77
|
+
```
|
|
78
|
+
|
|
79
|
+
---
|
|
80
|
+
|
|
81
|
+
### Step 2: Structured Exploration Loop
|
|
82
|
+
|
|
83
|
+
This is the core of the brainstorm. After the open-ended first round (Step 1), switch to structured batched questions using the `AskUserQuestion` tool. Repeat until the user signals they're done.
|
|
84
|
+
|
|
85
|
+
**Per Round Behavior**:
|
|
86
|
+
|
|
87
|
+
1. **Formulate questions** — create 3-4 questions based on the current state of the brainstorm, each with 2-4 options
|
|
88
|
+
2. **Present via `AskUserQuestion`** — call the tool with the batch of questions (see `.claude/resources/tools/interactive-questions-tool.md` for tool usage)
|
|
89
|
+
3. **Wait for responses** — user picks options or types custom answers via "Other"
|
|
90
|
+
4. **Process answers** — update silent tracking with the user's choices
|
|
91
|
+
5. **Commentary** — react to the answers in regular chat: connect dots, surface insights, challenge assumptions, make suggestions. This is what keeps it feeling like a brainstorm, not a form.
|
|
92
|
+
6. **Check for end signals** — if user typed "done", "wrap up", etc. in any "Other" field or in response to commentary, proceed to Step 3
|
|
93
|
+
7. **Repeat** — formulate next batch based on what was learned
|
|
94
|
+
|
|
95
|
+
**Question Formulation Rules**:
|
|
96
|
+
|
|
97
|
+
- Each question must have a **recommended option** as the first option with "(Recommended)" suffix on the label
|
|
98
|
+
- Mix question types across each batch — don't ask 4 clarifying questions in a row
|
|
99
|
+
- When the idea is too vague for structured options on a particular point, ask that question as regular chat within the commentary instead — not everything needs to go through `AskUserQuestion`
|
|
100
|
+
- Cap at **3-4 questions per `AskUserQuestion` call** (tool limit is 4)
|
|
101
|
+
- Each option needs a `label` (1-5 words) and `description` (explanation of what it means)
|
|
102
|
+
|
|
103
|
+
**Question Types to Mix**:
|
|
104
|
+
|
|
105
|
+
| Type | Purpose | Example Question |
|
|
106
|
+
|------|---------|---------|
|
|
107
|
+
| Clarifying | Understand the concept deeper | "What scope should this feature cover?" with options like "MVP only (Recommended)" / "Full feature" / "Phased rollout" |
|
|
108
|
+
| Challenging | Push back on assumptions | "Is this the right approach?" with options presenting alternatives |
|
|
109
|
+
| Expanding | Broaden scope or find connections | "What else could this enable?" with options for related features |
|
|
110
|
+
| Constraining | Find the MVP / simplest version | "What can we cut from v1?" with options for scope reduction |
|
|
111
|
+
| Connecting | Link to existing knowledge | "Which existing pattern fits best?" with options for known patterns |
|
|
112
|
+
|
|
113
|
+
**Commentary Between Batches**:
|
|
114
|
+
|
|
115
|
+
The commentary is what makes this a brainstorm and not a survey. After processing each batch of answers:
|
|
116
|
+
|
|
117
|
+
- **React** — show you understood the choices and what they mean together
|
|
118
|
+
- **Connect** — link answers across questions ("Your choice of X combined with Y suggests...")
|
|
119
|
+
- **Challenge** — if an answer seems contradictory or surprising, call it out
|
|
120
|
+
- **Suggest** — offer an insight the user might not have considered ("What if we also...")
|
|
121
|
+
- **Transition** — naturally lead into why the next batch of questions matters
|
|
122
|
+
|
|
123
|
+
Keep commentary concise (2-4 sentences). Don't lecture — think sharp coworker at a whiteboard.
|
|
124
|
+
|
|
125
|
+
**Silent Tracking**:
|
|
126
|
+
|
|
127
|
+
While processing responses and writing commentary, maintain an internal running tally of:
|
|
128
|
+
|
|
129
|
+
| Category | What to Track |
|
|
130
|
+
|----------|--------------|
|
|
131
|
+
| **Core Idea** | The central thesis — evolves as options are selected |
|
|
132
|
+
| **Key Decisions** | Options chosen by the user (with reasoning from descriptions) |
|
|
133
|
+
| **Open Questions** | Things raised but not yet resolved |
|
|
134
|
+
| **Constraints** | Limitations that surfaced (technical, time, scope, etc.) |
|
|
135
|
+
| **Inspirations / References** | Existing code, patterns, tools, or external ideas mentioned |
|
|
136
|
+
| **Rejected Alternatives** | Options NOT chosen — preserve as rejected alternatives with reasoning |
|
|
137
|
+
|
|
138
|
+
Do NOT show this tracking to the user during the conversation. It's used to generate the summary and output file.
|
|
139
|
+
|
|
140
|
+
---
|
|
141
|
+
|
|
142
|
+
### Step 3: End Detection
|
|
143
|
+
|
|
144
|
+
The brainstorm ends when the user signals they're done. Watch for:
|
|
145
|
+
|
|
146
|
+
**Clear End Signals** (transition immediately):
|
|
147
|
+
- "I'm done"
|
|
148
|
+
- "Let's wrap up"
|
|
149
|
+
- "That's enough"
|
|
150
|
+
- "Summarize"
|
|
151
|
+
- "Let's move on"
|
|
152
|
+
- "I think we've covered it"
|
|
153
|
+
- "Generate the file"
|
|
154
|
+
|
|
155
|
+
**Ambiguous Signals** (ask to confirm):
|
|
156
|
+
- Long pause with a short response like "yeah" or "ok"
|
|
157
|
+
- "I think so" or "maybe"
|
|
158
|
+
- Response: "Sounds like we might be reaching a natural stopping point — should I summarize what we've discussed, or is there another angle you want to explore?"
|
|
159
|
+
|
|
160
|
+
**Never End Signals** (keep going):
|
|
161
|
+
- User asks a new question
|
|
162
|
+
- User introduces a new angle
|
|
163
|
+
- User says "what about..." or "also..."
|
|
164
|
+
- User is mid-thought
|
|
165
|
+
|
|
166
|
+
**Default**: When in doubt, keep the brainstorm going. It's better to explore one more angle than to cut short.
|
|
167
|
+
|
|
168
|
+
---
|
|
169
|
+
|
|
170
|
+
### Step 4: Present Summary
|
|
171
|
+
|
|
172
|
+
When the brainstorm ends, present a structured summary of what was discussed:
|
|
173
|
+
|
|
174
|
+
```markdown
|
|
175
|
+
## Brainstorm Summary: {topic}
|
|
176
|
+
|
|
177
|
+
### Core Idea
|
|
178
|
+
{The central thesis as it evolved during the conversation}
|
|
179
|
+
|
|
180
|
+
### Key Decisions
|
|
181
|
+
- {Decision 1} — {reasoning}
|
|
182
|
+
- {Decision 2} — {reasoning}
|
|
183
|
+
|
|
184
|
+
### Open Questions
|
|
185
|
+
- {Question still unresolved}
|
|
186
|
+
|
|
187
|
+
### Constraints
|
|
188
|
+
- {Limitation that surfaced}
|
|
189
|
+
|
|
190
|
+
### Inspirations & References
|
|
191
|
+
- {Tool, pattern, or idea that came up}
|
|
192
|
+
|
|
193
|
+
### Rejected Alternatives
|
|
194
|
+
- {Alternative considered and discarded} — {why}
|
|
195
|
+
```
|
|
196
|
+
|
|
197
|
+
Present this as a chat message (not a file yet).
|
|
198
|
+
|
|
199
|
+
---
|
|
200
|
+
|
|
201
|
+
### Step 5: Offer MD File Generation
|
|
202
|
+
|
|
203
|
+
After presenting the summary, ask:
|
|
204
|
+
|
|
205
|
+
```markdown
|
|
206
|
+
Would you like me to save this as a brainstorm document? It can be used as
|
|
207
|
+
input for `/discovery-plan` later.
|
|
208
|
+
```
|
|
209
|
+
|
|
210
|
+
- **If yes**: Proceed to Step 6
|
|
211
|
+
- **If no**: Proceed to Step 7 (skip file generation)
|
|
212
|
+
|
|
213
|
+
---
|
|
214
|
+
|
|
215
|
+
### Step 6: Generate Output File
|
|
216
|
+
|
|
217
|
+
**Location**: `flow/brainstorms/brainstorm_{topic}_v{version}.md`
|
|
218
|
+
|
|
219
|
+
**Topic naming**: kebab-case derived from the idea (e.g., "plugin system" → `plugin-system`)
|
|
220
|
+
|
|
221
|
+
**Versioning**: Check `flow/brainstorms/` for existing files with the same topic. Increment version if found.
|
|
222
|
+
|
|
223
|
+
**Template**: Use the template from `.claude/resources/patterns/brainstorm-templates.md`
|
|
224
|
+
|
|
225
|
+
The output file must include all tracked categories plus the **"For Discovery" bridge section** that makes the handoff to `/discovery-plan` seamless.
|
|
226
|
+
|
|
227
|
+
After writing, report:
|
|
228
|
+
|
|
229
|
+
```markdown
|
|
230
|
+
Brainstorm saved.
|
|
231
|
+
|
|
232
|
+
**Created**: `flow/brainstorms/brainstorm_{topic}_v{version}.md`
|
|
233
|
+
|
|
234
|
+
To continue: `/discovery-plan @flow/brainstorms/brainstorm_{topic}_v{version}.md`
|
|
235
|
+
```
|
|
236
|
+
|
|
237
|
+
---
|
|
238
|
+
|
|
239
|
+
### Step 7: Offer Tasklist Entry (Optional)
|
|
240
|
+
|
|
241
|
+
After the brainstorm completes (whether or not an MD file was generated):
|
|
242
|
+
|
|
243
|
+
```markdown
|
|
244
|
+
Want me to add this to the tasklist?
|
|
245
|
+
```
|
|
246
|
+
|
|
247
|
+
- **If yes**: Add "Discovery: {topic}" to the **To Do** section of `flow/tasklist.md`
|
|
248
|
+
- **If no**: Done — do not add anything
|
|
249
|
+
|
|
250
|
+
---
|
|
251
|
+
|
|
252
|
+
## Output Format
|
|
253
|
+
|
|
254
|
+
See `.claude/resources/patterns/brainstorm-templates.md` for the full output template.
|
|
255
|
+
|
|
256
|
+
---
|
|
257
|
+
|
|
258
|
+
## Validation Checklist
|
|
259
|
+
|
|
260
|
+
Before completing the brainstorm, verify:
|
|
261
|
+
|
|
262
|
+
- [ ] Questions presented in batches with options via `AskUserQuestion`
|
|
263
|
+
- [ ] Commentary provided between question batches
|
|
264
|
+
- [ ] Open-ended first round (Step 1) before structured batches
|
|
265
|
+
- [ ] User signaled end (not auto-ended by LLM)
|
|
266
|
+
- [ ] Summary presented before offering file generation
|
|
267
|
+
- [ ] If file generated: saved to `flow/brainstorms/` with correct naming
|
|
268
|
+
- [ ] If file generated: includes "For Discovery" bridge section
|
|
269
|
+
- [ ] Tasklist only updated if user explicitly requested
|
|
270
|
+
- [ ] No source code written
|
|
271
|
+
- [ ] No brain entries created
|
|
272
|
+
- [ ] No memory entries created
|
|
273
|
+
- [ ] Codebase only read when user explicitly asked
|
|
274
|
+
|
|
275
|
+
---
|
|
276
|
+
|
|
277
|
+
## Related Files
|
|
278
|
+
|
|
279
|
+
| File | Purpose |
|
|
280
|
+
|------|---------|
|
|
281
|
+
| `.claude/commands/brainstorm.md` | Command file that invokes this skill |
|
|
282
|
+
| `.claude/resources/patterns/brainstorm-templates.md` | Output file template |
|
|
283
|
+
| `.claude/resources/skills/discovery-skill.md` | Discovery skill that consumes brainstorm output |
|
|
284
|
+
| `flow/brainstorms/` | Output directory for brainstorm documents |
|
|
@@ -49,7 +49,7 @@ This skill is **strictly for gathering and documenting requirements**. The proce
|
|
|
49
49
|
| Write to `flow/discovery/` | Save discovery document |
|
|
50
50
|
| Read project rule files | Understand patterns to follow |
|
|
51
51
|
|
|
52
|
-
> **Important**: The ONLY writable
|
|
52
|
+
> **Important**: The ONLY writable locations are `flow/discovery/`, `flow/resources/pending-patterns.md`, and `.claude/rules/core/*.md` (for approved patterns). No source code, configuration files, or any other project files should be modified.
|
|
53
53
|
|
|
54
54
|
---
|
|
55
55
|
|
|
@@ -74,8 +74,10 @@ This skill is **strictly for gathering and documenting requirements**. The proce
|
|
|
74
74
|
|
|
75
75
|
1. Identify references (look for @mentions, file paths, URLs)
|
|
76
76
|
2. Read each file using the Read tool
|
|
77
|
-
3.
|
|
78
|
-
4.
|
|
77
|
+
3. **If a brainstorm file** (`flow/brainstorms/brainstorm_*.md`): parse the "For Discovery" section — inherit resolved decisions, use open questions as investigation starting points, and skip rejected alternatives
|
|
78
|
+
4. Extract key information (requirements, constraints, contracts)
|
|
79
|
+
5. Summarize findings for each source
|
|
80
|
+
6. **Capture patterns**: While reading existing code and documents, watch for recurring conventions and established patterns. Silently append to `flow/resources/pending-patterns.md`. See `.claude/resources/core/pattern-capture.md` for buffer format and capture triggers.
|
|
79
81
|
|
|
80
82
|
**Document Analysis Format**:
|
|
81
83
|
|
|
@@ -109,6 +111,20 @@ Ask questions about gaps identified in documents and unclear requirements.
|
|
|
109
111
|
| Technical | Architecture, dependencies |
|
|
110
112
|
| UI/UX | User interface and experience |
|
|
111
113
|
|
|
114
|
+
**Design Awareness Questions**:
|
|
115
|
+
|
|
116
|
+
After standard clarifying questions, check for UI work. See `.claude/resources/core/design-awareness.md` for the full question flow.
|
|
117
|
+
|
|
118
|
+
1. **Always ask** (as part of the standard question batch): "Does this feature involve any UI or visual interface work?"
|
|
119
|
+
- If **Yes** or **Partially**: Add a follow-up question batch via `AskUserQuestion`:
|
|
120
|
+
- "Do you have an existing design to follow?" (screenshots/mockups, existing design system, or need new design direction)
|
|
121
|
+
- "What design personality fits this feature?" (only if no existing design — Stark, Aura, Neo, Zen, Flux, Terra)
|
|
122
|
+
- "What's the primary layout pattern?" (dashboard, content+sidebar, form workflow, data table)
|
|
123
|
+
- If **No**: Skip design questions entirely
|
|
124
|
+
2. **If user provides screenshots**: Analyze visually and extract structured design tokens (colors, typography, spacing, component patterns). See token extraction rules in `.claude/resources/core/design-awareness.md`.
|
|
125
|
+
3. **If user picks a personality**: Use the personality's default tokens from `.claude/resources/core/design-awareness.md`.
|
|
126
|
+
4. **Plugin detection**: Check if `.interface-design/system.md` exists. If found, offer to use it as the design source.
|
|
127
|
+
|
|
112
128
|
**Use Interactive Questions Tool**:
|
|
113
129
|
|
|
114
130
|
Follow `.claude/resources/tools/interactive-questions-tool.md`:
|
|
@@ -170,7 +186,9 @@ Categorize requirements as they are gathered:
|
|
|
170
186
|
|
|
171
187
|
### Step 5: Identify Technical Considerations
|
|
172
188
|
|
|
173
|
-
Document high-level technical insights (NO implementation code)
|
|
189
|
+
Document high-level technical insights (NO implementation code).
|
|
190
|
+
|
|
191
|
+
**While analyzing technical considerations**, watch for conventions in the existing codebase that should be captured as patterns. Silently append to `flow/resources/pending-patterns.md`.
|
|
174
192
|
|
|
175
193
|
```markdown
|
|
176
194
|
## Technical Considerations
|
|
@@ -230,6 +248,19 @@ Capture risks discovered:
|
|
|
230
248
|
|
|
231
249
|
---
|
|
232
250
|
|
|
251
|
+
### Step 8b: Pattern Review
|
|
252
|
+
|
|
253
|
+
After generating the discovery document but before completing the skill, run the pattern review protocol:
|
|
254
|
+
|
|
255
|
+
1. Read `flow/resources/pending-patterns.md`
|
|
256
|
+
2. If the buffer has entries, present grouped patterns for user approval
|
|
257
|
+
3. Write approved patterns to `.claude/rules/core/allowed-patterns.md` or `.claude/rules/core/forbidden-patterns.md`
|
|
258
|
+
4. Clear the buffer
|
|
259
|
+
|
|
260
|
+
See `.claude/resources/core/pattern-capture.md` for the full end-of-skill review protocol.
|
|
261
|
+
|
|
262
|
+
---
|
|
263
|
+
|
|
233
264
|
### Step 8: Generate Discovery Document
|
|
234
265
|
|
|
235
266
|
Create the discovery markdown file:
|
|
@@ -249,6 +280,8 @@ Create the discovery markdown file:
|
|
|
249
280
|
7. Risks and Unknowns
|
|
250
281
|
8. Next Steps
|
|
251
282
|
|
|
283
|
+
**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
|
+
|
|
252
285
|
---
|
|
253
286
|
|
|
254
287
|
## Output Format
|
|
@@ -276,6 +309,7 @@ Before completing discovery, verify:
|
|
|
276
309
|
- [ ] Risks and unknowns are identified
|
|
277
310
|
- [ ] Proposed approach is documented (high-level only)
|
|
278
311
|
- [ ] Next steps are defined (pointing to `/create-plan`)
|
|
312
|
+
- [ ] If UI work detected: `## Design Context` section included with structured tokens
|
|
279
313
|
- [ ] **NO implementation code is included**
|
|
280
314
|
- [ ] **NO source files were created or modified**
|
|
281
315
|
|
|
@@ -189,9 +189,20 @@ Wait for user confirmation before proceeding.
|
|
|
189
189
|
1. **Auto-switch to Plan mode** - Call `SwitchMode` tool
|
|
190
190
|
2. **Present phase details** - Show scope, tasks, and approach
|
|
191
191
|
3. **Wait for approval** - Get user confirmation
|
|
192
|
-
4. **
|
|
193
|
-
|
|
194
|
-
|
|
192
|
+
4. **Select model tier** - If `model_routing` is enabled in `flow/.flowconfig` (default: `true`):
|
|
193
|
+
- Read the phase's complexity score
|
|
194
|
+
- Look up model tier: **0-3 → Fast (haiku)**, **4-5 → Standard (sonnet)**, **6-10 → Powerful (opus)**
|
|
195
|
+
- For aggregated phases, use the **highest individual phase complexity** to determine the tier
|
|
196
|
+
- Spawn implementation as an **Agent subagent** with `model={tier}` parameter
|
|
197
|
+
- Include in Agent prompt: plan file path, current phase details, files modified so far, allowed/forbidden patterns
|
|
198
|
+
- If `model_routing` is `false` or key is missing, skip routing and implement directly (use session model)
|
|
199
|
+
- See `.claude/resources/core/model-routing.md` for full tier table, platform mappings, and rules
|
|
200
|
+
5. **Inject design context** - Before implementing, check if the discovery doc (from plan's "Based on Discovery" field) has a `## Design Context` section. If present and the phase involves UI work (see UI Phase Detection Heuristics in `.claude/resources/core/design-awareness.md`), prepend the Design Context to the implementation prompt with: "Follow these design tokens when implementing UI elements. Use the exact color values, typography, and spacing from the Design Context." If no Design Context or phase is not UI-related, skip this step.
|
|
201
|
+
6. **Implement** - Execute the phase following approved approach (via subagent if model routing is active, or directly if not)
|
|
202
|
+
7. **Capture patterns** - While implementing, watch for recurring conventions, anti-patterns, and workarounds. Silently append to `flow/resources/pending-patterns.md`. See `.claude/resources/core/pattern-capture.md` for buffer format and capture triggers.
|
|
203
|
+
8. **Update progress** - Mark tasks complete in plan file
|
|
204
|
+
9. **Record model used** - Track which model tier was used for this phase (for the completion summary)
|
|
205
|
+
10. **Continue to next phase** - NO BUILD between phases
|
|
195
206
|
|
|
196
207
|
**Phase Presentation Template**:
|
|
197
208
|
|
|
@@ -200,6 +211,7 @@ Wait for user confirmation before proceeding.
|
|
|
200
211
|
|
|
201
212
|
**Complexity**: X/10
|
|
202
213
|
**Scope**: [Phase scope description]
|
|
214
|
+
**Design Context**: Available / Not applicable
|
|
203
215
|
|
|
204
216
|
### Tasks to Complete:
|
|
205
217
|
- [ ] Task 1
|
|
@@ -213,6 +225,7 @@ Wait for user confirmation before proceeding.
|
|
|
213
225
|
- [ ] Following allowed patterns
|
|
214
226
|
- [ ] Avoiding forbidden patterns
|
|
215
227
|
- [ ] Using appropriate language patterns
|
|
228
|
+
- [ ] Following design tokens from Design Context (if applicable)
|
|
216
229
|
|
|
217
230
|
---
|
|
218
231
|
|
|
@@ -234,6 +247,31 @@ Then continue to the next phase (NO BUILD HERE).
|
|
|
234
247
|
|
|
235
248
|
---
|
|
236
249
|
|
|
250
|
+
### Step 5b: Phase-Boundary Context Check
|
|
251
|
+
|
|
252
|
+
**After each phase completes**, check context window usage by looking at the token count from the last response. If you notice the conversation is getting long (many phases completed, lots of file reads/edits), **proactively run `/compact`** with a summary of remaining work.
|
|
253
|
+
|
|
254
|
+
**When to compact** (at phase boundaries):
|
|
255
|
+
- Context feels heavy (many tool calls, large file reads accumulated)
|
|
256
|
+
- Multiple phases completed and more remain
|
|
257
|
+
- You're about to start a complex phase (complexity >= 6)
|
|
258
|
+
|
|
259
|
+
**How to compact at a phase boundary**:
|
|
260
|
+
|
|
261
|
+
Run `/compact` with instructions that preserve execution state:
|
|
262
|
+
|
|
263
|
+
```
|
|
264
|
+
/compact Executing plan: [plan file path]. Completed phases: [list]. Next phase: [name and scope]. Key files modified: [list]. Active tasklist items: [list from flow/tasklist.md]. Resume execution from phase [N].
|
|
265
|
+
```
|
|
266
|
+
|
|
267
|
+
**Rules**:
|
|
268
|
+
- NEVER compact mid-phase — only at phase boundaries (between phases)
|
|
269
|
+
- Always include enough context in the compact instructions to resume
|
|
270
|
+
- After compaction, re-read the plan file and continue from the next phase
|
|
271
|
+
- In autopilot mode, compact automatically without asking — this is a maintenance action, not a user decision
|
|
272
|
+
|
|
273
|
+
---
|
|
274
|
+
|
|
237
275
|
### Step 6: Handle Tests Phase
|
|
238
276
|
|
|
239
277
|
The Tests phase is **always executed separately**, regardless of complexity score:
|
|
@@ -247,6 +285,19 @@ The Tests phase is **always executed separately**, regardless of complexity scor
|
|
|
247
285
|
|
|
248
286
|
---
|
|
249
287
|
|
|
288
|
+
### Step 7b: Pattern Review
|
|
289
|
+
|
|
290
|
+
After all phases are complete but **before** build/test verification, run the pattern review protocol:
|
|
291
|
+
|
|
292
|
+
1. Read `flow/resources/pending-patterns.md`
|
|
293
|
+
2. If the buffer has entries, present grouped patterns for user approval
|
|
294
|
+
3. Write approved patterns to `.claude/rules/core/allowed-patterns.md` or `.claude/rules/core/forbidden-patterns.md`
|
|
295
|
+
4. Clear the buffer
|
|
296
|
+
|
|
297
|
+
See `.claude/resources/core/pattern-capture.md` for the full end-of-skill review protocol.
|
|
298
|
+
|
|
299
|
+
---
|
|
300
|
+
|
|
250
301
|
### Step 7: Completion - Build and Test Verification
|
|
251
302
|
|
|
252
303
|
**This is the ONLY place where build and tests are run.**
|
|
@@ -264,7 +315,18 @@ npm run build && npm run test
|
|
|
264
315
|
- If tests fail: Fix the issue, re-run verification
|
|
265
316
|
- Only proceed after everything passes
|
|
266
317
|
|
|
267
|
-
3. **Present summary** of completed work
|
|
318
|
+
3. **Present summary** of completed work, including model routing info if enabled:
|
|
319
|
+
|
|
320
|
+
```markdown
|
|
321
|
+
| Phase | Complexity | Model | Status |
|
|
322
|
+
|-------|-----------|-------|--------|
|
|
323
|
+
| 1. Setup types | 2/10 | haiku | Done |
|
|
324
|
+
| 2. Core logic | 5/10 | sonnet | Done |
|
|
325
|
+
| 3. Integration | 7/10 | opus | Done |
|
|
326
|
+
| 4. Tests | 4/10 | sonnet | Done |
|
|
327
|
+
|
|
328
|
+
**Model routing**: Saved ~X% vs all-opus execution
|
|
329
|
+
```
|
|
268
330
|
|
|
269
331
|
4. **List all key changes** made
|
|
270
332
|
|
|
@@ -0,0 +1,153 @@
|
|
|
1
|
+
# Flow Cost: Token Usage Reporting
|
|
2
|
+
|
|
3
|
+
## Overview
|
|
4
|
+
|
|
5
|
+
The `/flow cost` subcommand reads `~/.claude/metrics/costs.jsonl` and displays token usage and estimated cost summaries. It supports time-based and project-based filtering.
|
|
6
|
+
|
|
7
|
+
## Usage
|
|
8
|
+
|
|
9
|
+
```
|
|
10
|
+
/flow cost Show last 7 days summary
|
|
11
|
+
/flow cost --today Show today's usage
|
|
12
|
+
/flow cost --week Show last 7 days (default)
|
|
13
|
+
/flow cost --month Show last 30 days
|
|
14
|
+
/flow cost --project <name> Filter by project name
|
|
15
|
+
/flow cost --session <id> Show single session detail
|
|
16
|
+
/flow cost --detail Include model breakdown
|
|
17
|
+
```
|
|
18
|
+
|
|
19
|
+
## Implementation
|
|
20
|
+
|
|
21
|
+
When the user runs `/flow cost`, follow these steps:
|
|
22
|
+
|
|
23
|
+
### Step 1: Read Metrics File
|
|
24
|
+
|
|
25
|
+
1. Read `~/.claude/metrics/costs.jsonl`
|
|
26
|
+
2. If the file doesn't exist, display: "No cost data found. Cost tracking hooks will start recording after your next Claude response."
|
|
27
|
+
3. Parse each line as JSON, skip malformed lines
|
|
28
|
+
4. Also read any rotated files (`costs.*.jsonl`) in the same directory if the time range extends beyond the current file
|
|
29
|
+
|
|
30
|
+
### Step 2: Filter Entries
|
|
31
|
+
|
|
32
|
+
Apply filters based on flags:
|
|
33
|
+
|
|
34
|
+
| Flag | Filter Logic |
|
|
35
|
+
|------|-------------|
|
|
36
|
+
| `--today` | Entries where `timestamp` is today (local date) |
|
|
37
|
+
| `--week` | Entries from the last 7 days (default) |
|
|
38
|
+
| `--month` | Entries from the last 30 days |
|
|
39
|
+
| `--project <name>` | Entries where `project` matches `<name>` |
|
|
40
|
+
| `--session <id>` | Entries where `session_id` matches `<id>` |
|
|
41
|
+
|
|
42
|
+
**Exclude** entries with `type: "session_summary"` from the main table — these are aggregated separately.
|
|
43
|
+
|
|
44
|
+
### Step 3: Aggregate Data
|
|
45
|
+
|
|
46
|
+
Group filtered entries by `project` and compute:
|
|
47
|
+
|
|
48
|
+
- **Sessions**: Count unique `session_id` values
|
|
49
|
+
- **Responses**: Count of entries (each entry = one response)
|
|
50
|
+
- **Input Tokens**: Sum of `input_tokens`
|
|
51
|
+
- **Output Tokens**: Sum of `output_tokens`
|
|
52
|
+
- **Cache Creation**: Sum of `cache_creation_tokens`
|
|
53
|
+
- **Cache Read**: Sum of `cache_read_tokens`
|
|
54
|
+
- **Cost**: Sum of `estimated_cost_usd`
|
|
55
|
+
|
|
56
|
+
### Step 4: Format Output
|
|
57
|
+
|
|
58
|
+
#### Default Summary
|
|
59
|
+
|
|
60
|
+
```markdown
|
|
61
|
+
**Cost Report** (last 7 days)
|
|
62
|
+
|
|
63
|
+
| Project | Sessions | Responses | Input Tokens | Output Tokens | Cost |
|
|
64
|
+
|------------|----------|-----------|--------------|---------------|----------|
|
|
65
|
+
| parcels | 12 | 145 | 1.2M | 320K | $12.45 |
|
|
66
|
+
| plan-flow | 8 | 92 | 890K | 210K | $8.72 |
|
|
67
|
+
| **Total** | **20** | **237** | **2.1M** | **530K** | **$21.17** |
|
|
68
|
+
```
|
|
69
|
+
|
|
70
|
+
#### With `--detail` (model breakdown)
|
|
71
|
+
|
|
72
|
+
```markdown
|
|
73
|
+
**Cost Report** (last 7 days)
|
|
74
|
+
|
|
75
|
+
| Project | Model | Responses | Input | Output | Cache Read | Cost |
|
|
76
|
+
|------------|------------------|-----------|-----------|-----------|------------|---------|
|
|
77
|
+
| parcels | claude-opus-4-6 | 45 | 520K | 180K | 1.2M | $9.30 |
|
|
78
|
+
| parcels | claude-sonnet-4-6| 100 | 680K | 140K | 890K | $3.15 |
|
|
79
|
+
| plan-flow | claude-opus-4-6 | 32 | 410K | 120K | 780K | $6.20 |
|
|
80
|
+
| plan-flow | claude-sonnet-4-6| 60 | 480K | 90K | 560K | $2.52 |
|
|
81
|
+
| **Total** | | **237** | **2.1M** | **530K** | **3.4M** | **$21.17** |
|
|
82
|
+
```
|
|
83
|
+
|
|
84
|
+
#### Session Detail (`--session <id>`)
|
|
85
|
+
|
|
86
|
+
```markdown
|
|
87
|
+
**Session Detail**: abc-123
|
|
88
|
+
|
|
89
|
+
| # | Timestamp | Model | Input | Output | Cache | Cost |
|
|
90
|
+
|---|-----------|-------|-------|--------|-------|------|
|
|
91
|
+
| 1 | 10:23:15 | opus | 12K | 3.2K | 45K | $0.24 |
|
|
92
|
+
| 2 | 10:25:42 | opus | 18K | 5.1K | 52K | $0.38 |
|
|
93
|
+
| ...| ... | ... | ... | ... | ... | ... |
|
|
94
|
+
|
|
95
|
+
**Session Total**: 23 responses, $4.82, 45 minutes
|
|
96
|
+
```
|
|
97
|
+
|
|
98
|
+
### Step 5: Token Formatting
|
|
99
|
+
|
|
100
|
+
Format large numbers for readability:
|
|
101
|
+
|
|
102
|
+
| Range | Format | Example |
|
|
103
|
+
|-------|--------|---------|
|
|
104
|
+
| < 1,000 | Raw number | 847 |
|
|
105
|
+
| 1,000 - 999,999 | K with 1 decimal | 12.5K |
|
|
106
|
+
| >= 1,000,000 | M with 1 decimal | 2.1M |
|
|
107
|
+
|
|
108
|
+
Cost formatting: Always show 2 decimal places with `$` prefix (e.g., `$12.45`).
|
|
109
|
+
|
|
110
|
+
## JSONL Entry Schema
|
|
111
|
+
|
|
112
|
+
Each line in `costs.jsonl` has this structure:
|
|
113
|
+
|
|
114
|
+
```json
|
|
115
|
+
{
|
|
116
|
+
"timestamp": "2026-03-09T14:30:00.000Z",
|
|
117
|
+
"session_id": "abc-123-def",
|
|
118
|
+
"project": "plan-flow",
|
|
119
|
+
"model": "claude-opus-4-6",
|
|
120
|
+
"input_tokens": 12500,
|
|
121
|
+
"output_tokens": 3200,
|
|
122
|
+
"cache_creation_tokens": 9821,
|
|
123
|
+
"cache_read_tokens": 45000,
|
|
124
|
+
"estimated_cost_usd": 0.000243,
|
|
125
|
+
"hook_version": "1.0.0"
|
|
126
|
+
}
|
|
127
|
+
```
|
|
128
|
+
|
|
129
|
+
Session summary entries (appended by SessionEnd hook):
|
|
130
|
+
|
|
131
|
+
```json
|
|
132
|
+
{
|
|
133
|
+
"type": "session_summary",
|
|
134
|
+
"timestamp": "2026-03-09T15:00:00.000Z",
|
|
135
|
+
"session_id": "abc-123-def",
|
|
136
|
+
"project": "plan-flow",
|
|
137
|
+
"models": ["claude-opus-4-6"],
|
|
138
|
+
"response_count": 23,
|
|
139
|
+
"total_input_tokens": 287500,
|
|
140
|
+
"total_output_tokens": 73600,
|
|
141
|
+
"total_cache_creation_tokens": 225883,
|
|
142
|
+
"total_cache_read_tokens": 1035000,
|
|
143
|
+
"total_cost_usd": 4.823456,
|
|
144
|
+
"duration_minutes": 45,
|
|
145
|
+
"hook_version": "1.0.0"
|
|
146
|
+
}
|
|
147
|
+
```
|
|
148
|
+
|
|
149
|
+
## Error Handling
|
|
150
|
+
|
|
151
|
+
- If `~/.claude/metrics/costs.jsonl` doesn't exist: Show friendly message, no error
|
|
152
|
+
- If file is empty or all lines malformed: Show "No valid cost data found"
|
|
153
|
+
- If no entries match filter: Show "No entries found for the selected filter"
|
|
@@ -51,7 +51,7 @@ This skill is **strictly read-only analysis**. The review process:
|
|
|
51
51
|
| Write to `flow/reviewed-code/` | Save review notes locally |
|
|
52
52
|
| Read project rule files | Load patterns for analysis |
|
|
53
53
|
|
|
54
|
-
> **Important**: The ONLY writable
|
|
54
|
+
> **Important**: The ONLY writable locations are `flow/reviewed-code/`, `flow/resources/pending-patterns.md`, and `.claude/rules/core/*.md` (for approved patterns). No source code, configuration files, or any other project files should be modified.
|
|
55
55
|
|
|
56
56
|
---
|
|
57
57
|
|
|
@@ -158,6 +158,21 @@ When a pattern conflict is found:
|
|
|
158
158
|
- Suggest additions to `.claude/rules/core/allowed-patterns.md`
|
|
159
159
|
- Suggest additions to `.claude/rules/core/forbidden-patterns.md`
|
|
160
160
|
|
|
161
|
+
4. **Buffer patterns for capture**: Silently append identified patterns (both good patterns and anti-patterns found during review) to `flow/resources/pending-patterns.md`. See `.claude/resources/core/pattern-capture.md` for buffer format and capture triggers.
|
|
162
|
+
|
|
163
|
+
### Step 6b: Pattern Review
|
|
164
|
+
|
|
165
|
+
After analysis but before generating the review document, run the pattern review protocol:
|
|
166
|
+
|
|
167
|
+
1. Read `flow/resources/pending-patterns.md`
|
|
168
|
+
2. If the buffer has entries, present grouped patterns for user approval
|
|
169
|
+
3. Write approved patterns to `.claude/rules/core/allowed-patterns.md` or `.claude/rules/core/forbidden-patterns.md`
|
|
170
|
+
4. Clear the buffer
|
|
171
|
+
|
|
172
|
+
See `.claude/resources/core/pattern-capture.md` for the full end-of-skill review protocol.
|
|
173
|
+
|
|
174
|
+
---
|
|
175
|
+
|
|
161
176
|
### Step 6: Generate Review Document
|
|
162
177
|
|
|
163
178
|
Create a markdown file in `flow/reviewed-code/` with the naming convention:
|