@monoes/monomindcli 2.9.4 → 2.9.5

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 (173) hide show
  1. package/.claude/commands/mastermind/approvev1.md +94 -0
  2. package/.claude/commands/mastermind/architect.md +52 -0
  3. package/.claude/commands/mastermind/autodev.md +28 -0
  4. package/.claude/commands/mastermind/build.md +23 -0
  5. package/.claude/commands/mastermind/finish.md +17 -0
  6. package/.claude/commands/mastermind/runorgv1.md +159 -0
  7. package/.claude/commands/mastermind/taskdev.md +23 -0
  8. package/.claude/commands/mastermind/tdd.md +19 -0
  9. package/.claude/commands/mastermind/verify.md +19 -0
  10. package/.claude/helpers/intelligence.cjs +6 -27
  11. package/.claude/skills/agentic-jujutsu/SKILL.md +15 -17
  12. package/.claude/skills/hive-mind-advanced/SKILL.md +559 -212
  13. package/.claude/skills/hooks-automation/SKILL.md +1 -1
  14. package/.claude/skills/mastermind-approvev1/SKILL.md +191 -0
  15. package/.claude/skills/mastermind-architect/SKILL.md +862 -0
  16. package/.claude/skills/mastermind-autodev/SKILL.md +360 -0
  17. package/.claude/skills/mastermind-build/SKILL.md +169 -0
  18. package/.claude/skills/mastermind-companies/SKILL.md +256 -0
  19. package/.claude/skills/mastermind-content/SKILL.md +197 -0
  20. package/.claude/skills/mastermind-costs/SKILL.md +151 -0
  21. package/.claude/skills/mastermind-finance/SKILL.md +166 -0
  22. package/.claude/skills/mastermind-finish/SKILL.md +251 -0
  23. package/.claude/skills/mastermind-heartbeatv1/SKILL.md +167 -0
  24. package/.claude/skills/mastermind-instance-settings/SKILL.md +315 -0
  25. package/.claude/skills/mastermind-marketing/SKILL.md +228 -0
  26. package/.claude/skills/mastermind-marketing/references/copywriting-frameworks.md +181 -0
  27. package/.claude/skills/mastermind-marketing/references/persuasion-psychology.md +158 -0
  28. package/.claude/skills/mastermind-ops/SKILL.md +168 -0
  29. package/.claude/skills/mastermind-org-chart/SKILL.md +209 -0
  30. package/.claude/skills/mastermind-project-detail/SKILL.md +249 -0
  31. package/.claude/skills/mastermind-project-workspace/SKILL.md +244 -0
  32. package/.claude/skills/mastermind-projects/SKILL.md +167 -0
  33. package/.claude/skills/mastermind-runorgv1/SKILL.md +731 -0
  34. package/.claude/skills/mastermind-sales/SKILL.md +170 -0
  35. package/.claude/skills/mastermind-taskdev/SKILL.md +377 -0
  36. package/.claude/skills/mastermind-taskdev/code-quality-reviewer-prompt.md +60 -0
  37. package/.claude/skills/mastermind-taskdev/final-reviewer-prompt.md +144 -0
  38. package/.claude/skills/mastermind-taskdev/implementer-prompt.md +114 -0
  39. package/.claude/skills/mastermind-taskdev/spec-reviewer-prompt.md +80 -0
  40. package/.claude/skills/mastermind-tdd/SKILL.md +424 -0
  41. package/.claude/skills/mastermind-verify/SKILL.md +196 -0
  42. package/.claude/skills/mastermind-wiki/SKILL.md +314 -0
  43. package/.claude/skills/monolean-review/SKILL.md +57 -0
  44. package/.claude/skills/pair-programming/SKILL.md +1 -1
  45. package/.claude/skills/performance-analysis/SKILL.md +484 -228
  46. package/.claude/skills/swarm-advanced/SKILL.md +2 -2
  47. package/.claude/skills/swarm-orchestration/SKILL.md +150 -220
  48. package/.claude/skills/verification-quality/SKILL.md +571 -247
  49. package/README.md +3 -3
  50. package/dist/src/commands/agent-lifecycle.js +3 -3
  51. package/dist/src/commands/agent-lifecycle.js.map +1 -1
  52. package/dist/src/commands/autopilot.d.ts.map +1 -1
  53. package/dist/src/commands/autopilot.js +1 -7
  54. package/dist/src/commands/autopilot.js.map +1 -1
  55. package/dist/src/commands/doc.d.ts.map +1 -1
  56. package/dist/src/commands/doc.js +3 -14
  57. package/dist/src/commands/doc.js.map +1 -1
  58. package/dist/src/commands/doctor-env-checks.d.ts +1 -1
  59. package/dist/src/commands/doctor-env-checks.d.ts.map +1 -1
  60. package/dist/src/commands/doctor-project-checks.d.ts.map +1 -1
  61. package/dist/src/commands/doctor-project-checks.js +20 -3
  62. package/dist/src/commands/doctor-project-checks.js.map +1 -1
  63. package/dist/src/commands/doctor.d.ts.map +1 -1
  64. package/dist/src/commands/doctor.js +1 -30
  65. package/dist/src/commands/doctor.js.map +1 -1
  66. package/dist/src/commands/hooks-coverage-commands.d.ts.map +1 -1
  67. package/dist/src/commands/hooks-coverage-commands.js +67 -75
  68. package/dist/src/commands/hooks-coverage-commands.js.map +1 -1
  69. package/dist/src/commands/hooks-workers.d.ts.map +1 -1
  70. package/dist/src/commands/hooks-workers.js +10 -41
  71. package/dist/src/commands/hooks-workers.js.map +1 -1
  72. package/dist/src/commands/hooks.js +1 -1
  73. package/dist/src/commands/init.d.ts.map +1 -1
  74. package/dist/src/commands/init.js +7 -80
  75. package/dist/src/commands/init.js.map +1 -1
  76. package/dist/src/commands/mcp.d.ts.map +1 -1
  77. package/dist/src/commands/mcp.js +2 -78
  78. package/dist/src/commands/mcp.js.map +1 -1
  79. package/dist/src/commands/org.d.ts.map +1 -1
  80. package/dist/src/commands/org.js +3 -116
  81. package/dist/src/commands/org.js.map +1 -1
  82. package/dist/src/commands/performance.js +1 -1
  83. package/dist/src/commands/performance.js.map +1 -1
  84. package/dist/src/commands/security-cve.d.ts.map +1 -1
  85. package/dist/src/commands/security-cve.js +11 -1
  86. package/dist/src/commands/security-cve.js.map +1 -1
  87. package/dist/src/commands/security-misc.d.ts +9 -0
  88. package/dist/src/commands/security-misc.d.ts.map +1 -1
  89. package/dist/src/commands/security-misc.js +54 -33
  90. package/dist/src/commands/security-misc.js.map +1 -1
  91. package/dist/src/commands/security-scan.d.ts.map +1 -1
  92. package/dist/src/commands/security-scan.js +11 -3
  93. package/dist/src/commands/security-scan.js.map +1 -1
  94. package/dist/src/commands/swarm.d.ts.map +1 -1
  95. package/dist/src/commands/swarm.js +2 -7
  96. package/dist/src/commands/swarm.js.map +1 -1
  97. package/dist/src/init/claudemd-generator.js +1 -1
  98. package/dist/src/init/executor.d.ts.map +1 -1
  99. package/dist/src/init/executor.js +3 -13
  100. package/dist/src/init/executor.js.map +1 -1
  101. package/dist/src/init/kimi-generator.d.ts +2 -3
  102. package/dist/src/init/kimi-generator.d.ts.map +1 -1
  103. package/dist/src/init/kimi-generator.js +13 -45
  104. package/dist/src/init/kimi-generator.js.map +1 -1
  105. package/dist/src/init/statusline-generator.d.ts +1 -1
  106. package/dist/src/init/statusline-generator.js +1 -1
  107. package/dist/src/mcp-tools/embeddings-tools.js +2 -2
  108. package/dist/src/mcp-tools/embeddings-tools.js.map +1 -1
  109. package/dist/src/mcp-tools/hooks-intelligence.d.ts.map +1 -1
  110. package/dist/src/mcp-tools/hooks-intelligence.js +3 -29
  111. package/dist/src/mcp-tools/hooks-intelligence.js.map +1 -1
  112. package/dist/src/mcp-tools/hooks-routing.d.ts.map +1 -1
  113. package/dist/src/mcp-tools/hooks-routing.js +19 -32
  114. package/dist/src/mcp-tools/hooks-routing.js.map +1 -1
  115. package/dist/src/mcp-tools/monograph/query-tools.d.ts.map +1 -1
  116. package/dist/src/mcp-tools/monograph/query-tools.js +18 -48
  117. package/dist/src/mcp-tools/monograph/query-tools.js.map +1 -1
  118. package/dist/src/mcp-tools/performance-tools.d.ts.map +1 -1
  119. package/dist/src/mcp-tools/performance-tools.js +10 -15
  120. package/dist/src/mcp-tools/performance-tools.js.map +1 -1
  121. package/dist/src/memory/embedding-operations.d.ts +0 -4
  122. package/dist/src/memory/embedding-operations.d.ts.map +1 -1
  123. package/dist/src/memory/embedding-operations.js +32 -125
  124. package/dist/src/memory/embedding-operations.js.map +1 -1
  125. package/dist/src/memory/hnsw-operations.d.ts +1 -1
  126. package/dist/src/memory/hnsw-operations.js +1 -1
  127. package/dist/src/memory/memory-read.d.ts +1 -1
  128. package/dist/src/memory/memory-read.js +2 -2
  129. package/dist/src/memory/memory-read.js.map +1 -1
  130. package/dist/src/monovector/diff-classifier.js +3 -3
  131. package/dist/src/monovector/diff-classifier.js.map +1 -1
  132. package/dist/src/orgrt/checkpoint-ops.d.ts +1 -11
  133. package/dist/src/orgrt/checkpoint-ops.d.ts.map +1 -1
  134. package/dist/src/orgrt/checkpoint-ops.js +1 -15
  135. package/dist/src/orgrt/checkpoint-ops.js.map +1 -1
  136. package/dist/src/orgrt/checkpoint.js +1 -1
  137. package/dist/src/orgrt/checkpoint.js.map +1 -1
  138. package/dist/src/orgrt/daemon.d.ts +0 -6
  139. package/dist/src/orgrt/daemon.d.ts.map +1 -1
  140. package/dist/src/orgrt/daemon.js +0 -26
  141. package/dist/src/orgrt/daemon.js.map +1 -1
  142. package/dist/src/orgrt/decisions.d.ts +0 -13
  143. package/dist/src/orgrt/decisions.d.ts.map +1 -1
  144. package/dist/src/orgrt/decisions.js +0 -95
  145. package/dist/src/orgrt/decisions.js.map +1 -1
  146. package/dist/src/orgrt/kimicode-runner.js +1 -1
  147. package/dist/src/orgrt/kimicode-runner.js.map +1 -1
  148. package/dist/src/orgrt/opencode-runner.js +1 -1
  149. package/dist/src/orgrt/opencode-runner.js.map +1 -1
  150. package/dist/src/orgrt/session.d.ts +1 -27
  151. package/dist/src/orgrt/session.d.ts.map +1 -1
  152. package/dist/src/orgrt/session.js +3 -42
  153. package/dist/src/orgrt/session.js.map +1 -1
  154. package/dist/src/orgrt/task-dag.d.ts +1 -11
  155. package/dist/src/orgrt/task-dag.d.ts.map +1 -1
  156. package/dist/src/orgrt/task-dag.js +2 -93
  157. package/dist/src/orgrt/task-dag.js.map +1 -1
  158. package/dist/src/orgrt/templates.d.ts.map +1 -1
  159. package/dist/src/orgrt/templates.js +0 -24
  160. package/dist/src/orgrt/templates.js.map +1 -1
  161. package/dist/src/orgrt/types.d.ts +1 -70
  162. package/dist/src/orgrt/types.d.ts.map +1 -1
  163. package/dist/src/orgrt/types.js +0 -19
  164. package/dist/src/orgrt/types.js.map +1 -1
  165. package/dist/src/orgrt/vercel-providers.d.ts.map +1 -1
  166. package/dist/src/orgrt/vercel-providers.js +4 -9
  167. package/dist/src/orgrt/vercel-providers.js.map +1 -1
  168. package/dist/src/orgrt/vercel-runner.d.ts +23 -0
  169. package/dist/src/orgrt/vercel-runner.d.ts.map +1 -1
  170. package/dist/src/orgrt/vercel-runner.js +1 -26
  171. package/dist/src/orgrt/vercel-runner.js.map +1 -1
  172. package/dist/tsconfig.tsbuildinfo +1 -1
  173. package/package.json +5 -5
