swarm-engine 1.1.1 → 1.3.0

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 (275) hide show
  1. package/CLAUDE.md +1 -1
  2. package/README.md +102 -25
  3. package/commands/diff-review.md +27 -15
  4. package/commands/discover.md +102 -0
  5. package/commands/dynamic.md +136 -0
  6. package/commands/fix-pr.md +30 -24
  7. package/commands/postmortem.md +106 -0
  8. package/commands/red-team.md +41 -26
  9. package/commands/research.md +22 -1
  10. package/commands/review-cycle.md +38 -20
  11. package/commands/spike.md +108 -0
  12. package/commands/swarm.md +68 -60
  13. package/commands/tdd.md +44 -24
  14. package/dist/cli/commands/acp.d.ts.map +1 -1
  15. package/dist/cli/commands/acp.js +12 -2
  16. package/dist/cli/commands/acp.js.map +1 -1
  17. package/dist/cli/commands/agents.d.ts.map +1 -1
  18. package/dist/cli/commands/agents.js +16 -13
  19. package/dist/cli/commands/agents.js.map +1 -1
  20. package/dist/cli/commands/completions.d.ts.map +1 -1
  21. package/dist/cli/commands/completions.js +21 -9
  22. package/dist/cli/commands/completions.js.map +1 -1
  23. package/dist/cli/commands/compound.d.ts.map +1 -1
  24. package/dist/cli/commands/compound.js +1 -2
  25. package/dist/cli/commands/compound.js.map +1 -1
  26. package/dist/cli/commands/configure.d.ts.map +1 -1
  27. package/dist/cli/commands/configure.js +24 -8
  28. package/dist/cli/commands/configure.js.map +1 -1
  29. package/dist/cli/commands/convert.d.ts +1 -1
  30. package/dist/cli/commands/convert.d.ts.map +1 -1
  31. package/dist/cli/commands/convert.js +22 -48
  32. package/dist/cli/commands/convert.js.map +1 -1
  33. package/dist/cli/commands/doctor.d.ts.map +1 -1
  34. package/dist/cli/commands/doctor.js +1 -3
  35. package/dist/cli/commands/doctor.js.map +1 -1
  36. package/dist/cli/commands/init.d.ts.map +1 -1
  37. package/dist/cli/commands/init.js +17 -7
  38. package/dist/cli/commands/init.js.map +1 -1
  39. package/dist/cli/commands/install.d.ts.map +1 -1
  40. package/dist/cli/commands/install.js +1 -1
  41. package/dist/cli/commands/install.js.map +1 -1
  42. package/dist/cli/commands/learn.js +6 -6
  43. package/dist/cli/commands/learn.js.map +1 -1
  44. package/dist/cli/commands/mcp.d.ts.map +1 -1
  45. package/dist/cli/commands/mcp.js +1 -2
  46. package/dist/cli/commands/mcp.js.map +1 -1
  47. package/dist/cli/commands/memory.d.ts.map +1 -1
  48. package/dist/cli/commands/memory.js +1 -2
  49. package/dist/cli/commands/memory.js.map +1 -1
  50. package/dist/cli/commands/orchestrate.d.ts.map +1 -1
  51. package/dist/cli/commands/orchestrate.js +20 -7
  52. package/dist/cli/commands/orchestrate.js.map +1 -1
  53. package/dist/cli/commands/plan.d.ts.map +1 -1
  54. package/dist/cli/commands/plan.js.map +1 -1
  55. package/dist/cli/commands/plugin.d.ts.map +1 -1
  56. package/dist/cli/commands/plugin.js +8 -5
  57. package/dist/cli/commands/plugin.js.map +1 -1
  58. package/dist/cli/commands/resume.js +1 -1
  59. package/dist/cli/commands/resume.js.map +1 -1
  60. package/dist/cli/commands/run.d.ts.map +1 -1
  61. package/dist/cli/commands/run.js +20 -6
  62. package/dist/cli/commands/run.js.map +1 -1
  63. package/dist/cli/commands/share.d.ts.map +1 -1
  64. package/dist/cli/commands/share.js +6 -1
  65. package/dist/cli/commands/share.js.map +1 -1
  66. package/dist/cli/commands/status.d.ts.map +1 -1
  67. package/dist/cli/commands/status.js +15 -7
  68. package/dist/cli/commands/status.js.map +1 -1
  69. package/dist/cli/commands/template.d.ts.map +1 -1
  70. package/dist/cli/commands/template.js +14 -6
  71. package/dist/cli/commands/template.js.map +1 -1
  72. package/dist/cli/commands/vault.d.ts.map +1 -1
  73. package/dist/cli/commands/vault.js +14 -9
  74. package/dist/cli/commands/vault.js.map +1 -1
  75. package/dist/cli/commands/verify.d.ts.map +1 -1
  76. package/dist/cli/commands/verify.js +2 -2
  77. package/dist/cli/commands/verify.js.map +1 -1
  78. package/dist/cli/commands/watch.js +1 -1
  79. package/dist/cli/commands/watch.js.map +1 -1
  80. package/dist/cli/index.js +14 -4
  81. package/dist/cli/index.js.map +1 -1
  82. package/dist/core/checkpoint.js +1 -1
  83. package/dist/core/checkpoint.js.map +1 -1
  84. package/dist/core/event-bus.d.ts.map +1 -1
  85. package/dist/core/event-bus.js +9 -3
  86. package/dist/core/event-bus.js.map +1 -1
  87. package/dist/core/lifecycle.js.map +1 -1
  88. package/dist/core/patterns.d.ts.map +1 -1
  89. package/dist/core/patterns.js +31 -8
  90. package/dist/core/patterns.js.map +1 -1
  91. package/dist/core/permissions.d.ts.map +1 -1
  92. package/dist/core/permissions.js +21 -10
  93. package/dist/core/permissions.js.map +1 -1
  94. package/dist/core/registry.d.ts.map +1 -1
  95. package/dist/core/registry.js +10 -6
  96. package/dist/core/registry.js.map +1 -1
  97. package/dist/core/snapshots.d.ts.map +1 -1
  98. package/dist/core/snapshots.js +17 -5
  99. package/dist/core/snapshots.js.map +1 -1
  100. package/dist/core/types.d.ts +3 -0
  101. package/dist/core/types.d.ts.map +1 -1
  102. package/dist/core/types.js.map +1 -1
  103. package/dist/hooks/index.js.map +1 -1
  104. package/dist/index.d.ts +68 -6
  105. package/dist/index.d.ts.map +1 -1
  106. package/dist/index.js +60 -4
  107. package/dist/index.js.map +1 -1
  108. package/dist/memory/index.d.ts +1 -0
  109. package/dist/memory/index.d.ts.map +1 -1
  110. package/dist/memory/index.js +39 -24
  111. package/dist/memory/index.js.map +1 -1
  112. package/dist/memory/schema.d.ts +1 -0
  113. package/dist/memory/schema.d.ts.map +1 -1
  114. package/dist/memory/schema.js +20 -19
  115. package/dist/memory/schema.js.map +1 -1
  116. package/dist/plugin/index.d.ts.map +1 -1
  117. package/dist/plugin/index.js.map +1 -1
  118. package/dist/runtime/acp.d.ts.map +1 -1
  119. package/dist/runtime/acp.js +71 -41
  120. package/dist/runtime/acp.js.map +1 -1
  121. package/dist/runtime/adaptive.d.ts.map +1 -1
  122. package/dist/runtime/adaptive.js +30 -31
  123. package/dist/runtime/adaptive.js.map +1 -1
  124. package/dist/runtime/agent-runner.d.ts +52 -0
  125. package/dist/runtime/agent-runner.d.ts.map +1 -0
  126. package/dist/runtime/agent-runner.js +156 -0
  127. package/dist/runtime/agent-runner.js.map +1 -0
  128. package/dist/runtime/autonomy.d.ts +1 -0
  129. package/dist/runtime/autonomy.d.ts.map +1 -1
  130. package/dist/runtime/autonomy.js +37 -19
  131. package/dist/runtime/autonomy.js.map +1 -1
  132. package/dist/runtime/backends/claude.d.ts.map +1 -1
  133. package/dist/runtime/backends/claude.js +2 -2
  134. package/dist/runtime/backends/claude.js.map +1 -1
  135. package/dist/runtime/backends/codex.d.ts.map +1 -1
  136. package/dist/runtime/backends/codex.js +8 -11
  137. package/dist/runtime/backends/codex.js.map +1 -1
  138. package/dist/runtime/backends/gemini.d.ts.map +1 -1
  139. package/dist/runtime/backends/gemini.js +11 -7
  140. package/dist/runtime/backends/gemini.js.map +1 -1
  141. package/dist/runtime/backends/index.js +1 -1
  142. package/dist/runtime/backends/index.js.map +1 -1
  143. package/dist/runtime/backends/mock.d.ts.map +1 -1
  144. package/dist/runtime/backends/mock.js +1 -1
  145. package/dist/runtime/backends/mock.js.map +1 -1
  146. package/dist/runtime/backends/vercel-ai.d.ts.map +1 -1
  147. package/dist/runtime/backends/vercel-ai.js +41 -9
  148. package/dist/runtime/backends/vercel-ai.js.map +1 -1
  149. package/dist/runtime/cache-optimizer.d.ts.map +1 -1
  150. package/dist/runtime/cache-optimizer.js +3 -9
  151. package/dist/runtime/cache-optimizer.js.map +1 -1
  152. package/dist/runtime/cascade.d.ts.map +1 -1
  153. package/dist/runtime/cascade.js +34 -7
  154. package/dist/runtime/cascade.js.map +1 -1
  155. package/dist/runtime/chunker.d.ts.map +1 -1
  156. package/dist/runtime/chunker.js +12 -6
  157. package/dist/runtime/chunker.js.map +1 -1
  158. package/dist/runtime/compounder.d.ts +1 -1
  159. package/dist/runtime/compounder.d.ts.map +1 -1
  160. package/dist/runtime/compounder.js +30 -11
  161. package/dist/runtime/compounder.js.map +1 -1
  162. package/dist/runtime/cost-model.d.ts.map +1 -1
  163. package/dist/runtime/cost-model.js +1 -1
  164. package/dist/runtime/cost-model.js.map +1 -1
  165. package/dist/runtime/database.d.ts +16 -0
  166. package/dist/runtime/database.d.ts.map +1 -0
  167. package/dist/runtime/database.js +39 -0
  168. package/dist/runtime/database.js.map +1 -0
  169. package/dist/runtime/distiller.d.ts.map +1 -1
  170. package/dist/runtime/distiller.js +6 -3
  171. package/dist/runtime/distiller.js.map +1 -1
  172. package/dist/runtime/engine.d.ts +7 -9
  173. package/dist/runtime/engine.d.ts.map +1 -1
  174. package/dist/runtime/engine.js +129 -394
  175. package/dist/runtime/engine.js.map +1 -1
  176. package/dist/runtime/executor.d.ts +1 -2
  177. package/dist/runtime/executor.d.ts.map +1 -1
  178. package/dist/runtime/executor.js +45 -14
  179. package/dist/runtime/executor.js.map +1 -1
  180. package/dist/runtime/heuristics.d.ts +1 -0
  181. package/dist/runtime/heuristics.d.ts.map +1 -1
  182. package/dist/runtime/heuristics.js +44 -22
  183. package/dist/runtime/heuristics.js.map +1 -1
  184. package/dist/runtime/learning-engine.d.ts +51 -0
  185. package/dist/runtime/learning-engine.d.ts.map +1 -0
  186. package/dist/runtime/learning-engine.js +209 -0
  187. package/dist/runtime/learning-engine.js.map +1 -0
  188. package/dist/runtime/living-spec.js +3 -3
  189. package/dist/runtime/living-spec.js.map +1 -1
  190. package/dist/runtime/lsp.d.ts.map +1 -1
  191. package/dist/runtime/lsp.js +41 -14
  192. package/dist/runtime/lsp.js.map +1 -1
  193. package/dist/runtime/mcp.d.ts.map +1 -1
  194. package/dist/runtime/mcp.js +56 -19
  195. package/dist/runtime/mcp.js.map +1 -1
  196. package/dist/runtime/model-router.d.ts +1 -0
  197. package/dist/runtime/model-router.d.ts.map +1 -1
  198. package/dist/runtime/model-router.js +37 -21
  199. package/dist/runtime/model-router.js.map +1 -1
  200. package/dist/runtime/panes.d.ts.map +1 -1
  201. package/dist/runtime/panes.js +50 -49
  202. package/dist/runtime/panes.js.map +1 -1
  203. package/dist/runtime/plan-search.js +2 -2
  204. package/dist/runtime/plan-search.js.map +1 -1
  205. package/dist/runtime/plugins.d.ts +1 -1
  206. package/dist/runtime/plugins.d.ts.map +1 -1
  207. package/dist/runtime/plugins.js +63 -47
  208. package/dist/runtime/plugins.js.map +1 -1
  209. package/dist/runtime/reflexion.d.ts.map +1 -1
  210. package/dist/runtime/reflexion.js +4 -8
  211. package/dist/runtime/reflexion.js.map +1 -1
  212. package/dist/runtime/review-schema.d.ts.map +1 -1
  213. package/dist/runtime/review-schema.js +12 -12
  214. package/dist/runtime/review-schema.js.map +1 -1
  215. package/dist/runtime/rewriter.d.ts.map +1 -1
  216. package/dist/runtime/rewriter.js +29 -9
  217. package/dist/runtime/rewriter.js.map +1 -1
  218. package/dist/runtime/sharing.d.ts +1 -1
  219. package/dist/runtime/sharing.d.ts.map +1 -1
  220. package/dist/runtime/sharing.js +55 -27
  221. package/dist/runtime/sharing.js.map +1 -1
  222. package/dist/runtime/stats.d.ts +1 -0
  223. package/dist/runtime/stats.d.ts.map +1 -1
  224. package/dist/runtime/stats.js +40 -24
  225. package/dist/runtime/stats.js.map +1 -1
  226. package/dist/runtime/templates.d.ts.map +1 -1
  227. package/dist/runtime/templates.js +2 -2
  228. package/dist/runtime/templates.js.map +1 -1
  229. package/dist/runtime/traces.d.ts +1 -0
  230. package/dist/runtime/traces.d.ts.map +1 -1
  231. package/dist/runtime/traces.js +50 -28
  232. package/dist/runtime/traces.js.map +1 -1
  233. package/dist/runtime/verifier.d.ts.map +1 -1
  234. package/dist/runtime/verifier.js +12 -6
  235. package/dist/runtime/verifier.js.map +1 -1
  236. package/dist/runtime/worktree.d.ts.map +1 -1
  237. package/dist/runtime/worktree.js +35 -18
  238. package/dist/runtime/worktree.js.map +1 -1
  239. package/dist/tui/dashboard.d.ts.map +1 -1
  240. package/dist/tui/dashboard.js +20 -16
  241. package/dist/tui/dashboard.js.map +1 -1
  242. package/dist/tui/progress.d.ts +2 -0
  243. package/dist/tui/progress.d.ts.map +1 -1
  244. package/dist/tui/progress.js +105 -33
  245. package/dist/tui/progress.js.map +1 -1
  246. package/dist/tui/renderer.d.ts.map +1 -1
  247. package/dist/tui/renderer.js.map +1 -1
  248. package/dist/utils/compact-format.js +1 -1
  249. package/dist/utils/compact-format.js.map +1 -1
  250. package/dist/utils/config.d.ts.map +1 -1
  251. package/dist/utils/config.js.map +1 -1
  252. package/dist/utils/env.d.ts.map +1 -1
  253. package/dist/utils/env.js +19 -5
  254. package/dist/utils/env.js.map +1 -1
  255. package/dist/utils/errors.d.ts.map +1 -1
  256. package/dist/utils/errors.js +3 -7
  257. package/dist/utils/errors.js.map +1 -1
  258. package/dist/utils/output.d.ts.map +1 -1
  259. package/dist/utils/output.js +6 -2
  260. package/dist/utils/output.js.map +1 -1
  261. package/dist/utils/project-config.d.ts +18 -0
  262. package/dist/utils/project-config.d.ts.map +1 -1
  263. package/dist/utils/project-config.js +14 -6
  264. package/dist/utils/project-config.js.map +1 -1
  265. package/dist/utils/schemas.d.ts.map +1 -1
  266. package/dist/utils/schemas.js +12 -12
  267. package/dist/utils/schemas.js.map +1 -1
  268. package/dist/utils/terminal.d.ts.map +1 -1
  269. package/dist/utils/terminal.js +18 -7
  270. package/dist/utils/terminal.js.map +1 -1
  271. package/dist/utils/tiers.d.ts.map +1 -1
  272. package/dist/utils/tiers.js +14 -6
  273. package/dist/utils/tiers.js.map +1 -1
  274. package/package.json +14 -3
  275. package/skills/swarm-output-style/SKILL.md +114 -46
