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.
Files changed (31) hide show
  1. package/.claude/commands/brainstorm.md +228 -0
  2. package/.claude/commands/discovery-plan.md +25 -1
  3. package/.claude/commands/execute-plan.md +35 -0
  4. package/.claude/commands/flow.md +36 -3
  5. package/.claude/commands/review-code.md +10 -0
  6. package/.claude/resources/core/_index.md +37 -2
  7. package/.claude/resources/core/design-awareness.md +400 -0
  8. package/.claude/resources/core/model-routing.md +116 -0
  9. package/.claude/resources/core/pattern-capture.md +227 -0
  10. package/.claude/resources/patterns/_index.md +11 -1
  11. package/.claude/resources/patterns/brainstorm-templates.md +132 -0
  12. package/.claude/resources/patterns/discovery-templates.md +44 -0
  13. package/.claude/resources/skills/_index.md +28 -1
  14. package/.claude/resources/skills/brainstorm-skill.md +284 -0
  15. package/.claude/resources/skills/discovery-skill.md +38 -4
  16. package/.claude/resources/skills/execute-plan-skill.md +66 -4
  17. package/.claude/resources/skills/flow-cost.md +153 -0
  18. package/.claude/resources/skills/review-code-skill.md +16 -1
  19. package/.claude/rules/core/allowed-patterns.md +6 -0
  20. package/.claude/rules/core/forbidden-patterns.md +6 -0
  21. package/dist/cli/daemon/heartbeat-daemon.js +7 -2
  22. package/dist/cli/daemon/heartbeat-daemon.js.map +1 -1
  23. package/dist/cli/handlers/claude.d.ts.map +1 -1
  24. package/dist/cli/handlers/claude.js +130 -2
  25. package/dist/cli/handlers/claude.js.map +1 -1
  26. package/dist/cli/handlers/shared.d.ts.map +1 -1
  27. package/dist/cli/handlers/shared.js +2 -1
  28. package/dist/cli/handlers/shared.js.map +1 -1
  29. package/dist/cli/index.js +0 -0
  30. package/package.json +1 -1
  31. package/templates/shared/CLAUDE.md.template +27 -10