@@ -1,304 +1,560 @@
1
1
  ---
2
2
  name: performance-analysis
3
- description: Comprehensive performance analysis, bottleneck detection, and optimization recommendations for Monomind swarms
3
+ description: |
4
+ Comprehensive performance analysis, bottleneck detection, and optimization recommendations for Monomind swarms
4
5
  ---
5
6
 
6
- # performance-analysis — Measure, Don't Guess
7
+ # Performance Analysis Skill
8
+
9
+ Comprehensive performance analysis suite for identifying bottlenecks, profiling swarm operations, generating detailed reports, and providing actionable optimization recommendations.
7
10
 
8
11
  ## Overview
9
12
 
10
- Performance work without measurement is superstition. This skill wires a disciplined
11
- methodology to monomind's real `performance` and `analyze` command surfaces.
13
+ This skill consolidates all performance analysis capabilities:
14
+ - **Bottleneck Detection**: Identify performance bottlenecks across communication, processing, memory, and network
15
+ - **Performance Profiling**: Real-time monitoring and historical analysis of swarm operations
16
+ - **Report Generation**: Create comprehensive performance reports in multiple formats
17
+ - **Optimization Recommendations**: AI-powered suggestions for improving performance
12
18
 
13
- **Core principle:** ALWAYS measure before optimizing. ALWAYS confirm a bottleneck is
14
- real before fixing it. Symptoms are not root causes.
19
+ ## Quick Start
15
20
 
