devsandbox 0.11.1

Manage devcontainer-style sandboxes on docker, podman, or Apple container — many throwaway instances per repo from one TOML config.
---
title: Parallel coding agents
description: Several coding agents on one repo, fully isolated from one another.
order: 1
icon: git-branch
tags: [agents, worktrees, git]
related: [credentials, services, caches]
---

import AgentPrompt from '../../components/AgentPrompt.astro';
import AgentPromptLink from '../../components/AgentPromptLink.astro';
import Agent from '../../components/Agent.astro';
import AgentOnly from '../../components/AgentOnly.astro';
import AgentPicker from '../../components/AgentPicker.astro';

## The problem

Two agents in one checkout trip over each other's branches, stashes and dev servers. Each needs its own working tree and its own container.

The first `devsandbox run` of a sandbox mounts the repo itself. Every further instance gets its own git worktree and branch, in its own container.

<AgentPromptLink />

## Config

<AgentPicker />

```toml title="devsandboxes.toml" agent="claude"
[sandbox.app]
folder = "../app"          # your repo, next to this config dir
image = "node:22"
caches = ["npm"]
worktree-link = [".env"]   # one .env, shared by every instance

# Your Claude Code login, from the host.
mounts = ["source=${localEnv:HOME}/.claude,target=${containerEnv:HOME}/.claude,type=bind"]
containerEnv = { CLAUDE_CONFIG_DIR = "${containerEnv:HOME}/.claude" }

[sandbox.app.postCreateCommand]
deps = "npm install"
agent = "npm install -g @anthropic-ai/claude-code"
```

```toml title="devsandboxes.toml" agent="codex"
[sandbox.app]
folder = "../app"          # your repo, next to this config dir
image = "node:22"
caches = ["npm"]
worktree-link = [".env"]   # one .env, shared by every instance

# Your Codex login, from the host.
mounts = ["source=${localEnv:HOME}/.codex,target=${containerEnv:HOME}/.codex,type=bind"]

[sandbox.app.postCreateCommand]
deps = "npm install"
agent = "npm install -g @openai/codex"
```

<AgentOnly agent="claude">

On macOS <Agent /> keeps its login in the Keychain, so run `/login` once in any instance.

</AgentOnly>

## Try it

```bash
devsandbox run app --name fix-login                                 # your checkout
devsandbox run app --name add-profile-pic --branch feat/profile-pic  # its own worktree
```

```bash agent="claude"
devsandbox exec fix-login claude
devsandbox exec add-profile-pic claude
```

```bash agent="codex"
devsandbox exec fix-login codex
devsandbox exec add-profile-pic codex
```

When a task is done, push its branch and `devsandbox rm add-profile-pic`.

## How it works

- Worktrees live in `.worktrees/<name>` next to `devsandboxes.toml`, and `rm` deletes them with the container.
- [`worktree-link`](/docs/config#project-and-worktrees) links one shared copy of a gitignored file into each worktree.

## Agent instructions

<AgentPrompt prompt="parallel-agents" />