@@ -0,0 +1,227 @@
1
+
2
+ # Pattern Capture System
3
+
4
+ ## Purpose
5
+
6
+ Silent, automatic capture of coding patterns and anti-patterns during skill execution. Patterns are buffered during work and presented for user approval at the end of the skill. Approved patterns are written to `.claude/rules/core/allowed-patterns.md` or `.claude/rules/core/forbidden-patterns.md`.
7
+
8
+ **Buffer Location**: `flow/resources/pending-patterns.md`
9
+ **Target Files**: `.claude/rules/core/allowed-patterns.md` (allowed) | `.claude/rules/core/forbidden-patterns.md` (forbidden)
10
+
11
+ ---
12
+
13
+ ## Behavior
14
+
15
+ ### During Skill Execution (Silent Capture)
16
+
17
+ While executing `/execute-plan`, `/discovery-plan`, or `/review-code`, watch for patterns that meet the capture triggers below. When you identify a pattern worth capturing:
18
+
19
+ 1. **Do NOT interrupt the user** — continue the current work
20
+ 2. **Append the pattern** to `flow/resources/pending-patterns.md` using the buffer format below
21
+ 3. **Skip trivially obvious patterns** (e.g., "use semicolons") and patterns already documented in the target files
22
+
23
+ ### Capture Triggers
24
+
25
+ | Trigger | Category | Example |
26
+ |---------|----------|---------|
27
+ | Recurring convention across 3+ files | allowed | All API routes use `withAuth()` wrapper |
28
+ | Anti-pattern found during code review | forbidden | Nested callbacks in async code |
29
+ | Workaround applied during execution | forbidden | Manual type assertion to fix broken generic |
30
+ | User correction of approach | allowed/forbidden | "Don't use `any` here, use the generic" |
31
+ | Pattern conflict between new and existing code | either | New code uses barrel exports, existing doesn't |
32
+ | Convention discovered in existing codebase | allowed | All hooks follow `useXxx` naming with return tuple |
33
+
34
+ ### What NOT to Capture
35
+
36
+ - Patterns already in `allowed-patterns.md` or `forbidden-patterns.md`
37
+ - Generic language/framework best practices (these belong in `/setup` pattern files)
38
+ - One-off decisions that won't recur
39
+ - Patterns with no clear code example
40
+
41
+ ---
42
+
43
+ ## Buffer Format
44
+
45
+ File: `flow/resources/pending-patterns.md`
46
+
47
+ ```markdown
48
+ # Pending Patterns
49
+
50
+ Patterns captured during skill execution. Review at end of skill.
51
+
52
+ ---
53
+
54
+ ## Entry: {pattern-name}
55
+
56
+ - **Category**: allowed | forbidden
57
+ - **Confidence**: high | medium | low
58
+ - **Source**: {skill-name} {phase or step}
59
+ - **Description**: {one-line description}
60
+
61
+ ### Code Example
62
+
63
+ \`\`\`{language}
64
+ // {GOOD or BAD} - {brief explanation}
65
+ {code example}
66
+ \`\`\`
67
+
68
+ ### Rationale
69
+
70
+ {Why this pattern matters for this project}
71
+
72
+ ---
73
+ ```
74
+
75
+ Each entry is separated by `---`. Multiple entries accumulate during execution.
76
+
77
+ ---
78
+
79
+ ## End-of-Skill Review Protocol
80
+
81
+ After a skill completes its primary work (but before brain-capture), run the pattern review:
82
+
83
+ ### Step 1: Check Buffer
84
+
85
+ Read `flow/resources/pending-patterns.md`. If empty or doesn't exist, skip the review entirely.
86
+
87
+ ### Step 2: Group and Present
88
+
89
+ Group entries by category (allowed / forbidden) and present a numbered list:
90
+
91
+ ```markdown
92
+ ## Pattern Review
93
+
94
+ The following patterns were identified during execution:
95
+
96
+ ### Allowed Patterns (to add to allowed-patterns.md)
97
+
98
+ 1. **{pattern-name}** — {description} (Confidence: {level})
99
+ 2. **{pattern-name}** — {description} (Confidence: {level})
100
+
101
+ ### Forbidden Patterns (to add to forbidden-patterns.md)
102
+
103
+ 3. **{pattern-name}** — {description} (Confidence: {level})
104
+
105
+ **Options**: Enter numbers to approve (e.g., "1,3"), "all" to approve all, or "none" to skip.
106
+ ```
107
+
108
+ ### Step 3: Process User Selection
109
+
110
+ - **"all"**: Write all patterns to their target files
111
+ - **"none"**: Clear the buffer and continue
112
+ - **Numbers (e.g., "1,3")**: Write only selected patterns
113
+ - **Skip/ignore**: Treat as "none"
114
+
115
+ ### Step 4: Write Approved Patterns
116
+
117
+ For each approved pattern:
118
+
119
+ 1. **Run conflict detection** (see below)
120
+ 2. **Append** to the `## Project Patterns` or `## Project Anti-Patterns` section of the target file
121
+ 3. **Use the auto-captured entry format** (see below)
122
+
123
+ ### Step 5: Clear Buffer
124
+
125
+ After review (regardless of outcome), clear `flow/resources/pending-patterns.md` by writing an empty file with just the header:
126
+
127
+ ```markdown
128
+ # Pending Patterns
129
+
130
+ Patterns captured during skill execution. Review at end of skill.
131
+ ```
132
+
133
+ ---
134
+
135
+ ## Auto-Captured Entry Format
136
+
137
+ Patterns written to the target files use the same structure as existing patterns, plus a metadata footer:
138
+
139
+ ### For `allowed-patterns.md`
140
+
141
+ ```markdown
142
+ ### {Pattern Name}
143
+
144
+ {Description of what this pattern accomplishes.}
145
+
146
+ \`\`\`{language}
147
+ // GOOD - {brief explanation}
148
+ {code example}
149
+ \`\`\`
150
+
151
+ **Why**: {Explanation of benefits.}
152
+
153
+ _Auto-captured on {YYYY-MM-DD} from {source skill/phase}. Confidence: {level}._
154
+ ```
155
+
156
+ ### For `forbidden-patterns.md`
157
+
158
+ ```markdown
159
+ ### DON'T: {Pattern Name}
160
+
161
+ **Problem**: {Brief description of why this is problematic.}
162
+
163
+ \`\`\`{language}
164
+ // BAD - {brief explanation}
165
+ {code example}
166
+ \`\`\`
167
+
168
+ **Why This is Wrong**:
169
+
170
+ - {Reason 1}
171
+ - {Reason 2}
172
+
173
+ **Fix**: {Description of the correct approach.}
174
+
175
+ _Auto-captured on {YYYY-MM-DD} from {source skill/phase}. Confidence: {level}._
176
+ ```
177
+
178
+ ---
179
+
180
+ ## Conflict Detection
181
+
182
+ Before writing an approved pattern, scan the target file for contradictions:
183
+
184
+ ### Detection Rules
185
+
186
+ 1. **Name match**: Pattern with the same or very similar name already exists
187
+ 2. **Semantic contradiction**: New pattern says "do X", existing pattern says "don't do X" (or vice versa)
188
+ 3. **Overlapping scope**: Both patterns address the same code construct but recommend different approaches
189
+
190
+ ### When Conflict Found
191
+
192
+ Present the conflict to the user:
193
+
194
+ ```markdown
195
+ **Conflict detected** with existing pattern "{existing pattern name}":
196
+
197
+ - **Existing**: {summary of existing pattern}
198
+ - **New**: {summary of new pattern}
199
+
200
+ **Options**:
201
+ 1. **Add + Deprecate old** — Add new pattern and deprecate the existing one
202
+ 2. **Skip** — Don't add the new pattern
203
+ 3. **Add both** — Keep both patterns (they may apply in different contexts)
204
+ ```
205
+
206
+ ### Deprecation Format
207
+
208
+ When deprecating a pattern, modify the existing entry's heading:
209
+
210
+ ```markdown
211
+ ### ~~Pattern Name~~ (DEPRECATED: {YYYY-MM-DD} — Superseded by "{new pattern name}")
212
+ ```
213
+
214
+ The heading gets strikethrough. The body stays intact for historical reference. Do NOT delete deprecated patterns.
215
+
216
+ ---
217
+
218
+ ## Rules
219
+
220
+ 1. **Silent during execution**: Never interrupt work to discuss a captured pattern
221
+ 2. **Buffer is a file**: Always write to `flow/resources/pending-patterns.md` — never keep patterns only in conversation memory
222
+ 3. **User gate required**: Every pattern needs explicit user approval before being written to rule files
223
+ 4. **Check before capture**: Read target files before adding to buffer — skip already-documented patterns
224
+ 5. **One review per skill**: Present the review once at the end, not after each phase
225
+ 6. **Never delete rule entries**: Deprecated patterns stay with strikethrough for history
226
+ 7. **Metadata footer required**: Every auto-captured entry must include the `_Auto-captured on...` line
227
+ 8. **Clean buffer after review**: Always clear pending-patterns.md after the review step
@@ -5,7 +5,7 @@
5
5
 