16
- **Iron Law:**
17
- ```
18
- NO OPTIMIZATION WITHOUT A MEASURED BOTTLENECK FIRST
21
+ ### Basic Bottleneck Detection
22
+ ```bash
23
+ npx monomind bottleneck detect
19
24
  ```
20
25
 
21
- ## When to Use
22
-
23
- - Something feels slow (swarm run, memory search, build, MCP tool call)
24
- - Before/after a change that could affect performance
25
- - A regression report or user complaint about latency
26
- - Capacity planning — picking `maxAgents`, topology, or memory backend
27
- - Token burn higher than expected
28
-
29
- **Use ESPECIALLY when:** the fix "feels obvious". Obvious fixes without measurement
30
- are the most common source of fake optimizations.
31
-
32
- ## The Real Command Surface
33
-
34
- These are the ONLY performance/analysis commands. Anything else is wrong.
35
-
36
- | Command | What it does |
37
- |---|---|
38
- | `monomind performance benchmark` | Run benchmarks (wasm/neural/memory/search) |
39
- | `monomind performance profile` | Profile CPU/memory/IO over a window |
40
- | `monomind performance metrics` | View/export metrics (1h/24h/7d/30d) |
41
- | `monomind performance bottleneck` | Identify bottlenecks (quick or full) |
42
- | `monomind analyze diff` | Git diff risk + change classification |
43
- | `monomind analyze code` | Static code analysis |
44
- | `monomind analyze deps` | Dependency analysis (`--security` for CVEs) |
45
- | `monomind analyze ast` | AST analysis via tree-sitter |
46
- | `monomind analyze complexity` | Code complexity metrics |
47
- | `monomind analyze symbols` | Extract functions/classes/types |
48
- | `monomind analyze imports` | Import dependency graph |
49
- | `monomind doctor` | 28 health-check categories |
50
- | `monomind hooks metrics` | Learning metrics dashboard |
51
- | `monomind tokens dashboard` | Token usage (`today`/`week`/`30days`/`month`) |
52
-
53
- > Use `npx monomind@latest ...` from outside the repo; inside the repo `node packages/@monomind/cli/bin/cli.js ...` works too. Never use `monomind@alpha`.
54
-
55
- ## The Four Phases
56
-
57
- Complete each phase before moving on. Skipping a phase produces fake optimizations.
58
-
59
- ---
60
-
61
- ### Phase 1: Establish a Baseline
62
-
63
- Before changing anything, capture the current state so later comparison is honest.
64
-
26
+ ### Generate Performance Report
65
27
  ```bash