package/CLAUDE.md CHANGED
@@ -54,7 +54,7 @@ src/
54
54
  ├── memory/ # SQLite + FTS5 + Obsidian vault sync
55
55
  ├── hooks/ # TypeScript hook handlers (universal ANSI)
56
56
  ├── plugin/ # Claude Code plugin generator
57
- ├── cli/ # 21 CLI commands (15 visible + 6 hidden)
57
+ ├── cli/ # 23 CLI commands (17 visible + 6 hidden)
58
58
  └── utils/ # Logger, config, terminal, paths, redact, tokens, errors, env
59
59
  ```
60
60
 
package/README.md CHANGED
@@ -1,5 +1,10 @@
1
1
  # Swarm Engine
2
2
 
3
+ [![npm](https://img.shields.io/npm/v/swarm-engine)](https://www.npmjs.com/package/swarm-engine)
4
+ [![Node](https://img.shields.io/node/v/swarm-engine)](https://nodejs.org)
5
+ [![License: MIT](https://img.shields.io/badge/License-MIT-blue.svg)](https://opensource.org/licenses/MIT)
6
+ [![Tests](https://img.shields.io/badge/tests-871%20passing-brightgreen)]()
7
+
3
8
  **Your agents. Orchestrated.**
4
9
 
5
10
  Coordinate multiple AI agents working on your code - researching, implementing, reviewing, testing - with an intelligent planner that learns from every run.
@@ -9,29 +14,46 @@ Works with Claude Code, OpenAI Codex, and Google Gemini CLI. Mix models across a
9
14
  ## What It Looks Like
10
15
 
11
16
  ```
