Newhivemux swarm: Claude Code’s builds and tests run on your other Macs →

How to run a team of Claude Code agents with roles

Short answer

Claude Code has two built-in ways to split work. Subagents are helpers one session starts that report back to it. Agent teams (experimental, CLAUDE_CODE_EXPERIMENTAL_AGENT_TEAMS=1) let a lead session start teammates that message each other. For roles that keep their own session, model and prompt across reboots, hivemux teams run each role as a Claude Code session in its own tmux window.

By · · 4 min read

Splitting a project across several Claude Code agents, each with a role such as planning, development or QA, can be done three ways today. They differ in where the agents live, how they talk to each other and whether they last beyond one session.

Subagents Agent teams (experimental) hivemux teams
What runs Helpers inside one session Separate Claude Code instances started by a lead session One full Claude Code session per role, each in its own tmux window
How they talk Each returns a summary to the session that started it Teammates message each other directly; a shared task list and mailbox Roles message each other by name; hivemux logs every hand-off
Who you talk to The main session The lead (you can also message teammates) The lead gets the goal; you can type into any role’s window
Setup A Markdown file in .claude/agents/ CLAUDE_CODE_EXPERIMENTAL_AGENT_TEAMS=1 A template, three questions, or a chat that builds the team
After a reboot Nothing to keep In-process teammates are not resumed Every role resumes in its own conversation
Cost Counts toward the same usage limits “Significantly more tokens than a single session” One context per role, like any parallel sessions

The facts about subagents and agent teams come from Anthropic’s subagents and agent teams docs (November 2026).

Subagents: focused helpers inside one session

A subagent is a specialized assistant that one Claude Code session starts for a task. It runs in its own context window with its own system prompt, tools and permissions, and only its summary comes back, which keeps a long search or review out of the main conversation. Define one as a Markdown file:

---
name: code-reviewer
description: Reviews code for quality and best practices
tools: Read, Glob, Grep
model: sonnet
---
Review the changed files and report problems by severity.

Put it in .claude/agents/ for this project (and commit it) or ~/.claude/agents/ for all your projects. Use subagents when the work is a side task that should report back: research, a review, a test run.

Agent teams: a lead and teammates that talk to each other

Agent teams are Claude Code’s experimental way to run several instances together. One session is the lead: it starts teammates, assigns tasks from a shared task list and puts the results together. Teammates work in their own context windows and message each other directly. Turn it on with:

Terminal window
export CLAUDE_CODE_EXPERIMENTAL_AGENT_TEAMS=1

or { "env": { "CLAUDE_CODE_EXPERIMENTAL_AGENT_TEAMS": "1" } } in settings.json. By default the teammates run inside your terminal; inside tmux or iTerm2 each can get its own pane (teammateMode in ~/.claude/settings.json). The docs list limits worth knowing: one team per session, no nested teams, the lead stays the lead, and in-process teammates are not resumed. Agent teams fit work that splits into independent parts within one sitting, such as exploring several approaches at once.

hivemux teams: roles that keep their own session

hivemux is a tmux sidebar that shows every Claude Code session — running, waiting for you, or done — and lets you jump to the one that needs you. A hivemux team is a set of those sessions with roles in one project. Each role is started as claude -n <project>-<role> in a window named after the role, with its own model, effort and prompt, and the roles pass work to each other by name.

The hivemux team page on its Progress tab: a web and app team’s roles in flow order with their state and context, the box for the lead’s next goal, the flow of work and the questions waiting for you

To set one up, right-click a project’s name in the sidebar → Team…, or from a terminal:

Terminal window
hivemux team use web-app # the built-in Web & app service team
hivemux team up # open each role in its own window
hivemux team goal "Build a shop MVP with sign-in, a cart and checkout"

What the team page adds on top of the sessions:

  • Levels per role. Light, Standard, Careful or Best set the model, effort, an advisor model the role consults before settling an approach, and the model its subagents use. The whole team can run as Economy, Balanced or Quality.
  • Hand-offs you can follow. Every message from one role to another is logged and shown on the team page and in the sidebar (✉ Planning → Dev · 2m).
  • Diets. A role past its context line (120K tokens by default) brings its notes up to date, clears its context and carries on from the notes under the same name.
  • Questions in one place. Roles write what they need from you to .hivemux/questions.md; the team page lists the open ones.
  • The day’s report. Time worked, hand-offs, tasks done, tokens, and a timeline of who worked and waited when.
  • It lasts. The team lives in the project’s .hivemux/ folder. After a reboot, an update or clocking out and in, every role comes back in its own conversation; hivemux team save <id> keeps it as a template.

The full reference is in hivemux teams.

Which one to use

  • One task with side jobs (look something up, review a diff): subagents.
  • A one-sitting job that splits into independent parts and benefits from agents arguing over findings: agent teams, if you are fine with an experimental feature.
  • A project that runs for days with stable roles you want to watch, steer and pick up again tomorrow: a hivemux team.

All three spend more tokens than one session, because every agent carries its own context. For routine work, one session is still the cheapest way.

FAQ

What is the difference between Claude Code subagents and agent teams?

A subagent runs inside one session, in its own context window, does a focused task and returns only a summary to the session that started it. Agent teams start separate Claude Code instances that work independently and message each other directly, coordinated by a lead through a shared task list. Anthropic's docs suggest subagents for quick focused workers and agent teams when teammates need to share findings and coordinate.

How do I turn on Claude Code agent teams?

Agent teams are experimental and off by default. Set the environment variable CLAUDE_CODE_EXPERIMENTAL_AGENT_TEAMS to 1, in your shell or in the env block of settings.json, and start an interactive session. Sessions run with -p, including Agent SDK sessions, do not start teammates.

Do several Claude Code agents use more tokens?

Yes. Every agent has its own context window, so usage grows with the number of agents working at once. Anthropic's docs say agent teams use significantly more tokens than a single session and that one session is more cost-effective for routine tasks. Subagents also count toward the same usage limits.

Can a Claude Code team survive a reboot?

Agent teams cannot resume teammates that ran inside the lead's terminal (the in-process mode). A hivemux team keeps each role as a named Claude Code session, so after a reboot, an update or clocking out and in, every role comes back with claude --resume in its own conversation, with its model, effort and prompt.

Which roles should a Claude Code team have?

Start with as few as the work needs. hivemux's built-in Web & app service team has six roles (Research, Planning as the lead, Design, Dev, QA and Marketing), and its setup questions drop the ones you do not need, such as research when you already have a plan.