66
- # Benchmark the subsystems you care about
67
- npx monomind@latest performance benchmark -s all -i 100 -o json > baseline-bench.json
68
-
69
- # Snapshot current metrics for the relevant window
70
- npx monomind@latest performance metrics -t 24h -f json > baseline-metrics.json
71
-
72
- # Capture a profile so you know where time is going today
73
- npx monomind@latest performance profile -t all -d 60 -o baseline-profile.json
28
+ npx monomind analysis performance-report --format html --include-metrics
74
29
  ```
75
30
 
76
- **Success criteria:** you have numbers on disk for "before". No before, no after.
77
-
78
- ---
79
-
80
- ### Phase 2: Find the Bottleneck (don't guess, ask the system)
81
-
82
- `performance bottleneck` answers the question "where is time being spent?".
83
-
31
+ ### Analyze and Auto-Fix
84
32
  ```bash
85
- # Quick triage across the whole system
86
- npx monomind@latest performance bottleneck
87
-
88
- # Deep dive when quick confirms something is off
89
- npx monomind@latest performance bottleneck -d full
90
-
91
- # Scope to a suspected component (e.g. network, memory, search)
92
- npx monomind@latest performance bottleneck -c memory
33
+ npx monomind bottleneck detect --fix --threshold 15
93
34
  ```
94
35
 
95
- **Map symptoms to components:**
36
+ ## Core Capabilities
96
37
 
97
- | Symptom | First component to check |
98
- |---|---|
99
- | Slow swarm coordination | network (inter-agent messages) |
100
- | Memory search slow | memory (SQLite vs. WASM fallback path) |
101
- | Token burn surprise | cpu / model invocation |
102
- | Boot/startup slow | io (file reads, graph load) |
103
- | MCP tool latency | network (server round-trip) |
104
-
105
- **If `bottleneck` reports nothing:** the problem may be code-level, not system-level.
106
- Move to Phase 2b.
107
-
108
- #### Phase 2b: Code-Level Analysis
109
-
110
- When the system is healthy but the code is slow, switch to `analyze`:
38
+ ### 1. Bottleneck Detection
111
39
 
40
+ #### Command Syntax
112
41
  ```bash
113
- # Riskiest recent change — most likely regression source
114
- npx monomind@latest analyze diff --risk --classify -v
115
-
116
- # Flag high-complexity hotspots (default threshold 10)
117
- npx monomind@latest analyze complexity src/ -t 15 -f json
118
-
119
- # Inspect import graph for accidental heavy dependencies
120
- npx monomind@latest analyze imports src/ --external
121
-
122
- # Dependency audit (CVEs and bloat both hurt performance)
123
- npx monomind@latest analyze deps --security
42
+ npx monomind bottleneck detect [options]
124
43
  ```
125
44
 
126
- **Heuristic:** a regression that appeared in the last N commits is almost always
127
- visible in `analyze diff --risk`. Start there before going deeper.
128
-
129
- ---
130
-
131
- ### Phase 3: Interpret the Metrics
132
-
133
- Numbers without interpretation are noise. Read the dashboard, then explain it.
45
+ #### Options
46
+ - `--swarm-id, -s <id>` - Analyze specific swarm (default: current)
47
+ - `--time-range, -t <range>` - Analysis period: 1h, 24h, 7d, all (default: 1h)
48
+ - `--threshold <percent>` - Bottleneck threshold percentage (default: 20)
49
+ - `--export, -e <file>` - Export analysis to file
50
+ - `--fix` - Apply automatic optimizations
134
51
 
52
+ #### Usage Examples
135
53
  ```bash
136
- # Pull a metrics view for the affected window
137
- npx monomind@latest performance metrics -t 7d -f text
54
+ # Basic detection for current swarm
55
+ npx monomind bottleneck detect
138
56
 
139
- # Prometheus export for Grafana / long-term storage
140
- npx monomind@latest performance metrics -t 30d -f prometheus > metrics.prom
57
+ # Analyze specific swarm over 24 hours
58
+ npx monomind bottleneck detect --swarm-id swarm-123 -t 24h
141
59
 
142
- # Cross-check learning hooks (these run in the background and affect timings)
143
- npx monomind@latest hooks metrics
60
+ # Export detailed analysis
61
+ npx monomind bottleneck detect -t 24h -e bottlenecks.json
144
62
 
145
- # Token spend — high burn often correlates with perf pain
146
- npx monomind@latest tokens dashboard -p week --no-interactive
147
- ```
63
+ # Auto-fix detected issues
64
+ npx monomind bottleneck detect --fix --threshold 15
148
65
 
149
- **Interpretation rules:**
66
+ # Low threshold for sensitive detection
67
+ npx monomind bottleneck detect --threshold 10 --export critical-issues.json
68
+ ```
150
69
 