6
6
  Pattern files provide templates, examples, and guidelines for specific workflows. This is the largest category covering discovery, planning, testing, code review, and contracts.
7
7
 
8
- **Total Files**: 10 files, ~3,320 lines
8
+ **Total Files**: 11 files, ~3,420 lines
9
9
  **Reference Codes**: PTN-BR-1 through PTN-PR-6
10
10
 
11
11
  ---
@@ -21,6 +21,13 @@ Pattern files provide templates, examples, and guidelines for specific workflows
21
21
  | PTN-BR-3 | Feature status lifecycle and index update rules | brain-patterns.md | 162-210 |
22
22
  | PTN-BR-4 | Learning subdirectory for teaching curricula | brain-patterns.md | 12-14 |
23
23
 
24
+ ### Brainstorm Templates (`brainstorm-templates.md`)
25
+
26
+ | Code | Description | Source | Lines |
27
+ |------|-------------|--------|-------|
28
+ | PTN-BST-1 | Brainstorm document template with "For Discovery" bridge | brainstorm-templates.md | 5-75 |
29
+ | PTN-BST-2 | Status definitions and file naming conventions | brainstorm-templates.md | 77-105 |
30
+
24
31
  ### Contract Patterns (`contract-patterns.md`)
25
32
 
26
33
  | Code | Description | Source | Lines |
