Skip to content

Commit 19b4b14

Browse files
authored
Merge pull request #25602 from dvdksn/fix/issue-354-clone-mode-docs
Clarify clone mode and Claude worktree isolation
2 parents b349d3d + 40370f6 commit 19b4b14

3 files changed

Lines changed: 27 additions & 22 deletions

File tree

content/manuals/ai/sandboxes/agents/claude-code.md

Lines changed: 11 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -74,9 +74,9 @@ for available options.
7474
## Agents view
7575

7676
Claude Code's [agents view](https://code.claude.com/docs/en/agent-view)
77-
dispatches tasks to subagents that work in parallel, each in its own
78-
Git worktree. Pair it with [clone mode](../workflows.md#clone-mode) for an
79-
isolated multi-agent workflow:
77+
starts background sessions that run tasks in parallel. Pair it with
78+
[clone mode](../workflows.md#clone-mode) to keep their changes inside the
79+
sandbox:
8080

8181
```console
8282
$ sbx run --clone claude -- agents
@@ -92,10 +92,14 @@ use Claude Code's auto mode or pass the flag explicitly:
9292
$ sbx run --clone claude -- --dangerously-skip-permissions agents
9393
```
9494

95-
The subagents' worktrees live inside the sandbox's private clone — none
96-
of them touches your host repository. Each subagent commits to its own
97-
branch, and you review the work from the host by fetching the
98-
`sandbox-<sandbox-name>` remote:
95+
Claude Code may use branches or worktrees to keep changes from its background
96+
sessions separate. This depends on the task, Claude Code configuration, and
97+
project instructions. The `--clone` flag doesn't control this behavior. Claude
98+
Code creates any branches and worktrees inside the sandbox, not in your host
99+
checkout.
100+
101+
To review a branch created by a session, fetch the
102+
`sandbox-<sandbox-name>` remote from the host:
99103

100104
```console
101105
$ git fetch sandbox-<sandbox-name>

content/manuals/ai/sandboxes/usage.md

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -135,8 +135,10 @@ it when you create the sandbox:
135135

136136
- Direct mode is the default. The agent has read-write access to your working
137137
tree, and changes appear on your host immediately.
138-
- [Clone mode](#clone-mode) uses `--clone`. The agent works in a private Git
139-
clone inside the sandbox, and your host repository is mounted read-only.
138+
- [Clone mode](#clone-mode) uses `--clone`. The agent edits a separate Git clone
139+
inside the sandbox. Its changes stay there until you fetch them or the agent
140+
pushes them. Your host repository is also available at
141+
`/run/sandbox/source`, but only with read access.
140142

141143
For guidance on branch strategy, fetching work from a sandbox, and parallel
142144
agent workflows, see [Git workflows](workflows.md#git-workflows). For the

content/manuals/ai/sandboxes/workflows.md

Lines changed: 12 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -59,16 +59,16 @@ turn-by-turn.
5959

6060
### Clone mode
6161

62-
In clone mode, the sandbox gets a private Git clone. The agent manages its
63-
own branches and commits inside that clone; your host working tree is never
64-
touched. When the agent is done, you either fetch its branches to the host or
65-
ask the agent to push directly to your fork.
62+
In clone mode, `sbx` creates a separate Git clone inside the sandbox. The agent
63+
edits this clone instead of your host working tree. Its changes stay inside the
64+
sandbox until you fetch a branch or the agent pushes one to a remote. Your host
65+
repository is also available at `/run/sandbox/source`, but only with read
66+
access. The sandbox clone is not a Git worktree linked to your host checkout.
6667

67-
Clone mode is designed for parallelism: a single clone-mode sandbox can hold
68-
many branches at once, and subagent orchestrators (such as Claude Code's
69-
[agents view](agents/claude-code.md#agents-view)) can dispatch independent
70-
tasks to separate agents, each working on its own branch or worktree inside
71-
the clone.
68+
A single clone-mode sandbox can hold multiple branches and worktrees for
69+
parallel tasks. The `--clone` flag creates the clone, but it doesn't separate
70+
one task from another. To keep parallel tasks isolated, instruct your agent tool
71+
to create a separate branch or worktree for each task.
7272

7373
> [!NOTE]
7474
> `--clone` is a create-time flag and cannot be changed on an existing
@@ -135,10 +135,9 @@ It's only reachable while the sandbox is running:
135135
$ sbx run --clone claude
136136
```
137137

138-
2. Dispatch each independent task to a separate subagent. Claude Code handles
139-
branch isolation for subagents automatically in agents view. For other
140-
agents (such as Codex), add an instruction to `AGENTS.md` to get the same
141-
behavior:
138+
2. Dispatch each independent task to a separate background session. Your agent
139+
tool may use branches or worktrees to keep their changes separate. If it
140+
doesn't, add a project instruction such as:
142141

143142
```markdown
144143
Always start each task on its own git branch before making changes.

0 commit comments

Comments
 (0)