151
- - A single high number is not a bottleneck. A high number *with user-visible pain*
152
- is. Always tie metrics back to a symptom.
153
- - Compare like-for-like: same window, same load, same machine. A 7d average next to
154
- a 1h spike is meaningless.
155
- - Latency has tails. Always look at p95/p99, not just mean — means hide outliers.
156
- - Cache hit rate below ~80% usually means the working set is bigger than the cache
157
- OR the eviction policy is wrong. Both are fixable.
70
+ #### Metrics Analyzed
71
+
72
+ **Communication Bottlenecks:**
73
+ - Message queue delays
74
+ - Agent response times
75
+ - Coordination overhead
76
+ - Memory access patterns
77
+ - Inter-agent communication latency
78
+
79
+ **Processing Bottlenecks:**
80
+ - Task completion times
81
+ - Agent utilization rates
82
+ - Parallel execution efficiency
83
+ - Resource contention
84
+ - CPU/memory usage patterns
85
+
86
+ **Memory Bottlenecks:**
87
+ - Cache hit rates
88
+ - Memory access patterns
89
+ - Storage I/O performance
90
+ - Neural pattern loading times
91
+ - Memory allocation efficiency
92
+
93
+ **Network Bottlenecks:**
94
+ - API call latency
95
+ - MCP communication delays
96
+ - External service timeouts
97
+ - Concurrent request limits
98
+ - Network throughput issues
99
+
100
+ #### Output Format
101
+ ```
102
+ 🔍 Bottleneck Analysis Report
103
+ ━━━━━━━━━━━━━━━━━━━━━━━━━━━
104
+
105
+ 📊 Summary
106
+ ├── Time Range: Last 1 hour
107
+ ├── Agents Analyzed: 6
108
+ ├── Tasks Processed: 42
109
+ └── Critical Issues: 2
110
+
111
+ 🚨 Critical Bottlenecks
112
+ 1. Agent Communication (35% impact)
113
+ └── coordinator → coder-1 messages delayed by 2.3s avg
114
+
115
+ 2. Memory Access (28% impact)
116
+ └── Neural pattern loading taking 1.8s per access
117
+
118
+ ⚠️ Warning Bottlenecks
119
+ 1. Task Queue (18% impact)
120
+ └── 5 tasks waiting > 10s for assignment
121
+
122
+ 💡 Recommendations
123
+ 1. Switch to hierarchical topology (est. 40% improvement)
124
+ 2. Enable memory caching (est. 25% improvement)
125
+ 3. Increase agent concurrency to 8 (est. 20% improvement)
126
+
127
+ ✅ Quick Fixes Available
128
+ Run with --fix to apply:
129
+ - Enable smart caching
130
+ - Optimize message routing
131
+ - Adjust agent priorities
132
+ ```
158
133
 
159
- ---
134
+ ### 2. Performance Profiling
135
+
136
+ #### Real-time Detection
137
+ Automatic analysis during task execution:
138
+ - Execution time vs. complexity
139
+ - Agent utilization rates
140
+ - Resource constraints
141
+ - Operation patterns
142
+
143
+ #### Common Bottleneck Patterns
144
+
145
+ **Time Bottlenecks:**
146
+ - Tasks taking > 5 minutes
147
+ - Sequential operations that could parallelize
148
+ - Redundant file operations
149
+ - Inefficient algorithm implementations
150
+
151
+ **Coordination Bottlenecks:**
152
+ - Single agent for complex tasks
153
+ - Unbalanced agent workloads
154
+ - Poor topology selection
155
+ - Excessive synchronization points
156
+
157
+ **Resource Bottlenecks:**
158
+ - High operation count (> 100)
159
+ - Memory constraints
160
+ - I/O limitations
161
+ - Thread pool saturation
162
+
163
+ #### MCP Integration
164
+ ```javascript
165
+ // Check for bottlenecks in Claude Code
166
+ mcp__monomind__bottleneck_detect({
167
+ timeRange: "1h",
168
+ threshold: 20,
169
+ autoFix: false
170
+ })
171
+
172
+ // Get detailed task results with bottleneck analysis
173
+ mcp__monomind__task_results({
174
+ taskId: "task-123",
175
+ format: "detailed"
176
+ })
177
+ ```
160
178
 
161
- ### Phase 4: Apply One Fix, Re-measure, Decide
179
+ **Result Format:**
180
+ ```json
181
+ {
182
+ "bottlenecks": [
183
+ {
184
+ "type": "coordination",
185
+ "severity": "high",
186
+ "description": "Single agent used for complex task",
187
+ "recommendation": "Spawn specialized agents for parallel work",
188
+ "impact": "35%",
189
+ "affectedComponents": ["coordinator", "coder-1"]
190
+ }
191
+ ],
192
+ "improvements": [
193
+ {
194
+ "area": "execution_time",
195
+ "suggestion": "Use parallel task execution",
196
+ "expectedImprovement": "30-50% time reduction",
197
+ "implementationSteps": [
198
+ "Split task into smaller units",
199
+ "Spawn 3-4 specialized agents",
200
+ "Use mesh topology for coordination"
201
+ ]
202
+ }
203
+ ],
204
+ "metrics": {
205
+ "avgExecutionTime": "142s",
206
+ "agentUtilization": "67%",
207
+ "cacheHitRate": "82%",
208
+ "parallelizationFactor": 1.2
209
+ }
210
+ }
211
+ ```
162
212
 
163
- One change. One measurement. Then decide.
213
+ ### 3. Report Generation
164
214
 
215
+ #### Command Syntax
165
216
  ```bash
166
- # Apply the single fix you hypothesized from Phase 2/3 evidence
167
-
168
- # Re-run the EXACT same baseline commands
169
- npx monomind@latest performance benchmark -s all -i 100 -o json > after-bench.json
170
- npx monomind@latest performance metrics -t 24h -f json > after-metrics.json
171
- npx monomind@latest performance profile -t all -d 60 -o after-profile.json
172
-
173
- # Diff before vs after. Did the targeted metric move? Did anything else regress?
217
+ npx monomind analysis performance-report [options]
174
218
  ```
175
219
 