@@ -186,5 +193,8 @@ Pattern files provide templates, examples, and guidelines for specific workflows
186
193
  - **PTN-REV-***: Code review templates
187
194
  - **PTN-PR-***: PR review patterns
188
195
 
196
+ ### Brainstorm
197
+ - **PTN-BST-***: Brainstorm output templates
198
+
189
199
  ### Contracts
190
200
  - **PTN-CON-***: Integration contract patterns
@@ -0,0 +1,132 @@
1
+
2
+ ## Brainstorm Document Template
3
+
4
+ Use this template when generating brainstorm output files:
5
+
6
+ ```markdown
7
+ # Brainstorm: {Topic Name}
8
+
9
+ **Date**: {YYYY-MM-DD}
10
+ **Participants**: User + AI
11
+ **Status**: {crystallized | exploratory | early-stage}
12
+
13
+ ---
14
+
15
+ ## Core Idea
16
+
17
+ {The central thesis as it evolved during the conversation. This should be
18
+ a clear, concise description of what the idea IS — not how to build it.}
19
+
20
+ ---
21
+
22
+ ## Key Decisions
23
+
24
+ Forks that were discussed and resolved during the brainstorm.
25
+
26
+ | # | Decision | Reasoning |
27
+ |---|----------|-----------|
28
+ | 1 | {What was decided} | {Why this choice was made} |
29
+ | 2 | {What was decided} | {Why this choice was made} |
30
+
31
+ ---
32
+
33
+ ## Open Questions
34
+
35
+ Things raised during the brainstorm that remain unresolved.
36
+
37
+ - {Question 1}
38
+ - {Question 2}
39
+
40
+ ---
41
+
42
+ ## Constraints Discovered
43
+
44
+ Limitations that surfaced during the conversation.
45
+
46
+ - {Constraint 1 — where it came from}
47
+ - {Constraint 2 — where it came from}
48
+
49
+ ---
50
+
51
+ ## Inspirations & References
52
+
53
+ Existing tools, patterns, code, or external ideas that came up.
54
+
55
+ - {Reference 1} — {how it relates to the idea}
56
+ - {Reference 2} — {how it relates to the idea}
57
+
58
+ ---
59
+
60
+ ## Rejected Alternatives
61
+
62
+ Things considered and explicitly discarded, with reasoning preserved.
63
+
64
+ | Alternative | Why Rejected |
65
+ |-------------|-------------|
66
+ | {Option A} | {Reasoning for rejection} |
67
+ | {Option B} | {Reasoning for rejection} |
68
+
69
+ ---
70
+
71
+ ## For Discovery
72
+
73
+ This section bridges the brainstorm into the discovery phase. Feed this file
74
+ to `/discovery-plan` to ground the idea in the project's codebase.
75
+
76
+ ### Resolved During Brainstorm
77
+
78
+ These decisions are settled. Discovery should NOT re-ask them.
79
+
80
+ - {Decision 1}
81
+ - {Decision 2}
82
+
83
+ ### Still Open (Discovery Should Investigate)
84
+
85
+ These questions need codebase analysis and technical grounding.
86
+
87
+ - {Question 1 — what discovery should look for}
88
+ - {Question 2 — what discovery should look for}
89
+
90
+ ### Rejected (Do Not Revisit)
91
+
92
+ These were explicitly considered and rejected. Discovery should not re-propose them.
93
+
94
+ - {Rejected alternative 1}
95
+ - {Rejected alternative 2}
96
+ ```
97
+
98
+ ---
99
+
100
+ ## Status Definitions
101
+
102
+ | Status | Meaning |
103
+ |--------|---------|
104
+ | `crystallized` | Idea is clear and well-defined — ready for discovery |
105
+ | `exploratory` | Idea has shape but still has open questions |
106
+ | `early-stage` | Initial exploration — needs more brainstorming or research |
107
+
108
+ ---
109
+
110
+ ## File Naming
111
+
112
+ - **Format**: `brainstorm_{kebab-case-topic}_v{version}.md`
113
+ - **Location**: `flow/brainstorms/`
114
+ - **Examples**:
115
+ - `brainstorm_plugin-system_v1.md`
116
+ - `brainstorm_real-time-notifications_v1.md`
117
+ - `brainstorm_error-recovery-strategy_v2.md`
118
+
119
+ ---
120
+
121
+ ## Usage with Discovery
122
+
123
+ The brainstorm file is designed to be fed directly into `/discovery-plan`:
124
+
125
+ ```bash
126
+ /discovery-plan @flow/brainstorms/brainstorm_plugin-system_v1.md
127
+ ```
128
+
129
+ Discovery will:
130
+ 1. Read the brainstorm and inherit resolved decisions
131
+ 2. Use "Still Open" questions as starting points for codebase investigation
132
+ 3. Respect "Rejected" alternatives and not re-propose them
@@ -102,6 +102,50 @@ Use this template when creating discovery documents:
102
102
 