12
- Swarm Engine - hybrid pattern
17
+ Swarm Engine hybrid pattern
18
+
19
+ Phase: research ━━━━━━━━━━━━━━━━━━━━ done
20
+ ✓ researcher-code sonnet-4-6 3.2K tok 14s
21
+ ✓ researcher-context sonnet-4-6 1.8K tok 9s
22
+
23
+ Phase: implement ━━━━━━━━━━━━━━━━━━━ 1m 12s
24
+ ● implementer opus-4-6 8.4K tok 1m 12s src/auth/rate-limit.ts
13
25
 
14
- Phase 1: research ━━━━━━━━━━━━━━━━━━━━ 100% 42s
15
- researcher-code sonnet 3.2K tokens
16
- researcher-context sonnet 1.8K tokens
26
+ Phase: review ────────────────────── pending
27
+ reviewer-security opus-4-6
28
+ reviewer-perf sonnet-4-6
29
+ ○ reviewer-convention sonnet-4-6
17
30
 
18
- Phase 2: implement ━━━━━━━━━━━━━━━━━━━ 55% 1m 12s
19
- ● implementer opus src/auth/rate-limit.ts...
31
+ Timeline: ━━──── (1/3 phases)
20
32
 
21
- Phase 3: review pending
22
- reviewer-correctness ○ reviewer-security ○ reviewer-convention
33
+ Recent findings:
34
+ researcher-code: express-rate-limit already in package.json
35
+ ○ researcher-context: vault says rate limiter goes before auth middleware
23
36
 
