moflo 4.9.11 → 4.9.13

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.
@@ -1,55 +1,103 @@
1
1
  ---
2
- description: Review changed code for reuse, quality, and efficiency, then fix any issues found.
2
+ description: Review changed code for reuse, quality, and efficiency, then fix any issues found. Sizes review effort to the diff and routes the cheapest model that fits.
3
3
  ---
4
4
 
5
- # /simplify — Gate-Compliant Code Review
5
+ # /simplify — Adaptive Gate-Compliant Code Review
6
6
 
7
- Review all changed files for reuse opportunities, code quality, and efficiency improvements.
7
+ Review changed code for reuse, quality, and efficiency. **Effort scales with diff size; model is routed for cost.** A 5-line comment trim does not get 3 Opus agents.
8
8
 
9
- **This command overrides any built-in simplify skill.** Follow these steps exactly.
9
+ ## Phase 0: Gate prerequisites
10
10
 
11
- ## Prerequisites (MANDATORY do these FIRST)
11
+ These satisfy the memory-first and task-create-first gates. Always do them before any Agent spawn.
12
12
 
13
- 1. **Memory search**: Search for relevant patterns before reviewing
14
- ```
15
- mcp__moflo__memory_search — query: "code quality patterns", namespace: "patterns"
16
- ```
13
+ 1. **Memory search** `mcp__moflo__memory_search query: "code quality patterns", namespace: "patterns"`
14
+ 2. **Task create** — `TaskCreate — subject: "🔍 [Reviewer] Simplify changed code"`
17
15
 
18
- 2. **Create task**: Track the simplification work
19
- ```
20
- TaskCreate — subject: "🔍 [Reviewer] Simplify changed code", description: "Review changed files for reuse, quality, and efficiency"
16
+ ## Phase 1: Identify the diff
17
+
18
+ ```bash
19
+ git diff HEAD # working tree
20
+ git diff main...HEAD # committed since branch base
21
21
  ```
22
22
 
23
- ## Execution
23
+ Treat the union as the diff. Note whether `/simplify` already ran on this branch in this session — if so, you are in a **validation pass** (Phase 4 below).
24
24
 
25
- After prerequisites are satisfied, get the list of changed files:
25
+ ## Phase 2: Classify the diff
26
26
 
27
- ```bash
28
- git diff --name-only HEAD~1
29
- ```
27
+ Pick the smallest tier the diff genuinely fits.
30
28
 
31
- Then launch 3 reviewer agents **in parallel** (single message, multiple Agent tool calls).
29
+ | Tier | Trigger | Action |
30
+ |------|---------|--------|
31
+ | **TRIVIAL** | ≤10 net LOC, single file, comments/formatting/local renames only | Self-review, zero agents |
32
+ | **SMALL** | ≤200 net LOC, ≤2 files, no API/dependency change | **One agent** (default for most diffs, including critical surface) |
33
+ | **NORMAL** | ≥3 files, OR >200 LOC, OR public API change, OR new/removed dependency, OR cross-cutting refactor | Three parallel agents |
32
34
 
33
- **CRITICAL**: Each agent prompt below includes a mandatory memory search step. This is required because subagents must satisfy the memory-first gate independently before using Glob, Grep, or Read tools. Do NOT remove the memory search from agent prompts.
35
+ Critical-surface files (launcher, hooks, MCP wiring) raise the *care* of the agent prompt sharper checklist, blast-radius framing they do **not** automatically escalate to NORMAL. Risk-weighted headcount-weighted.
36
+
37
+ ## Phase 3: Route the model (skip for TRIVIAL)
38
+
39
+ Before spawning any Agent, ask the moflo router which model to use:
34
40
 
35
- ### Agent 1: Reuse Reviewer
36
41
  ```
37
- Agentname: "reuse-reviewer", run_in_background: true, subagent_type: "reviewer", prompt: "FIRST ACTION: Run mcp__moflo__memory_search with query 'code reuse patterns' and namespace 'patterns'. You MUST do this before any Glob, Grep, or Read calls. THEN review these changed files for code reuse opportunities. Look for: duplicated logic that could use existing utilities, patterns already solved elsewhere in the codebase, opportunities to extract shared helpers. Files: $CHANGED_FILES"
42
+ mcp__moflo__hooks_model-route{
43
+ task: "Review N-line change in <files> for reuse, quality, efficiency",
44
+ preferCost: true
45
+ }
38
46
  ```
39
47
 
40
- ### Agent 2: Quality Reviewer
48
+ **Wording rules:** the router's complexity score is keyword-sensitive. Avoid `refactor`, `architect`, `audit`, `system`, `redesign`, `migrate` — those force opus even when scoring suggests sonnet. State LOC count, file count, and "review for reuse, quality, efficiency". Nothing more.
49
+
50
+ **Hard rule for `/simplify`: opus is never correct.** Code review never needs Opus reasoning, even on critical surface. If the router returns `opus`, downgrade to `sonnet`. On router failure, default to `sonnet`. Comment trims and pure formatting → `haiku`.
51
+
52
+ ## Phase 4: Validation pass (re-run after fixes from a prior simplify)
53
+
54
+ If `/simplify` already ran on this branch in this session AND the only edits since are fixes the prior pass surfaced, **default to TRIVIAL self-review** regardless of LOC count. The fan-out happened; the fix is small relative to the already-reviewed diff.
55
+
56
+ Escalate one tier (self-review → SMALL agent) only if the fix introduced a new file, a new exported symbol, a new dependency, or a control-flow change not covered by the original findings. Never escalate a validation pass to NORMAL.
57
+
58
+ ## Phase 5: Run the appropriate review
59
+
60
+ ### TRIVIAL / Validation
61
+ Run the three category checks (reuse / quality / efficiency) yourself in one pass against the diff. Most TRIVIAL diffs are clean — confirm and exit. Budget: ~30 seconds, no Agent.
62
+
63
+ ### SMALL — one agent
41
64
  ```
