Open Source · MIT License

essaim

Spawn N coordinated Claude Code agents on your repo. Pick a preset — the orchestrator does the rest.

0 templates
0 BCE behaviors
0 presets
0effort levels
$ essaim run raid -p . --agents 4 --preset bug-hunt
⬡ spawning 4 agent-loops in parallel worktrees
Alpha discover → 12 findings   Beta discover → 9 findings   dedup via review…
✅ 7 tasks claimed & merged — zero conflicts, zero duplicate work

Why essaim?

Scale your team's AI agents without the chaos.

Multiple agents, one aligned process

Run several agents per developer on different tasks. Several developers with their own agents on the same repo. Specialize by role — one codes, one reviews, one tests. Effort profiles auto-pick Haiku / Sonnet / Opus per phase so you don't waste Opus tokens on coordination chatter.

💻 Dev A
agent-loop
phase: execute
src/auth
💻 Dev B
agent-loop
phase: discover
src/api
🧪 Tester
Sonnet (mid)
📝 Reviewer
Haiku (low)

Agents hear each other through MQTT — no sidecar

The agent-loop subscribes to the embedded MQTT broker once. Conflicts, messages, claims and resolutions arrive in real-time and are drained between turns. No separate liaison process, no polling, no extra tokens burned on coordination chatter.

Worker Alpha announce_work("Refactor auth")
mqtt coordinator/consultations/new score 100
push → Beta's loop queue
Agent Beta post_to_thread("compatible, will rebase")
✅ propose_resolution → approved in 38s

Dogfood everything

6 agents coordinated via work-stealing phases to rewrite the coordinator's own unit tests from scratch. Another raid found and patched 11 real bugs in the coordinator itself. Zero duplicated work, zero merge conflicts — all via the coordinator's own announce/MQTT/consensus loop.

La Mêlée run

Agents6 (agent-loop)
Phasesdiscover → execute
Threads opened8
MQTT messages exchanged25
Consensus7 reached · 0 duplicates
Tests produced~2 400 lines
Total tests (suite)652

See everything, miss nothing

A live SSE dashboard shows every decision in real-time. Who's working on what, which conflicts were detected, how they were resolved. Per-agent token gauge, Anthropic quota widget, scoring-layer breakdown. Complete traceability — every coordination decision is logged.

Alpha
Beta
Gamma
Delta
09:41 Alpha announced → types.ts
09:41 ⚡ Conflict scored 100
09:42 ✅ Consensus reached
2 consultations  ·  1 conflict  ·  45s avg

Zero conflicts. Everyone aligned.

Intent detection before code is written. Impact scoring across 4 layers. Automatic consultation when scores exceed thresholds. The coordinator doesn't replace developers — it eliminates the chaos when multiple agents work in parallel. Your agents, your repo, your rules — just without the collisions.

The coordination problem

AI coding agents accelerate individual work — but create new team-level problems when running in parallel.

💥

Regressions

Two agents touch the same file simultaneously. One's changes silently overwrite the other's. The bug only shows up in review — or production.

🔁

Duplicated effort

Without visibility into each other's intent, two agents implement the same feature with different APIs, different schemas, different assumptions.

🌫️

No visibility

Nobody knows what the other agents are doing. Plans stay local, decisions are invisible. Misalignment compounds silently until it explodes.

How it works

A lightweight coordination loop that runs before every coding session, not after.

1
📢

Announce

Agent declares intent — task description, target files, affected modules — before writing a single line of code.

2
🎯

Detect

The scorer evaluates overlap against all active intents across 4 layers: file, dependency, module, and semantic proximity.

3
💬

Consult

The coordinator publishes the new thread on MQTT. Each affected agent-loop drains the event between turns and posts context, constraints, or a resolution proposal — no separate sidecar process.

4

Resolve

Proposals are approved, contested, or re-proposed. The thread closes on consensus, or auto-resolves in gray zones. All decisions land on the dashboard timeline.

MQTT — the coordinator's nervous system

Every coordination event fans out on an embedded MQTT broker. Agents subscribe once and drain messages between turns — zero polling, zero sidecar.

📡

Embedded Aedes broker

