moflo 4.8.21 → 4.8.23

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 (178) hide show
  1. package/.claude/agents/browser/browser-agent.yaml +182 -182
  2. package/.claude/agents/core/coder.md +265 -265
  3. package/.claude/agents/core/planner.md +167 -167
  4. package/.claude/agents/core/researcher.md +189 -189
  5. package/.claude/agents/core/reviewer.md +325 -325
  6. package/.claude/agents/core/tester.md +318 -318
  7. package/.claude/agents/database-specialist.yaml +21 -21
  8. package/.claude/agents/dual-mode/codex-coordinator.md +224 -224
  9. package/.claude/agents/dual-mode/codex-worker.md +211 -211
  10. package/.claude/agents/dual-mode/dual-orchestrator.md +291 -291
  11. package/.claude/agents/github/code-review-swarm.md +537 -537
  12. package/.claude/agents/github/github-modes.md +172 -172
  13. package/.claude/agents/github/issue-tracker.md +318 -318
  14. package/.claude/agents/github/multi-repo-swarm.md +552 -552
  15. package/.claude/agents/github/pr-manager.md +190 -190
  16. package/.claude/agents/github/project-board-sync.md +508 -508
  17. package/.claude/agents/github/release-manager.md +366 -366
  18. package/.claude/agents/github/release-swarm.md +582 -582
  19. package/.claude/agents/github/repo-architect.md +397 -397
  20. package/.claude/agents/github/swarm-issue.md +572 -572
  21. package/.claude/agents/github/swarm-pr.md +427 -427
  22. package/.claude/agents/github/sync-coordinator.md +451 -451
  23. package/.claude/agents/github/workflow-automation.md +634 -634
  24. package/.claude/agents/goal/code-goal-planner.md +445 -445
  25. package/.claude/agents/hive-mind/collective-intelligence-coordinator.md +129 -129
  26. package/.claude/agents/hive-mind/queen-coordinator.md +202 -202
  27. package/.claude/agents/hive-mind/scout-explorer.md +241 -241
  28. package/.claude/agents/hive-mind/swarm-memory-manager.md +192 -192
  29. package/.claude/agents/hive-mind/worker-specialist.md +216 -216
  30. package/.claude/agents/index.yaml +17 -17
  31. package/.claude/agents/neural/safla-neural.md +73 -73
  32. package/.claude/agents/project-coordinator.yaml +15 -15
  33. package/.claude/agents/python-specialist.yaml +21 -21
  34. package/.claude/agents/reasoning/goal-planner.md +72 -72
  35. package/.claude/agents/security-auditor.yaml +20 -20
  36. package/.claude/agents/swarm/adaptive-coordinator.md +395 -395
  37. package/.claude/agents/swarm/hierarchical-coordinator.md +326 -326
  38. package/.claude/agents/swarm/mesh-coordinator.md +391 -391
  39. package/.claude/agents/templates/migration-plan.md +745 -745
  40. package/.claude/agents/typescript-specialist.yaml +21 -21
  41. package/.claude/checkpoints/1767754460.json +8 -8
  42. package/.claude/commands/agents/agent-spawning.md +28 -28
  43. package/.claude/commands/github/github-modes.md +146 -146
  44. package/.claude/commands/github/github-swarm.md +121 -121
  45. package/.claude/commands/github/issue-tracker.md +291 -291
  46. package/.claude/commands/github/pr-manager.md +169 -169
  47. package/.claude/commands/github/release-manager.md +337 -337
  48. package/.claude/commands/github/repo-architect.md +366 -366
  49. package/.claude/commands/github/sync-coordinator.md +300 -300
  50. package/.claude/commands/memory/neural.md +47 -47
  51. package/.claude/commands/sparc/analyzer.md +51 -51
  52. package/.claude/commands/sparc/architect.md +53 -53
  53. package/.claude/commands/sparc/ask.md +97 -97
  54. package/.claude/commands/sparc/batch-executor.md +54 -54
  55. package/.claude/commands/sparc/code.md +89 -89
  56. package/.claude/commands/sparc/coder.md +54 -54
  57. package/.claude/commands/sparc/debug.md +83 -83
  58. package/.claude/commands/sparc/debugger.md +54 -54
  59. package/.claude/commands/sparc/designer.md +53 -53
  60. package/.claude/commands/sparc/devops.md +109 -109
  61. package/.claude/commands/sparc/docs-writer.md +80 -80
  62. package/.claude/commands/sparc/documenter.md +54 -54
  63. package/.claude/commands/sparc/innovator.md +54 -54
  64. package/.claude/commands/sparc/integration.md +83 -83
  65. package/.claude/commands/sparc/mcp.md +117 -117
  66. package/.claude/commands/sparc/memory-manager.md +54 -54
  67. package/.claude/commands/sparc/optimizer.md +54 -54
  68. package/.claude/commands/sparc/orchestrator.md +131 -131
  69. package/.claude/commands/sparc/post-deployment-monitoring-mode.md +83 -83
  70. package/.claude/commands/sparc/refinement-optimization-mode.md +83 -83
  71. package/.claude/commands/sparc/researcher.md +54 -54
  72. package/.claude/commands/sparc/reviewer.md +54 -54
  73. package/.claude/commands/sparc/security-review.md +80 -80
  74. package/.claude/commands/sparc/sparc-modes.md +174 -174
  75. package/.claude/commands/sparc/sparc.md +111 -111
  76. package/.claude/commands/sparc/spec-pseudocode.md +80 -80
  77. package/.claude/commands/sparc/supabase-admin.md +348 -348
  78. package/.claude/commands/sparc/swarm-coordinator.md +54 -54
  79. package/.claude/commands/sparc/tdd.md +54 -54
  80. package/.claude/commands/sparc/tester.md +54 -54
  81. package/.claude/commands/sparc/tutorial.md +79 -79
  82. package/.claude/commands/sparc/workflow-manager.md +54 -54
  83. package/.claude/commands/sparc.md +166 -166
  84. package/.claude/commands/swarm/analysis.md +95 -95
  85. package/.claude/commands/swarm/development.md +96 -96
  86. package/.claude/commands/swarm/examples.md +168 -168
  87. package/.claude/commands/swarm/maintenance.md +102 -102
  88. package/.claude/commands/swarm/optimization.md +117 -117
  89. package/.claude/commands/swarm/research.md +136 -136
  90. package/.claude/commands/swarm/testing.md +131 -131
  91. package/.claude/commands/workflows/development.md +77 -77
  92. package/.claude/commands/workflows/research.md +62 -62
  93. package/.claude/guidance/moflo-bootstrap.md +126 -126
  94. package/.claude/guidance/shipped/agent-bootstrap.md +126 -126
  95. package/.claude/guidance/shipped/guidance-memory-strategy.md +262 -262
  96. package/.claude/guidance/shipped/memory-strategy.md +204 -204
  97. package/.claude/guidance/shipped/moflo.md +668 -653
  98. package/.claude/guidance/shipped/task-swarm-integration.md +441 -441
  99. package/.claude/helpers/intelligence.cjs +207 -207
  100. package/.claude/helpers/statusline.cjs +851 -851
  101. package/.claude/settings.local.json +18 -0
  102. package/.claude/skills/fl/SKILL.md +583 -583
  103. package/.claude/skills/flo/SKILL.md +583 -583
  104. package/.claude/skills/github-code-review/SKILL.md +1140 -1140
  105. package/.claude/skills/github-multi-repo/SKILL.md +874 -874
  106. package/.claude/skills/github-project-management/SKILL.md +1277 -1277
  107. package/.claude/skills/github-release-management/SKILL.md +1081 -1081
  108. package/.claude/skills/github-workflow-automation/SKILL.md +1065 -1065
  109. package/.claude/skills/hive-mind-advanced/SKILL.md +712 -712
  110. package/.claude/skills/hooks-automation/SKILL.md +1201 -1201
  111. package/.claude/skills/performance-analysis/SKILL.md +563 -563
  112. package/.claude/skills/sparc-methodology/SKILL.md +1115 -1115
  113. package/.claude/skills/swarm-advanced/SKILL.md +973 -973
  114. package/.claude/workflow-state.json +4 -4
  115. package/LICENSE +21 -21
  116. package/README.md +698 -685
  117. package/bin/cli.js +0 -0
  118. package/bin/gate-hook.mjs +50 -50
  119. package/bin/gate.cjs +138 -138
  120. package/bin/generate-code-map.mjs +775 -775
  121. package/bin/hook-handler.cjs +83 -83
  122. package/bin/hooks.mjs +656 -656
  123. package/bin/index-guidance.mjs +892 -892
  124. package/bin/index-tests.mjs +709 -709
  125. package/bin/lib/process-manager.mjs +243 -243
  126. package/bin/lib/registry-cleanup.cjs +41 -41
  127. package/bin/prompt-hook.mjs +72 -72
  128. package/bin/semantic-search.mjs +472 -472
  129. package/bin/session-start-launcher.mjs +238 -238
  130. package/bin/setup-project.mjs +250 -250
  131. package/package.json +123 -123
  132. package/src/@claude-flow/cli/README.md +452 -452
  133. package/src/@claude-flow/cli/bin/cli.js +180 -180
  134. package/src/@claude-flow/cli/bin/preinstall.cjs +2 -2
  135. package/src/@claude-flow/cli/dist/src/commands/completions.js +409 -409
  136. package/src/@claude-flow/cli/dist/src/commands/doctor.js +18 -2
  137. package/src/@claude-flow/cli/dist/src/commands/embeddings.js +25 -25
  138. package/src/@claude-flow/cli/dist/src/commands/github.js +61 -61
  139. package/src/@claude-flow/cli/dist/src/commands/hive-mind.js +90 -90
  140. package/src/@claude-flow/cli/dist/src/commands/hooks.js +9 -9
  141. package/src/@claude-flow/cli/dist/src/commands/init.js +3 -8
  142. package/src/@claude-flow/cli/dist/src/commands/ruvector/import.js +14 -14
  143. package/src/@claude-flow/cli/dist/src/commands/ruvector/setup.js +624 -624
  144. package/src/@claude-flow/cli/dist/src/config/moflo-config.d.ts +3 -0
  145. package/src/@claude-flow/cli/dist/src/config/moflo-config.js +101 -91
  146. package/src/@claude-flow/cli/dist/src/index.d.ts +5 -0
  147. package/src/@claude-flow/cli/dist/src/index.js +44 -0
  148. package/src/@claude-flow/cli/dist/src/init/claudemd-generator.d.ts +29 -29
  149. package/src/@claude-flow/cli/dist/src/init/claudemd-generator.js +43 -43
  150. package/src/@claude-flow/cli/dist/src/init/executor.js +453 -453
  151. package/src/@claude-flow/cli/dist/src/init/helpers-generator.js +482 -482
  152. package/src/@claude-flow/cli/dist/src/init/moflo-init.d.ts +30 -30
  153. package/src/@claude-flow/cli/dist/src/init/moflo-init.js +140 -140
  154. package/src/@claude-flow/cli/dist/src/init/statusline-generator.js +876 -876
  155. package/src/@claude-flow/cli/dist/src/memory/memory-initializer.js +371 -371
  156. package/src/@claude-flow/cli/dist/src/runtime/headless.js +28 -28
  157. package/src/@claude-flow/cli/dist/src/services/container-worker-pool.d.ts +197 -0
  158. package/src/@claude-flow/cli/dist/src/services/container-worker-pool.js +584 -0
  159. package/src/@claude-flow/cli/dist/src/services/daemon-lock.d.ts +14 -0
  160. package/src/@claude-flow/cli/dist/src/services/daemon-lock.js +1 -1
  161. package/src/@claude-flow/cli/dist/src/services/headless-worker-executor.js +84 -84
  162. package/src/@claude-flow/cli/package.json +1 -1
  163. package/src/@claude-flow/guidance/README.md +1195 -1195
  164. package/src/@claude-flow/guidance/package.json +198 -198
  165. package/src/@claude-flow/memory/README.md +587 -587
  166. package/src/@claude-flow/memory/dist/agentdb-backend.js +26 -26
  167. package/src/@claude-flow/memory/dist/auto-memory-bridge.test.js +27 -27
  168. package/src/@claude-flow/memory/dist/hybrid-backend.d.ts +245 -0
  169. package/src/@claude-flow/memory/dist/hybrid-backend.js +569 -0
  170. package/src/@claude-flow/memory/dist/hybrid-backend.test.d.ts +8 -0
  171. package/src/@claude-flow/memory/dist/hybrid-backend.test.js +320 -0
  172. package/src/@claude-flow/memory/dist/sqlite-backend.d.ts +121 -0
  173. package/src/@claude-flow/memory/dist/sqlite-backend.js +572 -0
  174. package/src/@claude-flow/memory/dist/sqljs-backend.js +26 -26
  175. package/src/@claude-flow/memory/package.json +44 -44
  176. package/src/@claude-flow/shared/README.md +323 -323
  177. package/src/@claude-flow/shared/dist/events/event-store.js +31 -31
  178. package/src/README.md +493 -493