24
- $0.24 spent | 12.8K tokens | ~2m remaining
37
+ 12.8K tokens $0.24 1m 36s ~2m remaining
25
38
  ```
26
39
 
27
40
  ```
28
- ┌─────────────────────────────────────────────────┐
29
- │ ✓ Orchestration complete │
30
- Pattern: hybrid (3 phases, 6 agents) │
31
- │ Duration: 3m 42s | Tokens: 47K | Cost: $0.38 │
32
- │ │
33
- Save as template? deploy-lambda │
34
- └─────────────────────────────────────────────────┘
41
+ +---------------------------------------------------------+
42
+ | |
43
+ | Orchestration complete |
44
+ | |
45
+ | Pattern: hybrid (3 phases, 6 agents) |
46
+ | Duration: 3m 42s |
47
+ | Tokens: 47.2K |
48
+ | Cost: $0.3814 |
49
+ | Tools: 142 calls |
50
+ | |
51
+ | Changes: |
52
+ | src/middleware/rate-limit.ts 48 +++ |
53
+ | src/routes/users.ts 3 +- |
54
+ | tests/middleware/rate-limit.test.ts 62 +++ |
55
+ | |
56
+ +---------------------------------------------------------+
35
57
  ```
36
58
 
37
59
  ## Install
@@ -66,17 +88,34 @@ Requires Node.js 20+, jq, and at least one of Claude Code, Codex, or Gemini CLI.
66
88
 
67
89
  ## Quick Start
68
90
 
69
- ```bash
70
- # From Claude Code (agents run in split panes)
91
+ In Claude Code:
92
+ ```
71
93
  /swarm "add rate limiting to the API"
94
+ ```
72
95
 
73
- # From any terminal
74
- swarm orchestrate "add rate limiting to the API"
96
+ That's it. Agents spawn as teammates, research the codebase, implement the changes, and review the result. You see their work in split panes and get a summary when they're done.
75
97
 
76
- # Preview what will happen before running
77
- swarm plan "add rate limiting" --dry-run
98
+ Other slash commands for specific patterns:
99
+ ```
100
+ /research "how does the auth system work?"
101
+ /tdd "add input validation to user endpoints"
102
+ /red-team "harden the payment flow"
103
+ /review-cycle "refactor the database layer"
104
+ ```
105
+
106
+ ### Standalone CLI
107
+
108
+ You can also run orchestrations directly from any terminal, outside of Claude Code:
109
+
110
+ ```bash
111
+ swarm orchestrate "add rate limiting" # inline progress
112
+ swarm orchestrate "add rate limiting" --panes # tmux split panes
113
+ swarm orchestrate "add rate limiting" --tui # full-screen dashboard
114
+ swarm plan "add rate limiting" # preview plan (free)
78
115
  ```
79
116
 
117
+ The `--panes` flag uses tmux to show each agent in its own split pane. Install with `brew install tmux` (macOS) or `sudo apt install tmux` (Linux).
118
+
80
119
  ## VS Code and Cursor
81
120
 
82
121
  Swarm Engine ships with a VS Code extension that works in both VS Code and Cursor.
@@ -103,13 +142,49 @@ Then: `Cmd+Shift+P` > "Extensions: Install from VSIX" > select the `.vsix` file.
103
142
  @swarm status