103
103
  [Identified difficulties]
104
104
 
105
+ ## Design Context
106
+
107
+ > Include this section only when UI work is confirmed during discovery.
108
+
109
+ ### Design Personality
110
+ {personality name} — {brief description of the visual style}
111
+
112
+ ### Color Palette
113
+ | Token | Value | Usage |
114
+ |-------|-------|-------|
115
+ | Primary | #XXXXXX | Main actions, CTAs |
116
+ | Secondary | #XXXXXX | Supporting elements |
117
+ | Background | #XXXXXX | Page/card backgrounds |
118
+ | Surface | #XXXXXX | Elevated surfaces |
119
+ | Text Primary | #XXXXXX | Main body text |
120
+ | Text Secondary | #XXXXXX | Secondary/muted text |
121
+ | Error | #XXXXXX | Error states |
122
+ | Success | #XXXXXX | Success states |
123
+
124
+ ### Typography
125
+ | Element | Font | Size | Weight |
126
+ |---------|------|------|--------|
127
+ | Heading 1 | {font} | {size} | {weight} |
128
+ | Heading 2 | {font} | {size} | {weight} |
129
+ | Body | {font} | {size} | {weight} |
130
+ | Caption | {font} | {size} | {weight} |
131
+
132
+ ### Spacing Scale
133
+ | Token | Value |
134
+ |-------|-------|
135
+ | xs | {value} |
136
+ | sm | {value} |
137
+ | md | {value} |
138
+ | lg | {value} |
139
+ | xl | {value} |
140
+
141
+ ### Component Patterns
142
+ - {Pattern 1}: {description}
143
+ - {Pattern 2}: {description}
144
+
145
+ ### Design Source
146
+ - **Source**: {screenshots / Figma export / design personality / existing system.md}
147
+ - **Files**: {list of provided design files, if any}
148
+
105
149
  ## Proposed Approach
106
150
 
107
151
  [High-level approach recommendation based on findings]
@@ -5,15 +5,29 @@
5
5
 
6
6
  Skills implement the workflow logic for commands. Each skill orchestrates a specific process like discovery, planning, execution, or code review.
7
7
 
8
- **Total Files**: 10 files, ~3,100 lines
8
+ **Total Files**: 12 files, ~3,500 lines
9
9
  **Reference Codes**: SKL-BR-1 through SKL-TEST-5
10
10
 
11
11
  > **Note**: All skills (except brain and flow) include a Resource Capture section. During execution, the LLM watches for valuable reference materials and asks the user before saving to `flow/resources/`. See `.claude/resources/core/resource-capture.md` for full rules.
12
+ >
13
+ > **Note**: The execute-plan, discovery, and review-code skills also include Pattern Capture. During execution, the LLM silently buffers coding patterns and anti-patterns, then presents them for user approval at the end. Approved patterns are written to `.claude/rules/core/allowed-patterns.md` or `forbidden-patterns.md`. See `.claude/resources/core/pattern-capture.md` for full rules.
14
+ >
15
+ > **Note**: The execute-plan skill supports **Model Routing** — automatic model selection per phase based on complexity scores (0-3 → haiku, 4-5 → sonnet, 6-10 → opus). Controlled by `model_routing` in `flow/.flowconfig`. See `.claude/resources/core/model-routing.md` for full rules.
16
+ >
17
+ > **Note**: The discovery skill also includes **Design Awareness**. During discovery, the LLM asks whether the feature involves UI work and captures structured design tokens (colors, typography, spacing) into a `## Design Context` section. During execution, these tokens are auto-injected into UI phase prompts. See `.claude/resources/core/design-awareness.md` for full rules.
12
18
 