176
- **Decision rules:**
177
-
178
- - Target metric improved, nothing regressed → ship it.
179
- - Target metric improved, something else regressed → weigh tradeoffs explicitly.
180
- Don't ship on hope.
181
- - Target metric unchanged → the bottleneck was misdiagnosed. Return to Phase 2 with
182
- new evidence. Do not apply a second fix on top of a failed one.
183
- - 3+ fixes in a row with no movement → this is architectural (see below).
184
-
185
- ---
186
-
187
- ## Methodology: Regression Detection
188
-
189
- Performance regressions slip in through code changes. Catch them at the diff, not in
190
- production.
191
-
220
+ #### Options
221
+ - `--format <type>` - Report format: json, html, markdown (default: markdown)
222
+ - `--include-metrics` - Include detailed metrics and charts
223
+ - `--compare <id>` - Compare with previous swarm
224
+ - `--time-range <range>` - Analysis period: 1h, 24h, 7d, 30d, all
225
+ - `--output <file>` - Output file path
226
+ - `--sections <list>` - Comma-separated sections to include
227
+
228
+ #### Report Sections
229
+ 1. **Executive Summary**
230
+ - Overall performance score
231
+ - Key metrics overview
232
+ - Critical findings
233
+
234
+ 2. **Swarm Overview**
235
+ - Topology configuration
236
+ - Agent distribution
237
+ - Task statistics
238
+
239
+ 3. **Performance Metrics**
240
+ - Execution times
241
+ - Throughput analysis
242
+ - Resource utilization
243
+ - Latency breakdown
244
+
245
+ 4. **Bottleneck Analysis**
246
+ - Identified bottlenecks
247
+ - Impact assessment
248
+ - Optimization priorities
249
+
250
+ 5. **Comparative Analysis** (when --compare used)
251
+ - Performance trends
252
+ - Improvement metrics
253
+ - Regression detection
254
+
255
+ 6. **Recommendations**
256
+ - Prioritized action items
257
+ - Expected improvements
258
+ - Implementation guidance
259
+
260
+ #### Usage Examples
192
261
  ```bash
193
- # Before merging any change that touches a hot path:
194
- npx monomind@latest analyze diff --risk -v
195
-
196
- # Classify the change so reviewers know what they're looking at
197
- npx monomind@latest analyze diff --classify --reviewers
262
+ # Generate HTML report with all metrics
263
+ npx monomind analysis performance-report --format html --include-metrics
264
+
265
+ # Compare current swarm with previous
266
+ npx monomind analysis performance-report --compare swarm-123 --format markdown
267
+
268
+ # Custom output with specific sections
269
+ npx monomind analysis performance-report \
270
+ --sections summary,metrics,recommendations \
271
+ --output reports/perf-analysis.html \
272
+ --format html
273
+
274
+ # Weekly performance report
275
+ npx monomind analysis performance-report \
276
+ --time-range 7d \
277
+ --include-metrics \
278
+ --format markdown \
279
+ --output docs/weekly-performance.md
280
+
281
+ # JSON format for CI/CD integration
282
+ npx monomind analysis performance-report \
283
+ --format json \
284
+ --output build/performance.json
285
+ ```
198
286
 
199
- # Compare the current branch against main explicitly
200
- npx monomind@latest analyze diff main..HEAD --risk --format json
287
+ #### Sample Markdown Report
288
+ ```markdown
289
+ # Performance Analysis Report
290
+
291
+ ## Executive Summary
292
+ - **Overall Score**: 87/100
293
+ - **Analysis Period**: Last 24 hours
294
+ - **Swarms Analyzed**: 3
295
+ - **Critical Issues**: 1
296
+
297
+ ## Key Metrics
298
+ | Metric | Value | Trend | Target |
299
+ |--------|-------|-------|--------|
300
+ | Avg Task Time | 42s | ↓ 12% | 35s |
301
+ | Agent Utilization | 78% | ↑ 5% | 85% |
302
+ | Cache Hit Rate | 91% | → | 90% |
303
+ | Parallel Efficiency | 2.3x | ↑ 0.4x | 2.5x |
304
+
305
+ ## Bottleneck Analysis
306
+ ### Critical
307
+ 1. **Agent Communication Delay** (Impact: 35%)
308
+ - Coordinator → Coder messages delayed by 2.3s avg
309
+ - **Fix**: Switch to hierarchical topology
310
+
311
+ ### Warnings
312
+ 1. **Memory Access Pattern** (Impact: 18%)
313
+ - Neural pattern loading: 1.8s per access
314
+ - **Fix**: Enable memory caching
315
+
316
+ ## Recommendations
317
+ 1. **High Priority**: Switch to hierarchical topology (40% improvement)
318
+ 2. **Medium Priority**: Enable memory caching (25% improvement)
319
+ 3. **Low Priority**: Increase agent concurrency to 8 (20% improvement)
201
320
  ```
202
321
 
203
- **CI integration (GitHub Action):**
322
+ ### 4. Optimization Recommendations
323
+
324
+ #### Automatic Fixes
325
+ When using `--fix`, the following optimizations may be applied:
326
+
327
+ **1. Topology Optimization**
328
+ - Switch to more efficient topology (mesh → hierarchical)
329
+ - Adjust communication patterns
330
+ - Reduce coordination overhead
331
+ - Optimize message routing
332
+
333
+ **2. Caching Enhancement**
334
+ - Enable memory caching
335
+ - Optimize cache strategies
336
+ - Preload common patterns
337
+ - Implement cache warming
338
+
339
+ **3. Concurrency Tuning**
340
+ - Adjust agent counts
341
+ - Optimize parallel execution
342
+ - Balance workload distribution
343
+ - Implement load balancing
344
+
345
+ **4. Priority Adjustment**
346
+ - Reorder task queues
347
+ - Prioritize critical paths
348
+ - Reduce wait times
349
+ - Implement fair scheduling
350
+
351
+ **5. Resource Optimization**
352
+ - Optimize memory usage
353
+ - Reduce I/O operations
354
+ - Batch API calls
355
+ - Implement connection pooling
356
+
357
+ #### Performance Impact
358
+ Typical improvements after bottleneck resolution:
359
+
360
+ - **Communication**: 30-50% faster message delivery
361
+ - **Processing**: 20-40% reduced task completion time
362
+ - **Memory**: 40-60% fewer cache misses
363
+ - **Network**: 25-45% reduced API latency
364
+ - **Overall**: 25-45% total performance improvement
365
+
366
+ ## Advanced Usage
367
+
368
+ ### Continuous Monitoring
369
+ ```bash
370
+ # Monitor performance in real-time
371
+ npx monomind swarm monitor --interval 5
372
+
373
+ # Generate hourly reports
374
+ while true; do
375
+ npx monomind analysis performance-report \
376
+ --format json \
377
+ --output logs/perf-$(date +%Y%m%d-%H%M).json
378
+ sleep 3600
379
+ done
380
+ ```
204
381
 