104
143
  ```
105
144
 
145
+ ## Use as a Library
146
+
147
+ Swarm Engine can be imported directly into Node.js applications:
148
+
149
+ ```bash
150
+ npm install swarm-engine
151
+ ```
152
+
153
+ ```ts
154
+ import { SwarmEngine } from 'swarm-engine';
155
+
156
+ const engine = new SwarmEngine({ mock: true });
157
+ const result = await engine.orchestrate({
158
+ task: 'Build a REST API',
159
+ pattern: 'hybrid',
160
+ });
161
+ console.log(result.status);
162
+ ```
163
+
164
+ Key exports:
165
+
166
+ ```ts
167
+ import {
168
+ SwarmEngine, // Main orchestration engine
169
+ AgentRegistry, // Load and manage agent definitions
170
+ EventBus, // Typed event system for monitoring
171
+ PatternRegistry, // Composable orchestration patterns
172
+ BackendRegistry, // Multi-backend (Claude, Codex, Gemini)
173
+ CostModel, // Estimate token costs before running
174
+ ModelRouter, // UCB1-based model selection
175
+ TemplateRegistry, // Save and replay successful workflows
176
+ } from 'swarm-engine';
177
+ ```
178
+
179
+ See [src/index.ts](src/index.ts) for the full export surface.
180
+
106
181
  ## Why Swarm Engine
107
182
 
108
- AI coding agents work alone. You get one agent, one model, one approach. For complex tasks, that's not enough.
183
+ Tools like Claude Code already let you spawn parallel agents with teams. That's powerful infrastructure. Swarm Engine builds on top of it with the parts you'd otherwise have to figure out yourself: which agents to run, in what order, with what prompts, on which models, and how to learn from the results.
109
184
 
110
- Swarm Engine orchestrates multiple agents in parallel. Each has a specialized role, the right model for the job, and shared knowledge from past runs.
185
+ It gives you composable patterns, cost-aware planning, specialized agent definitions, and a memory system that improves with every run. Think of it as the orchestration layer that turns ad-hoc multi-agent work into repeatable workflows.
111
186
 
112
- - **7 composable patterns** - hybrid, TDD, red-team, spike, discover, review-cycle, research. Compose them: `--pattern "research | tdd | red-team"`
187
+ - **7 composable patterns** - hybrid, TDD, red-team, spike, discover, review-cycle, research. Compose them: `--pattern "tdd | red-team"`. Plus 12 slash commands including postmortem, diff-review, and fix-pr.
113
188
  - **Intelligent planner** - cost-based optimization, adaptive execution, learns from every run
114
189
  - **Mix any backend** - Claude for implementation, Codex for review, Gemini for research. Different model per agent.
115
190
  - **Reusable templates** - save successful workflows, run them again with different parameters
@@ -171,6 +246,8 @@ swarm plan "add auth middleware" --pattern hybrid
171
246
  | `/spike <problem>` | Two approaches compete, judge picks winner |
172
247
  | `/red-team <task>` | Adversarial build and break |
173
248
  | `/discover <problem>` | Hypothesize, experiment, implement winner |
249
+ | `/dynamic <task>` | Planner decomposes into custom agent workflow |
250
+ | `/postmortem <error>` | Root cause analysis, fix, and prevention |
174
251
  | `/fix-pr <PR#>` | Fix PR review comments |
175
252
  | `/resume` | Resume from checkpoint |
176
253
 
@@ -5,11 +5,25 @@ argument-hint: "[base-branch] (default: main)"
5
5
 
6
6
  You are reviewing the current branch's diff with parallel reviewers before creating a PR.
7
7
 
8
+ Follow the `swarm-output-style` skill for ALL output formatting.
9
+
8
10
  ## Task
9
11
  $ARGUMENTS
10
12
 
11
13
  ## Workflow
12
14
 
15
+ ### Step 0: Show Pre-flight Plan
16
+
17
+ Before creating any team or spawning any agent, show the plan:
18
+
19
+ Show the pre-flight plan (see swarm-output-style skill). Include:
20
+ - Base branch and diff summary (file count, approximate line count)
21
+ - The 3 reviewers with model and focus area
22
+ - Estimated cost (~$0.10 correctness, ~$0.10 security, ~$0.04 convention = ~$0.24 total)
23
+ - Estimated time (~5-10 min)
24
+
25
+ Wait for user approval before proceeding.
26
+
13
27
  ### Setup: Create Team
14
28
  1. Create a team with `TeamCreate` (name: `diff-review-<timestamp>`, e.g., `diff-review-1234`)
15
29
  2. Create tasks with `TaskCreate` for each reviewer focus area
@@ -21,13 +35,16 @@ Determine the base branch (default: `main` if no argument provided). Run:
21
35
  - Identify all changed files
22
36
 
23
37
  ### Step 2: Dispatch Reviewers (parallel)
38
+
39
+ Show the phase banner with running total (see swarm-output-style skill).
40
+
24
41
  Spawn 3 reviewer teammates simultaneously, each with `team_name`, `name` (e.g., `reviewer-correctness`, `reviewer-security`, `reviewer-convention`), and `run_in_background: true`, each with the full diff, commit history, and project CLAUDE.md:
25
42
 
26
43
  1. **Correctness reviewer** (opus) — Logic errors, edge cases, off-by-ones, error handling, race conditions, resource leaks
27
44
  2. **Security reviewer** (opus) — OWASP top 10, auth issues, injection, data exposure, secrets in code
28
45
  3. **Convention reviewer** (sonnet) — Project patterns, naming, structure, CLAUDE.md compliance, test coverage
29
46
 
30
- As each reviewer teammate completes, send it a `shutdown_request` via `SendMessage` to close its split pane.
47
+ As each completes: show a one-line verdict (PASS/FAIL + finding count) (see swarm-output-style skill), then send `shutdown_request` via `SendMessage`.
31
48
 
32
49
  ### Step 3: Aggregate
33
50
  Merge all findings and categorize by priority:
@@ -36,21 +53,14 @@ Merge all findings and categorize by priority:
36
53
  - **Suggestion** — note in PR description (style, optional improvements)
37
54
 
38
55
  ### Step 4: Recommend
39
- Based on findings, give one recommendation:
40
-
41
- ```
42
- ## Diff Review Results
43
-
44
- ### Findings
45
- | Priority | File | Line | Finding | Reviewer |
46
- |----------|------|------|---------|----------|
47
- | Critical | ... | ... | ... | ... |
48
56
 
49
- ### Verdict
50
- - **Critical issues found** "Fix these before creating a PR"
51
- - **Only Important/Suggestions** "Ready for PR — consider addressing these"
52
- - **Clean** "LGTM ready for PR"
53
- ```
57
+ Show the full post-completion summary (see swarm-output-style skill). Include:
58
+ - Status (PASS / NEEDS ATTENTION / FAILED)
59
+ - Metrics (agents, duration, tokens, cost)
60
+ - Review gate result with per-reviewer table (findings by severity)
61
+ - Consolidated findings table (Priority | File | Line | Finding | Reviewer)
62
+ - Verdict: "Fix these before creating a PR" / "Ready for PR — consider addressing these" / "LGTM — ready for PR"
63
+ - Next steps (git push, gh pr create, or fix commands)
54
64
 
55
65
  ### Cleanup
56
66
  1. Send `shutdown_request` via `SendMessage` to any remaining active teammates
@@ -62,3 +72,5 @@ Based on findings, give one recommendation:
62
72
  - Include full diff context for each reviewer — they cannot access git
63
73
  - This workflow is read-only — report findings, never fix anything
64
74
  - Include file:line references for every finding