42
- Agent — name: "quality-reviewer", run_in_background: true, subagent_type: "reviewer", prompt: "FIRST ACTION: Run mcp__moflo__memory_search with query 'code quality patterns' and namespace 'patterns'. You MUST do this before any Glob, Grep, or Read calls. THEN review these changed files for code quality issues. Look for: unclear naming, overly complex logic, missing error handling at system boundaries, potential bugs, consistency with existing patterns. Files: $CHANGED_FILES"
65
+ Agent — {
66
+ subagent_type: "reviewer",
67
+ model: "<sonnet (or haiku for trivial-formatting tier from router)>",
68
+ prompt: "FIRST ACTION: Run mcp__moflo__memory_search with query 'code review patterns' and namespace 'patterns' to satisfy the memory-first gate. THEN review this diff for reuse, quality, and efficiency. <diff inline>. Flag specific issues as file:line + 1-line description. Max 5 file reads. Under 200 words. Skip cosmetic style. Don't suggest cross-cutting refactors of code outside this diff."
69
+ }
43
70
  ```
44
71
 
45
- ### Agent 3: Efficiency Reviewer
72
+ For critical-surface files, prepend a 1-line risk note (e.g., "This is `bin/session-start-launcher.mjs` — runs in every consumer's session-start hot path; cross-platform + blast-radius matter."). One careful agent, not three.
73
+
74
+ ### NORMAL — three parallel agents
75
+ Launch three agents in a single message, each at the routed model (typically sonnet). Each agent gets the SMALL-tier tool-budget cap.
76
+
77
+ - **Agent 1 (Reuse):** existing helpers/utilities that should be used; duplicated patterns; functions re-implementing something already in the codebase.
78
+ - **Agent 2 (Quality):** redundant state, parameter sprawl, copy-paste with variation, leaky abstractions, stringly-typed code, nested conditionals 3+ levels, unnecessary comments.
79
+ - **Agent 3 (Efficiency):** unnecessary work, missed concurrency, hot-path bloat, recurring no-op updates, TOCTOU existence checks, unbounded structures, over-broad reads.
80
+
81
+ Each agent prompt must start with `FIRST ACTION: mcp__moflo__memory_search ... namespace: "patterns"` — subagents must satisfy the memory-first gate independently before Glob/Grep/Read.
82
+
83
+ ## Phase 6: Fix or skip
84
+
85
+ Aggregate findings. Fix each issue directly that's worth fixing. False positives or out-of-scope: note and skip without arguing.
86
+
87
+ If fixes were made, re-run tests to confirm nothing broke. If tests fail after a fix, revert it.
88
+
89
+ After fixes: the next `/simplify` invocation is a **validation pass** (Phase 4). Bundle related fixes into one batch so a single validation pass covers them — don't re-fan-out for cosmetic micro-corrections.
90
+
91
+ ## Phase 7: Optional — record routing outcome
92
+
93
+ If you spawned an agent, feed back the outcome so the router learns:
94
+
46
95
  ```