382
+ ### CI/CD Integration
205
383
  ```yaml
206
- name: Performance Gate
207
- on: [pull_request]
384
+ # .github/workflows/performance.yml
385
+ name: Performance Analysis
386
+ on: [push, pull_request]
387
+
208
388
  jobs:
209
- perf:
389
+ analyze:
210
390
  runs-on: ubuntu-latest
211
391
  steps:
212
- - uses: actions/checkout@v4
213
- - name: Risk-classify the diff
214
- run: npx monomind@latest analyze diff main..HEAD --risk --format json > diff-risk.json
215
- - name: Snapshot metrics
216
- run: npx monomind@latest performance metrics -t 24h -f json > metrics.json
217
- - uses: actions/upload-artifact@v4
392
+ - uses: actions/checkout@v2
393
+ - name: Run Performance Analysis
394
+ run: |
395
+ npx monomind analysis performance-report \
396
+ --format json \
397
+ --output performance.json
398
+ - name: Check Performance Thresholds
399
+ run: |
400
+ npx monomind bottleneck detect \
401
+ --threshold 15 \
402
+ --export bottlenecks.json
403
+ - name: Upload Reports
404
+ uses: actions/upload-artifact@v2
218
405
  with:
219
- name: perf-gate
406
+ name: performance-reports
220
407
  path: |
221
- diff-risk.json
222
- metrics.json
408
+ performance.json
409
+ bottlenecks.json
223
410
  ```
224
411
 
225
- > Don't fail CI on a raw number threshold unless you have a stable baseline. Prefer
226
- > *risk classification* (qualitative) over *latency thresholds* (fragile) for the
227
- > gate, and use metrics for trend analysis offline.
412
+ ### Custom Analysis Scripts
413
+ ```javascript
414
+ // scripts/analyze-performance.js
415
+ const { exec } = require('child_process');
416
+ const fs = require('fs');
417
+
418
+ async function analyzePerformance() {
419
+ // Run bottleneck detection
420
+ const bottlenecks = await runCommand(
421
+ 'npx monomind bottleneck detect --format json'
422
+ );
423
+
424
+ // Generate performance report
425
+ const report = await runCommand(
426
+ 'npx monomind analysis performance-report --format json'
427
+ );
428
+
429
+ // Analyze results
430
+ const analysis = {
431
+ bottlenecks: JSON.parse(bottlenecks),
432
+ performance: JSON.parse(report),
433
+ timestamp: new Date().toISOString()
434
+ };
435
+
436
+ // Save combined analysis
437
+ fs.writeFileSync(
438
+ 'analysis/combined-report.json',
439
+ JSON.stringify(analysis, null, 2)
440
+ );
441
+
442
+ // Generate alerts if needed
443
+ if (analysis.bottlenecks.critical.length > 0) {
444
+ console.error('CRITICAL: Performance bottlenecks detected!');
445
+ process.exit(1);
446
+ }
447
+ }
448
+
449
+ function runCommand(cmd) {
450
+ return new Promise((resolve, reject) => {
451
+ exec(cmd, (error, stdout, stderr) => {
452
+ if (error) reject(error);
453
+ else resolve(stdout);
454
+ });
455
+ });
456
+ }
457
+
458
+ analyzePerformance().catch(console.error);
459
+ ```
228
460
 
229
- ---
461
+ ## Best Practices
230
462
 
231
- ## Methodology: Optimization Recommendations
463
+ ### 1. Regular Analysis
464
+ - Run bottleneck detection after major changes
465
+ - Generate weekly performance reports
466
+ - Monitor trends over time
467
+ - Set up automated alerts
232
468
 
233
- When `performance bottleneck` reports findings, map them to actions in this order:
469
+ ### 2. Threshold Tuning
470
+ - Start with default threshold (20%)
471
+ - Lower for production systems (10-15%)
472
+ - Higher for development (25-30%)
473
+ - Adjust based on requirements
234
474
 
235
- | Bottleneck type | First-action recommendation |
236
- |---|---|
237
- | network | Check topology (`hierarchical` vs `mesh`); reduce message round-trips |
238
- | memory | Confirm SQLite bridge is up (not the WASM/JSON fallback); widen cache |
239
- | cpu | Profile (`performance profile -t cpu`) to find the hot function |
240
- | io | Batch file reads; lazy-load graphs; check for sync I/O on hot path |
241
- | search | Rebuild monograph; verify BM25 index is current |
242
- | coordination | Lower `maxAgents` if utilization is low; raise it if queue is deep |
475
+ ### 3. Fix Strategy
476
+ - Always review before applying --fix
477
+ - Test fixes in development first
478
+ - Apply fixes incrementally
479
+ - Monitor impact after changes
243
480
 
