DEV Community

Dmitriy Solodukha
Dmitriy Solodukha

Posted on Originally published at caprock.dev

How to run several Claude Code agents in parallel

Run several Claude Code agents in parallel with subagents, agent teams, worktrees or -p, then keep one record of them and check the work with Caprock.

To run several coding agents in parallel on your machine, give each one
its own git worktree, so their edits never collide, and start one agent in
each. Claude Code's official docs name five built-in ways: subagents, agent
view (claude --bg, watched in claude agents), agent teams, dynamic
workflows and projects, with claude --worktree <name> for a separate
checkout; OpenAI's Codex runs subagents in parallel, and its desktop app
gives each chat a worktree. To run different agents side by side, desktop
apps such as Orca, T3 Code, Conductor and Caprock open each in its own tab or
workspace. Caprock is free and open source, on macOS, Windows and Linux, and
adds a record of every session on the machine and a task runner that calls a
task done only when your tests pass.

In short

  • Inside one session: ask for subagents — "…in parallel using separate subagents".
  • Side by side: claude --worktree <name> per session, or claude --bg "<task>" and watch them in claude agents.
  • A team: CLAUDE_CODE_EXPERIMENTAL_AGENT_TEAMS=1, at about 7× the tokens of a standard session in plan mode.
  • In one app: Caprock — type a task into ⌘K and it opens a new agent on it in a new worktree; ⌘J jumps to the next session waiting on you.
  • Done means tests pass: Caprock's task runner runs your checks (done_criteria) in the task's own worktree before a task counts as done.

How to run several coding agents in parallel on your machine

The method works for any agent in a terminal, Claude Code, Codex or
OpenCode alike: one git worktree per agent, each with its own branch.

  1. Make a checkout per agent, next to your repository: git worktree add ../myapp-auth -b agent/auth
  2. And one for the second agent: git worktree add ../myapp-tests -b agent/tests
  3. Start Claude Code in the first: cd ../myapp-auth && claude
  4. Start Codex, or another agent, in the second: cd ../myapp-tests && codex

Each agent edits only its own folder; you merge the branches when the work
is done, and git worktree remove <path> deletes a checkout. Claude Code
does the first step for you with claude --worktree <name>. Codex's desktop
app runs each chat in a worktree of its own, and its CLI runs subagents in
parallel, "enabled by default" in current releases (OpenAI's docs, read 18
November 2026). The agents' own parallel modes keep to one vendor: "In every
approach the workers are Claude sessions", as Anthropic's page puts it.

Ways to run Claude Code agents in parallel

Claude Code's own options and Caprock's task runner, from Anthropic's docs and Caprock's source, checked 1 October 2026.

Option Runs as Own checkout Who says it is done
Subagents a side task inside your session with isolation: worktree the subagent
claude --worktree a whole session yes, under .claude/worktrees/ the agent
claude --bg a background session yes, before it edits the agent
Agent teams a lead and teammate sessions no, one shared checkout the agents
Caprock's app, ⌘K a session in a tab yes, under .caprock-worktrees/ the agent
Caprock's task runner a worker session per task yes, under .caprock-worktrees/ your checks, run by Caprock

Dynamic workflows add verifier agents — which are still agents.

How to manage several Claude Code sessions without juggling terminals

Let Claude Code keep the list, and give every session its own checkout. The
free ways, all built in:

  • Agent view. claude agents is one screen for every background session: Working, Needs input, Idle, Completed, Failed. Start one with claude --bg "<task>", or send an open session there with /bg. A research preview.
  • Worktrees. claude --worktree <name> gives a session its own checkout and branch, so two sessions never edit the same files.
  • tmux. claude -w <name> --tmux opens that worktree session in a tmux session of its own, or in iTerm2's own panes when iTerm2 is available.
  • Claude Desktop's Code tab. A sidebar of sessions, Ctrl+Tab to cycle them, ⌘-click (Ctrl-click on Windows) to open two side by side; it needs a paid plan.

What they leave out: agent view lists only background sessions, so a
claude open in another terminal stays out until you background it; agent
view and the Code tab manage Claude sessions only, not Codex or OpenCode; and
/usage prices only the session you are in.

Caprock fills those gaps. Anthropic's own desktop app is a window for one
agent, free with a plan; Caprock, a free desktop app for macOS, Windows and
Linux, is the record across agents: every Claude Code, Codex, OpenCode or
Gemini CLI session, the claude you started in your own terminal included,
with who is waiting on you, who is stuck, how close each subscription is to
its limit and what each pull request cost. The tabs — up to four panes each,
the waiting sessions first, ⌘J to the next — are how you live with it. It
never types into a session it did not start. The app and its record are
below.

Subagents: parallel work inside one session

A subagent does a side task in its own context window and returns only a
summary. Ask for several at once — "Research the authentication, database, and
API modules in parallel using separate subagents" — or define your own in
.claude/agents/. With isolation: worktree in its front matter, a subagent
edits a temporary git worktree, not your checkout. Every field, and what
subagents cost: Claude Code subagents.

Multiple sessions: worktrees, background and -p

  1. Start a session in its own checkout, on a branch worktree-: claude --worktree feature-auth
  2. Start a background session (or /bg inside one); it moves into a worktree before it edits: claude --bg "<task>"
  3. Open agent view: every background session, and whether it is working, needs input or finished: claude agents — A research preview.
  4. Run without the interface, for scripts and CI: claude -p "<task>" --output-format json — The JSON result includes total_cost_usd.

With -p there is no one to answer a permission prompt, so it is denied;
pre-approve tools with --allowedTools or a permission mode.

Agent teams: Claude Code's orchestrator

Agent teams are experimental and off by default. Turn them on with an
environment variable, in your shell or in settings.json:

