planflow-ai 1.2.0 → 1.3.2

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 (48) 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/heartbeat.md +1 -1
  6. package/.claude/commands/learn.md +1 -1
  7. package/.claude/commands/{brain.md → note.md} +12 -12
  8. package/.claude/commands/review-code.md +63 -0
  9. package/.claude/commands/review-pr.md +53 -0
  10. package/.claude/resources/core/_index.md +85 -2
  11. package/.claude/resources/core/design-awareness.md +400 -0
  12. package/.claude/resources/core/model-routing.md +116 -0
  13. package/.claude/resources/core/pattern-capture.md +227 -0
  14. package/.claude/resources/core/resource-capture.md +1 -1
  15. package/.claude/resources/core/review-adaptive-depth.md +217 -0
  16. package/.claude/resources/core/review-multi-agent.md +289 -0
  17. package/.claude/resources/core/review-severity-ranking.md +149 -0
  18. package/.claude/resources/core/review-verification.md +158 -0
  19. package/.claude/resources/patterns/_index.md +11 -1
  20. package/.claude/resources/patterns/brainstorm-templates.md +132 -0
  21. package/.claude/resources/patterns/discovery-templates.md +44 -0
  22. package/.claude/resources/patterns/review-code-templates.md +315 -2
  23. package/.claude/resources/skills/_index.md +37 -2
  24. package/.claude/resources/skills/brain-skill.md +3 -3
  25. package/.claude/resources/skills/brainstorm-skill.md +284 -0
  26. package/.claude/resources/skills/discovery-skill.md +38 -4
  27. package/.claude/resources/skills/execute-plan-skill.md +66 -4
  28. package/.claude/resources/skills/flow-cost.md +153 -0
  29. package/.claude/resources/skills/review-code-skill.md +89 -1
  30. package/.claude/resources/skills/review-pr-skill.md +58 -0
  31. package/.claude/rules/core/allowed-patterns.md +6 -0
  32. package/.claude/rules/core/forbidden-patterns.md +6 -0
  33. package/README.md +38 -3
  34. package/dist/cli/daemon/heartbeat-daemon.js +7 -2
  35. package/dist/cli/daemon/heartbeat-daemon.js.map +1 -1
  36. package/dist/cli/handlers/claude.d.ts.map +1 -1
  37. package/dist/cli/handlers/claude.js +138 -2
  38. package/dist/cli/handlers/claude.js.map +1 -1
  39. package/dist/cli/handlers/shared.d.ts.map +1 -1
  40. package/dist/cli/handlers/shared.js +2 -1
  41. package/dist/cli/handlers/shared.js.map +1 -1
  42. package/dist/cli/index.js +0 -0
  43. package/package.json +1 -1
  44. package/rules/skills/brain-skill.mdc +4 -4
  45. package/skills/plan-flow/SKILL.md +1 -1
  46. package/skills/plan-flow/brain/SKILL.md +1 -1
  47. package/templates/shared/AGENTS.md.template +1 -1
  48. package/templates/shared/CLAUDE.md.template +28 -11
@@ -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
@@ -13,7 +13,7 @@ During any skill execution, the LLM watches for information that could be valuab
13
13
 
14
14
  ### During Any Skill Execution
15
15
 
16
- While executing any plan-flow skill (`/setup`, `/discovery-plan`, `/create-plan`, `/execute-plan`, `/review-code`, `/review-pr`, `/write-tests`, `/create-contract`, `/brain`), watch for information that meets the capture criteria below.
16
+ While executing any plan-flow skill (`/setup`, `/discovery-plan`, `/create-plan`, `/execute-plan`, `/review-code`, `/review-pr`, `/write-tests`, `/create-contract`, `/note`), watch for information that meets the capture criteria below.
17
17
 
18
18
  When you identify something worth preserving:
19
19
 