244
- **Always:** state the recommendation as a hypothesis, apply it as a single change,
245
- and verify with Phase 4. Recommendations without re-measurement are guesses.
481
+ ### 4. Report Integration
482
+ - Include in documentation
483
+ - Share with team regularly
484
+ - Track improvements over time
485
+ - Use for capacity planning
246
486
 
247
- ---
487
+ ### 5. Continuous Optimization
488
+ - Learn from each analysis
489
+ - Build performance budgets
490
+ - Establish baselines
491
+ - Set improvement goals
248
492
 
249
- ## Continuous Monitoring
493
+ ## Troubleshooting
250
494
 
495
+ ### Common Issues
496
+
497
+ **High Memory Usage**
251
498
  ```bash
252
- # Weekly metrics snapshot for trend analysis
253
- npx monomind@latest performance metrics -t 7d -f json > "perf-$(date +%Y%m%d).json"
499
+ # Analyze memory bottlenecks
500
+ npx monomind bottleneck detect --threshold 10
254
501
 
255
- # Doctor runs 28 health categories — include it in weekly review
256
- npx monomind@latest doctor
502
+ # Check cache performance
503
+ npx monomind cache manage --action stats
257
504
 
258
- # Hooks metrics show what the background workers are costing you
259
- npx monomind@latest hooks metrics
505
+ # Review memory metrics
506
+ npx monomind memory usage
260
507
  ```
261
508
 
262
- For long-term storage, pipe `performance metrics -f prometheus` into a Prometheus
263
- instance and let Grafana draw the trends.
509
+ **Slow Task Execution**
510
+ ```bash
511
+ # Identify slow tasks
512
+ npx monomind task status --detailed
513
+
514
+ # Analyze coordination overhead
515
+ npx monomind bottleneck detect --time-range 1h
264
516
 
265
- ---
517
+ # Check agent utilization
518
+ npx monomind agent metrics
519
+ ```
520
+
521
+ **Poor Cache Performance**
522
+ ```bash
523
+ # Analyze cache hit rates
524
+ npx monomind analysis performance-report --sections metrics
266
525
 
267
- ## Red Flags — STOP and Return to Phase 1
526
+ # Review cache strategy
527
+ npx monomind cache manage --action analyze
268
528
 
269
- | Thought / Action | What it means |
270
- |---|---|
271
- | "This is obviously slow, let me optimize it" | No measured bottleneck. Phase 1 first. |
272
- | "I'll add a cache, that always helps" | Cache without a measured miss rate is bloat. |
273
- | "Let me try a few optimizations together" | Can't isolate what worked. One change. |
274
- | "Benchmark improved so we're done" | Did anything else regress? Check, don't assume. |
275
- | "It feels faster now" | Feeling is not measurement. Re-run baseline. |
276
- | 3+ fixes applied, no movement | Architectural problem. Stop, discuss design. |
529
+ # Enable cache warming
530
+ npx monomind bottleneck detect --fix
531
+ ```
277
532
 
278
533
  ## Integration with Other Skills
279
534
 
280
- - **`mastermind-debug`** — Phase 1 root-cause methodology underpins this skill
281
- - **`swarm-orchestration`** — topology decisions driven by bottleneck findings
282
- - **`verification-quality`** — confirm the optimization actually held
283
- - **`mastermind-verify`** — evidence-before-claims for "is it faster?"
535
+ - **swarm-orchestration**: Use performance data to optimize topology
536
+ - **memory-management**: Improve cache strategies based on analysis
537
+ - **task-coordination**: Adjust scheduling based on bottlenecks
538
+ - **neural-training**: Train patterns from performance data
284
539
 
285
- ## Quick Reference
540
+ ## Related Commands
286
541
 
287
- | Phase | Key command | Success criteria |
288
- |---|---|---|
289
- | 1. Baseline | `performance benchmark` + `metrics` | Numbers on disk |
290
- | 2. Bottleneck | `performance bottleneck -d full` | Named component or code hotspot |
291
- | 2b. Code-level | `analyze diff --risk`, `analyze complexity` | Risky change or hotspot file found |
292
- | 3. Interpret | `performance metrics`, `tokens dashboard` | Metric tied to a symptom |
293
- | 4. Fix + re-measure | same baseline commands | Target moved, nothing regressed |
542
+ - `npx monomind swarm monitor` - Real-time monitoring
543
+ - `npx monomind token usage` - Token optimization analysis
544
+ - `npx monomind cache manage` - Cache optimization
545
+ - `npx monomind agent metrics` - Agent performance metrics
546
+ - `npx monomind task status` - Task execution analysis
294
547
 
295
548
  ## See Also
296
549
 
297
- - [Systematic Debugging](../mastermind-debug/SKILL.md)
298
- - [Swarm Orchestration](../swarm-orchestration/SKILL.md)
299
- - [Verification & Quality](../verification-quality/SKILL.md)
550
+ - [Bottleneck Detection Guide](https://github.com/monoes/monomind/wiki/bottleneck-detect)
551
+ - [Performance Report Guide](https://github.com/monoes/monomind/wiki/performance-report)
552
+ - [Performance Bottlenecks Overview](https://github.com/monoes/monomind/wiki/performance-bottlenecks)
553
+ - [Swarm Monitoring Documentation](../swarm-orchestration/SKILL.md)
554
+ - [Memory Management Documentation](../memory-management/SKILL.md)
300
555
 
301
556
  ---
302
557
 
303
- **Version**: 2.0.0
304
- **Last Updated**: 2026-08-12
558
+ **Version**: 1.0.0
559
+ **Last Updated**: 2025-10-19
560
+ **Maintainer**: Monomind Team