# Run multiple Claude Code and Codex agents in parallel

> Run several coding agents at once without slowing your laptop: a git worktree and a session per agent, on one bigger box or a box each, with what each costs.

URL: https://prized.dev/docs/parallel-agents

Each agent runs its own installs, builds and tests, so three agents on a laptop share one CPU and one battery with your editor. On a box, each agent gets its own git worktree and tmux session, and they keep working with the lid closed.

## 1. Add a worktree per task [#1-add-a-worktree-per-task]

```bash
prized ssh
```

Then, on the box:

```bash title="you@box"
cd ~/code/myproject
git worktree add ../myproject-auth -b auth
git worktree add ../myproject-billing -b billing
```

Each worktree is its own folder and branch with tracked files only, so install dependencies in it. Worktrees beside the project stay on the box; only `~/code/myproject` syncs to your laptop ([Sync](https://prized.dev/docs/sync#add-a-project)).

## 2. Start an agent in each [#2-start-an-agent-in-each]

```bash
prized agents run claude --session claude-auth --dir code/myproject-auth
prized agents run codex --session codex-billing --dir code/myproject-billing
```

`--dir` is relative to your home on the box. Attach with `prized ssh -s claude-auth` to give an agent its task, and detach with Ctrl-b, then d; to skip attaching, hand it the task with [`prized prompt`](https://prized.dev/docs/remote-agents). Give each dev server its own port, such as 3001 and 3002 ([Ports](https://prized.dev/docs/ports)).

## 3. Watch them [#3-watch-them]

`prized ssh --ls` lists the sessions. For one view of every agent, `prized herdr` opens [herdr](https://prized.dev/docs/herdr), which shows each agent started in its tabs as working, blocked, idle or done, and notifies you when one needs you.

## 4. Review and merge [#4-review-and-merge]

```bash title="you@box ~/code/myproject-auth"
git diff
git add -A
git commit -m "Add rate limiting to the login endpoint"
git push -u origin auth
```

`gh` on the box is signed in if it was on your laptop at setup, so `gh pr create` works there. Once merged, `git worktree remove ../myproject-auth` cleans up.

## A box per agent [#a-box-per-agent]

Separate boxes keep one agent's build from slowing another, and each box pauses on its own; this needs a plan, since the free credit runs one box at a time. Fork the box you set up (here `mango`), project and tools included, then connect the copy and start its agent:

```bash
prized fork mango --name mango-2 --wait
prized init --box mango-2
prized --box mango-2 agents run claude --dir code/myproject
```

A fork takes minutes; to start many boxes from one point, save a [template](https://prized.dev/docs/snapshots#templates). Give each box's dev server its own port, since the same port on two boxes collides on your laptop ([Several boxes](https://prized.dev/docs/boxes#several-boxes)).

## What it costs [#what-it-costs]

For the same total CPU and memory, several Smalls cost less per hour awake than one bigger box:

| Setup       | In total       | Awake, per hour |
| ----------- | -------------- | --------------- |
| One Medium  | 8 vCPU, 32 GB  | $0.342          |
| Two Smalls  | 8 vCPU, 32 GB  | $0.274          |
| One Large   | 16 vCPU, 64 GB | $0.685          |
| Four Smalls | 16 vCPU, 64 GB | $0.548          |

An eight hour day of four agents is $4.38 on four Smalls, or $5.48 on one Large. On the $30 of free credit, one Small runs your agents side by side at $0.137 an hour, about nine days around the clock ([Billing](https://prized.dev/docs/billing)).