{ "env": { "CLAUDE_CODE_EXPERIMENTAL_AGENT_TEAMS": "1" } }
Enter fullscreen mode Exit fullscreen mode

Then ask for teammates in plain language. Your session becomes the lead: it
fills a shared task list and spawns teammates, each a separate Claude Code
instance that claims tasks and messages the others.

…approximately 7x more tokens than standard sessions when teammates run in plan mode.

— Anthropic's costs page, on agent teams

Teammates share one checkout, so give each different files. They are not
spawned in -p mode, and /resume does not restore in-process teammates.

What gets hard with several agents at once

  • Seeing all of them. Agent view lists background sessions; sessions open in other terminals do not appear until you background them, and subagents and teammates are not separate rows.
  • Cost per session. /usage prices only the session you are in. Agent view's docs warn that ten agents use quota roughly ten times as fast as one.
  • Knowing which one is stuck. A session repeating the same tool call looks like a busy one.
  • Verifying the work. Every option ends with an agent saying it finished. The docs' answer is hooks you write yourself (TaskCompleted exits 2 to refuse completion) and watching: "letting a team run unattended for too long increases the risk of wasted effort."

Several agents, one record: the Caprock app

The Caprock app's command palette over six agent tabs: the session waiting on you first, then actions such as New agent, New shell, Open file and Open the dashboard

The command palette (⌘K). The macOS app replaying a real Caprock work session. Example figures.

Caprock is a free desktop app for macOS, Windows and Linux. Each project in
its sidebar opens to its worktrees and the agent sessions and shells in each.

  • Tabs and split panes. New agent (⇧⌘N) starts Claude Code, Codex, OpenCode, Gemini CLI, Grok Build or Hermes Agent in a terminal tab of its project. ⌘E opens a shell beside it, ⇧⌘E below it, up to four panes a tab. Closing a tab ends an idle agent, its conversation saved, and asks about one still working.
  • A task becomes a worktree. In the palette (⌘K), type a task that matches nothing — "Add rate limiting to the API" — and Enter opens New agent with it as the first message, in a new worktree named after it (add-rate-limiting-to-the-api), on its own branch.
  • What is waiting on you. Sessions stopped on a permission prompt or waiting for your answer come first in the sidebar and the palette; ⌘J opens the next one. The Dock badge (a dot on the Windows taskbar) counts them, and on macOS the menu bar names them beside its icon (2 waiting).
  • Review each worktree. Click a worktree's ±N to see its diff, stage, commit and push, and open a pull request once GitHub is connected.

Starting several sessions from the app does not make them cheaper or safer
than starting them in terminals: each is a whole session, and two agents
editing the same checkout still collide. Give each its own worktree.

A dashboard of every Claude Code session at once

Claude Code's own is agent view, claude agents: every background session
and whether it is working, needs input or finished, but not the sessions open
in other terminals. Caprock's Home screen shows every Claude
Code session on the machine at once, including the ones you start in your
own terminals:

Caprock's Home screen: today's cost at API list price, then a per-minute pulse for each session with its cost and a repeated-call count

The top of the Home screen.

  • Cost per session, beside its last hour of activity, and per project.
  • Loop alerts — a session repeating the same tool call is flagged with the call and what the session has spent; the rule, and the two other ways a session stops moving, in Claude Code stuck.
  • Waiting on you — a session idle at a question gets a row, with "what did it ask?" to read it without finding the terminal.

Caprock watches the sessions you start in your own terminal; it only stops or
types into the ones it started itself.

Caprock's task runner: an orchestrator with a test gate

The Tasks screen with the task runner off: you write the task, a worker does it on its own branch and worktree, Caprock runs the checks, you take the branch

The task runner before it is switched on.

The task runner is off by default; turn it on from the Tasks screen. A task is
a markdown file with a title, a budget and done_criteria — shell commands
that must pass:

caprock task create --title "Add a /healthz endpoint" \
    --done-criteria "go test ./..." --done-criteria "go vet ./..." --budget 3
Enter fullscreen mode Exit fullscreen mode

After you press Start orchestrator, an orchestrator session assigns each
task to a worker, one task per worker at a time. Each worker is a Claude Code
session in its own git worktree, at <repo>/.caprock-worktrees/<worker-id> on
branch caprock/<worker-id>. Your working tree is not touched.

The verification loop: what Caprock does, not the agent.

When Caprock
The worker says it is done runs each done_criteria command in its worktree, 5 minutes at most
Every check passes moves the task to Done
A check fails sends the failing output back to the worker
Three rounds have failed stops the task in Needs you
The task goes over budget stops it in Needs you
A check looks destructive waits for your approval

A Done card shows the diff, the checks that passed, the branch and the git
command that merges it. Caprock never merges into your branches; you land the
work.

Before you turn it on

  • Workers skip permission prompts (--dangerously-skip-permissions). A task body is acted on without asking.
  • Nothing detects two workers editing the same file. Give tasks that run at the same time different files.
  • Set a budget. A task created without one gets $5; a task file you write by hand with no budget has no limit.

Agent teams, subagents or Caprock's runner

  • Subagents — a side task whose output you do not need in your context, in one session.
  • Agent teams — work that needs discussion, such as reviewers challenging each other, if you will stay and steer and can pay for several full sessions.
  • Worktrees and agent view — independent tasks you hand off and review by hand.
  • Caprock's app — several agents, or several kinds of agent, across projects, and one record of who is waiting on you, who is stuck, how close each limit is and what each pull request cost. Install it; more on worktrees in Claude Code worktrees.
  • Caprock's task runner — independent tasks where a test, not an agent, decides when the work is finished.

Sources


Originally published at caprock.dev, where it is kept up to date.

Top comments (0)