47
- Agentname: "efficiency-reviewer", run_in_background: true, subagent_type: "reviewer", prompt: "FIRST ACTION: Run mcp__moflo__memory_search with query 'performance optimization patterns' and namespace 'patterns'. You MUST do this before any Glob, Grep, or Read calls. THEN review these changed files for efficiency improvements. Look for: unnecessary allocations, O(n^2) where O(n) is possible, redundant operations, opportunities to batch or cache. Files: $CHANGED_FILES"
96
+ mcp__moflo__hooks_model-outcome{ task: "...", model: "<chosen>", outcome: "success" | "failure" | "escalated" }
48
97
  ```
49
98
 
50
- ## Post-Review
99
+ `escalated` only when a real miss happened that a higher tier would have caught — never used to retroactively justify opus.
100
+
101
+ ## Briefly summarize
51
102
 
52
- 1. Collect findings from all 3 reviewers
53
- 2. Apply fixes that preserve ALL existing functionality — no behavior changes
54
- 3. If fixes were made, re-run tests to confirm nothing broke
55
- 4. If tests fail after fixes, revert the simplification changes
103
+ End with one or two sentences: which tier ran, which model, what was fixed (or "clean — no changes"). No headers, no bullets.
@@ -0,0 +1,305 @@
1
+ ---
2
+ name: eldar
3
+ description: Consult the Eldar — audit a project's moflo + Claude Code setup for portable, high-leverage gaps and guide remediation. Default mode is read-only audit with severity-ranked findings; --fix presents an interactive triage menu and walks the user through each chosen fix (healer, missing CLAUDE.md, sparse guidance, hook/MCP wiring, empty memory namespaces, stack→guidance gaps). Use when starting in a new project, when Claude feels lost or inefficient, when guidance/CLAUDE.md is sparse, or as a periodic health check.
4
+ arguments: "[--fix]"
5
+ ---
6
+
7
+ # /eldar — Consult the Eldar
8
+
9
+ The Eldar audit a project's moflo + Claude Code setup for portable, high-leverage gaps. **Audit is read-only by default; `--fix` walks through remediation.** The Eldar consult the **Healer** (`flo healer`, the thematic alias for `flo doctor`), they do not replace them.
10
+
11
+ **Arguments:** $ARGUMENTS
12
+
13
+ ## Modes
14
+
15
+ | Mode | Trigger | What it does |
16
+ |------|---------|--------------|
17
+ | Audit | no flag (default) | Read-only scan; produces categorized findings + top-3 recommendation |
18
+ | Fix | `--fix` | Audit, then interactive triage menu; user picks findings to address one at a time |
19
+
20
+ ## Step 0 — Memory First
21
+
22
+ Before any file reads, run:
23
+
24
+ ```
25
+ mcp__moflo__memory_search { query: "guidance rules project conventions stack", namespace: "guidance" }
26
+ ```
27
+
28
+ The memory-first gate blocks reads otherwise. The search also surfaces any project-specific conventions the Eldar should weigh in their findings.
29
+
30
+ ## Step 1 — Run the Audit
31
+
32
+ Walk the checklist below in order. Each check is a single category in the final report. Be explicit about what you find — both presence and absence. Severities: `error` (blocks productive work), `warn` (degrades quality), `info` (suggestion).
33
+
34
+ ### 1a. Setup Health — call the Healer
35
+
36
+ ```bash
37
+ npx moflo healer --json
38
+ ```
39
+
40
+ Parse the JSON output. Surface every `failed` check as `error`, every `warn` as `warn`. Do **not** invoke `flo doctor` directly — use the `healer` alias for thematic consistency.
41
+
42
+ ### 1b. Index Freshness
43
+
44
+ Check for `.moflo/moflo.db` (existence + mtime). Query memory namespaces to confirm guidance + code-map are populated:
45
+
46
+ ```
47
+ mcp__moflo__memory_stats — { namespace: "guidance" }
48
+ mcp__moflo__memory_stats — { namespace: "code-map" }
49
+ ```
50
+
51
+ Flag if `entries === 0` (warn) or db missing (error).
52
+
53
+ ### 1c. Version Skew
54
+
55
+ ```bash
56
+ npm view moflo version # latest published
57
+ node -e "console.log(require('./package.json').devDependencies?.moflo || require('./package.json').dependencies?.moflo || 'not-installed')"
58
+ ```
59
+
60
+ Compute minor-version delta. Warn if behind by ≥3 minors; info if behind by 1–2.
61
+
62
+ ### 1d. Model & Token Routing
63
+
64
+ ```
65
+ mcp__moflo__hooks_model-stats — {}
66
+ ```
67
+
68
+ If recent sonnet→opus escalation rate exceeds ~30%, flag as `info`: "router escalating frequently — see `.claude/guidance/shipped/moflo-claude-swarm-cohesion.md` for tuning". If stats unavailable (no history), skip silently.
69
+
70
+ ### 1e. CLAUDE.md
71
+
72
+ Check `CLAUDE.md` (and `.claude/CLAUDE.md`) for:
73
+
74
+ | Check | Threshold | Severity |
75
+ |-------|-----------|----------|
76
+ | Exists | required | error if missing |
77
+ | Line count | 20–500 | warn if outside range |
78
+ | Referenced files exist | every relative path it cites | warn per missing path |
79
+
80
+ Use `Grep` over the file content for `\.claude/[a-z-]+/[a-z-]+\.md` patterns and verify each path resolves.
81
+
82
+ ### 1f. Guidance Content
83
+
84
+ Count `.md` files under `.claude/guidance/` (recursive). Severity table:
85
+
86
+ | File count | Severity |
87
+ |------------|----------|
88
+ | 0 | warn — "no guidance docs; Claude has nothing project-specific to follow" |
89
+ | 1–2 | warn — "very sparse guidance" |
90
+ | 3–10 | info |
91
+ | 11+ | info |
92
+
93
+ ### 1g. Guidance Structure (only if 1f found ≥1 file)
94
+
95
+ Apply the universal rules from `.claude/guidance/shipped/moflo-guidance-rules.md`. For each `.md` file, check:
96
+
97
+ - Has `**Purpose:**` line right after H1
98
+ - Has `## See Also` at end
99
+ - Under 500 lines
100
+ - H2 headings are specific (not "Overview", "Configuration", "Examples")
101
+ - No hedged language in rule contexts (`should`, `might`, `consider`)
102
+
103
+ Do **not** duplicate `/guidance -a`'s logic verbatim — just produce a one-line summary per file (`<file>: <N issues>`). The Eldar surface gaps; `/guidance -a` does the deep audit.
104
+
105
+ ### 1h. Memory Health
106
+
107
+ For each of the canonical namespaces, check entry count:
108
+
109
+ ```
110
+ mcp__moflo__memory_stats — { namespace: "guidance" }
111
+ mcp__moflo__memory_stats — { namespace: "patterns" }
112
+ mcp__moflo__memory_stats — { namespace: "learnings" }
113
+ ```
114
+
115
+ Flag empty `learnings` as `info` (project hasn't accumulated decisions yet — fine for new projects). Flag empty `guidance` as `warn` (no indexed guidance means semantic search is degraded).
116
+
117
+ ### 1i. Hooks & MCP Wiring
118
+
119
+ Read `.claude/settings.json`. Check:
120
+
121
+ | Check | Severity |
122
+ |-------|----------|
123
+ | Session-start hook references the moflo launcher | error if missing |
124
+ | `mcpServers.moflo` is configured | error if missing |
125
+ | `hooks` section exists with at least pre-task/post-task entries | warn if absent |
126
+
127
+ If settings.json is malformed JSON, surface as `error`.
128
+
129
+ ### 1j. Settings Sanity
130
+
131
+ Spot-check `.claude/settings.json` for:
132
+
133
+ - `permissions` block exists (info if absent — every prompt becomes a confirmation)
134
+ - `env` block has at least the moflo entries the launcher writes
135
+ - `statusLine` is configured (info — quality-of-life, not blocking)
136
+
137
+ ### 1k. Spell Inventory
138
+
139
+ ```bash
140
+ npx moflo spell list
141
+ ```
142
+
143
+ Flag `info` if count is 0 (no spells registered — user may not know they exist).
144
+
145
+ ### 1l. Subagent Fleet
146
+
147
+ ```
148
+ Glob — { pattern: ".claude/agents/**/*.md" }
149
+ ```
150
+
151
+ Count the result. `info` if 0 (no project-specific subagents — user is relying entirely on built-ins).
152
+
153
+ ### 1m. Stack → Guidance Cross-Reference (highest leverage)
154
+
155
+ Detect the project's stack from manifests:
156
+
157
+ | Manifest | Detected stack |
158
+ |----------|----------------|
159
+ | `package.json` deps | Node — inspect for React, Next, Drizzle, Prisma, Express, NestJS, Vite, etc. |
160
+ | `pyproject.toml` / `requirements.txt` | Python — Django, FastAPI, SQLAlchemy, etc. |
161
+ | `Cargo.toml` | Rust — axum, tokio, sqlx, etc. |
162
+ | `go.mod` | Go — gin, sqlc, gorm, etc. |
163
+ | `Gemfile` | Ruby — Rails, Sidekiq, etc. |
164
+
165
+ For each detected technology, check whether `.claude/guidance/` mentions it (Grep for the technology name across the directory). Each `(detected stack item, no guidance match)` pair becomes one `info` finding: "uses Drizzle ORM but no DB-conventions guidance — high-leverage gap".
166
+
167
+ This is the **highest-impact finding** for new adopters. Lead with it in the recommendation.
168
+
169
+ ### 1n. Anti-Pattern from History (best-effort, optional)
170
+
171
+ If recent transcripts/commits are accessible, scan them for repeated manual work that an existing spell or agent already covers (e.g., 5+ separate `git status`/`git diff`/run-tests sequences in a session that `/simplify` would have handled). Surface as `info`: "consider /simplify for review loops". If unavailable, skip silently — never block the audit on this.
172
+
173
+ ## Step 2 — Render the Report
174
+
175
+ Output a single table grouped by category, sorted by severity (`error` → `warn` → `info`):
176
+
177
+ ```
178
+ ELDAR AUDIT — <project name>
179
+ ─────────────────────────────
180
+
181
+ Category Finding Severity
182
+ ─────────────────────────────────────────────────────────────────────────
183
+ Setup health Healer reports 0 errors, 1 warning warn
184
+ Index freshness Guidance index empty warn
185
+ CLAUDE.md File missing error
186
+ Guidance content 0 docs in .claude/guidance/ warn
187
+ Memory health guidance namespace empty warn
188
+ Stack → guidance Drizzle ORM in deps; no DB guidance info
189
+ Stack → guidance React Native; no mobile guidance info
190
+ Hooks & MCP wiring all wired ok
191
+ ... (etc) ...
192
+ ```
193
+
194
+ Then list the **top 3 ranked recommendations** in plain English, with rationale and citation:
195
+
196
+ ```
197
+ TOP 3 RECOMMENDATIONS
198
+ ─────────────────────
199
+
200
+ 1. Add CLAUDE.md (error)
201
+ Without it, Claude has no project entry point. Use the Eldar's
202
+ stack-aware scaffold via `/eldar --fix`.
203
+
204
+ 2. Add Drizzle conventions guidance (info — high leverage)
205
+ You use Drizzle ORM but have no DB-conventions doc. This is the
206
+ single highest-leverage gap for getting Claude to write idiomatic
207
+ queries and migrations in your codebase.
208
+ See: .claude/guidance/shipped/moflo-guidance-rules.md
209
+
210
+ 3. Run `flo healer --fix` (warn)
211
+ One auto-fixable warning. Run via `/eldar --fix` and select Healer.
212
+ ```
213
+
214
+ End the audit with a one-line prompt: "Run `/eldar --fix` to address these interactively."
215
+
216
+ ## Step 3 — Fix Mode (`--fix` flag only)
217
+
218
+ After the report, present a numbered triage menu:
219
+
220
+ ```
221
+ TRIAGE MENU
222
+ ───────────
223
+ [1] Add CLAUDE.md
224
+ [2] Add Drizzle conventions guidance
225
+ [3] Run flo healer --fix (1 warning)
226
+ [4] Add empty .claude/guidance/ docs to memory namespaces
227
+
228
+ Choose: all, none, or comma-separated numbers (e.g., 1,3): _
229
+ ```
230
+
231
+ Drive each chosen finding through its sub-flow. Confirm before any write.
232
+
233
+ ### 3a. CLAUDE.md scaffold
234
+
235
+ Ask the user 2–4 targeted questions based on detected stack:
236
+
237
+ 1. "What does this project do? (1-2 sentences for Claude's context)"
238
+ 2. "Primary tech stack confirmed: <detected list>. Anything missing?"
239
+ 3. "Any conventions Claude should follow (testing approach, branch model, etc.)?"
240
+ 4. "Any high-blast-radius areas Claude should be careful with?"
241
+
242
+ Compose a CLAUDE.md draft incorporating their answers + standard moflo memory-first rule. **Show the draft to the user before writing.** Never auto-fill opinionated content.
243
+
244
+ ### 3b. Stack → guidance authoring
245
+
246
+ For each chosen stack-gap finding:
247
+
248
+ - Hand off to `/guidance` skill for the heavy lifting — it already enforces the universal rules.
249
+ - Brief the user on what gap will be filled: "drafting Drizzle conventions doc covering query patterns, migrations, schema files".
250
+ - Ask 2–4 targeted questions about *their* conventions (not generic Drizzle tips — Claude should follow how *they* use it).
251
+ - The `/guidance` skill produces the draft and walks the user through the rules check.
252
+
253
+ ### 3c. Healer fixes
254
+
255
+ ```bash
256
+ npx moflo healer --fix
257
+ ```
258
+
259
+ Pass through the output verbatim. If the Healer reports manual-only fixes, surface them as next steps.
260
+
261
+ ### 3d. Hook/MCP wiring repair
262
+
263
+ Suggest:
264
+
265
+ ```bash
266
+ npx moflo init --upgrade
267
+ ```
268
+
269
+ This is the standard wiring repair path. If the user is wary of running init, surface the specific missing keys from `.claude/settings.json` and offer to write them directly.
270
+
271
+ ### 3e. Empty namespaces
272
+
273
+ Suggest concrete first entries based on detected stack. Example: "Your project uses Drizzle. Want me to seed `learnings` with the most common Drizzle gotchas as a starting set? You'd review each before storage."
274
+
275
+ If the user declines, that's fine — empty `learnings` is a valid state for a young project.
276
+
277
+ ### 3f. After each fix
278
+
279
+ After each chosen fix completes, ask: "Continue to next finding? (y/n)". Don't run them all in a batch — every change is high-leverage and deserves the user's attention.
280
+
281
+ ## Step 4 — Wrap-Up
282
+
283
+ After audit (or audit + chosen fixes), end with:
284
+
285
+ - **Audit-only**: One sentence — what was found, what to do next.
286
+ - **Fix mode**: One sentence per applied fix, plus a closing line on what remains.
287
+
288
+ Never leave the user without a clear next step.
289
+
290
+ ## Important
291
+
292
+ - **Memory-first is mandatory.** Step 0 runs the search; the gate blocks reads otherwise.
293
+ - **Call the Healer, not the Doctor.** `npx moflo healer` (alias) — never `flo doctor` — for thematic consistency.
294
+ - **No auto-write of opinionated content.** Every guidance doc, every CLAUDE.md draft, every namespace seed gets shown to the user first.
295
+ - **Portable only.** This skill ships to consumers via `.claude/skills/**/*.md` in the package files array. Never assume moflo source paths or moflo-internal state.
296
+ - **No kitchen sink.** The audit checklist is locked at the categories above. New checks require a specific portable benefit and an issue to discuss them.
297
+ - **Read-only by default.** `/eldar` (no flag) never writes. Only `--fix` writes, and only with per-finding confirmation.
298
+ - **Hand off to specialists.** `/guidance` for guidance authoring, `flo healer --fix` for setup repair, `flo init --upgrade` for wiring. The Eldar route, they don't reimplement.
299
+
300
+ ## See Also
301
+
302
+ - `.claude/guidance/shipped/moflo-guidance-rules.md` — Universal guidance writing rules used by `/guidance` and surfaced in 1g
303
+ - `.claude/skills/guidance/SKILL.md` — The skill `/eldar --fix` hands off to for guidance authoring
304
+ - `.claude/guidance/shipped/moflo-core-guidance.md` — moflo CLI / hooks / memory reference; useful when explaining wiring findings
305
+ - `.claude/guidance/shipped/moflo-claude-swarm-cohesion.md` — Subagent + task coordination reference cited in routing findings
@@ -5,7 +5,7 @@ description: Review changed code for reuse, quality, and efficiency, then fix an
5
5
 
6
6
  # /simplify — Adaptive Code Review
7
7
 
8
- Review changed code for reuse opportunities, quality issues, and efficiency improvements. **Effort scales with diff size** — a 5-line comment trim doesn't get the same treatment as a 500-line refactor.
8
+ Review changed code for reuse opportunities, quality issues, and efficiency improvements. **Effort scales with diff size and reuses prior context** — a 5-line comment trim doesn't get the same treatment as a 500-line refactor, and a re-run after fixing pass-1 findings doesn't re-pay for a fresh fan-out.
9
9
 
10
10
  ## Phase 1: Identify changes
11
11
 
@@ -13,9 +13,11 @@ Run `git diff HEAD` (working tree) and `git diff main...HEAD` (committed) to get
13
13
 
14
14
  Treat the union of staged + unstaged + committed-since-base as the diff to review.
15
15
 
16
+ Also note: was `/simplify` already run on this branch in this session? If yes, you're in a **validation pass** (Phase 2.5 below) — most of the heavy lifting is done.
17
+
16
18
  ## Phase 2: Classify the diff
17
19
 
18
- Pick the **smallest tier** the diff genuinely fits. When in doubt, escalate.
20
+ Pick the **smallest tier** the diff genuinely fits. When in doubt, escalate one step (not two).
19
21
 
20
22
  ### TRIVIAL — self-review, no agent spawn
21
23
  ALL of these must hold:
@@ -28,38 +30,103 @@ ALL of these must hold:
28
30
  Examples that qualify: trimming a comment, fixing a typo in a log message, renaming a private helper, reformatting a single block.
29
31
  Examples that DON'T qualify: changing an `if` condition, reordering function args, deleting a try/catch.
30
32
 
31
- ### SMALL — single agent, all three categories
33
+ ### SMALL — single agent, all three categories (DEFAULT for most diffs)
32
34
  ALL of these must hold:
33
- - ≤50 net LOC changed
35
+ - ≤200 net LOC changed
34
36
  - ≤2 files
35
37
  - No structural changes (no new modules, no API additions/removals, no contract changes)
36
38
 
37
- Examples that qualify: extracting a constant, inlining a one-liner, swapping a `for` for a `forEach`, adding one early-return.
39
+ This is the default tier for **most real diffs**, including changes to critical surface (launcher, hooks, MCP wiring). Critical surface raises the *care* of the agent prompt (sharper checklist, blast-radius framing), not the *number* of agents.
40
+
41
+ Examples that qualify: extracting a constant, inlining a one-liner, swapping a `for` for a `forEach`, adding one early-return, refactoring a single function within a file, adding a cache fast-path inside an existing block.
38
42
 
39
- ### NORMAL — three parallel agents (the original flow)
40
- Anything that doesn't fit TRIVIAL or SMALL. Includes any diff that:
41
- - Spans 3+ files
43
+ ### NORMAL — three parallel agents
44
+ Reserved for **genuinely cross-cutting** changes. ANY of these triggers NORMAL:
45
+ - 3+ files changed
46
+ - >200 net LOC changed
42
47
  - Adds/removes/renames a public API
43
- - Changes control flow in a non-trivial way
44
48
  - Introduces or removes a dependency
45
- - Touches `bin/`, hooks, MCP tool handlers, or anything called out in `CLAUDE.md` as critical surface
49
+ - Cross-cutting refactor (touches the same pattern in multiple modules)
50
+
51
+ Three agents exist to cover orthogonal axes (Reuse / Quality / Efficiency) when the change is broad enough that one agent's tool-call budget can't survey it all. For single-file edits, one focused agent always covers all three axes — three is duplication, not coverage.
52
+
53
+ ## Phase 2.5: Validation pass (re-run after fixes)
54
+
55
+ If `/simplify` already ran on this branch in this session AND the only edits since are fixes driven by the prior pass's findings, default to **self-review tier** regardless of LOC count. The fan-out already happened; the fix is small relative to the diff that was already reviewed.
56
+
57
+ Escalate one tier (self-review → SMALL agent) only if the fix introduced any of:
58
+ - A new file
59
+ - A new exported symbol
60
+ - A new dependency or import from a previously-untouched module
61
+ - A change to control flow not covered in the original findings
62
+
63
+ Do **not** escalate to NORMAL on a validation pass. If the fix is so structural that NORMAL is warranted, treat it as a fresh diff and start over from Phase 1.
64
+
65
+ ## Phase 2.7: Route the model (before any Agent spawn)
66
+
67
+ For every tier that spawns an Agent (SMALL / NORMAL — TRIVIAL self-review skips this), call the moflo router to pick the cheapest model that fits the task **before** invoking Agent:
68
+
69
+ ```
70
+ mcp__moflo__hooks_model-route — {
71
+ task: "<diff summary — see wording rules below>",
72
+ preferCost: true
73
+ }
74
+ ```
75
+
76
+ ### Wording the task description
77
+
78
+ The router's complexity score is keyword-sensitive. Words like `refactor`, `architect`, `audit`, `system`, `redesign`, `migrate` flip a high-complexity flag and force opus *even when scoring suggests sonnet*. For `/simplify` you are **always doing code review**, never genuine architecture, so frame the task accordingly:
79
+
80
+ - ✅ Good: `"Review 110-line single-file change in bin/session-start-launcher.mjs for reuse, quality, efficiency."`
81
+ - ❌ Bad: `"Review refactor that adds mtime-cache fast-path and architects new caching layer."`
46
82
 
47
- When CLAUDE.md flags a file as critical surface (SessionStart, launcher, hooks, MCP coordinator wiring, swarm/hive-mind), **always escalate to NORMAL** regardless of LOC count. Risk-weighted, not size-weighted.
83
+ Drop the trigger words. State LOC count, file count, and "review for reuse, quality, efficiency". That's enough signal.
84
+
85
+ ### Applying the result
86
+
87
+ The router returns `{ model: 'haiku' | 'sonnet' | 'opus', complexity, reasoning, alternatives, ... }`.
88
+
89
+ **Hard rule for `/simplify`: opus is never correct.** Code review does not require Opus-tier reasoning even on critical surface. If the router returns `opus`:
90
+
91
+ 1. Look at `alternatives` — if `sonnet` scores higher than the selected model's confidence, downgrade to sonnet.
92
+ 2. Otherwise, downgrade to sonnet anyway (treat opus as "router was uncertain — pick the safer middle").
93
+
94
+ Pass the final model verbatim to the Agent's `model` parameter (Agent accepts `'haiku' | 'sonnet' | 'opus'`). On router failure (MCP call errors), default to `'sonnet'`.
95
+
96
+ In practice: comment trims and pure formatting → haiku; everything else for `/simplify` → sonnet.
97
+
98
+ ### Feed back the outcome
99
+
100
+ After the agent completes, record the outcome so the router learns:
101
+
102
+ ```
103
+ mcp__moflo__hooks_model-outcome — { task: "<same wording as route call>", model: "<chosen>", outcome: "success" | "failure" | "escalated" }
104
+ ```
105
+
106
+ `escalated` = the agent missed something a higher-tier pass would have caught. That signal teaches the router to bias similar tasks upward next time. Don't fake `escalated` to retroactively justify opus — only record it when a *real* miss happened.
48
107
 
49
108
  ## Phase 3: Run the appropriate review
50
109
 
51
- ### TRIVIAL: self-review
52
- Run the same three category checks (reuse / quality / efficiency) yourself, in one pass, against the diff. Most TRIVIAL diffs will be clean — the goal is to confirm, not to fan out. If you find an issue, fix it; otherwise stamp clean. Total budget: ~30 seconds, no Agent calls.
110
+ ### TRIVIAL / Validation: self-review
111
+ Run the same three category checks (reuse / quality / efficiency) yourself, in one pass, against the diff. Most TRIVIAL and validation diffs will be clean — the goal is to confirm, not to fan out. If you find an issue, fix it; otherwise stamp clean. Total budget: ~30 seconds, no Agent calls. No router call needed.
53
112
 
54
- ### SMALL: one agent
55
- Launch a SINGLE Agent with subagent_type `reviewer` covering all three categories in one prompt. Pass the diff inline. Budget: ~1 minute.
113
+ ### SMALL: one agent (model from router)
114
+ Launch a SINGLE Agent with subagent_type `reviewer`, passing the model returned by Phase 2.7's router call. Cap the agent's tool budget by being explicit:
56
115
 
57
116
  ```
58
- Agent — subagent_type: "reviewer", prompt: "Review this diff for reuse, quality, and efficiency. <diff inline>. Flag specific issues with file:line; skip generic advice. Under 200 words."
117
+ Agent — {
118
+ subagent_type: "reviewer",
119
+ model: "<from router, typically 'sonnet'>",
120
+ prompt: "Review this diff for reuse, quality, and efficiency. <diff inline>. Flag specific issues as file:line + 1-line description. Max 5 file reads. Under 200 words. Skip cosmetic style. Don't suggest cross-cutting refactors of code outside this diff."
121
+ }
59
122
  ```
60
123
 
61
- ### NORMAL: three parallel agents (original flow)
62
- Launch three agents in a single message — Reuse, Quality, Efficiency — passing the full diff to each. Use the original flow's category checklists.
124
+ For critical-surface files, prepend a 1-line risk note to the prompt (e.g., "This is `bin/session-start-launcher.mjs` — runs in every consumer's session-start hot path; cross-platform + blast-radius matter."). One careful agent, not three.
125
+
126
+ Budget: ~1 minute.
127
+
128
+ ### NORMAL: three parallel agents (model from router, applied to all)
129
+ Launch three agents in a single message — Reuse, Quality, Efficiency — passing the full diff and the same routed `model` to each. Each agent gets the same tool-budget cap as SMALL.
63
130
 
64
131
  **Reuse**: existing helpers/utilities that should be used instead; duplicated patterns; new functions that re-implement something already in the codebase.
65
132
 
@@ -69,14 +136,16 @@ Launch three agents in a single message — Reuse, Quality, Efficiency — passi
69
136
 
70
137
  ## Phase 4: Fix or skip
71
138
 
72
- Aggregate findings. Fix each one directly. False positives or not-worth-fixing — note and skip without arguing. If TRIVIAL self-review found nothing, just confirm clean and exit.
139
+ Aggregate findings. Fix each one directly. False positives or not-worth-fixing — note and skip without arguing. If self-review found nothing, just confirm clean and exit.
73
140
 
74
141
  If fixes were made, re-run tests to confirm nothing broke. If tests fail after a fix, revert it.
75
142
 
143
+ After fixes: the next `/simplify` invocation is a **validation pass** (Phase 2.5). Do not re-fan-out unless the fix added genuinely new concerns — bundle related fixes into one batch so a single validation pass covers them.
144
+
76
145
  ## Phase 5: Stamp the gate
77
146
 
78
- Whatever tier ran, the gate (`check-before-pr`) registers /simplify as having executed. The skill is satisfied.
147
+ Whatever tier ran, the gate (`check-before-pr`) registers /simplify as having executed. The skill is satisfied. Self-review counts.
79
148
 
80
149
  ## Briefly summarize
81
150
 
82
- End with one or two sentences: which tier, what was fixed (or "clean — no changes"). No headers, no bullets unless needed.
151
+ End with one or two sentences: which tier ran, what was fixed (or "clean — no changes"). No headers, no bullets unless needed.
package/README.md CHANGED
@@ -431,6 +431,18 @@ Inside your AI client, use the `/spell-builder` skill to create, edit, and valid
431
431
  /spell-builder # Start the spell builder
432
432
  ```
433
433
 
434
+ ### Other AI-client skills shipped with MoFlo
435
+
436
+ Beyond `/flo`, `/spell-builder`, and `/eldar`, MoFlo ships a handful of focused slash-command skills that work in any consumer project once you `flo init`:
437
+
438
+ | Skill | Purpose |
439
+ |-------|---------|
440
+ | `/guidance` | Author and audit guidance docs in `.claude/guidance/`. Default mode walks you through one doc; `/guidance -a` audits every doc against the universal guidance rules (Purpose lines, See Also, line counts, hedged language). |
441
+ | `/simplify` | Adaptive code review on the current diff. Tier-based fan-out — trivial edits get a self-review, small diffs get one routed agent, cross-cutting refactors get three parallel agents. Routes through the moflo model router for cost-aware execution. |
442
+ | `/spell-schedule` | Schedule a spell on the local moflo daemon (cron, interval, or one-time) without leaving the chat. For remote Anthropic-cloud agents on a schedule, use Claude Code's built-in `/schedule` instead. |
443
+
444
+ Run any of them with no arguments to see full usage, or browse the source in `.claude/skills/` (each skill is a single `SKILL.md` file).
445
+
434
446
  ### Epics
435
447
 
436
448
  Epics are a specialized process for handling GitHub issues that contain multiple child stories. When you pass a GitHub issue to `/flo` and it's detected as an epic, MoFlo processes each child story sequentially through the full `/flo` process (research → implement → test → PR).
@@ -553,6 +565,19 @@ flo healer -c embeddings # Check only embeddings health
553
565
  flo healer --verbose # Verbose output
554
566
  ```
555
567
 
568
+ #### `/eldar` — Consult the Eldar (project setup audit + wizard)
569
+
570
+ Where the Healer checks your moflo install, `/eldar` audits how Claude is set up to *use* the project — guidance, CLAUDE.md, memory namespaces, hook/MCP wiring, model routing, and stack-aware guidance gaps — then walks you through fixing whichever findings you pick. Use it when starting in a new project, when Claude feels lost or inefficient, or as a periodic health check.
571
+
572
+ ```
573
+ /eldar # Read-only audit; categorized report + top-3 ranked recommendation
574
+ /eldar --fix # Audit, then interactive triage menu — pick which findings to address
575
+ ```
576
+
577
+ The Eldar **consult** the Healer (they call `flo healer --json` as one of the audit checks) — they don't replace it. Categories audited include setup health, index freshness, version skew, model/token routing, CLAUDE.md size + reference integrity, guidance content + structure, memory health, hook/MCP wiring, settings sanity, spell + subagent inventory, **stack → guidance cross-reference** (detects tech from package.json/pyproject.toml/Cargo.toml/go.mod and flags every detected technology with no matching guidance doc — the highest-leverage finding for new adopters), and best-effort anti-pattern detection from history.
578
+
579
+ In `--fix` mode, each chosen finding drives the appropriate sub-flow: Healer for setup repair, the `/guidance` skill for guidance authoring (wizard, never autogen), a stack-aware scaffold for missing CLAUDE.md, `flo init --upgrade` for hook/MCP wiring. Every write is confirmed before it lands.
580
+
556
581
  #### `flo diagnose` — Integration Tests
557
582
 
558
583
  While `healer` checks your environment, `diagnose` exercises every subsystem end-to-end: memory CRUD, embedding generation, semantic search, swarm lifecycle, hive-mind consensus, task management, hooks, config, neural patterns, and init idempotency. All test data is cleaned up after each test — nothing is left behind.