13
19
  ---
14
20
 
15
21
  ## Reference Codes
16
22
 
23
+ ### Brainstorm Skill (`brainstorm-skill.md`)
24
+
25
+ | Code | Description | Source | Lines |
26
+ |------|-------------|--------|-------|
27
+ | SKL-BS-1 | Purpose, restrictions, and inputs | brainstorm-skill.md | 8-60 |
28
+ | SKL-BS-2 | Conversational loop, question types, and silent tracking | brainstorm-skill.md | 62-150 |
29
+ | SKL-BS-3 | End detection, summary, output generation, and tasklist offer | brainstorm-skill.md | 152-220 |
30
+
17
31
  ### Brain Skill (`brain-skill.md`)
18
32
 
19
33
  | Code | Description | Source | Lines |
@@ -58,6 +72,15 @@ Skills implement the workflow logic for commands. Each skill orchestrates a spec
58
72
  | SKL-LRN-3 | Teaching mode restrictions and curriculum generation | learn-skill.md | 140-175 |
59
73
  | SKL-LRN-4 | Step confirmation flow and storage rules | learn-skill.md | 177-210 |
60
74
 
75
+ ### Flow Cost Skill (`flow-cost.md`)
76
+
77
+ | Code | Description | Source | Lines |
78
+ |------|-------------|--------|-------|
79
+ | SKL-COST-1 | Usage and filter flags | flow-cost.md | 7-18 |
80
+ | SKL-COST-2 | Implementation steps (read, filter, aggregate, format) | flow-cost.md | 20-85 |
81
+ | SKL-COST-3 | Output format examples (default, detail, session) | flow-cost.md | 87-145 |
82
+ | SKL-COST-4 | JSONL schema and error handling | flow-cost.md | 147-195 |
83
+
61
84
  ### Execute Plan Skill (`execute-plan-skill.md`)
62
85
 
63
86
  | Code | Description | Source | Lines |
@@ -164,7 +187,9 @@ Skills implement the workflow logic for commands. Each skill orchestrates a spec
164
187
 
165
188
  | Command | Skill | Key Codes |
166
189
  |---------|-------|-----------|
190
+ | `/brainstorm` | brainstorm-skill | SKL-BS-1 through SKL-BS-3 |
167
191
  | `/brain` | brain-skill | SKL-BR-1 through SKL-BR-3 |
192
+ | `/flow cost` | flow-cost | SKL-COST-1 through SKL-COST-4 |
168
193
  | `/learn` | learn-skill | SKL-LRN-1 through SKL-LRN-4 |
169
194
  | `/discovery-plan` | discovery-skill | SKL-DIS-1 through SKL-DIS-4 |
170
195
  | `/create-plan` | create-plan-skill | SKL-PLN-1 through SKL-PLN-4 |
@@ -186,7 +211,9 @@ Skills implement the workflow logic for commands. Each skill orchestrates a spec
186
211
  | execute-plan-skill | 388 | 6 | High - phase execution logic |
187
212
  | review-code-skill | 308 | 5 | Medium - pattern matching |
188
213
  | discovery-skill | 295 | 4 | Medium - requirements gathering |
214
+ | brainstorm-skill | 280 | 3 | Medium - structured exploration with interactive questions |
189
215
  | write-tests-skill | 294 | 5 | Medium - iterative testing |
190
216
  | create-plan-skill | 271 | 4 | Low - plan structuring |
191
217
  | learn-skill | 185 | 4 | Medium - pattern extraction + teaching mode |
218
+ | flow-cost | 195 | 4 | Low - JSONL parsing and reporting |
192
219
  | create-contract-skill | 239 | 4 | Low - contract generation |