@claude-flow/cli 3.6.9 → 3.6.11
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +149 -27
- package/bin/cli.js +14 -3
- package/dist/src/commands/memory.d.ts.map +1 -1
- package/dist/src/commands/memory.js +74 -18
- package/dist/src/commands/memory.js.map +1 -1
- package/dist/src/init/claudemd-generator.d.ts +2 -11
- package/dist/src/init/claudemd-generator.d.ts.map +1 -1
- package/dist/src/init/claudemd-generator.js +227 -409
- package/dist/src/init/claudemd-generator.js.map +1 -1
- package/dist/src/mcp-client.d.ts.map +1 -1
- package/dist/src/mcp-client.js +16 -1
- package/dist/src/mcp-client.js.map +1 -1
- package/dist/src/mcp-tools/memory-tools.d.ts.map +1 -1
- package/dist/src/mcp-tools/memory-tools.js +100 -39
- package/dist/src/mcp-tools/memory-tools.js.map +1 -1
- package/dist/src/plugins/store/discovery.d.ts.map +1 -1
- package/dist/src/plugins/store/discovery.js +86 -34
- package/dist/src/plugins/store/discovery.js.map +1 -1
- package/dist/tsconfig.tsbuildinfo +1 -1
- package/package.json +1 -1
|
@@ -1,545 +1,363 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* CLAUDE.md Generator
|
|
3
|
-
* Generates
|
|
4
|
-
* with template variants for different usage patterns.
|
|
3
|
+
* Generates lean, enforceable Claude Code configuration optimized for token efficiency.
|
|
5
4
|
*
|
|
6
5
|
* Templates: minimal | standard | full | security | performance | solo
|
|
7
|
-
* All templates use
|
|
6
|
+
* All templates use imperative rules and agent comms-first coordination.
|
|
8
7
|
*/
|
|
9
|
-
// --- Section Generators
|
|
8
|
+
// --- Section Generators ---
|
|
10
9
|
function behavioralRules() {
|
|
11
|
-
return `##
|
|
10
|
+
return `## Rules
|
|
12
11
|
|
|
13
12
|
- Do what has been asked; nothing more, nothing less
|
|
14
|
-
- NEVER create files unless
|
|
15
|
-
-
|
|
16
|
-
- NEVER
|
|
17
|
-
- NEVER save working files, text/mds, or tests to the root folder
|
|
18
|
-
- Never continuously check status after spawning a swarm — wait for results
|
|
13
|
+
- NEVER create files unless absolutely necessary — prefer editing existing files
|
|
14
|
+
- NEVER create documentation files unless explicitly requested
|
|
15
|
+
- NEVER save working files or tests to root — use \`/src\`, \`/tests\`, \`/docs\`, \`/config\`, \`/scripts\`
|
|
19
16
|
- ALWAYS read a file before editing it
|
|
20
|
-
- NEVER commit secrets, credentials, or .env files
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
return `## File Organization
|
|
24
|
-
|
|
25
|
-
- NEVER save to root folder — use the directories below
|
|
26
|
-
- Use \`/src\` for source code files
|
|
27
|
-
- Use \`/tests\` for test files
|
|
28
|
-
- Use \`/docs\` for documentation and markdown files
|
|
29
|
-
- Use \`/config\` for configuration files
|
|
30
|
-
- Use \`/scripts\` for utility scripts
|
|
31
|
-
- Use \`/examples\` for example code`;
|
|
17
|
+
- NEVER commit secrets, credentials, or .env files
|
|
18
|
+
- Keep files under 500 lines
|
|
19
|
+
- Validate input at system boundaries`;
|
|
32
20
|
}
|
|
33
|
-
function
|
|
34
|
-
return `##
|
|
21
|
+
function agentComms() {
|
|
22
|
+
return `## Agent Comms (SendMessage-First Coordination)
|
|
35
23
|
|
|
36
|
-
|
|
37
|
-
- Keep files under 500 lines
|
|
38
|
-
- Use typed interfaces for all public APIs
|
|
39
|
-
- Prefer TDD London School (mock-first) for new code
|
|
40
|
-
- Use event sourcing for state changes
|
|
41
|
-
- Ensure input validation at system boundaries
|
|
24
|
+
Named agents coordinate via \`SendMessage\`, not polling or shared state.
|
|
42
25
|
|
|
43
|
-
|
|
26
|
+
\`\`\`
|
|
27
|
+
Lead (you) ←→ architect ←→ developer ←→ tester ←→ reviewer
|
|
28
|
+
(named agents message each other directly)
|
|
29
|
+
\`\`\`
|
|
44
30
|
|
|
45
|
-
|
|
46
|
-
- **Max Agents**: ${options.runtime.maxAgents}
|
|
47
|
-
- **Memory**: ${options.runtime.memoryBackend}
|
|
48
|
-
- **HNSW**: ${options.runtime.enableHNSW ? 'Enabled' : 'Disabled'}
|
|
49
|
-
- **Neural**: ${options.runtime.enableNeural ? 'Enabled' : 'Disabled'}`;
|
|
50
|
-
}
|
|
51
|
-
function concurrencyRules() {
|
|
52
|
-
return `## Concurrency: 1 MESSAGE = ALL RELATED OPERATIONS
|
|
53
|
-
|
|
54
|
-
- All operations MUST be concurrent/parallel in a single message
|
|
55
|
-
- Use Claude Code's Agent tool for spawning agents, not just MCP
|
|
56
|
-
- ALWAYS spawn ALL agents in ONE message with full instructions via Agent tool
|
|
57
|
-
- ALWAYS batch ALL file reads/writes/edits in ONE message
|
|
58
|
-
- ALWAYS batch ALL Bash commands in ONE message`;
|
|
59
|
-
}
|
|
60
|
-
function swarmOrchestration() {
|
|
61
|
-
return `## Swarm Orchestration
|
|
31
|
+
### Spawning a Coordinated Team
|
|
62
32
|
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
33
|
+
\`\`\`javascript
|
|
34
|
+
// ALL agents in ONE message, each knows WHO to message next
|
|
35
|
+
Agent({ prompt: "Research the codebase. SendMessage findings to 'architect'.",
|
|
36
|
+
subagent_type: "researcher", name: "researcher", run_in_background: true })
|
|
37
|
+
Agent({ prompt: "Wait for 'researcher'. Design solution. SendMessage to 'coder'.",
|
|
38
|
+
subagent_type: "system-architect", name: "architect", run_in_background: true })
|
|
39
|
+
Agent({ prompt: "Wait for 'architect'. Implement it. SendMessage to 'tester'.",
|
|
40
|
+
subagent_type: "coder", name: "coder", run_in_background: true })
|
|
41
|
+
Agent({ prompt: "Wait for 'coder'. Write tests. SendMessage results to 'reviewer'.",
|
|
42
|
+
subagent_type: "tester", name: "tester", run_in_background: true })
|
|
43
|
+
Agent({ prompt: "Wait for 'tester'. Review code quality and security.",
|
|
44
|
+
subagent_type: "reviewer", name: "reviewer", run_in_background: true })
|
|
45
|
+
|
|
46
|
+
// Kick off the pipeline
|
|
47
|
+
SendMessage({ to: "researcher", summary: "Start", message: "[task context]" })
|
|
48
|
+
\`\`\`
|
|
49
|
+
|
|
50
|
+
### Patterns
|
|
67
51
|
|
|
68
|
-
|
|
52
|
+
| Pattern | Flow | Use When |
|
|
53
|
+
|---------|------|----------|
|
|
54
|
+
| **Pipeline** | A → B → C → D | Sequential dependencies (feature dev) |
|
|
55
|
+
| **Fan-out** | Lead → A, B, C → Lead | Independent parallel work (research) |
|
|
56
|
+
| **Supervisor** | Lead ↔ workers | Ongoing coordination (complex refactor) |
|
|
69
57
|
|
|
70
|
-
|
|
71
|
-
|------|---------|---------|------|-----------|
|
|
72
|
-
| **1** | Agent Booster (WASM) | <1ms | $0 | Simple transforms (var→const, add types) — Skip LLM |
|
|
73
|
-
| **2** | Haiku | ~500ms | $0.0002 | Simple tasks, low complexity (<30%) |
|
|
74
|
-
| **3** | Sonnet/Opus | 2-5s | $0.003-0.015 | Complex reasoning, architecture, security (>30%) |
|
|
58
|
+
### Rules
|
|
75
59
|
|
|
76
|
-
-
|
|
60
|
+
- ALWAYS name agents — \`name: "role"\` makes them addressable
|
|
61
|
+
- ALWAYS include comms instructions in prompts — who to message, what to send
|
|
62
|
+
- Spawn ALL agents in ONE message with \`run_in_background: true\`
|
|
63
|
+
- After spawning: STOP, tell user what's running, wait for results
|
|
64
|
+
- NEVER poll status — agents message back or complete automatically`;
|
|
77
65
|
}
|
|
78
|
-
function
|
|
79
|
-
return `## Swarm
|
|
66
|
+
function swarmConfig(options) {
|
|
67
|
+
return `## Swarm & Routing
|
|
80
68
|
|
|
81
|
-
|
|
82
|
-
-
|
|
83
|
-
-
|
|
84
|
-
-
|
|
85
|
-
-
|
|
86
|
-
-
|
|
69
|
+
### Config
|
|
70
|
+
- **Topology**: ${options.runtime.topology} (anti-drift)
|
|
71
|
+
- **Max Agents**: ${options.runtime.maxAgents}
|
|
72
|
+
- **Memory**: ${options.runtime.memoryBackend}
|
|
73
|
+
- **HNSW**: ${options.runtime.enableHNSW ? 'Enabled' : 'Disabled'}
|
|
74
|
+
- **Neural**: ${options.runtime.enableNeural ? 'Enabled' : 'Disabled'}
|
|
87
75
|
|
|
88
76
|
\`\`\`bash
|
|
89
77
|
npx @claude-flow/cli@latest swarm init --topology hierarchical --max-agents 8 --strategy specialized
|
|
90
|
-
\`\`\``;
|
|
91
|
-
}
|
|
92
|
-
function autoStartProtocol() {
|
|
93
|
-
return `## Swarm Protocols & Routing
|
|
94
|
-
|
|
95
|
-
### Auto-Start Swarm Protocol
|
|
96
|
-
|
|
97
|
-
When the user requests a complex task, spawn agents in background and WAIT:
|
|
98
|
-
|
|
99
|
-
\`\`\`javascript
|
|
100
|
-
// STEP 1: Initialize swarm coordination
|
|
101
|
-
Bash("npx @claude-flow/cli@latest swarm init --topology hierarchical --max-agents 8 --strategy specialized")
|
|
102
|
-
|
|
103
|
-
// STEP 2: Spawn ALL agents IN BACKGROUND in a SINGLE message
|
|
104
|
-
Agent("Research requirements", "Analyze codebase patterns and store findings in memory", {subagent_type: "researcher", run_in_background: true})
|
|
105
|
-
Agent("Design architecture", "Design architecture based on research", {subagent_type: "system-architect", run_in_background: true})
|
|
106
|
-
Agent("Implement solution", "Implement the solution following the design", {subagent_type: "coder", run_in_background: true})
|
|
107
|
-
Agent("Write tests", "Write comprehensive tests for the implementation", {subagent_type: "tester", run_in_background: true})
|
|
108
|
-
Agent("Review code quality", "Review code quality, security, and best practices", {subagent_type: "reviewer", run_in_background: true})
|
|
109
78
|
\`\`\`
|
|
110
79
|
|
|
111
80
|
### Agent Routing
|
|
112
81
|
|
|
113
|
-
|
|
|
114
|
-
|
|
115
|
-
|
|
|
116
|
-
|
|
|
117
|
-
|
|
|
118
|
-
|
|
|
119
|
-
|
|
|
120
|
-
|
|
121
|
-
###
|
|
122
|
-
|
|
123
|
-
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
- Never poll agent status repeatedly — trust agents to return
|
|
133
|
-
- When agent results arrive, review ALL results before proceeding`;
|
|
82
|
+
| Task | Agents | Topology |
|
|
83
|
+
|------|--------|----------|
|
|
84
|
+
| Bug Fix | researcher, coder, tester | hierarchical |
|
|
85
|
+
| Feature | architect, coder, tester, reviewer | hierarchical |
|
|
86
|
+
| Refactor | architect, coder, reviewer | hierarchical |
|
|
87
|
+
| Performance | perf-engineer, coder | hierarchical |
|
|
88
|
+
| Security | security-architect, auditor | hierarchical |
|
|
89
|
+
|
|
90
|
+
### When to Swarm
|
|
91
|
+
- **YES**: 3+ files, new features, cross-module refactoring, API changes, security, performance
|
|
92
|
+
- **NO**: single file edits, 1-2 line fixes, docs updates, config changes, questions
|
|
93
|
+
|
|
94
|
+
### 3-Tier Model Routing
|
|
95
|
+
|
|
96
|
+
| Tier | Handler | Use Cases |
|
|
97
|
+
|------|---------|-----------|
|
|
98
|
+
| 1 | Agent Booster (WASM) | Simple transforms — skip LLM, use Edit directly |
|
|
99
|
+
| 2 | Haiku | Simple tasks, low complexity |
|
|
100
|
+
| 3 | Sonnet/Opus | Architecture, security, complex reasoning |`;
|
|
134
101
|
}
|
|
135
|
-
function
|
|
136
|
-
return `##
|
|
137
|
-
|
|
138
|
-
### Core Commands
|
|
139
|
-
|
|
140
|
-
| Command | Subcommands | Description |
|
|
141
|
-
|---------|-------------|-------------|
|
|
142
|
-
| \`init\` | 4 | Project initialization |
|
|
143
|
-
| \`agent\` | 8 | Agent lifecycle management |
|
|
144
|
-
| \`swarm\` | 6 | Multi-agent swarm coordination |
|
|
145
|
-
| \`memory\` | 11 | AgentDB memory with HNSW search |
|
|
146
|
-
| \`task\` | 6 | Task creation and lifecycle |
|
|
147
|
-
| \`session\` | 7 | Session state management |
|
|
148
|
-
| \`hooks\` | 17 | Self-learning hooks + 12 workers |
|
|
149
|
-
| \`hive-mind\` | 6 | Byzantine fault-tolerant consensus |
|
|
150
|
-
|
|
151
|
-
### Quick CLI Examples
|
|
102
|
+
function memoryAndLearning() {
|
|
103
|
+
return `## Memory & Learning
|
|
152
104
|
|
|
105
|
+
### Before Any Task
|
|
153
106
|
\`\`\`bash
|
|
154
|
-
npx @claude-flow/cli@latest
|
|
155
|
-
npx @claude-flow/cli@latest
|
|
156
|
-
|
|
157
|
-
npx @claude-flow/cli@latest memory search --query "authentication patterns"
|
|
158
|
-
npx @claude-flow/cli@latest doctor --fix
|
|
159
|
-
\`\`\``;
|
|
160
|
-
}
|
|
161
|
-
function agentTypes() {
|
|
162
|
-
return `## Available Agents (16 Roles + Custom)
|
|
107
|
+
npx @claude-flow/cli@latest memory search --query "[task keywords]" --namespace patterns
|
|
108
|
+
npx @claude-flow/cli@latest hooks route --task "[task description]"
|
|
109
|
+
\`\`\`
|
|
163
110
|
|
|
164
|
-
###
|
|
165
|
-
|
|
111
|
+
### After Success
|
|
112
|
+
\`\`\`bash
|
|
113
|
+
npx @claude-flow/cli@latest memory store --namespace patterns --key "[name]" --value "[what worked]"
|
|
114
|
+
npx @claude-flow/cli@latest hooks post-task --task-id "[id]" --success true --store-results true
|
|
115
|
+
\`\`\`
|
|
166
116
|
|
|
167
|
-
###
|
|
168
|
-
\`security-architect\`, \`security-auditor\`, \`memory-specialist\`, \`performance-engineer\`
|
|
117
|
+
### MCP Tools (use \`ToolSearch("keyword")\` to discover)
|
|
169
118
|
|
|
170
|
-
|
|
171
|
-
|
|
119
|
+
| Category | Key Tools |
|
|
120
|
+
|----------|-----------|
|
|
121
|
+
| **Memory** | \`memory_store\`, \`memory_search\`, \`memory_search_unified\` |
|
|
122
|
+
| **Bridge** | \`memory_import_claude\`, \`memory_bridge_status\` |
|
|
123
|
+
| **Swarm** | \`swarm_init\`, \`swarm_status\`, \`swarm_health\` |
|
|
124
|
+
| **Agents** | \`agent_spawn\`, \`agent_list\`, \`agent_status\` |
|
|
125
|
+
| **Hooks** | \`hooks_route\`, \`hooks_post-task\`, \`hooks_worker-dispatch\` |
|
|
126
|
+
| **Security** | \`aidefence_scan\`, \`aidefence_is_safe\`, \`aidefence_has_pii\` |
|
|
127
|
+
| **Hive-Mind** | \`hive-mind_init\`, \`hive-mind_consensus\`, \`hive-mind_spawn\` |
|
|
172
128
|
|
|
173
|
-
###
|
|
174
|
-
\`pr-manager\`, \`code-review-swarm\`, \`issue-tracker\`, \`release-manager\`
|
|
129
|
+
### Background Workers
|
|
175
130
|
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
| Hook | Description |
|
|
184
|
-
|------|-------------|
|
|
185
|
-
| \`pre-task\` / \`post-task\` | Task lifecycle with learning |
|
|
186
|
-
| \`pre-edit\` / \`post-edit\` | File editing with neural training |
|
|
187
|
-
| \`session-start\` / \`session-end\` | Session state persistence |
|
|
188
|
-
| \`route\` | Route task to optimal agent |
|
|
189
|
-
| \`intelligence\` | RuVector intelligence system |
|
|
190
|
-
| \`worker\` | Background worker management |
|
|
191
|
-
|
|
192
|
-
### 12 Background Workers
|
|
193
|
-
|
|
194
|
-
| Worker | Priority | Description |
|
|
195
|
-
|--------|----------|-------------|
|
|
196
|
-
| \`optimize\` | high | Performance optimization |
|
|
197
|
-
| \`audit\` | critical | Security analysis |
|
|
198
|
-
| \`testgaps\` | normal | Test coverage analysis |
|
|
199
|
-
| \`map\` | normal | Codebase mapping |
|
|
200
|
-
| \`deepdive\` | normal | Deep code analysis |
|
|
201
|
-
| \`document\` | normal | Auto-documentation |
|
|
131
|
+
| Worker | When |
|
|
132
|
+
|--------|------|
|
|
133
|
+
| \`audit\` | After security changes |
|
|
134
|
+
| \`optimize\` | After performance work |
|
|
135
|
+
| \`testgaps\` | After adding features |
|
|
136
|
+
| \`map\` | Every 5+ file changes |
|
|
137
|
+
| \`document\` | After API changes |
|
|
202
138
|
|
|
203
139
|
\`\`\`bash
|
|
204
|
-
npx @claude-flow/cli@latest hooks pre-task --description "[task]"
|
|
205
|
-
npx @claude-flow/cli@latest hooks post-task --task-id "[id]" --success true
|
|
206
140
|
npx @claude-flow/cli@latest hooks worker dispatch --trigger audit
|
|
207
141
|
\`\`\``;
|
|
208
142
|
}
|
|
209
|
-
function
|
|
210
|
-
return `##
|
|
143
|
+
function agentTypes() {
|
|
144
|
+
return `## Agents
|
|
211
145
|
|
|
212
|
-
|
|
213
|
-
|
|
214
|
-
|
|
215
|
-
|
|
216
|
-
|
|
146
|
+
**Core**: \`coder\`, \`reviewer\`, \`tester\`, \`planner\`, \`researcher\`
|
|
147
|
+
**Architecture**: \`system-architect\`, \`backend-dev\`, \`mobile-dev\`
|
|
148
|
+
**Security**: \`security-architect\`, \`security-auditor\`
|
|
149
|
+
**Performance**: \`performance-engineer\`, \`perf-analyzer\`
|
|
150
|
+
**Coordination**: \`hierarchical-coordinator\`, \`mesh-coordinator\`, \`adaptive-coordinator\`
|
|
151
|
+
**GitHub**: \`pr-manager\`, \`code-review-swarm\`, \`issue-tracker\`, \`release-manager\`
|
|
152
|
+
|
|
153
|
+
Any string works as a custom agent type.`;
|
|
154
|
+
}
|
|
155
|
+
function cliQuickRef() {
|
|
156
|
+
return `## CLI Quick Reference
|
|
217
157
|
|
|
218
|
-
### After Completing Any Task Successfully
|
|
219
158
|
\`\`\`bash
|
|
220
|
-
npx @claude-flow/cli@latest
|
|
221
|
-
npx @claude-flow/cli@latest
|
|
159
|
+
npx @claude-flow/cli@latest init --wizard # Setup
|
|
160
|
+
npx @claude-flow/cli@latest swarm init --v3-mode # Start swarm
|
|
161
|
+
npx @claude-flow/cli@latest memory search --query "" # Vector search
|
|
162
|
+
npx @claude-flow/cli@latest hooks route --task "" # Route to agent
|
|
163
|
+
npx @claude-flow/cli@latest doctor --fix # Diagnostics
|
|
164
|
+
npx @claude-flow/cli@latest security scan # Security scan
|
|
165
|
+
npx @claude-flow/cli@latest performance benchmark # Benchmarks
|
|
222
166
|
\`\`\`
|
|
223
167
|
|
|
224
|
-
|
|
225
|
-
- ALWAYS store patterns in memory after solving bugs, completing features, or finding optimizations`;
|
|
168
|
+
26 commands, 140+ subcommands. Use \`--help\` on any command for details.`;
|
|
226
169
|
}
|
|
227
|
-
function
|
|
228
|
-
return `##
|
|
229
|
-
|
|
230
|
-
### MCP Tools (use via ToolSearch to discover)
|
|
231
|
-
|
|
232
|
-
| Tool | Description |
|
|
233
|
-
|------|-------------|
|
|
234
|
-
| \`memory_store\` | Store value with ONNX 384-dim vector embedding |
|
|
235
|
-
| \`memory_search\` | Semantic vector search by query |
|
|
236
|
-
| \`memory_retrieve\` | Get entry by key |
|
|
237
|
-
| \`memory_list\` | List entries in namespace |
|
|
238
|
-
| \`memory_delete\` | Delete entry |
|
|
239
|
-
| \`memory_import_claude\` | Import Claude Code memories into AgentDB (allProjects=true for all) |
|
|
240
|
-
| \`memory_search_unified\` | Search across ALL namespaces (Claude + AgentDB + patterns) |
|
|
241
|
-
| \`memory_bridge_status\` | Show bridge health, vectors, SONA, intelligence |
|
|
242
|
-
|
|
243
|
-
### CLI Commands
|
|
170
|
+
function setupAndBoundary() {
|
|
171
|
+
return `## Setup
|
|
244
172
|
|
|
245
173
|
\`\`\`bash
|
|
246
|
-
|
|
247
|
-
npx @claude-flow/cli@latest
|
|
248
|
-
|
|
249
|
-
# Semantic search
|
|
250
|
-
npx @claude-flow/cli@latest memory search --query "authentication patterns"
|
|
251
|
-
|
|
252
|
-
# Import all Claude Code memories into AgentDB
|
|
253
|
-
node .claude/helpers/auto-memory-hook.mjs import-all
|
|
174
|
+
claude mcp add claude-flow -- npx -y @claude-flow/cli@latest
|
|
175
|
+
npx @claude-flow/cli@latest daemon start
|
|
176
|
+
npx @claude-flow/cli@latest doctor --fix
|
|
254
177
|
\`\`\`
|
|
255
178
|
|
|
256
|
-
|
|
257
|
-
|
|
258
|
-
Claude Code auto-memory files (\`~/.claude/projects/*/memory/*.md\`) are automatically imported into AgentDB with ONNX vector embeddings on session start. Use \`memory_search_unified\` to search across both stores.`;
|
|
259
|
-
}
|
|
260
|
-
function securityRulesLight() {
|
|
261
|
-
return `## Security Rules
|
|
262
|
-
|
|
263
|
-
- NEVER hardcode API keys, secrets, or credentials in source files
|
|
264
|
-
- NEVER commit .env files or any file containing secrets
|
|
265
|
-
- Always validate user input at system boundaries
|
|
266
|
-
- Always sanitize file paths to prevent directory traversal
|
|
267
|
-
- Run \`npx @claude-flow/cli@latest security scan\` after security-related changes`;
|
|
179
|
+
**Agent tool** handles execution (agents, files, code, git). **MCP tools** handle coordination (swarm, memory, hooks). **CLI** is the same via Bash.`;
|
|
268
180
|
}
|
|
269
181
|
function buildAndTest() {
|
|
270
182
|
return `## Build & Test
|
|
271
183
|
|
|
272
|
-
|
|
273
|
-
|
|
274
|
-
npm run build
|
|
275
|
-
|
|
276
|
-
# Test
|
|
277
|
-
npm test
|
|
184
|
+
- ALWAYS run tests after code changes
|
|
185
|
+
- ALWAYS verify build succeeds before committing
|
|
278
186
|
|
|
279
|
-
|
|
280
|
-
npm run
|
|
281
|
-
|
|
282
|
-
|
|
283
|
-
- ALWAYS run tests after making code changes
|
|
284
|
-
- ALWAYS verify build succeeds before committing`;
|
|
187
|
+
\`\`\`bash
|
|
188
|
+
npm run build && npm test
|
|
189
|
+
\`\`\``;
|
|
285
190
|
}
|
|
286
191
|
function securitySection() {
|
|
287
|
-
return `## Security
|
|
192
|
+
return `## Security
|
|
288
193
|
|
|
289
|
-
- NEVER hardcode
|
|
290
|
-
-
|
|
291
|
-
- Always
|
|
292
|
-
- Always
|
|
293
|
-
- Always use parameterized queries — never concatenate SQL strings
|
|
294
|
-
- Run security audit after any authentication or authorization changes
|
|
194
|
+
- NEVER hardcode secrets in source — use environment variables
|
|
195
|
+
- Always validate input at boundaries (Zod schemas)
|
|
196
|
+
- Always sanitize file paths (prevent traversal)
|
|
197
|
+
- Always use parameterized queries (prevent injection)
|
|
295
198
|
|
|
296
|
-
### Security Scanning
|
|
297
199
|
\`\`\`bash
|
|
298
200
|
npx @claude-flow/cli@latest security scan --depth full
|
|
299
201
|
npx @claude-flow/cli@latest security audit --report
|
|
300
|
-
npx @claude-flow/cli@latest security cve --check
|
|
301
202
|
\`\`\`
|
|
302
203
|
|
|
303
|
-
|
|
304
|
-
- \`security-architect\` — threat modeling, architecture review
|
|
305
|
-
- \`security-auditor\` — code audit, vulnerability detection
|
|
306
|
-
- Use agent routing code 9 (hierarchical/specialized) for security tasks`;
|
|
204
|
+
Agents: \`security-architect\` (threat modeling), \`security-auditor\` (vulnerability detection)`;
|
|
307
205
|
}
|
|
308
206
|
function performanceSection() {
|
|
309
|
-
return `## Performance
|
|
207
|
+
return `## Performance
|
|
310
208
|
|
|
311
|
-
- Always
|
|
312
|
-
- Always profile before optimizing — never guess
|
|
313
|
-
-
|
|
314
|
-
- Use DiskANN or HNSW for vector search (auto-selected by dataset size)
|
|
315
|
-
- Use Int8 quantization for ~4x memory reduction when needed
|
|
209
|
+
- Always benchmark before AND after optimization
|
|
210
|
+
- Always profile before optimizing — never guess bottlenecks
|
|
211
|
+
- Use HNSW/DiskANN for vector search, Int8 quantization for memory reduction
|
|
316
212
|
|
|
317
|
-
### Performance Tooling
|
|
318
213
|
\`\`\`bash
|
|
319
214
|
npx @claude-flow/cli@latest performance benchmark --suite all
|
|
320
215
|
npx @claude-flow/cli@latest performance profile --target "[component]"
|
|
321
|
-
npx @claude-flow/cli@latest performance metrics --format table
|
|
322
216
|
\`\`\`
|
|
323
217
|
|
|
324
|
-
|
|
325
|
-
- \`performance-engineer\` — profiling, benchmarking, optimization
|
|
326
|
-
- \`perf-analyzer\` — bottleneck detection, analysis
|
|
327
|
-
- Use agent routing code 7 (hierarchical/specialized) for performance tasks`;
|
|
218
|
+
Agents: \`performance-engineer\` (profiling), \`perf-analyzer\` (bottleneck detection)`;
|
|
328
219
|
}
|
|
329
|
-
function
|
|
330
|
-
return `##
|
|
331
|
-
|
|
332
|
-
|
|
333
|
-
|
|
334
|
-
-
|
|
335
|
-
-
|
|
336
|
-
|
|
337
|
-
|
|
338
|
-
|
|
339
|
-
|
|
340
|
-
3. **DISTILL** — Extract key learnings, store as patterns with embeddings
|
|
341
|
-
4. **CONSOLIDATE** — Persist patterns to disk across sessions`;
|
|
342
|
-
}
|
|
343
|
-
function envVars() {
|
|
344
|
-
return `## Environment Variables
|
|
220
|
+
function hooksRef() {
|
|
221
|
+
return `## Hooks
|
|
222
|
+
|
|
223
|
+
| Hook | Purpose |
|
|
224
|
+
|------|---------|
|
|
225
|
+
| \`pre-task\` / \`post-task\` | Task lifecycle + learning |
|
|
226
|
+
| \`pre-edit\` / \`post-edit\` | File editing + neural training |
|
|
227
|
+
| \`session-start\` / \`session-end\` | Session persistence |
|
|
228
|
+
| \`route\` | Route to optimal agent |
|
|
229
|
+
| \`intelligence\` | Pattern learning (SONA) |
|
|
230
|
+
| \`worker\` | Background worker dispatch |
|
|
345
231
|
|
|
346
232
|
\`\`\`bash
|
|
347
|
-
|
|
348
|
-
|
|
349
|
-
|
|
350
|
-
|
|
351
|
-
|
|
233
|
+
npx @claude-flow/cli@latest hooks pre-task --description "[task]"
|
|
234
|
+
npx @claude-flow/cli@latest hooks post-task --task-id "[id]" --success true
|
|
235
|
+
npx @claude-flow/cli@latest hooks session-start --session-id "[id]"
|
|
236
|
+
npx @claude-flow/cli@latest hooks route --task "[task]"
|
|
237
|
+
npx @claude-flow/cli@latest hooks worker dispatch --trigger audit
|
|
352
238
|
\`\`\``;
|
|
353
239
|
}
|
|
354
|
-
function
|
|
355
|
-
return `##
|
|
356
|
-
|
|
357
|
-
|
|
358
|
-
|
|
359
|
-
|
|
360
|
-
|
|
361
|
-
|
|
362
|
-
|
|
363
|
-
| **Swarm** | \`swarm_init\`, \`swarm_status\`, \`swarm_health\` | Multi-agent coordination |
|
|
364
|
-
| **Agents** | \`agent_spawn\`, \`agent_list\`, \`agent_status\` | Agent lifecycle |
|
|
365
|
-
| **Hive-Mind** | \`hive-mind_init\`, \`hive-mind_spawn\`, \`hive-mind_consensus\` | Byzantine/Raft consensus |
|
|
366
|
-
| **Hooks** | \`hooks_route\`, \`hooks_session-start\`, \`hooks_post-task\` | Task routing + learning |
|
|
367
|
-
| **Workers** | \`hooks_worker-list\`, \`hooks_worker-dispatch\` | 12 background workers |
|
|
368
|
-
| **Security** | \`aidefence_scan\`, \`aidefence_is_safe\` | Prompt injection detection |
|
|
369
|
-
| **Intelligence** | \`hooks_intelligence\`, \`neural_status\` | Pattern learning + SONA |
|
|
370
|
-
|
|
371
|
-
### Swarm Capabilities
|
|
372
|
-
|
|
373
|
-
- **Topologies**: hierarchical (anti-drift), mesh, ring, star, adaptive
|
|
374
|
-
- **Consensus**: Raft (leader-based), Byzantine (PBFT), Gossip (eventual)
|
|
375
|
-
- **Hive-Mind**: Queen-led coordination with spawn, broadcast, consensus voting, shared memory
|
|
376
|
-
- **12 Background Workers**: audit, optimize, testgaps, map, deepdive, document, refactor, benchmark, ultralearn, consolidate, predict, preload
|
|
377
|
-
|
|
378
|
-
### Memory Capabilities
|
|
379
|
-
|
|
380
|
-
- **ONNX Embeddings**: all-MiniLM-L6-v2, 384 dimensions — real neural vectors
|
|
381
|
-
- **DiskANN**: SSD-friendly vector search (8,000x faster insert than HNSW, perfect recall at 1K)
|
|
382
|
-
- **sql.js**: Cross-platform SQLite (WASM, no native compilation)
|
|
383
|
-
- **Claude Code Bridge**: Auto-imports MEMORY.md files into AgentDB on session start
|
|
384
|
-
- **Unified Search**: \`memory_search_unified\` searches Claude memories + AgentDB + patterns
|
|
385
|
-
- **SONA Learning**: Trajectory recording → pattern extraction → file persistence
|
|
386
|
-
|
|
387
|
-
### How to Discover Tools
|
|
388
|
-
|
|
389
|
-
Use ToolSearch to find specific tools:
|
|
390
|
-
\`\`\`
|
|
391
|
-
ToolSearch("memory search") → memory_store, memory_search, memory_search_unified
|
|
392
|
-
ToolSearch("swarm") → swarm_init, swarm_status, swarm_health, swarm_shutdown
|
|
393
|
-
ToolSearch("hive consensus") → hive-mind_consensus, hive-mind_status
|
|
394
|
-
ToolSearch("+aidefence") → aidefence_scan, aidefence_is_safe, aidefence_has_pii
|
|
395
|
-
\`\`\``;
|
|
240
|
+
function intelligenceSystem() {
|
|
241
|
+
return `## Intelligence (SONA + HNSW)
|
|
242
|
+
|
|
243
|
+
Pipeline: **RETRIEVE** (vector search) → **JUDGE** (success/failure) → **DISTILL** (extract patterns) → **CONSOLIDATE** (persist)
|
|
244
|
+
|
|
245
|
+
- **ONNX Embeddings**: all-MiniLM-L6-v2, 384-dim
|
|
246
|
+
- **HNSW/DiskANN**: 150x-12,500x faster search
|
|
247
|
+
- **SONA**: Sub-millisecond pattern adaptation
|
|
248
|
+
- **Claude Bridge**: Auto-imports \`~/.claude/projects/*/memory/*.md\` into AgentDB`;
|
|
396
249
|
}
|
|
397
|
-
function
|
|
398
|
-
return `##
|
|
250
|
+
function federationRef() {
|
|
251
|
+
return `## Federation
|
|
252
|
+
|
|
253
|
+
Cross-installation agent collaboration with zero-trust security.
|
|
399
254
|
|
|
400
255
|
\`\`\`bash
|
|
401
|
-
|
|
402
|
-
npx @claude-flow/cli@latest
|
|
403
|
-
npx @claude-flow/cli@latest
|
|
256
|
+
npx @claude-flow/cli@latest federation init
|
|
257
|
+
npx @claude-flow/cli@latest federation join wss://peer:8443
|
|
258
|
+
npx @claude-flow/cli@latest federation send --to peer --type task-request --message "..."
|
|
259
|
+
npx @claude-flow/cli@latest federation status
|
|
404
260
|
\`\`\`
|
|
405
261
|
|
|
406
|
-
|
|
407
|
-
|
|
408
|
-
-
|
|
409
|
-
-
|
|
410
|
-
|
|
411
|
-
|
|
412
|
-
|
|
413
|
-
## Support
|
|
262
|
+
- 5-tier trust: UNTRUSTED → VERIFIED → ATTESTED → TRUSTED → PRIVILEGED
|
|
263
|
+
- PII pipeline: 14 types auto-stripped before data leaves your node
|
|
264
|
+
- mTLS + ed25519 handshake, HMAC-signed envelopes
|
|
265
|
+
- Compliance: HIPAA, SOC2, GDPR audit modes`;
|
|
266
|
+
}
|
|
267
|
+
function envVars() {
|
|
268
|
+
return `## Environment
|
|
414
269
|
|
|
415
|
-
|
|
416
|
-
-
|
|
270
|
+
\`\`\`bash
|
|
271
|
+
CLAUDE_FLOW_CONFIG=./claude-flow.config.json
|
|
272
|
+
CLAUDE_FLOW_LOG_LEVEL=info
|
|
273
|
+
CLAUDE_FLOW_MEMORY_BACKEND=hybrid
|
|
274
|
+
CLAUDE_FLOW_MEMORY_PATH=./data/memory
|
|
275
|
+
\`\`\``;
|
|
417
276
|
}
|
|
418
277
|
// --- Template Composers ---
|
|
419
|
-
/**
|
|
420
|
-
* Template section map — defines which sections are included per template.
|
|
421
|
-
*/
|
|
422
278
|
const TEMPLATE_SECTIONS = {
|
|
423
279
|
minimal: [
|
|
424
280
|
behavioralRules,
|
|
425
|
-
|
|
426
|
-
|
|
281
|
+
(_opts) => agentComms(),
|
|
282
|
+
swarmConfig,
|
|
427
283
|
(_opts) => buildAndTest(),
|
|
428
|
-
(_opts) =>
|
|
429
|
-
concurrencyRules,
|
|
430
|
-
(_opts) => antiDriftConfig(),
|
|
431
|
-
executionRules,
|
|
432
|
-
(_opts) => cliCommandsTable(),
|
|
284
|
+
(_opts) => cliQuickRef(),
|
|
433
285
|
(_opts) => setupAndBoundary(),
|
|
434
286
|
],
|
|
435
287
|
standard: [
|
|
436
288
|
behavioralRules,
|
|
437
|
-
|
|
438
|
-
|
|
439
|
-
(_opts) =>
|
|
440
|
-
(_opts) => securityRulesLight(),
|
|
441
|
-
concurrencyRules,
|
|
442
|
-
(_opts) => swarmOrchestration(),
|
|
443
|
-
(_opts) => antiDriftConfig(),
|
|
444
|
-
executionRules,
|
|
445
|
-
(_opts) => cliCommandsTable(),
|
|
289
|
+
(_opts) => agentComms(),
|
|
290
|
+
swarmConfig,
|
|
291
|
+
(_opts) => memoryAndLearning(),
|
|
446
292
|
(_opts) => agentTypes(),
|
|
447
|
-
(_opts) =>
|
|
448
|
-
(_opts) =>
|
|
293
|
+
(_opts) => buildAndTest(),
|
|
294
|
+
(_opts) => cliQuickRef(),
|
|
449
295
|
(_opts) => setupAndBoundary(),
|
|
450
296
|
],
|
|
451
297
|
full: [
|
|
452
298
|
behavioralRules,
|
|
453
|
-
|
|
454
|
-
|
|
455
|
-
(_opts) =>
|
|
456
|
-
(_opts) => securityRulesLight(),
|
|
457
|
-
concurrencyRules,
|
|
458
|
-
(_opts) => swarmOrchestration(),
|
|
459
|
-
(_opts) => antiDriftConfig(),
|
|
460
|
-
(_opts) => autoStartProtocol(),
|
|
461
|
-
executionRules,
|
|
462
|
-
(_opts) => cliCommandsTable(),
|
|
299
|
+
(_opts) => agentComms(),
|
|
300
|
+
swarmConfig,
|
|
301
|
+
(_opts) => memoryAndLearning(),
|
|
463
302
|
(_opts) => agentTypes(),
|
|
464
|
-
(_opts) =>
|
|
465
|
-
(_opts) => learningProtocol(),
|
|
466
|
-
(_opts) => memoryCommands(),
|
|
467
|
-
(_opts) => mcpToolDiscovery(),
|
|
303
|
+
(_opts) => hooksRef(),
|
|
468
304
|
(_opts) => intelligenceSystem(),
|
|
305
|
+
(_opts) => federationRef(),
|
|
306
|
+
(_opts) => buildAndTest(),
|
|
469
307
|
(_opts) => envVars(),
|
|
308
|
+
(_opts) => cliQuickRef(),
|
|
470
309
|
(_opts) => setupAndBoundary(),
|
|
471
310
|
],
|
|
472
311
|
security: [
|
|
473
312
|
behavioralRules,
|
|
474
|
-
|
|
475
|
-
|
|
476
|
-
(_opts) => buildAndTest(),
|
|
477
|
-
concurrencyRules,
|
|
478
|
-
(_opts) => swarmOrchestration(),
|
|
479
|
-
(_opts) => antiDriftConfig(),
|
|
480
|
-
executionRules,
|
|
313
|
+
(_opts) => agentComms(),
|
|
314
|
+
swarmConfig,
|
|
481
315
|
(_opts) => securitySection(),
|
|
482
|
-
(_opts) =>
|
|
316
|
+
(_opts) => memoryAndLearning(),
|
|
483
317
|
(_opts) => agentTypes(),
|
|
484
|
-
(_opts) =>
|
|
318
|
+
(_opts) => buildAndTest(),
|
|
319
|
+
(_opts) => cliQuickRef(),
|
|
485
320
|
(_opts) => setupAndBoundary(),
|
|
486
321
|
],
|
|
487
322
|
performance: [
|
|
488
323
|
behavioralRules,
|
|
489
|
-
|
|
490
|
-
|
|
491
|
-
(_opts) => buildAndTest(),
|
|
492
|
-
(_opts) => securityRulesLight(),
|
|
493
|
-
concurrencyRules,
|
|
494
|
-
(_opts) => swarmOrchestration(),
|
|
495
|
-
(_opts) => antiDriftConfig(),
|
|
496
|
-
executionRules,
|
|
324
|
+
(_opts) => agentComms(),
|
|
325
|
+
swarmConfig,
|
|
497
326
|
(_opts) => performanceSection(),
|
|
498
|
-
(_opts) =>
|
|
327
|
+
(_opts) => memoryAndLearning(),
|
|
499
328
|
(_opts) => agentTypes(),
|
|
500
|
-
(_opts) => memoryCommands(),
|
|
501
329
|
(_opts) => intelligenceSystem(),
|
|
330
|
+
(_opts) => buildAndTest(),
|
|
331
|
+
(_opts) => cliQuickRef(),
|
|
502
332
|
(_opts) => setupAndBoundary(),
|
|
503
333
|
],
|
|
504
334
|
solo: [
|
|
505
335
|
behavioralRules,
|
|
506
|
-
|
|
507
|
-
|
|
336
|
+
(_opts) => agentComms(),
|
|
337
|
+
(_opts) => memoryAndLearning(),
|
|
508
338
|
(_opts) => buildAndTest(),
|
|
509
|
-
(_opts) =>
|
|
510
|
-
concurrencyRules,
|
|
511
|
-
executionRules,
|
|
512
|
-
(_opts) => cliCommandsTable(),
|
|
513
|
-
(_opts) => memoryCommands(),
|
|
339
|
+
(_opts) => cliQuickRef(),
|
|
514
340
|
(_opts) => setupAndBoundary(),
|
|
515
341
|
],
|
|
516
342
|
};
|
|
517
343
|
// --- Public API ---
|
|
518
|
-
/**
|
|
519
|
-
* Generate CLAUDE.md content based on init options and template.
|
|
520
|
-
* Template is determined by: options.runtime.claudeMdTemplate > explicit param > 'standard'
|
|
521
|
-
*/
|
|
522
344
|
export function generateClaudeMd(options, template) {
|
|
523
345
|
const tmpl = template ?? options.runtime.claudeMdTemplate ?? 'standard';
|
|
524
346
|
const sections = TEMPLATE_SECTIONS[tmpl] ?? TEMPLATE_SECTIONS.standard;
|
|
525
|
-
const header = `# Claude Code Configuration
|
|
347
|
+
const header = `# Ruflo — Claude Code Configuration\n`;
|
|
526
348
|
const body = sections.map(fn => fn(options)).join('\n\n');
|
|
527
349
|
return `${header}\n${body}\n`;
|
|
528
350
|
}
|
|
529
|
-
/**
|
|
530
|
-
* Generate minimal CLAUDE.md content (backward-compatible alias).
|
|
531
|
-
*/
|
|
532
351
|
export function generateMinimalClaudeMd(options) {
|
|
533
352
|
return generateClaudeMd(options, 'minimal');
|
|
534
353
|
}
|
|
535
|
-
/** Available template names for CLI wizard */
|
|
536
354
|
export const CLAUDE_MD_TEMPLATES = [
|
|
537
|
-
{ name: 'minimal', description: '
|
|
538
|
-
{ name: 'standard', description: 'Recommended —
|
|
539
|
-
{ name: 'full', description: 'Everything — hooks,
|
|
540
|
-
{ name: 'security', description: 'Security-focused — adds
|
|
541
|
-
{ name: 'performance', description: 'Performance-focused — adds benchmarking, profiling,
|
|
542
|
-
{ name: 'solo', description: 'Solo developer —
|
|
355
|
+
{ name: 'minimal', description: 'Lean start — rules, agent comms, swarm config, CLI ref (~80 lines)' },
|
|
356
|
+
{ name: 'standard', description: 'Recommended — adds memory, learning, agent types (~140 lines)' },
|
|
357
|
+
{ name: 'full', description: 'Everything — hooks, intelligence, federation (~220 lines)' },
|
|
358
|
+
{ name: 'security', description: 'Security-focused — adds scanning, audit, threat agents' },
|
|
359
|
+
{ name: 'performance', description: 'Performance-focused — adds benchmarking, profiling, SONA' },
|
|
360
|
+
{ name: 'solo', description: 'Solo developer — comms, memory, no swarm (~90 lines)' },
|
|
543
361
|
];
|
|
544
362
|
export default generateClaudeMd;
|
|
545
363
|
//# sourceMappingURL=claudemd-generator.js.map
|