75
+ - Follow the swarm-output-style skill for ALL output formatting
76
+ - Show the plan first, spend tokens second
@@ -0,0 +1,102 @@
1
+ ---
2
+ description: "Hypothesis-driven development — form theories, test cheaply, build the winner"
3
+ argument-hint: "<complex problem where the right approach is unclear>"
4
+ ---
5
+
6
+ You are running a discovery cycle: form hypotheses, test them cheaply, then implement the winner.
7
+
8
+ Follow the `swarm-output-style` skill for ALL output formatting.
9
+
10
+ ## Task
11
+ $ARGUMENTS
12
+
13
+ ## Workflow
14
+
15
+ ### Step 0: Show Pre-flight Plan
16
+
17
+ Before creating any team or spawning any agent, show the plan:
18
+
19
+ Show the pre-flight plan (see swarm-output-style skill). Include:
20
+ - All phases (Hypothesize, Experiment, Implement, Review)
21
+ - Agents per phase with model and focus
22
+ - Estimated cost (~$0.12 hypothesize, ~$0.12 experiment at sonnet rates, ~$0.19 implement, ~$0.20 review)
23
+ - Estimated time (~20-40 min total)
24
+
25
+ Wait for user approval before proceeding.
26
+
27
+ ### Setup: Create Team
28
+ 1. Create a team with `TeamCreate` (name: `discover-<timestamp>`)
29
+ 2. Create tasks with `TaskCreate` for each work unit
30
+
31
+ ### Phase 1: Hypothesize — parallel
32
+
33
+ Show the phase banner with running total (see swarm-output-style skill).
34
+
35
+ Spawn 2-3 researcher teammates (sonnet) simultaneously, each with `team_name`, `name`, and `run_in_background: true`:
36
+ - Each researcher explores a different angle of the problem
37
+ - Each proposes a hypothesis: "I think the best approach is X because Y"
38
+ - Each identifies what evidence would prove or disprove the hypothesis
39
+
40
+ As each completes: show a one-line completion summary (see swarm-output-style skill), then send `shutdown_request` via `SendMessage`.
41
+
42
+ Present the hypotheses to the user. Select 2-3 to test.
43
+
44
+ ### Phase 2: Experiment — parallel (cheap, fast)
45
+
46
+ Show the phase banner with running total (see swarm-output-style skill).
47
+
48
+ Spawn 2-3 implementer teammates (sonnet, not opus — keep it cheap) simultaneously, each with `team_name`, `name`, and `run_in_background: true`:
49
+ - Each builds a minimal proof-of-concept for one hypothesis
50
+ - NOT a full implementation — just enough to validate or invalidate
51
+ - Time-box: keep experiments under 5 minutes each
52
+ - Each reports: hypothesis confirmed or rejected, with evidence
53
+
54
+ As each completes: show a one-line completion summary (confirmed/rejected + key evidence) (see swarm-output-style skill), then send `shutdown_request` via `SendMessage`.
55
+
56
+ Present the experiment results. Identify the winning hypothesis.
57
+
58
+ ### Phase 3: Implement — sequential (depends on Phase 2)
59
+
60
+ Show the phase banner with running total (see swarm-output-style skill).
61
+
62
+ Spawn an implementer teammate (opus) with `team_name`, `name`, and `run_in_background: true`:
63
+ - Full implementation of the winning approach
64
+ - Informed by what was learned from ALL experiments (including failed ones)
65
+ - Include tests
66
+
67
+ As the teammate completes: show a one-line completion summary (see swarm-output-style skill), then send `shutdown_request` via `SendMessage`.
68
+
69
+ ### Phase 4: Review — parallel (depends on Phase 3)
70
+
71
+ Show the phase banner with running total (see swarm-output-style skill).
72
+
73
+ Spawn 2 reviewer teammates (opus) simultaneously with `team_name`, `name`, and `run_in_background: true`:
74
+ - **reviewer-correctness**: Logic, edge cases, error handling
75
+ - **reviewer-convention**: Project patterns, code style
76
+
77
+ As each completes: show a one-line verdict (PASS/FAIL + finding count) (see swarm-output-style skill), then send `shutdown_request` via `SendMessage`.
78
+
79
+ ### Phase 5: Report
80
+
81
+ Show the full post-completion summary (see swarm-output-style skill). Include:
82
+ - Status (PASS / NEEDS ATTENTION / FAILED)
83
+ - Metrics (phases, agents, duration, tokens, cost)
84
+ - Hypotheses tested (table with confirmed/rejected)
85
+ - Winner and rationale
86
+ - What was learned from rejected hypotheses
87
+ - What changed (files)
88
+ - Review gate result
89
+ - Next steps
90
+
91
+ ### Cleanup
92
+ 1. Send `shutdown_request` via `SendMessage` to any remaining active teammates
93
+ 2. Call `TeamDelete` to clean up the team
94
+
95
+ ## Rules
96
+ - All agents must be spawned as team members (TeamCreate → TaskCreate → Agent with team_name/name/run_in_background → SendMessage shutdown → TeamDelete)
97
+ - Experiments must be CHEAP — use sonnet, keep scope minimal, time-box to 5 minutes
98
+ - Failed experiments are valuable — include their learnings in the final implementation context
99
+ - The user approves the winning hypothesis before full implementation begins
100
+ - If no hypothesis is clearly better, recommend combining the best elements from multiple experiments
101
+ - Follow the swarm-output-style skill for ALL output formatting
102
+ - Show the plan first, spend tokens second
@@ -0,0 +1,136 @@
1
+ ---
2
+ description: "Let the planner decompose your task into a custom agent workflow -- no pattern selection needed"
3
+ argument-hint: "<any task -- the planner figures out the approach>"
4
+ ---
5
+
6
+ You are running a dynamic orchestration: instead of following a predefined pattern, the planner analyzes the task and builds a custom workflow.
7
+
8
+ Follow the `swarm-output-style` skill for ALL output formatting.
9
+
10
+ ## Task
11
+ $ARGUMENTS
12
+
13
+ ## Workflow
14
+
15
+ ### Step 0: Check Memory
16
+
17
+ Search for relevant context:
18
+ ```bash
19
+ cd ~/dev/swarm-engine && npx tsx src/cli/index.ts memory search "<relevant keywords>"
20
+ ```
21
+
22
+ ### Step 1: Analyze and Decompose
23
+
24
+ You ARE the planner. Analyze the task and decompose it into subtasks. For each subtask, decide:
25
+
26
+ 1. **What agent type** should handle it (researcher, implementer, reviewer, tester, debugger, refactorer, etc.)
27
+ 2. **What model** it needs (expensive tasks like security review get claude-opus-4-6, simple tasks like scanning get claude-sonnet-4-6)
28
+ 3. **What dependencies** it has (which subtasks must complete before this one can start)
29
+ 4. **What files** it will touch (no two agents should modify the same files)
30
+
31
+ Group subtasks into waves based on dependencies:
32
+ - **Wave 1**: Independent tasks that can run in parallel (typically research)
33
+ - **Wave 2**: Tasks that depend on Wave 1 results (typically implementation)
34
+ - **Wave 3**: Tasks that depend on Wave 2 (typically review, testing)
35
+ - Add more waves as needed
36
+
37
+ ### Step 2: Show Pre-flight Plan
38
+
39
+ Present the decomposition as a pre-flight plan:
40
+
41
+ ```
42
+ ## Dynamic Orchestration Plan
43
+
44
+ **Task**: [task description]
45
+ **Waves**: [N] | **Agents**: [N] | **Est. cost**: ~$[amount] | **Est. time**: ~[duration]
46
+
47
+ ### Wave 1 -- parallel (~[time], ~$[cost])
48
+ | Agent | Type | Model | Focus | Dependencies |
49
+ |-------|------|-------|-------|-------------|
50
+ | `name` | [type] | [model] | [what it does] | none |
51
+
52
+ ### Wave 2 -- parallel (~[time], ~$[cost])
53
+ | Agent | Type | Model | Focus | Dependencies |
54
+ |-------|------|-------|-------|-------------|
55
+ | `name` | [type] | [model] | [what it does] | Wave 1 |
56
+
57
+ [repeat for all waves]
58
+
59
+ **File ownership:**
60
+ | Agent | Files |
61
+ |-------|-------|
62
+ | `name` | [files this agent will touch] |
63
+
64
+ Proceed?
65
+ ```
66
+
67
+ Wait for user approval before proceeding.
68
+
69
+ ### Step 3: Create Team and Execute
70
+
71
+ 1. `TeamCreate` (name: `dynamic-<timestamp>`)
72
+ 2. `TaskCreate` for each wave
73
+
74
+ Execute each wave in order:
75
+
76
+ For each wave:
77
+ 1. Show the phase banner with running total
78
+ 2. Spawn all agents in this wave in parallel, each with `team_name`, `name`, and `run_in_background: true`
79
+ 3. Include context from all completed previous waves
80
+ 4. As each completes: show a one-line completion summary, then send `shutdown_request`
81
+ 5. After all agents in the wave complete: show wave summary
82
+
83
+ **Between waves**: If any agent failed or returned low confidence, show error recovery options before proceeding to the next wave.
84
+
85
+ ### Step 4: Quality Gate
86
+
87
+ After the final wave, assess the combined output:
88
+ - Did all agents succeed?
89
+ - Are there file conflicts or inconsistencies between agent outputs?
90
+ - Do the changes compile/pass linting?
91
+
92
+ If issues found, spawn a fixer agent to resolve them.
93
+
94
+ ### Step 5: Record and Report
95
+
96
+ Store results in engine memory:
97
+ ```bash
98
+ echo "<outcome summary>" | cd ~/dev/swarm-engine && npx tsx src/cli/index.ts memory store outcome "<title>" --repo "<repo>"
99
+ ```
100
+
101
+ Show the full post-completion summary (see swarm-output-style skill). Include:
102
+ - Status
103
+ - Wave breakdown (which agents ran in each wave)
104
+ - Metrics (waves, agents, duration, tokens, cost)
105
+ - What changed (files with git diff --stat)
106
+ - Quality gate result
107
+ - Next steps
108
+
109
+ ### Cleanup
110
+ 1. Send `shutdown_request` to any remaining active teammates
111
+ 2. Call `TeamDelete` to clean up the team
112
+
113
+ ## Decomposition Guidelines
114
+
115
+ When deciding how to break down a task:
116
+
117
+ **Research first**: Always start with at least one researcher to understand the codebase before modifying it.
118
+
119
+ **Parallelize aggressively**: If two subtasks touch different files and don't depend on each other, run them in parallel.
120
+
121
+ **Right-size agents**: Use the cheapest model that can handle the task. Research and scanning with sonnet. Implementation and review with opus.
122
+
123
+ **File ownership**: Each file should be owned by exactly one agent. If two agents need the same file, make one depend on the other.
124
+
125
+ **Review everything**: The final wave should always include at least one reviewer checking the combined output.
126
+
127
+ **Keep it simple**: Most tasks need 2-4 waves and 3-8 agents. Don't over-decompose a task that one agent could handle. If the task is simple, use 1 wave with 1-2 agents.
128
+
129
+ ## Rules
130
+ - Show the plan first, spend tokens second
131
+ - All agents must use team protocol (TeamCreate, Agent with team_name/name/run_in_background, SendMessage shutdown, TeamDelete)
132
+ - No two agents modify the same files in the same wave
133
+ - Every agent dispatch includes full context from previous waves
134
+ - Always include a review step in the final wave
135
+ - Follow the swarm-output-style skill for ALL output formatting
136
+ - Maximum 6 waves -- if you need more, the task should be split into separate orchestrations
@@ -5,6 +5,8 @@ argument-hint: "<PR number or URL>"
5
5
 
