#claude-code #agents #mcp #orchestration #tooling
how i run multi-agent claude code in production
the three-layer setup i actually use to run several claude code agents at once — orchestration, persistent memory, and a live dashboard. real configs, copy-paste.
- published
- updated
- reading time
- 5 min read
most people use claude code as one agent in one terminal. that’s fine until the work outgrows a single context window — then you’re babysitting one agent doing everything sequentially, watching it forget what it learned an hour ago, with no idea what it’s actually doing until it’s done.
i run it differently. several agents at once, each cheap and specialized, a persistent memory layer underneath them, and a dashboard so i can see all of it in real time. three layers. here’s the whole thing, with the real configs.
layer 1 — orchestration: the expensive agent doesn’t do the work
the core idea i stole from augment’s orchestration pattern: the smart model is expensive, so it should never touch execution. it makes decisions and delegates everything else to cheaper agents. straight from my orchestrator prompt:
you are the orchestrator. you are expensive. every token you spend on execution is a token wasted — delegate execution to cheaper sub-agents and spend your tokens on decisions.
concretely, the orchestrator (opus) does five things: understand intent, break it into tasks, delegate each to the right specialist, use an independent verifier when the risk justifies it, and synthesize. it costs ~20x more per token than a haiku explorer — so every grep it does itself is money lit on fire.
the team i actually run is a direct map from role to claude code agent type and model:
| role | claude code agent | model | permissions |
|---|---|---|---|
| orchestrator | claude (default) | opus | full tools, delegates to sub-agents |
| context gathering | Explore | haiku | read-only: Bash(grep/find), Read |
| research | Explore | sonnet | read-only + WebSearch, WebFetch |
| planning | Plan | opus | read + write (plan files only) |
| coding | general-purpose | sonnet | full tools except destructive ops |
| validation | general-purpose | sonnet | full tools, focus on test execution |
every request gets classified into an intent first, which decides which agents even run:
| intent | when | agents used |
|---|---|---|
research | understand something, no code changes | Explore (parallel) → synthesize |
plan | want a design before committing | Explore (parallel) → Plan |
implement | want working code delivered | Explore → Plan → Code → Validate |
validate | test/verify existing code | Explore → Validate |
the rule that makes it fast: exploration is always parallel. spawn two or three
Explore agents with different questions in a single message and let them sweep the
codebase at once. planning, coding, and validation are sequential — each needs the
last phase’s output. so a typical implement run looks like:
# via nathanmauro.io/r/multi-agent-claude-code
# exploration phase — parallel, one message, three cheap agents
Agent(subagent_type="Explore", prompt="[context-gathering prompt] + where are the API route handlers and middleware?")
Agent(subagent_type="Explore", prompt="[context-gathering prompt] + how is auth wired through requests?")
Agent(subagent_type="Explore", prompt="[research prompt] + what does the existing cache layer look like?")
# then sequential
Agent(subagent_type="Plan", prompt="[planning prompt] + requirements + exploration findings")
Agent(subagent_type="general-purpose", prompt="[coding prompt] + plan step 1")
Agent(subagent_type="general-purpose", prompt="[validation prompt] + run the integration tests")
each agent’s system prompt lives in a file (agents/context-gathering.md,
agents/coding.md, …) and gets prepended to the task. the orchestrator’s whole
job is to compose those prompts and stay out of the weeds.
layer 2 — memory: so agents stop forgetting
update, 2026-11-12: this layer used to be memory-agent, a python mcp server with twelve memory tools and auto-capture hooks. it is retired. layer 2 is now black box, described below. the original section is still in this site’s git history if you want the old configs.
the second bottleneck is amnesia. every new session starts cold. the fix that stuck is not “remember everything”, it’s a narrow ledger: keep the decision, the reason, and the next step, and let the next session recall them before it starts.
black box is that ledger. it’s a local java + sqlite server with an mcp endpoint, so claude code and codex write to the same place:
# via nathanmauro.io/r/multi-agent-claude-code
git clone https://github.com/nathanmauro/black-box.git
cd black-box
git checkout 7ff29321ed76afa09f84d2262f5230e76c5478c6 # v0.3.0, the version this post describes
./scripts/quickstart.sh # builds, starts a scratch db, serves http://localhost:8766
claude mcp add --transport http --scope user black-box http://localhost:8766/mcp
codex mcp add black-box --url http://localhost:8766/mcp
three calls carry most of the weight:
| tool | when | what it keeps |
|---|---|---|
recallContext | start of a task | a bounded set of earlier decisions and handoffs for the project or topic, with sources |
captureDecision | when a choice is made | what changed, why, and which alternatives were rejected |
captureHandoff | closeout | the verified state, unfinished work, and one useful next action |
lexical recall works with no model at all; semantic recall is optional and falls back to lexical.
opt-in hooks can record session events or inject a compact recall packet at startup. it runs on
127.0.0.1 by default and never needs a hosted service.
since 0.3.0, each project also carries a small live set of broadcasts:
hazard (an active lock, a dirty tree, a warning; 72h default ttl), invariant (a standing
fact), and tentacle (started-but-unfinished work, cleared only explicitly, with an optional
follow-up time). setBroadcast and clearBroadcast write them over mcp, or rest at
/api/broadcasts; listBroadcasts sweeps forgotten tentacles across every project, and
recallContext attaches a bounded digest (8 items, 1,500 characters) whenever recall resolves to
a project.
the difference from the old setup: memory-agent tried to summarize everything a session did. black box only keeps what a later session needs to continue, so the recall is small enough to trust and cheap enough to run at the start of every task.
layer 3 — visibility: watch all of them at once
running five agents you can’t see is its own kind of blind. so the third layer is agent observatory — a local dashboard that indexes sessions, events, and memory from claude code, codex, augment, and cursor into one searchable interface.
# via nathanmauro.io/r/multi-agent-claude-code
make build
./agent-observatory
# → http://127.0.0.1:3284
go backend, sqlite (wal) with fts5, websocket for live updates, solidjs frontend. five pages — overview (running processes, recent sessions, timeline), sessions, timeline, memory, and full-text search across all of it. per-agent parsers handle the different on-disk formats (jsonl for claude/codex/cursor, json for augment).
everything stays local. it binds to localhost, never uploads, and never mutates agent-owned files. it’s a read-only window, not another thing that can break your agents.
how the three fit together
the loop in practice: orchestrator classifies intent and fans out cheap explorers in parallel → black box recalls the decisions and handoffs past sessions left for this project so nobody re-discovers them → planning and coding run sequentially against real context → observatory shows me the whole thing live so i can kill a bad run early instead of paying for it to finish.
none of these layers is exotic. orchestration is a prompt-composition pattern. memory is a sqlite ledger behind mcp. visibility is a parser plus a web ui. the leverage is in running them together — cheap parallel work, no amnesia between sessions, and eyes on all of it.
i’ve been running this setup daily as my primary workflow. it’s not a framework, there’s no install script for the whole thing, and i’m sure half of it is wrong in ways i haven’t hit yet. but it’s real, it’s what i actually use, and the configs above are copy-paste.
the orchestration prompts, gates, and handoff formats from this post now live in a public repo, agentic-workflows, and render on this site as the field manual. free, mit, copy what helps.
update, 2026-11-21: the repo now covers the multi-engine setup this grew into. claude builds in
isolated workflows, gemini swarms in antigravity fan out across repos, codex verifies when asked,
and every agent that edits gets its own worktree. the repo link above is re-pinned to that commit.
layer 2 is re-pinned to black box 0.3.0, registers under its new black-box mcp name, and gains a
paragraph on broadcasts.