Installation
For most users, the fastest path is the npm install. Source install is best when you want to work on crewswarm itself.
Fastest path: npm
npm install -g crewswarm
crewswarm
Contributor path: clone the repo
git clone https://github.com/crewswarm/crewswarm.git
cd crewswarm
Install dependencies and run setup
npm install
bash install.sh
Start the local stack
npm run restart-all
Once running, open the dashboard at http://127.0.0.1:4319 and Vibe at http://127.0.0.1:3333.
System Services
| Service | Port | Role |
|---|---|---|
| RT Message Bus | 18889 |
Real-time agent communication backbone. |
| Sub-Agents | - |
Worker Bridges (crew-coder, crew-pm, etc.). |
| crew-lead | 5010 |
Chat commander — dashboard chat, crewchat, Telegram. |
| Telegram Bridge | - |
@crewswarm_bot → crew-main. |
| WhatsApp Bridge | - |
Personal bot via Baileys linked device. |
| Code Engine | 4096 |
Coding execution server for external runtimes and engine lanes. |
| Dashboard | 4319 |
Setup, providers, agent management, chat, and runtime visibility. |
| MCP + OpenAI API | 5020 |
MCP tools + /v1/chat/completions for Open WebUI, LM Studio, Aider. |
| Vibe UI | 3333 |
Browser workspace for files, quick edits, engine chat, and live agent visibility. |
| Vibe Watch Server | 3334 |
CLI → Vibe live reload WebSocket relay. |
| OpenClaw Gateway | 18789 |
Optional legacy service for the OpenClaw desktop app. |
| PM Loops | - |
Planning, delegation, and review loops coordinated by crew-lead and the runtime. |
Execution Modes
CrewSwarm supports six CLI execution engines, a native executor, and a direct API mode. Coding roles (crew-coder, crew-fixer, crew-coder-front/back) should always run through a CLI engine so they get tool access, file edits, and terminal capabilities. Analysis and planning roles can use Direct API.
Direct API
Agents call LLMs (Groq, Anthropic, OpenAI, Google, xAI) directly. Best for analysis, planning, and chat-only roles that don't require file system access.
OpenCode (Default)
Recommended coding runtime for many agent tasks. Good fit when you want tool access, file edits, and sandboxed execution in one lane.
Claude Code CLI
Uses Anthropic's native claude -p CLI for tasks that benefit from its codebase reasoning and workflow style. Runs Claude Sonnet 4.6 or Opus 4.6.
Cursor CLI
Uses Cursor's CLI when you want its composer workflow, model access, and editor-style coding lane inside the swarm. Default model: composer-2-fast.
Gemini CLI
Uses Google's gemini CLI for tasks that benefit from Gemini's large context window and multimodal capabilities. Runs Gemini 2.5 Flash or 3.1 Pro.
Codex CLI
Uses OpenAI's codex CLI for coding tasks routed through GPT-5.x models. Good fit for code generation, edits, and tool-use workflows via OpenAI's stack.
crew-cli (Native)
CrewSwarm's built-in L3 executor with 45+ built-in tools (LSP, git, web, memory, tracker). Multi-model routing, JIT context discovery, and streaming output without an external CLI dependency.
Engine selection: crew config set engine <name> or pass --engine per task. Set to auto to let the runtime pick based on role and model.
Git Worktree Isolation
When a PM loop dispatches multiple agents in the same wave, each agent automatically gets its own git worktree — an isolated copy of the repo on its own branch. Parallel agents can't conflict with each other on the filesystem.
How it works
- Wave dispatcher creates a worktree per agent at
/tmp/crewswarm-wt-{pipelineId}-{agentId} - Each agent receives its isolated directory as
projectDir— works with any engine (Claude Code, Codex, Gemini, Cursor, OpenCode, crew-cli) - After the wave completes, all branches merge back automatically and conflicts are reported via SSE
- Worktrees are cleaned up on completion or cancellation
Configuration
- Enabled by default for multi-agent waves (2+ agents)
- Single-agent waves skip worktree overhead automatically
- Disable globally:
CREWSWARM_WORKTREE_ISOLATION=false - Disable per-pipeline: set
worktreeIsolation: falsein the pipeline spec - Falls back to shared directory if git is unavailable or the project isn't a repo
Session Management
The CLI persists every conversation as a crash-safe JSONL transcript. Sessions survive unexpected exits and can be resumed at any time.
/sessions — List past sessions with turn count, token usage, and the first message of each conversation.
crew /sessions
/resume [id] — Resume a previous session. When called without an ID, an interactive picker is displayed. Pass a session ID directly to skip the picker.
# Interactive picker
crew /resume
# Resume a specific session
crew /resume abc123
/clear — Wipe the current session transcript and start fresh.
crew /clear
Transcripts are stored in JSONL format — one JSON object per line — so partial writes from crashes never corrupt the file. Each line records the role, content, timestamp, and token count.
Tool Hooks
Hooks let you intercept tool calls before or after execution. Define them in .crew/hooks.json at your project root.
Configuration format
{
"hooks": {
"PreToolUse": [
{
"matcher": "shell|run_cmd",
"command": "node .crew/validate-shell.js",
"timeout": 5000
}
],
"PostToolUse": [
{
"matcher": ".*",
"command": "node .crew/log-tool.js",
"timeout": 3000
}
]
}
}
PreToolUse hooks fire before a tool runs. The tool input is piped as JSON on stdin. Your hook script can:
- Allow — exit 0 with no output to let the call proceed unchanged.
- Deny — exit non-zero to block the tool call entirely.
- Modify — exit 0 and write modified JSON to
stdoutto change the tool input.
PostToolUse hooks fire after a tool completes. The tool output is piped as JSON on stdin. Use these for logging, auditing, or triggering side effects.
The matcher field is a regex tested against the tool name. The timeout field (in milliseconds) kills the hook process if it exceeds the limit.
Git Worktree Isolation
Agents can work in an isolated Git worktree so your main working directory stays untouched.
enter_worktree — Creates a new branch and a separate working directory. The agent operates entirely inside this worktree, leaving your checked-out files unchanged.
crew enter_worktree feature/new-api
exit_worktree — Tears down the worktree. If no changes were made, the branch and directory are automatically cleaned up. If the branch has commits, it is kept so you can review or merge later.
crew exit_worktree
merge_worktree — Merges the worktree branch back into your current branch and cleans up the worktree directory.
crew merge_worktree feature/new-api
This is especially useful for long-running or speculative tasks where you want to inspect results before they affect your working tree.
CLI Environment Variables
These environment variables control CLI behavior. Set them in your shell profile or pass them inline.
| Variable | Default | Description |
|---|---|---|
CREW_NO_STREAM |
false |
Set to true to disable streaming and receive the full response at once. |
CREW_HOOKS_FILE |
.crew/hooks.json |
Path to the hooks configuration file. Override to use a custom location. |
CREW_MAX_SESSION_TOKENS |
100000 |
Token budget for a single session. The CLI warns and pauses when the limit is approached. |
# Example: run with streaming disabled and a 50K token budget
CREW_NO_STREAM=true CREW_MAX_SESSION_TOKENS=50000 crew "refactor auth module"
Token-Aware Compaction
Long sessions accumulate context. Instead of blindly truncating old messages, crew-cli adapts compression based on how full the context window is:
- < 50% used — light compression, keeps first 5 + last 8 turns in full detail
- 50–75% used — standard compression, first 3 + last 5 detailed, middle summarized
- > 75% used — aggressive, first 1 + last 3 detailed, everything else compressed
Per-model context window sizes are known (Gemini 1M, GPT-4o 128K, Claude 200K, etc.) so compression is tuned automatically. Token estimation uses a ~3.7 chars/token ratio — no external tokenizer dependency.
Set CREW_MAX_SESSION_TOKENS to control the token budget for session transcripts (default: 100K).
Swarm Chat & @Mentions
Swarm Chat is a shared channel where you and agents communicate. Use @agent-name to dispatch tasks directly to any agent — results flow back into the channel automatically.
# In Dashboard → Swarm Chat:
@crew-coder build a REST API for /users
@crew-qa test the /users endpoint
@crew-copywriter write API docs for the users service
How it works: When you @mention an agent with a work order (verb + specific task), the system classifies the intent and dispatches via the RT bus. The agent executes using its configured engine (Claude Code, Gemini, etc.) and the result is persisted to the shared project message history.
Agent-to-agent: Agents can chain work autonomously. If crew-coder responds with "let me ask @crew-qa to test this", the system auto-dispatches to crew-qa. A hop limit (default 4) prevents infinite loops — send /continue to resume.
Chat vs code routing: Conversational messages ("hi", "what's your status?") go directly to the agent's LLM model. Only coding tasks route through CLI engines. This keeps chat fast and cheap.
Toggle: Autonomous mentions are on by default. Disable in Dashboard → Settings or via crewswarm.json → settings.autonomousMentionsEnabled.
tmux Bridge (Multi-Agent Sessions)
When running multi-wave pipelines, agents can share execution context via tmux panes. The bridge lets the orchestrator label panes with agent IDs, read agent output, and hand off sessions between pipeline waves.
# Enable the bridge (requires tmux installed)
export CREWSWARM_TMUX_BRIDGE=1
# Or toggle in Dashboard → Settings → Engines
How it works: When Agent A finishes wave 1, the session manager transfers the tmux pane to Agent B. Agent B can read Agent A's output and continue in the same working directory. No context is lost between waves.
When to use: PM loop pipelines, multi-step builds where agents chain (coder → QA → fixer). Not needed for single-task dispatch.
The bridge is a built-in bash script (scripts/tmux-bridge) — no external dependencies beyond tmux.
System Infrastructure
Cost Tracking
Every LLM call records model, tokens, cached tokens, and cost. Pricing is per-provider (Anthropic $3/M input with 90% cache discount, Groq $0.27/M, Google free for Flash). View in Dashboard or via crew cost CLI. Env: no config needed, automatic.
Intelligent Retry
The retry manager (lib/crew-lead/retry-manager.mjs) detects 3 failure patterns:
- Agent asked a question → re-dispatch with "proceed without asking"
- Agent returned a plan → re-dispatch with "write code, not plans"
- Agent bailed out → re-dispatch with "complete the task"
Max 2 retries per task. Stats available via getRetryStats().
Task Deduplication
File-based distributed locks in ~/.crewswarm/runtime/task-leases/. 45-second lease, 10-second heartbeat. Prevents two agents from executing the same task. Env: automatic, no config needed.
MCP Server
Runs on port 5020. Exposes 64 tools via JSON-RPC. Start with npm run mcp. Test:
curl http://localhost:5020/health
Best Practices
-
Update the Brain
Maintain
memory/brain.mdin your project. This file is the primary context source for all agents. Use it to store project rules and architectural decisions. -
Leverage the PM Loop
Don't manage tasks manually. Create a
ROADMAP.mdand letcrew-pmhandle the decomposition. This enables autonomous, multi-step progress. -
Task Granularity
The smaller the task, the higher the success rate. If a task is complex, ask
crew-pmto break it down further before dispatching it tocrew-coder.
Ready to build?
Clone the repo and start your first crew today.