The coordinator ships its own broker — no Mosquitto, no RabbitMQ to deploy. TCP on port 1883 for local/LAN, WebSocket on /mqtt over the coordinator's HTTP port for remote agents and the Bun binary.

Push, not poll

The agent-loop subscribes to every coordinator topic at startup. New threads, messages, claims and completions arrive through a queue drained between turns — latency < 50ms end-to-end with zero wasted tokens.

🛡

Self-filter built-in

Each message carries an agent_id. The listener drops messages from the local agent, so the loop never wakes itself on its own actions. One less tokens-burning rabbit hole.

Topic map

Eight topics cover every event class. Wildcards (+) let agents subscribe to all threads at once.

Topic Emitted when Key payload
coordinator/consultations/new A thread is opened thread_id, subject, initiator_id, target_files
.../consultations/+/messages Someone posts to a thread agent_id, name, content, type
.../consultations/+/status Thread transitions state status: open/resolving/resolved/timeout
.../consultations/+/claimed Work-stealing claim (atomic) claimed_by, thread_id
.../consultations/+/completed Claimed task finishes agent_id, thread_id, resolution
coordinator/agents/+/status Agent online / offline status, name, modules
coordinator/broadcast System-wide announcement arbitrary JSON
coordinator/quota/update Anthropic quota refresh usage, limit, utilization_pct

Push delivery flow

# Coordinator publishes an event
coordinator.bridge.publish("coordinator/consultations/new", payload)
 
# Broker fans out over TCP 1883 or WS /mqtt
aedes → subscribers → agent-loop queue
 
# Agent-loop, between two turns
const interrupts = listener.drain()
const context = buildInterruptContext(interrupts)
claude.resume({ prompt: context, model: effort.model })
 
✅ next turn sees "you have a pending thread on types.ts"

BCE — Behavior Composition Engine