@@ -0,0 +1,217 @@
1
+
2
+ # Review Adaptive Depth
3
+
4
+ ## Purpose
5
+
6
+ Scale review depth based on changeset size. Small changes get a fast lightweight pass, large changes get a deeper multi-category review with severity-grouped output and executive summary. Medium changes use the standard review (no behavior change).
7
+
8
+ **Scope**: `/review-code` (Step 1b) and `/review-pr` (Step 1b). Applied after identifying changed files, before loading patterns.
9
+
10
+ **Goal**: Save tokens on trivial PRs and improve quality on complex ones. A 5-line typo fix shouldn't get the same depth as a 2000-line refactor.
11
+
12
+ ---
13
+
14
+ ## Size Detection
15
+
16
+ ### Line Counting Rules
17
+
18
+ Count total lines changed (additions + deletions) from the diff.
19
+
20
+ **Exclude** from the count:
21
+ - Lock files: `package-lock.json`, `yarn.lock`, `pnpm-lock.yaml`, `Gemfile.lock`, `poetry.lock`, `Cargo.lock`, `go.sum`
22
+ - Generated files: any path containing `.generated.`, `dist/`, `build/`, `.min.js`, `.min.css`
23
+ - Pure whitespace/formatting changes (lines where only indentation changed)
24
+
25
+ **For review-code**: Use `git diff --stat` to get line counts, then subtract excluded files.
26
+
27
+ **For review-pr**: Use PR diff stats from `gh pr diff --stat` or Azure DevOps diff API, then subtract excluded files.
28
+
29
+ ### Display Format
30
+
31
+ Always show the detected mode before starting the review:
32
+
33
+ ```markdown
34
+ **Review mode**: {Lightweight|Standard|Deep} ({N} lines changed across {M} files)
35
+ ```
36
+
37
+ ---
38
+
39
+ ## Tier Definitions
40
+
41
+ | Tier | Lines Changed | Review Mode |
42
+ |------|--------------|-------------|
43
+ | **Small** | < 50 | Lightweight |
44
+ | **Medium** | 50–500 | Standard (current behavior, no changes) |
45
+ | **Large** | 500+ | Deep |
46
+
47
+ Thresholds are hardcoded. No configuration needed.
48
+
49
+ ---
50
+
51
+ ## Lightweight Review Mode (Small, < 50 lines)
52
+
53
+ For changesets under 50 lines, perform a focused quick-scan review.
54
+
55
+ ### What to Check (ONLY these)
56
+
57
+ 1. **Security issues** — hardcoded secrets, injection vulnerabilities, auth bypass, exposed credentials
58
+ 2. **Obvious logic bugs** — wrong condition, off-by-one, null/undefined access, infinite loops
59
+ 3. **Breaking changes** — API signature changes, removed exports, changed return types
60
+
61
+ ### What to Skip
62
+
63
+ - Naming suggestions
64
+ - Pattern compliance
65
+ - Performance optimization
66
+ - Test coverage analysis
67
+ - Similar implementation search
68
+ - Pattern conflict detection
69
+
70
+ ### Verification Pass
71
+
72
+ **Skip entirely.** Lightweight reviews produce few findings — verification adds overhead with minimal value on small changesets.
73
+
74
+ ### Output
75
+
76
+ If no issues found, output a short **LGTM review**:
77
+
78
+ ```markdown
79
+ ## Review Summary
80
+
81
+ | Metric | Value |
82
+ |--------|-------|
83
+ | **Review Mode** | Lightweight (< 50 lines) |
84
+ | **Total Findings** | 0 |
85
+ | **Status** | LGTM |
86
+
87
+ ## Positive Highlights
88
+
89
+ - {Highlight 1}
90
+ - {Highlight 2}
91
+ - {Highlight 3}
92
+
93
+ ## Commit Readiness
94
+
95
+ | Status | Ready to Commit |
96
+ |--------|-----------------|
97
+ | Reason | No issues found in lightweight review |
98
+ ```
99
+
100
+ If issues ARE found, use the standard finding format but keep the compact template (no Reference Implementations, no Pattern Conflicts sections).
101
+
102
+ ---
103
+
104
+ ## Deep Review Mode (Large, 500+ lines)
105
+
106
+ For changesets over 500 lines, perform a structured multi-pass review.
107
+
108
+ ### Step 1: Categorize Changed Files
109
+
110
+ Group all changed files by type:
111
+
112
+ | Category | Heuristics |
113
+ |----------|-----------|
114
+ | **Core Logic** | `src/`, `lib/`, `app/` (excluding UI paths), service files, utility files, business logic |
115
+ | **Infrastructure** | Config files, CI/CD (`.github/`, `.gitlab-ci`), build config, Docker, env files |
116
+ | **UI/Presentation** | Components, pages, layouts, styles, templates — detected by path (`components/`, `pages/`, `views/`) or extension (`.tsx`, `.jsx`, `.vue`, `.svelte`, `.css`, `.scss`) |
117
+ | **Tests** | Any file in `__tests__/`, `test/`, `tests/`, `spec/`, or files ending in `.test.*`, `.spec.*` |
118
+
119
+ Files that don't match any heuristic → default to **Core Logic**.
120
+
121
+ ### Step 2: Prioritize Review Order
122
+
123
+ Review in this order: **Core Logic → Infrastructure → UI → Tests**
124
+
125
+ Core logic gets the deepest review. Tests get a quick coverage-adequacy scan.
126
+
127
+ ### Step 3: Focused Passes per Category
128
+
129
+ | Category | Focus Areas |
130
+ |----------|-------------|
131
+ | **Core Logic** | Bugs, edge cases, security, error handling, null safety |
132
+ | **Infrastructure** | Security (secrets, permissions), breaking changes, compatibility |
133
+ | **UI/Presentation** | Accessibility, performance (re-renders, large bundles), state management |
134
+ | **Tests** | Coverage adequacy, test quality (quick scan only — not a full analysis) |
135
+
136
+ ### Step 4: Always Run Verification Pass
137
+
138
+ All findings from deep review must go through the standard verification pass (see `review-verification.md`).
139
+
140
+ ### Step 5: Severity-Grouped Output
141
+
142
+ Group findings by severity instead of by file:
143
+
144
+ ```markdown
145
+ ## Critical Findings
146
+ ### Finding 1: ...
147
+ ### Finding 2: ...
148
+
149
+ ## Major Findings
150
+ ### Finding 3: ...
151
+
152
+ ## Minor Findings
153
+ ### Finding 4: ...
154
+
155
+ ## Suggestions
156
+ ### Finding 5: ...
157
+ ```
158
+
159
+ ### Step 6: Executive Summary
160
+
161
+ Add an executive summary at the top of the review document, before the findings:
162
+
163
+ ```markdown
164
+ ## Executive Summary
165
+
166
+ ### Files Changed by Category
167
+
168
+ | Category | Files | Lines Changed |
169
+ |----------|-------|--------------|
170
+ | Core Logic | {N} | +{add}/-{del} |
171
+ | Infrastructure | {N} | +{add}/-{del} |
172
+ | UI/Presentation | {N} | +{add}/-{del} |
173
+ | Tests | {N} | +{add}/-{del} |
174
+
175
+ ### Risk Assessment
176
+
177
+ **Overall Risk**: {Low | Medium | High}
178
+
179
+ {1-2 sentence justification based on scope, categories affected, and finding severity distribution}
180
+
181
+ ### Top 3 Findings
182
+
183
+ 1. **[{Severity}]** {Finding title} — {one-line description} (`{file}:{line}`)
184
+ 2. **[{Severity}]** {Finding title} — {one-line description} (`{file}:{line}`)
185
+ 3. **[{Severity}]** {Finding title} — {one-line description} (`{file}:{line}`)
186
+ ```
187
+
188
+ ---
189
+
190
+ ## Insertion Points
191
+
192
+ ### For review-code-skill.md
193
+
194
+ Insert as **Step 1b: Determine Review Depth** — after Step 1 (Identify Changed Files), before Step 2 (Load Review Patterns).
195
+
196
+ **Lightweight shortcut**: If Small tier, skip Steps 2-5 (pattern loading, similar implementations, full analysis, pattern conflicts). Perform abbreviated analysis checking only security/logic/breaking changes. Skip verification pass. Generate lightweight template.
197
+
198
+ **Deep expansion**: If Large tier, in Step 3 categorize files by type. In Step 4 run focused passes per category. In Step 5b apply verification to all findings. In Step 6 use deep template with severity grouping + executive summary.
199
+
200
+ ### For review-pr-skill.md
201
+
202
+ Insert as **Step 1b: Determine Review Depth** — after Step 1 (Fetch PR Information), before Step 2 (Load Review Patterns).
203
+
204
+ Same lightweight shortcut and deep expansion logic as review-code.
205
+
206
+ ---
207
+
208
+ ## Related Files
209
+
210
+ | File | Purpose |
211
+ |------|---------|
212
+ | `.claude/resources/skills/review-code-skill.md` | Add Step 1b (Determine Review Depth) |
213
+ | `.claude/resources/skills/review-pr-skill.md` | Add Step 1b (Determine Review Depth) |
214
+ | `.claude/resources/patterns/review-code-templates.md` | Add lightweight and deep templates |
215
+ | `.claude/resources/core/review-verification.md` | Verification pass (skipped for lightweight, required for deep) |
216
+ | `.claude/commands/review-code.md` | Add Adaptive Depth section |
217
+ | `.claude/commands/review-pr.md` | Add Adaptive Depth section |