6
6
  You are fixing PR review comments by dispatching parallel implementers grouped by file.
7
7
 
8
+ Follow the `swarm-output-style` skill for ALL output formatting.
9
+
8
10
  ## Task
9
11
  $ARGUMENTS
10
12
 
@@ -25,46 +27,48 @@ For each file group, classify every comment:
25
27
  - **Nit/style fix** → assign to implementer (sonnet)
26
28
  - **Question/discussion** → skip, include in report
27
29
 
28
- ### Step 3: Present Plan
29
- Show the user the dispatch plan:
30
+ ### Step 3: Show Pre-flight Plan
31
+
32
+ Show the pre-flight plan (see swarm-output-style skill). Use the dispatch plan format:
30
33
 
31
34
  ```
32
- ## Fix Plan
35
+ ## Orchestration Plan
36
+
37
+ **Task**: Fix [N] review comments across [M] file groups for PR #[number]
38
+ **Pattern**: parallel-fix | **Phases**: 1 | **Agents**: [N] | **Est. cost**: ~$[amount] | **Est. time**: ~[duration]
33
39
 
34
- | File Group | Comments | Agent | Model | Summary |
35
- |------------|----------|-------|-------|---------|
36
- | src/foo.py | 3 | implementer | opus | [what to fix] |
37
- | src/bar.py | 1 | implementer | sonnet | [style nit] |
38
- | src/baz.py | 2 | (skipped) | | [questions only] |
40
+ ### Phase 1: Fix -- parallel (~[time], ~$[cost])
41
+ | Agent | Model | Focus |
42
+ |-------|-------|-------|
43
+ | `fixer-foo` | opus | src/foo.py [what to fix] |
44
+ | `fixer-bar` | sonnet | src/bar.py — [style nit] |
45
+ | `fixer-baz` | — | src/baz.py — SKIPPED (questions only) |
46
+
47
+ Proceed?
39
48
  ```
40
49
 
41
- Ask the user to approve before proceeding.
50
+ Wait for user approval before proceeding.
42
51
 
43
52
  ### Step 4: Dispatch Implementers
53
+
54
+ Show the phase banner with running total (see swarm-output-style skill).
55
+
44
56
  Spawn one implementer teammate per file group, ALL in parallel, each with `team_name`, `name` (e.g., `fixer-foo`, `fixer-bar`), and `run_in_background: true`. Each dispatch includes:
45
57
  - The exact comment text for their file(s)
46
58
  - The full PR diff for context
47
59
  - The original PR description
48
60
  - Clear instructions on what to change
49
61
 
50
- As each teammate completes, send it a `shutdown_request` via `SendMessage` to close its split pane.
62
+ As each completes: show a one-line completion summary (see swarm-output-style skill), then send `shutdown_request` via `SendMessage`.
51
63
 
52
64
  ### Step 5: Report
53
- Once all implementers complete, produce a summary:
54
65
 
55
- ```
56
- ## PR Fix Report
57
-
58
- ### Comments Addressed
59
- - [file:line — what was fixed, which comment]
60
-
61
- ### Comments Skipped
62
- - [file:line — why (question/discussion)]
63
-
64
- ### Next Steps
65
- - Push changes: `git push`
66
- - Re-request review: `gh pr edit <the PR> --add-reviewer [reviewer]`
67
- ```
66
+ Show the full post-completion summary (see swarm-output-style skill). Include:
67
+ - Status (PASS / NEEDS ATTENTION)
68
+ - Metrics (agents, duration, tokens, cost)
69
+ - Comments addressed (file:line — what was fixed, which comment)
70
+ - Comments skipped (file:line — why)
71
+ - Next steps (git push, re-request review)
68
72
 
69
73
  ### Cleanup
70
74
  1. Send `shutdown_request` via `SendMessage` to any remaining active teammates
@@ -76,3 +80,5 @@ Once all implementers complete, produce a summary:
76
80
  - Group by file to avoid merge conflicts between parallel implementers
77
81
  - Include the exact comment text in each implementer dispatch
78
82
  - Use opus for logic/behavior changes, sonnet for style/nit fixes
83
+ - Follow the swarm-output-style skill for ALL output formatting
84
+ - Show the plan first, spend tokens second