Every agent prompt, hook, and MCP config is assembled — not hand-written. Pick a preset, BCE resolves the behaviors, applies composition rules, and emits prompt.md + hooks/*.sh + .mcp.json.

32 behaviors
20 presets
3 composition rules
3 workflow phases
4 behavioral layers

How the engine assembles an agent

A preset names the behaviors. The engine resolves, validates, composes, and emits three artifacts.

Preset
raid.yaml
BCE engine
resolve · validate · compose · assemble
prompt.md
hooks/*.sh
 
.mcp.json

Four behavioral layers, deterministic section order

Each behavior contributes numbered sections. Layers guarantee a stable prompt shape no matter the preset.

Foundationwho am I, which project · project-context, coordinator-rules
000–009
layer 1
Patternshow I coordinate · worktree, shared, sequential-wait, announce, conflict-resolution
010–029
layer 2
Missionwhat I actually do · bug-hunting, test-writing, quality-audit, phase-discover, phase-execute, phase-review, …
030–050
layer 3
Transversalstyle and safety · activity-tracking, read-only-mode
050–099
layer 4

Composition rules adapt behavior combinations

Three rules rewrite or strip sections when certain behaviors are combined — so a read-only agent doesn't say "before modifying" and a solo agent doesn't mention coordination at all.

announce-readonly-adaptation

When announce-before-write meets read-only-mode, section 020 is rewritten as "before your analysis" instead of "before modifying".

sequential-then-announce

When sequential-wait meets announce-before-write, section 012 is injected: "wait for predecessor → announce → code".

solo-mode-strip

When coordinator-rules.solo_mode = true, the engine strips announce + conflict-resolution entirely and overrides context with "you work alone".

Phases & work-stealing

Behaviors can declare a phase. When a preset has phased behaviors, the agent-loop executes them sequentially with different tool permissions. The execute phase loops: each agent atomically claims one task from the pool, runs it, drains MQTT, claims the next.

Phase Tools Loop Purpose
discover read_only no Scan code, list findings. Each agent explores independently.
review none no Compare discoveries to existing threads. Emit NEW/DUP/ENRICH actions — dedup the pool.
execute full yes Work-stealing loop: atomic claim via /api/claim-task, execute, DONE, claim next. Grace period before exit.
(no phase) full no One-shot mode (backward-compat). Preset runs as a single claude session.

Effort profiles pick the model per phase

Four levels map to model + thinking keyword + turn budget. Cheap Haiku for ack chatter, full Opus with ultrathink for architecture debates — scoped phase by phase.

Level Model Thinking maxTurns Use case
low claude-haiku-4-5 none 15 MQTT ack, coordination chatter, trivial review
mid claude-sonnet-4-6 think 8 Discover phase, standard execute, dispatched workers
high claude-opus-4-6 think-hard 20 Complex execute with thinking headroom
max claude-opus-4-6 ultrathink 60 Architecture debates, deep reasoning

One CLI to compose, inspect and build

$ essaim bce list behaviors
32 behaviors — foundation / patterns / mission / transversal
 
$ essaim bce list presets
21 presets — raid, melee, essaim, chaine, revue, maitre, …
 
$ essaim bce build raid --dry-run
# Preview prompt.md + hooks + .mcp.json without writing to disk
 
$ essaim bce build raid \
  --set coordinator-rules.solo_mode=true \
  --set bug-hunting.modules='["src/auth"]'

Why not just git worktrees?

Worktrees are necessary but not sufficient. They solve file access — the coordinator solves coordination.

📂

Worktrees prevent file conflicts

Git worktrees isolate at the filesystem level. Two agents can't overwrite the same file. But they CAN produce logically incompatible changes that merge cleanly and break at runtime.

🎯

The coordinator prevents intent conflicts

By announcing intentions before coding, agents know what others are planning. A worktree won't tell Agent B that Agent A is about to change the User interface it depends on.

🤝

Use both together

Worktrees handle the filesystem. The coordinator handles the semantics. Together: zero file conflicts AND zero intent conflicts.

4-layer conflict scoring

Every intent is scored 0–100 against all active agents. Score determines the response.

Same file announced — both agents target the exact same source file
100
Blocking — consult required
Dependency overlap — one agent's output is consumed by the other's module
80
Gray zone — review
Module overlap — agents work in the same bounded context or feature area
30
Gray zone — monitor
No link — fully independent tasks, no shared files or modules
0
Pass — proceed safely

How agents communicate

Two modes of operation — interactive sessions or automated pipelines.

Interactive

Claude Code sessions

Each developer runs claude normally. Session hooks auto-register the agent, attach the agent-loop's MQTT listener, and track file edits. Coordination is transparent.

Developer starts claude
session-start hook fires
Register + subscribe MQTT
Identity & modules · Aedes subscribe · dependency map load
Developer works normally
announce_work · Edit files · heartbeat
Between-turn MQTT drain
New threads · claims · resolutions injected into next prompt
Developer closes claude
session-stop hook fires
Release MQTT · set offline · release claims
Orchestrated

Work-stealing templates

essaim run <template> launches N agent-loops in parallel worktrees. Each runs the phased protocol: discover in read-only, dedup via review, then atomically claim tasks from the shared pool until drained.

run raid -p . --agents 3
Phase 1 — DISCOVER (read-only)
each agent scans independently · lists findings
Phase 2 — REVIEW (dedup)
compare to pool · NEW / DUP / ENRICH
Agent 1 — EXECUTE
claim → fix → DONE → claim next
Agent 2 — EXECUTE
claim → fix → DONE → claim next
Agent N — EXECUTE
claim → fix → DONE → claim next
atomic
claim via
MCP

MQTT push
Pool drained — report
token breakdown · dashboard timeline · worktrees ready to merge

Real-time dashboard

Observe what every agent is doing, what conflicts were detected, and what decisions were reached.

Alpha — working
Beta — idle
Gamma — waiting
Delta — offline
essaim v0.1.0 · quota 62%
09:41:02 Alpha announced: "Add updated_at to User" → types.ts, user.service.ts
09:41:03 Beta announced: "Migrate User schema" → types.ts, migrations/
09:41:04 ⚡ Conflict scored 100 (layer 0a) — same file: types.ts — thread T-812 opened
09:41:09 Alpha post_to_thread: "adding a single field, no interface rename"
09:41:14 Beta post_to_thread: "compatible — I'll add migration after your field lands"
09:41:21 Alpha propose_resolution → status resolving
09:41:38 ✅ Consensus — Alpha proceeds, Beta waits (38s)
09:42:05 quota_update — utilization 62.4% · +180k tokens last 5min

Get started in 3 steps

Self-hosted, no cloud dependency. Runs locally with Docker.

Step 1

Start the coordinator

One binary. MCP server, Aedes MQTT broker and dashboard — all in one process.

npm install -g essaim
Step 2

Initialize your project

Writes BCE-assembled hooks + .mcp.json into your project. Picks up the coordinator URL + your identity.

essaim init ~/project \
--url http://localhost:3100 \
--name "Alice" \
--preset bug-hunt
Step 3

Run your first swarm

Launch Claude normally — the agent-loop is transparent. Or dispatch a template with N coordinated agents.

cd ~/project && claude
# or
mcp-coordinator run raid -p . --agents 3

Validated scenarios

Four canonical conflict scenarios — all tested, all resolved correctly.

Scenario Description Score Outcome
S1 Same file targeted by two agents simultaneously 100 Consultation triggered → consensus reached
S3 Agent A's module depends on Agent B's current output 80 Gray zone — dependency flagged, agents notified
S2 Both agents work within the same feature module 30 Gray zone — monitored, no blocking
S4 Fully independent tasks, no shared files or modules 0 Auto-resolved — both agents proceed

12 Behavioral Templates

Pre-composed behavioral presets. Each template assembles agents from reusable YAML behaviors — coordination, workspace, mission, safety.

Foundation
Coordination
Mission
Safety
🐛
Le Raid
N chasseurs traquent les bugs en parallele. Chacun annonce avant d'ecrire un test pour eviter les doublons.
Chasseur 1 Chasseur 2 Chasseur 3 | | | announce announce announce | | | hunt bugs hunt bugs hunt bugs write test write test write test | | | +-------conflict?-------+ resolve
2-3 agents parallel codeur
project-context · coordinator-rules
worktree · announce · conflict-resolution
phase-discoverphase-execute · bug-hunting
🧪
La Melee
N agents ecrivent des tests en free-for-all. Coordination pour eviter les doublons sur les memes fichiers.
Agent A Agent B Agent C Agent D | | | | announce announce announce announce | | | | write write write write tests tests tests tests +---------+-dedup-+---------+
2-6 agents parallel codeur
project-context · coordinator-rules
worktree · announce · conflict-resolution
phase-discoverphase-execute · test-writing
🧹
L'Essaim
N agents refactorisent des tranches de fichiers en parallele. Revert automatique si les tests echouent.
files: [a b c] [d e f] [g h i] Ref.1 Ref.2 Ref.3 | | | rename extract simplify cleanup functions conditions | | | test OK test OK test FAIL revert
3-6 agents parallel codeur
project-context · coordinator-rules
worktree · announce · conflict-resolution
phase-discoverphase-execute · parallel-refactoring
La Chaine
Pipeline sequentiel: implementeur, reviewer, testeur. Chaque etape attend la precedente.
Implementeur ---> Reviewer ---> Testeur (codeur) (read-only) (codeur) | | | analyse attends attends implemente lit code lance tests propose observe ajoute tests approve? verifie pass
3 agents sequential mixed sequential-then-announce
project-context · coordinator-rules
worktree · sequential-wait · announce
implement · review · test
read-only-mode (reviewer)
🏃
Le Relais
3 coureurs se relaient. Chacun documente son travail pour le suivant. Amelioration cumulative.
C1 Nettoyage ---> C2 Archi. ---> C3 Finition | | | duplication extraire fns coherence noms clairs separation docs imports morts complexite edge cases | | | notes pour C2 notes pour C3 bilan final
3 agents sequential codeur sequential-then-announce
project-context · coordinator-rules
worktree · sequential-wait · announce · conflict-resolution
relay-runner (step 1/2/3)
🔍
La Revue
N auteurs + N reviewers en assignation croisee. Reviewer i review le module de Auteur (i+1) % N.
Auteur A ---review---> Reviewer B module: auth review: auth approve / contest Auteur B ---review---> Reviewer A module: users review: users
2-4 pairs parallel mixed
project-context · coordinator-rules
worktree · announce
code-review-author · code-review-reviewer
read-only-mode (reviewer)
👑
Le Maitre
1 tech lead analyse et distribue. N workers executent les taches assignees en parallele.
Tech Lead (communicant) analyse projet identifie taches +------+------+ | | | Worker Worker Worker attend attend attend execute execute execute +------+------+ lead: resume
1 + 2-4 hierarchy mixed
project-context · coordinator-rules
worktree (workers) · shared (lead) · announce
task-distribution · task-execution
🛡
Le Gardien
1 agent analyse la qualite du projet en 6 categories. Read-only, aucune modification.
Le Gardien (communicant) | +-----+-----+ | | | Structure Conv. Complexite | | | Dette Tests Docs +-----+-----+ Rapport global
1 agent shared communicant announce-readonly
project-context · coordinator-rules
shared-workspace · announce
quality-audit
read-only-mode
💬
Le Debat
3 agents debattent comment restructurer du code. Aucun code produit — consensus uniquement.
Separation Strategy Minimal | | | propose propose propose +--------debate--------+ arguments reponses consensus (aucun code produit)
3 agents shared communicant announce-readonly
project-context · coordinator-rules
shared-workspace · announce
debate-position (param: position)
read-only-mode
🌐
Babel
Traducteur + reviseur sequentiel. Preserve la structure Markdown, ne traduit pas le code.
Traducteur --------> Reviseur lit *.md lit original traduit + traduction preserve MD fidelite? pas le code naturalite? propose terminologie?
2 agents sequential communicant sequential-then-announce
project-context · coordinator-rules
worktree · sequential-wait · announce
translation · translation-review
🎮
L'Arene
Quiz competitif sur la base de code. Le quizmaster pose, les joueurs repondent en citant le code.
Quizmaster lit 5+ fichiers pose 5 questions +----------+ | | Joueur A Joueur B repond repond cite code cite code +----------+ juge + score
3 agents shared communicant announce-readonly
project-context · coordinator-rules
shared-workspace · announce
quiz-master · quiz-player
read-only-mode
Le Carrefour
Test de detection de conflits. Agents travaillent sur les memes fichiers volontairement.
shared files: [a.ts b.ts c.ts] | | | Alpha Bravo Charlie lisibilite perf. robustesse +----------+---------+ CONFLIT! consultation consensus implement AFTER
2-3 agents parallel codeur
project-context · coordinator-rules
worktree · announce · conflict-resolution
conflict-test

Built with itself

We used the coordinator to coordinate 4 agents writing tests for the coordinator.

$ essaim run raid -p . --agents 3 --max-quota-pct 90
Pre-flight: workspace quota 62.4% → OK
3 worktrees · 3 agent-loops · Aedes broker ready
Phase DISCOVER (read-only, Sonnet+think)
Chasseur-1 found 5 · Chasseur-2 found 4 · Chasseur-3 found 6
Phase REVIEW (dedup) → 11 unique findings posted
4 duplicates detected and skipped via phase-review
Phase EXECUTE (work-stealing, loop) → 11 fixes committed
All claims atomic via /api/claim-task · zero double-work
Result: 11 real bugs patched · 652 tests still green · token report written

Roadmap

Where we're going next.

Done

v0.1 — Initial release

12 portable templates, 32 BCE behaviors, 21 presets, 4 effort levels. Work-stealing phases (discover → review → execute). MQTT coordination via embedded Aedes broker. Token diagnostics and quota pre-flight.

In Progress

v0.2 — Stabilization

Test coverage to 100%. Gray-zone introspection (score 30–89) validated end-to-end. TLS + remote MQTT for team setups. Per-team quota partitioning.

Planned

v0.3 — Plugin presets

Community preset registry. Publish and install presets via npm. Custom behavior authoring guide. IDE integration for preset browsing.

Planned

v1.0 — Cross-repo swarms

Coordinate agent swarms across multiple repositories. Shared dependency map across microservice and monorepo boundaries. Directed lead→worker dispatch for large-scale raids.

Future

Long-term — Semantic conflict detection

AST-level analysis above filename scoring. Detect API contract changes, interface incompatibilities, and breaking changes before any thread opens. tengu_harbor server-gated push integration.