@@ -1,653 +1,668 @@
1
- # Moflo CLI & MCP Reference
2
-
3
- **Purpose:** Complete CLI and MCP reference for moflo — hooks, memory, agents, swarm, neural, and doctor commands. Read when using moflo features or debugging agent coordination.
4
-
5
- **MCP-First Policy:** Always prefer MCP tools (`mcp__moflo__*`) over CLI commands. Use `ToolSearch` to load them, then call directly. CLI is fallback only.
6
-
7
- ---
8
-
9
- ## Getting Started
10
-
11
- ### Installation
12
-
13
- ```bash
14
- npm install moflo
15
- npx flo init # Interactive setup wizard
16
- ```
17
-
18
- `flo init` does the following:
19
- 1. Creates `moflo.yaml` with detected project settings
20
- 2. Sets up `.claude/settings.json` hooks (SessionStart, pre-edit, etc.)
21
- 3. Configures `.mcp.json` for MCP tool access
22
- 4. Copies the agent bootstrap guide to `.claude/guidance/`
23
- 5. Injects a memory search section into CLAUDE.md
24
-
25
- ### Post-Install
26
-
27
- ```bash
28
- npx flo-setup # Copy bootstrap guidance, inject CLAUDE.md section
29
- npx flo doctor --fix # Verify everything is working
30
- ```
31
-
32
- ---
33
-
34
- ## Building from Source
35
-
36
- Moflo is a TypeScript monorepo using **project references** (`tsc -b`). The root `tsconfig.json` is a solution-style config that delegates to `src/tsconfig.json`, which references all 17 `@claude-flow/*` sub-packages.
37
-
38
- ### Build Commands
39
-
40
- ```bash
41
- npm run build # Runs tsc -b (project references build)
42
- npm run build:ts # Build @claude-flow/cli only (legacy shortcut)
43
- npm run build:guidance # Build @claude-flow/guidance only (legacy shortcut)
44
- ```
45
-
46
- ### Architecture
47
-
48
- ```
49
- tsconfig.json → Solution root (references src/)
50
- src/tsconfig.json → References all @claude-flow/* packages
51
- src/tsconfig.base.json → Shared compilerOptions (ES2022, bundler, composite)
52
- src/@claude-flow/shared/ → Base types (no deps)
53
- src/@claude-flow/cli/ → CLI + MCP server (depends on shared, swarm)
54
- src/@claude-flow/hooks/ → Hook system (depends on shared, neural, memory)
55
- src/@claude-flow/memory/ → Memory backends (no deps)
56
- src/@claude-flow/guidance/ → Guidance indexing (depends on hooks)
57
- src/@claude-flow/testing/ → Regression tests (depends on shared, memory, swarm)
58
- ... (17 packages total)
59
- ```
60
-
61
- ### Important Rules
62
-
63
- 1. **Always build from root** — `npm run build` (which runs `tsc -b`) builds all packages in dependency order. Do NOT build individual packages in isolation unless you know what you're doing.
64
- 2. **Never bypass the build** — The `dist/` directories contain compiled JS that ships with `npm publish`. If you edit `.ts` source, you MUST rebuild before publishing.
65
- 3. **Do not work around build errors** — If `tsc -b` fails, fix the type errors. Do not manually compile individual packages to skip errors, as this leads to drift between source and compiled output.
66
- 4. **Sub-packages need `composite: true`** — Every sub-package tsconfig must have `"composite": true` in compilerOptions for project references to work.
67
- 5. **Cross-package imports need `paths`** — If package A imports from `@claude-flow/B`, package A's tsconfig needs both a `"references"` entry and a `"paths"` mapping pointing to B's source.
68
-
69
- ### Publishing
70
-
71
- ```bash
72
- npm version patch # Bump version (auto-syncs cli sub-package version)
73
- npm run build # MUST succeed with zero errors
74
- npm publish --otp=XXX # Requires 2FA OTP
75
- ```
76
-
77
- ---
78
-
79
- ## Session Start Automation
80
-
81
- When a Claude Code session starts, moflo automatically runs three background indexers:
82
-
83
- | Indexer | Command | Namespace | What it does |
84
- |---------|---------|-----------|--------------|
85
- | Guidance | `npx flo-index` | `guidance` | Chunks markdown docs, builds RAG links, generates 384-dim embeddings |
86
- | Code Map | `npx flo-codemap` | `code-map` | Scans source for types, interfaces, exports, directory structure |
87
- | Learning | `npx flo-learn` | `patterns` | Pattern research on codebase for cross-session learning |
88
-
89
- These run in background and are incremental (unchanged files are skipped). Controlled by `auto_index` in `moflo.yaml`.
90
-
91
- ### Helper Script Auto-Sync
92
-
93
- On version change, `session-start-launcher.mjs` copies helper scripts from the installed moflo package to the consumer project's `.claude/helpers/` and `.claude/scripts/` directories. This ensures hooks always run the latest version.
94
-
95
- **Rule: static files, not dynamic generation.** If a helper script has no dynamic content (no per-project interpolation), it must be shipped as a pre-built static file in `bin/` and synced via the session-start file lists. Do not generate static content dynamically at runtime — it adds fragile moving parts (background `init --upgrade`, race conditions with session-start exit) and causes stale scripts when the sync list is incomplete.
96
-
97
- | Source | Target | Files |
98
- |--------|--------|-------|
99
- | `bin/` | `.claude/scripts/` | `hooks.mjs`, `session-start-launcher.mjs`, `index-guidance.mjs`, `build-embeddings.mjs`, `generate-code-map.mjs`, `semantic-search.mjs` |
100
- | `bin/` | `.claude/helpers/` | `gate.cjs`, `gate-hook.mjs`, `prompt-hook.mjs`, `hook-handler.cjs` |
101
- | `src/@claude-flow/cli/.claude/helpers/` | `.claude/helpers/` | `auto-memory-hook.mjs`, `statusline.cjs`, `pre-commit`, `post-commit` |
102
-
103
- When adding a new helper script: generate it once, save it to `bin/`, and add it to the appropriate list in `session-start-launcher.mjs`.
104
-
105
- ### Bundled Guidance
106
-
107
- Moflo ships its own guidance files (in `.claude/guidance/` within the package). When installed as a dependency, these are **automatically indexed** alongside the consumer project's guidance under the `guidance` namespace. This means agents in your project can search for moflo system docs (swarm patterns, memory commands, etc.) without any extra setup.
108
-
109
- ---
110
-
111
- ## Bin Commands
112
-
113
- | Command | Script | Purpose |
114
- |---------|--------|---------|
115
- | `npx flo-index` | `bin/index-guidance.mjs` | Index guidance docs with RAG linking + embeddings |
116
- | `npx flo-codemap` | `bin/generate-code-map.mjs` | Generate structural code map (types, interfaces, directories) |
117
- | `npx flo-learn` | Learning service | Pattern research on codebase |
118
- | `npx flo-setup` | `bin/setup-project.mjs` | Copy bootstrap guidance, inject CLAUDE.md memory section |
119
- | `npx flo-search` | `bin/semantic-search.mjs` | Standalone semantic search with detailed output |
120
-
121
- ### Common Flags
122
-
123
- | Flag | Applies to | Effect |
124
- |------|-----------|--------|
125
- | `--force` | flo-index, flo-codemap | Reindex everything (ignore hash cache) |
126
- | `--file <path>` | flo-index | Index a specific file only |
127
- | `--no-embeddings` | flo-index | Skip embedding generation |
128
- | `--verbose` | flo-index | Show detailed chunk-level output |
129
- | `--namespace <ns>` | flo-search | Filter search to specific namespace |
130
- | `--limit <n>` | flo-search | Number of results (default: 5) |
131
-
132
- ---
133
-
134
- ## MCP Tools Setup
135
-
136
- MCP tools are the preferred way for Claude to interact with moflo. `flo init` creates a `.mcp.json` in the project root:
137
-
138
- ```json
139
- {
140
- "mcpServers": {
141
- "moflo": {
142
- "command": "node",
143
- "args": ["node_modules/moflo/src/@claude-flow/cli/bin/cli.js", "mcp", "start"]
144
- }
145
- }
146
- }
147
- ```
148
-
149
- This gives Claude access to 200+ MCP tools (`mcp__moflo__memory_*`, `mcp__moflo__hooks_*`, `mcp__moflo__swarm_*`, etc.) without any global installation.
150
-
151
- ---
152
-
153
- ## Project Config (Anti-Drift Defaults)
154
-
155
- - **Topology**: hierarchical (prevents drift)
156
- - **Max Agents**: 8 (smaller = less drift)
157
- - **Strategy**: specialized (clear roles)
158
- - **Consensus**: raft
159
- - **Memory**: hybrid
160
- - **HNSW**: Enabled
161
- - **Neural**: Enabled
162
-
163
- ---
164
-
165
- ## CLI Commands (26 Commands, 140+ Subcommands)
166
-
167
- ### Core Commands
168
-
169
- | Command | Subcommands | Description |
170
- |-------------|-------------|--------------------------------------------------------------------------|
171
- | `init` | 4 | Project initialization with wizard, presets, skills, hooks |
172
- | `agent` | 8 | Agent lifecycle (spawn, list, status, stop, metrics, pool, health, logs) |
173
- | `swarm` | 6 | Multi-agent swarm coordination and orchestration |
174
- | `memory` | 11 | AgentDB memory with vector search (150x-12,500x faster) |
175
- | `mcp` | 9 | MCP server management and tool execution |
176
- | `task` | 6 | Task creation, assignment, and lifecycle |
177
- | `session` | 7 | Session state management and persistence |
178
- | `config` | 7 | Configuration management and provider setup |
179
- | `status` | 3 | System status monitoring with watch mode |
180
- | `workflow` | 6 | Workflow execution and template management |
181
- | `hooks` | 17 | Self-learning hooks + 12 background workers |
182
- | `hive-mind` | 6 | Queen-led Byzantine fault-tolerant consensus |
183
-
184
- ### Advanced Commands
185
-
186
- | Command | Subcommands | Description |
187
- |---------------|-------------|-------------------------------------------------------------------------------|
188
- | `daemon` | 5 | Background worker daemon (start, stop, status, trigger, enable) |
189
- | `neural` | 5 | Neural pattern training (train, status, patterns, predict, optimize) |
190
- | `security` | 6 | Security scanning (scan, audit, cve, threats, validate, report) |
191
- | `performance` | 5 | Performance profiling (benchmark, profile, metrics, optimize, report) |
192
- | `providers` | 5 | AI providers (list, add, remove, test, configure) |
193
- | `plugins` | 5 | Plugin management (list, install, uninstall, enable, disable) |
194
- | `deployment` | 5 | Deployment management (deploy, rollback, status, environments, release) |
195
- | `embeddings` | 4 | Vector embeddings (embed, batch, search, init) - 75x faster with agentic-flow |
196
- | `claims` | 4 | Claims-based authorization (check, grant, revoke, list) |
197
- | `migrate` | 5 | V2 to V3 migration with rollback support |
198
- | `doctor` | 1 | System diagnostics with health checks |
199
- | `completions` | 4 | Shell completions (bash, zsh, fish, powershell) |
200
-
201
- ### Quick Examples (MCP Preferred)
202
-
203
- | Task | MCP Tool | CLI Fallback |
204
- |------|----------|-------------|
205
- | Search memory | `mcp__moflo__memory_search` | `memory search --query "..."` |
206
- | Spawn agent | `mcp__moflo__agent_spawn` | `agent spawn -t coder --name my-coder` |
207
- | Init swarm | `mcp__moflo__swarm_init` | `swarm init --v3-mode` |
208
- | System health | `mcp__moflo__system_health` | `doctor --fix` |
209
- | Benchmark | `mcp__moflo__performance_benchmark` | `performance benchmark --suite all` |
210
-
211
- **CLI-only (no MCP equivalent — setup tasks):**
212
- ```bash
213
- npx flo init --wizard
214
- npx flo daemon start
215
- ```
216
-
217
- ---
218
-
219
- ## Available Agents (60+ Types)
220
-
221
- ### Core Development
222
- `coder`, `reviewer`, `tester`, `planner`, `researcher`
223
-
224
- ### Specialized Agents
225
- `security-architect`, `security-auditor`, `memory-specialist`, `performance-engineer`
226
-
227
- ### Swarm Coordination
228
- `hierarchical-coordinator`, `mesh-coordinator`, `adaptive-coordinator`, `collective-intelligence-coordinator`, `swarm-memory-manager`
229
-
230
- ### Consensus & Distributed
231
- `byzantine-coordinator`, `raft-manager`, `gossip-coordinator`, `consensus-builder`, `crdt-synchronizer`, `quorum-manager`, `security-manager`
232
-
233
- ### Performance & Optimization
234
- `perf-analyzer`, `performance-benchmarker`, `task-orchestrator`, `memory-coordinator`, `smart-agent`
235
-
236
- ### GitHub & Repository
237
- `github-modes`, `pr-manager`, `code-review-swarm`, `issue-tracker`, `release-manager`, `workflow-automation`, `project-board-sync`, `repo-architect`, `multi-repo-swarm`
238
-
239
- ### SPARC Methodology
240
- `sparc-coord`, `sparc-coder`, `specification`, `pseudocode`, `architecture`, `refinement`
241
-
242
- ### Specialized Development
243
- `backend-dev`, `mobile-dev`, `ml-developer`, `cicd-engineer`, `api-docs`, `system-architect`, `code-analyzer`, `base-template-generator`
244
-
245
- ### Testing & Validation
246
- `tdd-london-swarm`, `production-validator`
247
-
248
- ### Agent Routing (Anti-Drift)
249
-
250
- | Code | Task | Agents |
251
- |------|-------------|-------------------------------------------------|
252
- | 1 | Bug Fix | coordinator, researcher, coder, tester |
253
- | 3 | Feature | coordinator, architect, coder, tester, reviewer |
254
- | 5 | Refactor | coordinator, architect, coder, reviewer |
255
- | 7 | Performance | coordinator, perf-engineer, coder |
256
- | 9 | Security | coordinator, security-architect, auditor |
257
- | 11 | Docs | researcher, api-docs |
258
-
259
- **Codes 1-9: hierarchical/specialized (anti-drift). Code 11: mesh/balanced**
260
-
261
- ---
262
-
263
- ## Hooks System (27 Hooks + 12 Workers)
264
-
265
- ### All Available Hooks
266
-
267
- | Hook | Description | Key Options |
268
- |--------------------|------------------------------------------|---------------------------------------------|
269
- | `pre-edit` | Get context before editing files | `--file`, `--operation` |
270
- | `post-edit` | Record editing outcome for learning | `--file`, `--success`, `--train-neural` |
271
- | `pre-command` | Assess risk before commands | `--command`, `--validate-safety` |
272
- | `post-command` | Record command execution outcome | `--command`, `--track-metrics` |
273
- | `pre-task` | Record task start, get agent suggestions | `--description`, `--coordinate-swarm` |
274
- | `post-task` | Record task completion for learning | `--task-id`, `--success`, `--store-results` |
275
- | `session-start` | Start/restore session | `--session-id`, `--auto-configure` |
276
- | `session-end` | End session and persist state | `--generate-summary`, `--export-metrics` |
277
- | `session-restore` | Restore a previous session | `--session-id`, `--latest` |
278
- | `route` | Route task to optimal agent | `--task`, `--context`, `--top-k` |
279
- | `explain` | Explain routing decision | `--topic`, `--detailed` |
280
- | `pretrain` | Bootstrap intelligence from repo | `--model-type`, `--epochs` |
281
- | `build-agents` | Generate optimized agent configs | `--agent-types`, `--focus` |
282
- | `metrics` | View learning metrics dashboard | `--v3-dashboard`, `--format` |
283
- | `transfer` | Transfer patterns via IPFS registry | `store`, `from-project` |
284
- | `intelligence` | RuVector intelligence system | `trajectory-*`, `pattern-*`, `stats` |
285
- | `worker` | Background worker management | `list`, `dispatch`, `status`, `detect` |
286
- | `coverage-route` | Route based on test coverage gaps | `--task`, `--path` |
287
- | `coverage-suggest` | Suggest coverage improvements | `--path` |
288
- | `coverage-gaps` | List coverage gaps with priorities | `--format`, `--limit` |
289
-
290
- ### 12 Background Workers
291
-
292
- | Worker | Priority | Description |
293
- |---------------|----------|----------------------------|
294
- | `ultralearn` | normal | Deep knowledge acquisition |
295
- | `optimize` | high | Performance optimization |
296
- | `consolidate` | low | Memory consolidation |
297
- | `predict` | normal | Predictive preloading |
298
- | `audit` | critical | Security analysis |
299
- | `map` | normal | Codebase mapping |
300
- | `preload` | low | Resource preloading |
301
- | `deepdive` | normal | Deep code analysis |
302
- | `document` | normal | Auto-documentation |
303
- | `refactor` | normal | Refactoring suggestions |
304
- | `benchmark` | normal | Performance benchmarking |
305
- | `testgaps` | normal | Test coverage analysis |
306
-
307
- ### Essential Hook Commands (MCP Preferred)
308
-
309
- | Hook | MCP Tool | Key Params |
310
- |------|----------|------------|
311
- | Pre-task | `mcp__moflo__hooks_pre-task` | `description` |
312
- | Post-task | `mcp__moflo__hooks_post-task` | `taskId`, `success` |
313
- | Post-edit | `mcp__moflo__hooks_post-edit` | `file`, `trainNeural` |
314
- | Session-start | `mcp__moflo__hooks_session-start` | `sessionId` |
315
- | Session-end | `mcp__moflo__hooks_session-end` | `exportMetrics` |
316
- | Route | `mcp__moflo__hooks_route` | `task` |
317
- | Worker-dispatch | `mcp__moflo__hooks_worker-dispatch` | `trigger` |
318
-
319
- ---
320
-
321
- ## Hive-Mind Consensus
322
-
323
- ### Topologies
324
- - `hierarchical` - Queen controls workers directly
325
- - `mesh` - Fully connected peer network
326
- - `hierarchical-mesh` - Hybrid (recommended)
327
- - `adaptive` - Dynamic based on load
328
-
329
- ### Consensus Strategies
330
- - `byzantine` - BFT (tolerates f < n/3 faulty)
331
- - `raft` - Leader-based (tolerates f < n/2)
332
- - `gossip` - Epidemic for eventual consistency
333
- - `crdt` - Conflict-free replicated data types
334
- - `quorum` - Configurable quorum-based
335
-
336
- ---
337
-
338
- ## RuVector Integration (HNSW Vector Search)
339
-
340
- | Feature | Performance | Description |
341
- |---------|-------------|-------------|
342
- | **HNSW Index** | 150x-12,500x faster | Hierarchical Navigable Small World search |
343
- | **MicroLoRA** | <100us adaptation | Fast model adaptation (508k+ ops/sec) |
344
- | **FlashAttention** | 2.49x-7.47x speedup | Optimized attention computation |
345
- | **Int8 Quantization** | 3.92x memory reduction | Compressed weight storage |
346
-
347
- ---
348
-
349
- ## Auto-Learning Protocol
350
-
351
- ### Before Starting Coding Tasks
352
-
353
- **MCP (Preferred):** `mcp__moflo__memory_search` — `query: "[task keywords]", namespace: "patterns"`
354
-
355
- **CLI Fallback:**
356
- ```bash
357
- npx flo memory search --query '[task keywords]' --namespace patterns
358
- ```
359
-
360
- ### After Completing Any Task Successfully (MCP Preferred)
361
-
362
- | Step | MCP Tool | Key Params |
363
- |------|----------|------------|
364
- | 1. Store pattern | `mcp__moflo__memory_store` | `namespace: "patterns", key: "[name]", value: "[what worked]"` |
365
- | 2. Train neural | `mcp__moflo__hooks_post-edit` | `file: "[main-file]", trainNeural: true` |
366
- | 3. Record completion | `mcp__moflo__hooks_post-task` | `taskId: "[id]", success: true, storeResults: true` |
367
-
368
- ### Continuous Improvement Triggers
369
-
370
- | Trigger | Worker | When to Use |
371
- |------------------------|------------|----------------------------|
372
- | After major refactor | `optimize` | Performance optimization |
373
- | After adding features | `testgaps` | Find missing test coverage |
374
- | After security changes | `audit` | Security analysis |
375
- | After API changes | `document` | Update documentation |
376
- | Every 5+ file changes | `map` | Update codebase map |
377
- | Complex debugging | `deepdive` | Deep code analysis |
378
-
379
- ### Memory-Enhanced Development
380
-
381
- **ALWAYS check memory before:**
382
- - Starting a new feature (search for similar implementations)
383
- - Debugging an issue (search for past solutions)
384
- - Refactoring code (search for learned patterns)
385
- - Performance work (search for optimization strategies)
386
-
387
- **ALWAYS store in memory after:**
388
- - Solving a tricky bug (store the solution pattern)
389
- - Completing a feature (store the approach)
390
- - Finding a performance fix (store the optimization)
391
- - Discovering a security issue (store the vulnerability pattern)
392
-
393
- ---
394
-
395
- ## Memory Commands Reference (MCP Preferred)
396
-
397
- ### Store Data
398
-
399
- **MCP:** `mcp__moflo__memory_store`
400
- - Required: `key`, `value`
401
- - Optional: `namespace` (default: "default"), `ttl`, `tags`
402
-
403
- **CLI Fallback:**
404
- ```bash
405
- npx flo memory store --key "pattern-auth" --value "JWT with refresh tokens" --namespace patterns
406
- ```
407
-
408
- ### Search Data (semantic vector search)
409
-
410
- **MCP:** `mcp__moflo__memory_search`
411
- - Required: `query`
412
- - Optional: `namespace`, `limit`, `threshold`
413
-
414
- **CLI Fallback:**
415
- ```bash
416
- npx flo memory search --query "authentication patterns" --namespace patterns --limit 5
417
- ```
418
-
419
- ### List Entries
420
-
421
- **MCP:** `mcp__moflo__memory_list`
422
- - Optional: `namespace`, `limit`
423
-
424
- ### Retrieve Specific Entry
425
-
426
- **MCP:** `mcp__moflo__memory_retrieve`
427
- - Required: `key`
428
- - Optional: `namespace` (default: "default")
429
-
430
- ---
431
-
432
- ## Claude Code vs MCP vs CLI Tools
433
-
434
- ### Claude Code Handles ALL EXECUTION:
435
- - **Task tool**: Spawn and run agents concurrently
436
- - File operations (Read, Write, Edit, Glob, Grep)
437
- - Code generation and programming
438
- - Bash commands and system operations
439
- - Git operations
440
-
441
- ### MCP Tools Handle Coordination (Preferred):
442
-
443
- | Operation | MCP Tool |
444
- |-----------|----------|
445
- | Swarm init | `mcp__moflo__swarm_init` |
446
- | Agent spawn | `mcp__moflo__agent_spawn` |
447
- | Memory store | `mcp__moflo__memory_store` |
448
- | Memory search | `mcp__moflo__memory_search` |
449
- | Hooks (all) | `mcp__moflo__hooks_<hook-name>` |
450
-
451
- ### CLI Commands (Fallback Only):
452
-
453
- Only use CLI via Bash when MCP tools are unavailable:
454
- ```bash
455
- npx flo <command> [options]
456
- ```
457
-
458
- **KEY**: MCP tools coordinate strategy, Claude Code's Task tool executes with real agents.
459
-
460
- ---
461
-
462
- ## Doctor Health Checks
463
-
464
- **MCP:** `mcp__moflo__system_health` | **CLI:** `npx flo doctor`
465
-
466
- Checks: Node version (20+), Git, config validity, daemon status, memory database, API keys, MCP servers, disk space, TypeScript.
467
-
468
- ---
469
-
470
- ## Environment Variables
471
-
472
- ```bash
473
- # Configuration
474
- CLAUDE_FLOW_CONFIG=./claude-flow.config.json
475
- CLAUDE_FLOW_LOG_LEVEL=info
476
-
477
- # MCP Server
478
- CLAUDE_FLOW_MCP_PORT=3000
479
- CLAUDE_FLOW_MCP_HOST=localhost
480
- CLAUDE_FLOW_MCP_TRANSPORT=stdio
481
-
482
- # Memory
483
- CLAUDE_FLOW_MEMORY_BACKEND=hybrid
484
- CLAUDE_FLOW_MEMORY_PATH=./data/memory
485
- ```
486
-
487
- ---
488
-
489
- ## Quick Setup
490
-
491
- ### Project-Level MCP (Recommended)
492
-
493
- Configure `.mcp.json` in the project root:
494
-
495
- ```json
496
- {
497
- "mcpServers": {
498
- "moflo": {
499
- "command": "node",
500
- "args": ["node_modules/moflo/src/@claude-flow/cli/bin/cli.js", "mcp", "start"]
501
- }
502
- }
503
- }
504
- ```
505
-
506
- ### Alternative: Global MCP Registration
507
-
508
- ```bash
509
- claude mcp add moflo -- npx @claude-flow/cli@alpha
510
- npx flo daemon start
511
- npx flo doctor --fix
512
- ```
513
-
514
- ---
515
-
516
- ## Project Configuration (moflo.yaml)
517
-
518
- Moflo reads `moflo.yaml` (or `moflo.config.json`) from the project root. All fields have sensible defaults — the file is optional.
519
-
520
- ### Full Reference
521
-
522
- ```yaml
523
- project:
524
- name: "my-project" # Project name (default: directory name)
525
-
526
- # Guidance/knowledge docs to index for semantic search
527
- guidance:
528
- directories: # Directories to scan for .md files
529
- - .claude/guidance # Default
530
- - docs/guides # Default
531
- namespace: guidance # Memory namespace for indexed docs
532
-
533
- # Source directories for code navigation map
534
- code_map:
535
- directories: # Directories to scan for source files
536
- - src # Default
537
- - packages
538
- - lib
539
- - app
540
- extensions: [".ts", ".tsx", ".js", ".jsx", ".py", ".go", ".rs", ".java"]
541
- exclude: [node_modules, dist, .next, coverage, build, __pycache__, target, .git]
542
- namespace: code-map
543
-
544
- # Workflow gates (enforced via Claude Code hooks)
545
- gates:
546
- memory_first: true # Search memory before Glob/Grep
547
- task_create_first: true # TaskCreate before Agent tool
548
- context_tracking: true # Track context bracket (FRESH/MODERATE/DEPLETED/CRITICAL)
549
-
550
- # Auto-index on session start
551
- auto_index:
552
- guidance: true # Run flo-index (guidance RAG indexer)
553
- code_map: true # Run flo-codemap (structural code index)
554
-
555
- # Memory backend
556
- memory:
557
- backend: sql.js # sql.js (WASM) | agentdb | json
558
- embedding_model: Xenova/all-MiniLM-L6-v2 # 384-dim neural embeddings
559
- namespace: default # Default namespace for memory operations
560
-
561
- # Hook toggles (all on by default — disable to slim down)
562
- hooks:
563
- pre_edit: true # Track file edits for learning
564
- post_edit: true # Record edit outcomes, train neural patterns
565
- pre_task: true # Get agent routing before task spawn
566
- post_task: true # Record task results for learning
567
- gate: true # Workflow gate enforcement (memory-first, task-create-first)
568
- route: true # Intelligent task routing on each prompt
569
- stop_hook: true # Session-end persistence and metric export
570
- session_restore: true # Restore session state on start
571
- notification: true # Hook into Claude Code notifications
572
-
573
- # Model preferences (haiku, sonnet, opus)
574
- models:
575
- default: opus # General tasks
576
- research: sonnet # Research/exploration agents
577
- review: opus # Code review agents
578
- test: sonnet # Test-writing agents
579
-
580
- # Intelligent model routing (auto-selects haiku/sonnet/opus per task)
581
- model_routing:
582
- enabled: false # Set true to enable dynamic routing
583
- confidence_threshold: 0.85 # Min confidence before escalating
584
- cost_optimization: true # Prefer cheaper models when confident
585
- circuit_breaker: true # Penalize models that fail repeatedly
586
- # agent_overrides:
587
- # security-architect: opus
588
- # researcher: sonnet
589
-
590
- # Status line display
591
- status_line:
592
- enabled: true # Show status line at all
593
- branding: "Moflo V4" # Text in status bar
594
- mode: single-line # single-line (default) or dashboard (multi-line)
595
- show_git: true # Git branch, changes, ahead/behind
596
- show_model: true # Current model name
597
- show_session: true # Session duration
598
- show_intelligence: true # Intelligence % indicator
599
- show_swarm: true # Active swarm agents count
600
- show_hooks: true # Enabled hooks count
601
- show_mcp: true # MCP server count
602
- show_security: true # CVE/security status (dashboard only)
603
- show_adrs: true # ADR compliance (dashboard only)
604
- show_agentdb: true # AgentDB vectors/size (dashboard only)
605
- show_tests: true # Test file count (dashboard only)
606
- ```
607
-
608
- ### Key Behaviors
609
-
610
- | Config | Effect |
611
- |--------|--------|
612
- | `auto_index.guidance: false` | Skip guidance indexing on session start |
613
- | `auto_index.code_map: false` | Skip code map generation on session start |
614
- | `gates.memory_first: true` | Block Glob/Grep/Read until memory is searched first |
615
- | `gates.task_create_first: true` | Block Agent/Task tool until TaskCreate is called |
616
- | `gates.context_tracking: true` | Show FRESH/MODERATE/DEPLETED/CRITICAL context bracket |
617
- | `hooks.pre_edit: false` | Disable file-edit tracking (skips pre-edit hook) |
618
- | `hooks.post_edit: false` | Disable edit outcome recording and neural training |
619
- | `hooks.pre_task: false` | Disable agent routing recommendations before spawn |
620
- | `hooks.post_task: false` | Disable task result recording for learning |
621
- | `hooks.gate: false` | Disable all workflow gates (memory-first, task-create-first) |
622
- | `hooks.route: false` | Disable intelligent task routing on each prompt |
623
- | `hooks.stop_hook: false` | Disable session-end persistence and metric export |
624
- | `hooks.notification: false` | Disable notification hook |
625
- | `model_routing.enabled: true` | Auto-select haiku/sonnet/opus based on task complexity |
626
- | `status_line.mode: dashboard` | Switch to multi-line status display |
627
- | `status_line.show_swarm: false` | Hide swarm agent count from status bar |
628
-
629
- ---
630
-
631
- ## Troubleshooting Common Issues
632
-
633
- | Symptom | Cause | Fix |
634
- |---------|-------|-----|
635
- | No MCP tools available | `.mcp.json` missing or moflo not installed | Run `npx flo init` or manually create `.mcp.json` |
636
- | Memory search returns nothing | Indexer hasn't run yet | Run `npx flo-index --force` to index guidance |
637
- | Low search quality | Guidance docs missing `**Purpose:**` lines or generic headings | Follow guidance optimization rules in `guidance-memory-strategy.md` |
638
- | Session start slow | All three indexers running | Set `auto_index.code_map: false` in `moflo.yaml` if code map not needed |
639
- | Status line not showing | `statusline.cjs` error or `status_line.enabled: false` | Run `node .claude/helpers/statusline.cjs` to test, check `moflo.yaml` |
640
- | Embeddings falling back to hash | Transformers.js not available | Install `@xenova/transformers` moflo includes it but some environments strip it |
641
- | `flo` command not found | Not in PATH | Use `npx flo` or `node node_modules/moflo/bin/index-guidance.mjs` |
642
- | Bundled guidance not indexed | Running inside moflo repo (same dir) | Bundled guidance only indexes when installed as a dependency in a different project |
643
-
644
- See `memory-strategy.md` for memory-specific troubleshooting.
645
-
646
- ---
647
-
648
- ## See Also
649
-
650
- - `.claude/guidance/agent-bootstrap.md` - Subagent memory-first protocol and store patterns
651
- - `.claude/guidance/task-swarm-integration.md` - Task & swarm coordination with TaskCreate/TaskUpdate
652
- - `.claude/guidance/memory-strategy.md` - Database schema, namespaces, search commands, RAG linking
653
- - `.claude/guidance/guidance-memory-strategy.md` - How to write guidance docs that index well for RAG
1
+ # Moflo CLI & MCP Reference
2
+
3
+ **Purpose:** Complete CLI and MCP reference for moflo — hooks, memory, agents, swarm, neural, and doctor commands. Read when using moflo features or debugging agent coordination.
4
+
5
+ **MCP-First Policy:** Always prefer MCP tools (`mcp__moflo__*`) over CLI commands. Use `ToolSearch` to load them, then call directly. CLI is fallback only.
6
+
7
+ ---
8
+
9
+ ## Getting Started
10
+
11
+ ### Installation
12
+
13
+ ```bash
14
+ npm install moflo
15
+ npx flo init # Interactive setup wizard
16
+ ```
17
+
18
+ `flo init` does the following:
19
+ 1. Creates `moflo.yaml` with detected project settings
20
+ 2. Sets up `.claude/settings.json` hooks (SessionStart, pre-edit, etc.)
21
+ 3. Configures `.mcp.json` for MCP tool access
22
+ 4. Copies the agent bootstrap guide to `.claude/guidance/`
23
+ 5. Injects a memory search section into CLAUDE.md
24
+
25
+ ### Post-Install
26
+
27
+ ```bash
28
+ npx flo-setup # Copy bootstrap guidance, inject CLAUDE.md section
29
+ npx flo doctor --fix # Verify everything is working
30
+ ```
31
+
32
+ ---
33
+
34
+ ## Building from Source
35
+
36
+ Moflo is a TypeScript monorepo using **project references** (`tsc -b`). The root `tsconfig.json` is a solution-style config that delegates to `src/tsconfig.json`, which references all 17 `@claude-flow/*` sub-packages.
37
+
38
+ ### Build Commands
39
+
40
+ ```bash
41
+ npm run build # Runs tsc -b (project references build)
42
+ npm run build:ts # Build @claude-flow/cli only (legacy shortcut)
43
+ npm run build:guidance # Build @claude-flow/guidance only (legacy shortcut)
44
+ ```
45
+
46
+ ### Architecture
47
+
48
+ ```
49
+ tsconfig.json → Solution root (references src/)
50
+ src/tsconfig.json → References all @claude-flow/* packages
51
+ src/tsconfig.base.json → Shared compilerOptions (ES2022, bundler, composite)
52
+ src/@claude-flow/shared/ → Base types (no deps)
53
+ src/@claude-flow/cli/ → CLI + MCP server (depends on shared, swarm)
54
+ src/@claude-flow/hooks/ → Hook system (depends on shared, neural, memory)
55
+ src/@claude-flow/memory/ → Memory backends (no deps)
56
+ src/@claude-flow/guidance/ → Guidance indexing (depends on hooks)
57
+ src/@claude-flow/testing/ → Regression tests (depends on shared, memory, swarm)
58
+ ... (17 packages total)
59
+ ```
60
+
61
+ ### Important Rules
62
+
63
+ 1. **Always build from root** — `npm run build` (which runs `tsc -b`) builds all packages in dependency order. Do NOT build individual packages in isolation unless you know what you're doing.
64
+ 2. **Never bypass the build** — The `dist/` directories contain compiled JS that ships with `npm publish`. If you edit `.ts` source, you MUST rebuild before publishing.
65
+ 3. **Do not work around build errors** — If `tsc -b` fails, fix the type errors. Do not manually compile individual packages to skip errors, as this leads to drift between source and compiled output.
66
+ 4. **Sub-packages need `composite: true`** — Every sub-package tsconfig must have `"composite": true` in compilerOptions for project references to work.
67
+ 5. **Cross-package imports need `paths`** — If package A imports from `@claude-flow/B`, package A's tsconfig needs both a `"references"` entry and a `"paths"` mapping pointing to B's source.
68
+
69
+ ### Publishing
70
+
71
+ ```bash
72
+ npm version patch # Bump version (auto-syncs cli sub-package version)
73
+ npm run build # MUST succeed with zero errors
74
+ npm publish --otp=XXX # Requires 2FA OTP
75
+ ```
76
+
77
+ ---
78
+
79
+ ## Session Start Automation
80
+
81
+ When a Claude Code session starts, moflo automatically runs three background indexers:
82
+
83
+ | Indexer | Command | Namespace | What it does |
84
+ |---------|---------|-----------|--------------|
85
+ | Guidance | `npx flo-index` | `guidance` | Chunks markdown docs, builds RAG links, generates 384-dim embeddings |
86
+ | Code Map | `npx flo-codemap` | `code-map` | Scans source for types, interfaces, exports, directory structure |
87
+ | Learning | `npx flo-learn` | `patterns` | Pattern research on codebase for cross-session learning |
88
+
89
+ These run in background and are incremental (unchanged files are skipped). Controlled by `auto_index` in `moflo.yaml`.
90
+
91
+ ### Helper Script Auto-Sync
92
+
93
+ On version change, `session-start-launcher.mjs` copies helper scripts from the installed moflo package to the consumer project's `.claude/helpers/` and `.claude/scripts/` directories. This ensures hooks always run the latest version.
94
+
95
+ **Rule: static files, not dynamic generation.** If a helper script has no dynamic content (no per-project interpolation), it must be shipped as a pre-built static file in `bin/` and synced via the session-start file lists. Do not generate static content dynamically at runtime — it adds fragile moving parts (background `init --upgrade`, race conditions with session-start exit) and causes stale scripts when the sync list is incomplete.
96
+
97
+ | Source | Target | Files |
98
+ |--------|--------|-------|
99
+ | `bin/` | `.claude/scripts/` | `hooks.mjs`, `session-start-launcher.mjs`, `index-guidance.mjs`, `build-embeddings.mjs`, `generate-code-map.mjs`, `semantic-search.mjs` |
100
+ | `bin/` | `.claude/helpers/` | `gate.cjs`, `gate-hook.mjs`, `prompt-hook.mjs`, `hook-handler.cjs` |
101
+ | `src/@claude-flow/cli/.claude/helpers/` | `.claude/helpers/` | `auto-memory-hook.mjs`, `statusline.cjs`, `pre-commit`, `post-commit` |
102
+
103
+ When adding a new helper script: generate it once, save it to `bin/`, and add it to the appropriate list in `session-start-launcher.mjs`.
104
+
105
+ ### Bundled Guidance
106
+
107
+ Moflo ships its own guidance files (in `.claude/guidance/` within the package). When installed as a dependency, these are **automatically indexed** alongside the consumer project's guidance under the `guidance` namespace. This means agents in your project can search for moflo system docs (swarm patterns, memory commands, etc.) without any extra setup.
108
+
109
+ ---
110
+
111
+ ## Bin Commands
112
+
113
+ | Command | Script | Purpose |
114
+ |---------|--------|---------|
115
+ | `npx flo-index` | `bin/index-guidance.mjs` | Index guidance docs with RAG linking + embeddings |
116
+ | `npx flo-codemap` | `bin/generate-code-map.mjs` | Generate structural code map (types, interfaces, directories) |
117
+ | `npx flo-learn` | Learning service | Pattern research on codebase |
118
+ | `npx flo-setup` | `bin/setup-project.mjs` | Copy bootstrap guidance, inject CLAUDE.md memory section |
119
+ | `npx flo-search` | `bin/semantic-search.mjs` | Standalone semantic search with detailed output |
120
+
121
+ ### Common Flags
122
+
123
+ | Flag | Applies to | Effect |
124
+ |------|-----------|--------|
125
+ | `--force` | flo-index, flo-codemap | Reindex everything (ignore hash cache) |
126
+ | `--file <path>` | flo-index | Index a specific file only |
127
+ | `--no-embeddings` | flo-index | Skip embedding generation |
128
+ | `--verbose` | flo-index | Show detailed chunk-level output |
129
+ | `--namespace <ns>` | flo-search | Filter search to specific namespace |
130
+ | `--limit <n>` | flo-search | Number of results (default: 5) |
131
+
132
+ ---
133
+
134
+ ## MCP Tools Setup
135
+
136
+ MCP tools are the preferred way for Claude to interact with moflo. `flo init` creates a `.mcp.json` in the project root:
137
+
138
+ ```json
139
+ {
140
+ "mcpServers": {
141
+ "moflo": {
142
+ "command": "node",
143
+ "args": ["node_modules/moflo/src/@claude-flow/cli/bin/cli.js", "mcp", "start"]
144
+ }
145
+ }
146
+ }
147
+ ```
148
+
149
+ This gives Claude access to 200+ MCP tools (`mcp__moflo__memory_*`, `mcp__moflo__hooks_*`, `mcp__moflo__swarm_*`, etc.) without any global installation.
150
+
151
+ ---
152
+
153
+ ## Project Config (Anti-Drift Defaults)
154
+
155
+ - **Topology**: hierarchical (prevents drift)
156
+ - **Max Agents**: 8 (smaller = less drift)
157
+ - **Strategy**: specialized (clear roles)
158
+ - **Consensus**: raft
159
+ - **Memory**: hybrid
160
+ - **HNSW**: Enabled
161
+ - **Neural**: Enabled
162
+
163
+ ---
164
+
165
+ ## CLI Commands (26 Commands, 140+ Subcommands)
166
+
167
+ ### Core Commands
168
+
169
+ | Command | Subcommands | Description |
170
+ |-------------|-------------|--------------------------------------------------------------------------|
171
+ | `init` | 4 | Project initialization with wizard, presets, skills, hooks |
172
+ | `agent` | 8 | Agent lifecycle (spawn, list, status, stop, metrics, pool, health, logs) |
173
+ | `swarm` | 6 | Multi-agent swarm coordination and orchestration |
174
+ | `memory` | 11 | AgentDB memory with vector search (150x-12,500x faster) |
175
+ | `mcp` | 9 | MCP server management and tool execution |
176
+ | `task` | 6 | Task creation, assignment, and lifecycle |
177
+ | `session` | 7 | Session state management and persistence |
178
+ | `config` | 7 | Configuration management and provider setup |
179
+ | `status` | 3 | System status monitoring with watch mode |
180
+ | `workflow` | 6 | Workflow execution and template management |
181
+ | `hooks` | 17 | Self-learning hooks + 12 background workers |
182
+ | `hive-mind` | 6 | Queen-led Byzantine fault-tolerant consensus |
183
+
184
+ ### Advanced Commands
185
+
186
+ | Command | Subcommands | Description |
187
+ |---------------|-------------|-------------------------------------------------------------------------------|
188
+ | `daemon` | 5 | Background worker daemon (start, stop, status, trigger, enable) |
189
+ | `neural` | 5 | Neural pattern training (train, status, patterns, predict, optimize) |
190
+ | `security` | 6 | Security scanning (scan, audit, cve, threats, validate, report) |
191
+ | `performance` | 5 | Performance profiling (benchmark, profile, metrics, optimize, report) |
192
+ | `providers` | 5 | AI providers (list, add, remove, test, configure) |
193
+ | `plugins` | 5 | Plugin management (list, install, uninstall, enable, disable) |
194
+ | `deployment` | 5 | Deployment management (deploy, rollback, status, environments, release) |
195
+ | `embeddings` | 4 | Vector embeddings (embed, batch, search, init) - 75x faster with agentic-flow |
196
+ | `claims` | 4 | Claims-based authorization (check, grant, revoke, list) |
197
+ | `migrate` | 5 | V2 to V3 migration with rollback support |
198
+ | `doctor` | 1 | System diagnostics with health checks |
199
+ | `completions` | 4 | Shell completions (bash, zsh, fish, powershell) |
200
+
201
+ ### Quick Examples (MCP Preferred)
202
+
203
+ | Task | MCP Tool | CLI Fallback |
204
+ |------|----------|-------------|
205
+ | Search memory | `mcp__moflo__memory_search` | `memory search --query "..."` |
206
+ | Spawn agent | `mcp__moflo__agent_spawn` | `agent spawn -t coder --name my-coder` |
207
+ | Init swarm | `mcp__moflo__swarm_init` | `swarm init --v3-mode` |
208
+ | System health | `mcp__moflo__system_health` | `doctor --fix` |
209
+ | Benchmark | `mcp__moflo__performance_benchmark` | `performance benchmark --suite all` |
210
+
211
+ **CLI-only (no MCP equivalent — setup tasks):**
212
+ ```bash
213
+ npx flo init --wizard
214
+ npx flo daemon start
215
+ ```
216
+
217
+ ---
218
+
219
+ ## Available Agents (60+ Types)
220
+
221
+ ### Core Development
222
+ `coder`, `reviewer`, `tester`, `planner`, `researcher`
223
+
224
+ ### Specialized Agents
225
+ `security-architect`, `security-auditor`, `memory-specialist`, `performance-engineer`
226
+
227
+ ### Swarm Coordination
228
+ `hierarchical-coordinator`, `mesh-coordinator`, `adaptive-coordinator`, `collective-intelligence-coordinator`, `swarm-memory-manager`
229
+
230
+ ### Consensus & Distributed
231
+ `byzantine-coordinator`, `raft-manager`, `gossip-coordinator`, `consensus-builder`, `crdt-synchronizer`, `quorum-manager`, `security-manager`
232
+
233
+ ### Performance & Optimization
234
+ `perf-analyzer`, `performance-benchmarker`, `task-orchestrator`, `memory-coordinator`, `smart-agent`
235
+
236
+ ### GitHub & Repository
237
+ `github-modes`, `pr-manager`, `code-review-swarm`, `issue-tracker`, `release-manager`, `workflow-automation`, `project-board-sync`, `repo-architect`, `multi-repo-swarm`
238
+
239
+ ### SPARC Methodology
240
+ `sparc-coord`, `sparc-coder`, `specification`, `pseudocode`, `architecture`, `refinement`
241
+
242
+ ### Specialized Development
243
+ `backend-dev`, `mobile-dev`, `ml-developer`, `cicd-engineer`, `api-docs`, `system-architect`, `code-analyzer`, `base-template-generator`
244
+
245
+ ### Testing & Validation
246
+ `tdd-london-swarm`, `production-validator`
247
+
248
+ ### Agent Routing (Anti-Drift)
249
+
250
+ | Code | Task | Agents |
251
+ |------|-------------|-------------------------------------------------|
252
+ | 1 | Bug Fix | coordinator, researcher, coder, tester |
253
+ | 3 | Feature | coordinator, architect, coder, tester, reviewer |
254
+ | 5 | Refactor | coordinator, architect, coder, reviewer |
255
+ | 7 | Performance | coordinator, perf-engineer, coder |
256
+ | 9 | Security | coordinator, security-architect, auditor |
257
+ | 11 | Docs | researcher, api-docs |
258
+
259
+ **Codes 1-9: hierarchical/specialized (anti-drift). Code 11: mesh/balanced**
260
+
261
+ ---
262
+
263
+ ## Hooks System (27 Hooks + 12 Workers)
264
+
265
+ ### All Available Hooks
266
+
267
+ | Hook | Description | Key Options |
268
+ |--------------------|------------------------------------------|---------------------------------------------|
269
+ | `pre-edit` | Get context before editing files | `--file`, `--operation` |
270
+ | `post-edit` | Record editing outcome for learning | `--file`, `--success`, `--train-neural` |
271
+ | `pre-command` | Assess risk before commands | `--command`, `--validate-safety` |
272
+ | `post-command` | Record command execution outcome | `--command`, `--track-metrics` |
273
+ | `pre-task` | Record task start, get agent suggestions | `--description`, `--coordinate-swarm` |
274
+ | `post-task` | Record task completion for learning | `--task-id`, `--success`, `--store-results` |
275
+ | `session-start` | Start/restore session | `--session-id`, `--auto-configure` |
276
+ | `session-end` | End session and persist state | `--generate-summary`, `--export-metrics` |
277
+ | `session-restore` | Restore a previous session | `--session-id`, `--latest` |
278
+ | `route` | Route task to optimal agent | `--task`, `--context`, `--top-k` |
279
+ | `explain` | Explain routing decision | `--topic`, `--detailed` |
280
+ | `pretrain` | Bootstrap intelligence from repo | `--model-type`, `--epochs` |
281
+ | `build-agents` | Generate optimized agent configs | `--agent-types`, `--focus` |
282
+ | `metrics` | View learning metrics dashboard | `--v3-dashboard`, `--format` |
283
+ | `transfer` | Transfer patterns via IPFS registry | `store`, `from-project` |
284
+ | `intelligence` | RuVector intelligence system | `trajectory-*`, `pattern-*`, `stats` |
285
+ | `worker` | Background worker management | `list`, `dispatch`, `status`, `detect` |
286
+ | `coverage-route` | Route based on test coverage gaps | `--task`, `--path` |
287
+ | `coverage-suggest` | Suggest coverage improvements | `--path` |
288
+ | `coverage-gaps` | List coverage gaps with priorities | `--format`, `--limit` |
289
+
290
+ ### 12 Background Workers
291
+
292
+ | Worker | Priority | Description |
293
+ |---------------|----------|----------------------------|
294
+ | `ultralearn` | normal | Deep knowledge acquisition |
295
+ | `optimize` | high | Performance optimization |
296
+ | `consolidate` | low | Memory consolidation |
297
+ | `predict` | normal | Predictive preloading |
298
+ | `audit` | critical | Security analysis |
299
+ | `map` | normal | Codebase mapping |
300
+ | `preload` | low | Resource preloading |
301
+ | `deepdive` | normal | Deep code analysis |
302
+ | `document` | normal | Auto-documentation |
303
+ | `refactor` | normal | Refactoring suggestions |
304
+ | `benchmark` | normal | Performance benchmarking |
305
+ | `testgaps` | normal | Test coverage analysis |
306
+
307
+ ### Essential Hook Commands (MCP Preferred)
308
+
309
+ | Hook | MCP Tool | Key Params |
310
+ |------|----------|------------|
311
+ | Pre-task | `mcp__moflo__hooks_pre-task` | `description` |
312
+ | Post-task | `mcp__moflo__hooks_post-task` | `taskId`, `success` |
313
+ | Post-edit | `mcp__moflo__hooks_post-edit` | `file`, `trainNeural` |
314
+ | Session-start | `mcp__moflo__hooks_session-start` | `sessionId` |
315
+ | Session-end | `mcp__moflo__hooks_session-end` | `exportMetrics` |
316
+ | Route | `mcp__moflo__hooks_route` | `task` |
317
+ | Worker-dispatch | `mcp__moflo__hooks_worker-dispatch` | `trigger` |
318
+
319
+ ---
320
+
321
+ ## Hive-Mind Consensus
322
+
323
+ ### Topologies
324
+ - `hierarchical` - Queen controls workers directly
325
+ - `mesh` - Fully connected peer network
326
+ - `hierarchical-mesh` - Hybrid (recommended)
327
+ - `adaptive` - Dynamic based on load
328
+
329
+ ### Consensus Strategies
330
+ - `byzantine` - BFT (tolerates f < n/3 faulty)
331
+ - `raft` - Leader-based (tolerates f < n/2)
332
+ - `gossip` - Epidemic for eventual consistency
333
+ - `crdt` - Conflict-free replicated data types
334
+ - `quorum` - Configurable quorum-based
335
+
336
+ ---
337
+
338
+ ## RuVector Integration (HNSW Vector Search)
339
+
340
+ | Feature | Performance | Description |
341
+ |---------|-------------|-------------|
342
+ | **HNSW Index** | 150x-12,500x faster | Hierarchical Navigable Small World search |
343
+ | **MicroLoRA** | <100us adaptation | Fast model adaptation (508k+ ops/sec) |
344
+ | **FlashAttention** | 2.49x-7.47x speedup | Optimized attention computation |
345
+ | **Int8 Quantization** | 3.92x memory reduction | Compressed weight storage |
346
+
347
+ ---
348
+
349
+ ## Auto-Learning Protocol
350
+
351
+ ### Before Starting Coding Tasks
352
+
353
+ **MCP (Preferred):** `mcp__moflo__memory_search` — `query: "[task keywords]", namespace: "patterns"`
354
+
355
+ **CLI Fallback:**
356
+ ```bash
357
+ npx flo memory search --query '[task keywords]' --namespace patterns
358
+ ```
359
+
360
+ ### After Completing Any Task Successfully (MCP Preferred)
361
+
362
+ | Step | MCP Tool | Key Params |
363
+ |------|----------|------------|
364
+ | 1. Store pattern | `mcp__moflo__memory_store` | `namespace: "patterns", key: "[name]", value: "[what worked]"` |
365
+ | 2. Train neural | `mcp__moflo__hooks_post-edit` | `file: "[main-file]", trainNeural: true` |
366
+ | 3. Record completion | `mcp__moflo__hooks_post-task` | `taskId: "[id]", success: true, storeResults: true` |
367
+
368
+ ### Continuous Improvement Triggers
369
+
370
+ | Trigger | Worker | When to Use |
371
+ |------------------------|------------|----------------------------|
372
+ | After major refactor | `optimize` | Performance optimization |
373
+ | After adding features | `testgaps` | Find missing test coverage |
374
+ | After security changes | `audit` | Security analysis |
375
+ | After API changes | `document` | Update documentation |
376
+ | Every 5+ file changes | `map` | Update codebase map |
377
+ | Complex debugging | `deepdive` | Deep code analysis |
378
+
379
+ ### Memory-Enhanced Development
380
+
381
+ **ALWAYS check memory before:**
382
+ - Starting a new feature (search for similar implementations)
383
+ - Debugging an issue (search for past solutions)
384
+ - Refactoring code (search for learned patterns)
385
+ - Performance work (search for optimization strategies)
386
+
387
+ **ALWAYS store in memory after:**
388
+ - Solving a tricky bug (store the solution pattern)
389
+ - Completing a feature (store the approach)
390
+ - Finding a performance fix (store the optimization)
391
+ - Discovering a security issue (store the vulnerability pattern)
392
+
393
+ ---
394
+
395
+ ## Memory Commands Reference (MCP Preferred)
396
+
397
+ ### Store Data
398
+
399
+ **MCP:** `mcp__moflo__memory_store`
400
+ - Required: `key`, `value`
401
+ - Optional: `namespace` (default: "default"), `ttl`, `tags`
402
+
403
+ **CLI Fallback:**
404
+ ```bash
405
+ npx flo memory store --key "pattern-auth" --value "JWT with refresh tokens" --namespace patterns
406
+ ```
407
+
408
+ ### Search Data (semantic vector search)
409
+
410
+ **MCP:** `mcp__moflo__memory_search`
411
+ - Required: `query`
412
+ - Optional: `namespace`, `limit`, `threshold`
413
+
414
+ **CLI Fallback:**
415
+ ```bash
416
+ npx flo memory search --query "authentication patterns" --namespace patterns --limit 5
417
+ ```
418
+
419
+ ### List Entries
420
+
421
+ **MCP:** `mcp__moflo__memory_list`
422
+ - Optional: `namespace`, `limit`
423
+
424
+ ### Retrieve Specific Entry
425
+
426
+ **MCP:** `mcp__moflo__memory_retrieve`
427
+ - Required: `key`
428
+ - Optional: `namespace` (default: "default")
429
+
430
+ ---
431
+
432
+ ## Claude Code vs MCP vs CLI Tools
433
+
434
+ ### Claude Code Handles ALL EXECUTION:
435
+ - **Task tool**: Spawn and run agents concurrently
436
+ - File operations (Read, Write, Edit, Glob, Grep)
437
+ - Code generation and programming
438
+ - Bash commands and system operations
439
+ - Git operations
440
+
441
+ ### MCP Tools Handle Coordination (Preferred):
442
+
443
+ | Operation | MCP Tool |
444
+ |-----------|----------|
445
+ | Swarm init | `mcp__moflo__swarm_init` |
446
+ | Agent spawn | `mcp__moflo__agent_spawn` |
447
+ | Memory store | `mcp__moflo__memory_store` |
448
+ | Memory search | `mcp__moflo__memory_search` |
449
+ | Hooks (all) | `mcp__moflo__hooks_<hook-name>` |
450
+
451
+ ### CLI Commands (Fallback Only):
452
+
453
+ Only use CLI via Bash when MCP tools are unavailable:
454
+ ```bash
455
+ npx flo <command> [options]
456
+ ```
457
+
458
+ **KEY**: MCP tools coordinate strategy, Claude Code's Task tool executes with real agents.
459
+
460
+ ---
461
+
462
+ ## Doctor Health Checks
463
+
464
+ **MCP:** `mcp__moflo__system_health` | **CLI:** `npx flo doctor`
465
+
466
+ Checks: Node version (20+), Git, config validity, daemon status, memory database, API keys, MCP servers, disk space, TypeScript.
467
+
468
+ ---
469
+
470
+ ## Environment Variables
471
+
472
+ ```bash
473
+ # Configuration
474
+ CLAUDE_FLOW_CONFIG=./claude-flow.config.json
475
+ CLAUDE_FLOW_LOG_LEVEL=info
476
+
477
+ # MCP Server
478
+ CLAUDE_FLOW_MCP_PORT=3000
479
+ CLAUDE_FLOW_MCP_HOST=localhost
480
+ CLAUDE_FLOW_MCP_TRANSPORT=stdio
481
+
482
+ # Memory
483
+ CLAUDE_FLOW_MEMORY_BACKEND=hybrid
484
+ CLAUDE_FLOW_MEMORY_PATH=./data/memory
485
+ ```
486
+
487
+ ---
488
+
489
+ ## Quick Setup
490
+
491
+ ### Project-Level MCP (Recommended)
492
+
493
+ Configure `.mcp.json` in the project root:
494
+
495
+ ```json
496
+ {
497
+ "mcpServers": {
498
+ "moflo": {
499
+ "command": "node",
500
+ "args": ["node_modules/moflo/src/@claude-flow/cli/bin/cli.js", "mcp", "start"]
501
+ }
502
+ }
503
+ }
504
+ ```
505
+
506
+ ### Alternative: Global MCP Registration
507
+
508
+ ```bash
509
+ claude mcp add moflo -- npx @claude-flow/cli@alpha
510
+ npx flo daemon start
511
+ npx flo doctor --fix
512
+ ```
513
+
514
+ ---
515
+
516
+ ## Project Configuration (moflo.yaml)
517
+
518
+ Moflo reads `moflo.yaml` (or `moflo.config.json`) from the project root. All fields have sensible defaults — the file is optional.
519
+
520
+ ### Full Reference
521
+
522
+ ```yaml
523
+ project:
524
+ name: "my-project" # Project name (default: directory name)
525
+
526
+ # Guidance/knowledge docs to index for semantic search
527
+ guidance:
528
+ directories: # Directories to scan for .md files
529
+ - .claude/guidance # Default
530
+ - docs/guides # Default
531
+ namespace: guidance # Memory namespace for indexed docs
532
+
533
+ # Source directories for code navigation map
534
+ code_map:
535
+ directories: # Directories to scan for source files
536
+ - src # Default
537
+ - packages
538
+ - lib
539
+ - app
540
+ extensions: [".ts", ".tsx", ".js", ".jsx", ".py", ".go", ".rs", ".java"]
541
+ exclude: [node_modules, dist, .next, coverage, build, __pycache__, target, .git]
542
+ namespace: code-map
543
+
544
+ # Workflow gates (enforced via Claude Code hooks)
545
+ gates:
546
+ memory_first: true # Search memory before Glob/Grep
547
+ task_create_first: true # TaskCreate before Agent tool
548
+ context_tracking: true # Track context bracket (FRESH/MODERATE/DEPLETED/CRITICAL)
549
+
550
+ # Auto-index on session start
551
+ auto_index:
552
+ guidance: true # Run flo-index (guidance RAG indexer)
553
+ code_map: true # Run flo-codemap (structural code index)
554
+
555
+ # Memory backend
556
+ memory:
557
+ backend: sql.js # sql.js (WASM) | agentdb | json
558
+ embedding_model: Xenova/all-MiniLM-L6-v2 # 384-dim neural embeddings
559
+ namespace: default # Default namespace for memory operations
560
+
561
+ # Hook toggles (all on by default — disable to slim down)
562
+ hooks:
563
+ pre_edit: true # Track file edits for learning
564
+ post_edit: true # Record edit outcomes, train neural patterns
565
+ pre_task: true # Get agent routing before task spawn
566
+ post_task: true # Record task results for learning
567
+ gate: true # Workflow gate enforcement (memory-first, task-create-first)
568
+ route: true # Intelligent task routing on each prompt
569
+ stop_hook: true # Session-end persistence and metric export
570
+ session_restore: true # Restore session state on start
571
+ notification: true # Hook into Claude Code notifications
572
+
573
+ # Model preferences (haiku, sonnet, opus)
574
+ models:
575
+ default: opus # General tasks
576
+ research: sonnet # Research/exploration agents
577
+ review: opus # Code review agents
578
+ test: sonnet # Test-writing agents
579
+
580
+ # Intelligent model routing (auto-selects haiku/sonnet/opus per task)
581
+ model_routing:
582
+ enabled: false # Set true to enable dynamic routing
583
+ confidence_threshold: 0.85 # Min confidence before escalating
584
+ cost_optimization: true # Prefer cheaper models when confident
585
+ circuit_breaker: true # Penalize models that fail repeatedly
586
+ # agent_overrides:
587
+ # security-architect: opus
588
+ # researcher: sonnet
589
+
590
+ # Status line display
591
+ status_line:
592
+ enabled: true # Show status line at all
593
+ branding: "Moflo V4" # Text in status bar
594
+ mode: single-line # single-line (default) or dashboard (multi-line)
595
+ show_git: true # Git branch, changes, ahead/behind
596
+ show_model: true # Current model name
597
+ show_session: true # Session duration
598
+ show_intelligence: true # Intelligence % indicator
599
+ show_swarm: true # Active swarm agents count
600
+ show_hooks: true # Enabled hooks count
601
+ show_mcp: true # MCP server count
602
+ show_security: true # CVE/security status (dashboard only)
603
+ show_adrs: true # ADR compliance (dashboard only)
604
+ show_agentdb: true # AgentDB vectors/size (dashboard only)
605
+ show_tests: true # Test file count (dashboard only)
606
+ ```
607
+
608
+ ### Key Behaviors
609
+
610
+ | Config | Effect |
611
+ |--------|--------|
612
+ | `auto_index.guidance: false` | Skip guidance indexing on session start |
613
+ | `auto_index.code_map: false` | Skip code map generation on session start |
614
+ | `gates.memory_first: true` | Block Glob/Grep/Read until memory is searched first |
615
+ | `gates.task_create_first: true` | Block Agent/Task tool until TaskCreate is called |
616
+ | `gates.context_tracking: true` | Show FRESH/MODERATE/DEPLETED/CRITICAL context bracket |
617
+ | `hooks.pre_edit: false` | Disable file-edit tracking (skips pre-edit hook) |
618
+ | `hooks.post_edit: false` | Disable edit outcome recording and neural training |
619
+ | `hooks.pre_task: false` | Disable agent routing recommendations before spawn |
620
+ | `hooks.post_task: false` | Disable task result recording for learning |
621
+ | `hooks.gate: false` | Disable all workflow gates (memory-first, task-create-first) |
622
+ | `hooks.route: false` | Disable intelligent task routing on each prompt |
623
+ | `hooks.stop_hook: false` | Disable session-end persistence and metric export |
624
+ | `hooks.notification: false` | Disable notification hook |
625
+ | `model_routing.enabled: true` | Auto-select haiku/sonnet/opus based on task complexity |
626
+ | `status_line.mode: dashboard` | Switch to multi-line status display |
627
+ | `status_line.show_swarm: false` | Hide swarm agent count from status bar |
628
+
629
+ ---
630
+
631
+ ## Cross-Platform Compatibility
632
+
633
+ All code changes MUST work on Windows, macOS, and Linux. Follow these rules:
634
+
635
+ - **Paths**: Use `path.join()` / `path.resolve()`, never hardcoded `/` or `\\` separators
636
+ - **Process spawning**: Use `detached: !isWin` for background processes; on Windows use `shell: true, windowsHide: true` instead
637
+ - **Process killing**: Use `taskkill /F /PID` on Windows, `process.kill(pid, signal)` on POSIX
638
+ - **Process inspection**: Use PowerShell `Get-CimInstance` on Windows, `/proc/<pid>/cmdline` on Linux, `ps -p <pid>` on macOS
639
+ - **Shell commands**: Never assume bash use `child_process.spawn` with explicit args instead of shell string interpolation
640
+ - **File locking**: Use `fs.writeFileSync(path, data, { flag: 'wx' })` for atomic locks (works cross-platform)
641
+ - **Signals**: SIGHUP/SIGTERM are POSIX-only; on Windows use `taskkill` or process exit events
642
+ - **Line endings**: Use `\n` in code; let git handle CRLF conversion
643
+ - **Temp dirs**: Use `os.tmpdir()`, not `/tmp`
644
+ - **PID recycling**: Windows recycles PIDs aggressively — always verify process command line, not just PID liveness
645
+
646
+ ## Troubleshooting Common Issues
647
+
648
+ | Symptom | Cause | Fix |
649
+ |---------|-------|-----|
650
+ | No MCP tools available | `.mcp.json` missing or moflo not installed | Run `npx flo init` or manually create `.mcp.json` |
651
+ | Memory search returns nothing | Indexer hasn't run yet | Run `npx flo-index --force` to index guidance |
652
+ | Low search quality | Guidance docs missing `**Purpose:**` lines or generic headings | Follow guidance optimization rules in `guidance-memory-strategy.md` |
653
+ | Session start slow | All three indexers running | Set `auto_index.code_map: false` in `moflo.yaml` if code map not needed |
654
+ | Status line not showing | `statusline.cjs` error or `status_line.enabled: false` | Run `node .claude/helpers/statusline.cjs` to test, check `moflo.yaml` |
655
+ | Embeddings falling back to hash | Transformers.js not available | Install `@xenova/transformers` — moflo includes it but some environments strip it |
656
+ | `flo` command not found | Not in PATH | Use `npx flo` or `node node_modules/moflo/bin/index-guidance.mjs` |
657
+ | Bundled guidance not indexed | Running inside moflo repo (same dir) | Bundled guidance only indexes when installed as a dependency in a different project |
658
+
659
+ See `memory-strategy.md` for memory-specific troubleshooting.
660
+
661
+ ---
662
+
663
+ ## See Also
664
+
665
+ - `.claude/guidance/agent-bootstrap.md` - Subagent memory-first protocol and store patterns
666
+ - `.claude/guidance/task-swarm-integration.md` - Task & swarm coordination with TaskCreate/TaskUpdate
667
+ - `.claude/guidance/memory-strategy.md` - Database schema, namespaces, search commands, RAG linking
668
+ - `.claude/guidance/guidance-memory-strategy.md` - How to write guidance docs that index well for RAG