Skip to content

Commit 3260d0f

Browse files
authored
Merge pull request #24625 from dvdksn/sbx/hands-on-quickstart
sandboxes: expand get-started into first-session walkthrough
2 parents b0e4469 + a02744c commit 3260d0f

File tree

2 files changed

+130
-17
lines changed

2 files changed

+130
-17
lines changed

content/manuals/ai/sandboxes/get-started.md

Lines changed: 130 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,8 @@
22
title: Get started with Docker Sandboxes
33
linkTitle: Get started
44
weight: 10
5-
description: Install the sbx CLI and run an AI coding agent in an isolated sandbox.
5+
description: Install the sbx CLI, configure credentials, and work through your first sandbox session.
6+
keywords: sandbox, sbx, get started, install, credentials, branch mode, network policy
67
---
78

89
{{< summary-bar feature_name="Docker Sandboxes sbx" >}}
@@ -12,6 +13,10 @@ sandbox gets its own Docker daemon, filesystem, and network — the agent can
1213
build containers, install packages, and modify files without touching your host
1314
system.
1415

16+
This page walks through a typical first session: installing the CLI,
17+
authenticating your agent, running a sandbox, working with branches, and
18+
cleaning up.
19+
1520
## Prerequisites
1621

1722
- macOS (Apple silicon) or Windows (x86_64, Windows 11 required)
@@ -23,8 +28,7 @@ system.
2328
- An API key or authentication method for the agent you want to use. Most
2429
agents require an API key for their model provider (Anthropic, OpenAI,
2530
Google, and others). See the [agent pages](agents/) for provider-specific
26-
instructions, and [Credentials](security/credentials.md) for how to store
27-
and manage keys.
31+
instructions.
2832

2933
Docker Desktop is not required to use `sbx`.
3034

@@ -66,15 +70,48 @@ Choose a default network policy:
6670
Use ↑/↓ to navigate, Enter to select, or press 1–3.
6771
```
6872

69-
See [Policies](security/policy.md) for a full description of each option.
73+
**Balanced** is a good starting point — it permits traffic to common
74+
development services while blocking everything else. You can adjust individual
75+
rules later. See [Policies](security/policy.md) for a full description of each
76+
option.
7077

7178
> [!NOTE]
7279
> See the [FAQ](faq.md) for details on why sign-in is required and what
7380
> happens with your data.
7481
82+
## Authenticate your agent
83+
84+
Agents need credentials for their model provider. How you provide them depends
85+
on the agent.
86+
87+
For Claude Code with a Claude subscription (Max, Team, or Enterprise), no
88+
upfront setup is needed — use the `/login` command inside the sandbox to sign
89+
in with OAuth. The session token stays on your host and is injected by a
90+
proxy, not stored inside the sandbox.
91+
92+
For agents that use API keys (or if you prefer API key authentication for
93+
Claude Code), store the key before starting a sandbox:
94+
95+
```console
96+
$ sbx secret set -g anthropic
97+
```
98+
99+
This prompts for the secret value and stores it in your OS keychain. A proxy on
100+
your host injects the key into outbound API requests so it's never exposed
101+
inside the sandbox. See [Credentials](security/credentials.md) for details on
102+
scoping, supported services, and alternative methods.
103+
104+
To give the agent access to GitHub for creating pull requests or interacting
105+
with repositories:
106+
107+
```console
108+
$ sbx secret set -g github -t "$(gh auth token)"
109+
```
110+
75111
## Run your first sandbox
76112

77-
Pick a project directory and launch an agent with [`sbx run`](/reference/cli/sbx/run/):
113+
Pick a project directory and launch an agent with
114+
[`sbx run`](/reference/cli/sbx/run/):
78115

79116
```console
80117
$ cd ~/my-project
@@ -84,30 +121,106 @@ $ sbx run claude
84121
Replace `claude` with the agent you want to use — see [Agents](agents/) for the
85122
full list.
86123

87-
The first run takes a little longer while the agent image is pulled.
88-
Subsequent runs reuse the cached image and start in seconds.
124+
The first run takes a little longer while the agent image is pulled. Subsequent
125+
runs reuse the cached image and start in seconds.
89126

90127
You can check what's running at any time:
91128

92129
```console
93130
$ sbx ls
94-
NAME STATUS UPTIME
95-
claude-my-project running 12s
131+
SANDBOX AGENT STATUS PORTS WORKSPACE
132+
claude-my-project claude running ~/my-project
133+
```
134+
135+
You can also run `sbx` with no arguments to open an interactive dashboard.
136+
The dashboard shows your sandboxes with live status, lets you attach to
137+
agents, open shells, and manage network rules from one place. See
138+
[Interactive mode](usage.md#interactive-mode) for details.
139+
140+
![The sbx interactive dashboard showing sandbox status, resource usage, and network governance controls.](images/sbx-dashboard.png)
141+
142+
## Use branch mode
143+
144+
By default, the agent edits your working tree directly. To give it its own
145+
Git branch, use `--branch`:
146+
147+
```console
148+
$ sbx run claude --branch my-feature
149+
```
150+
151+
This creates a [Git worktree](https://git-scm.com/docs/git-worktree) under
152+
`.sbx/` in your repository root. The agent works on its own branch and
153+
directory without touching your main working tree.
154+
155+
When the session ends, review what the agent did from the worktree:
156+
157+
```console
158+
$ cd .sbx/<sandbox-name>-worktrees/my-feature
159+
$ git log
160+
$ git diff main
96161
```
97162

98-
The agent can modify files in your project directory, so review changes before
99-
merging. See [Workspace trust](security/workspace.md) for details.
163+
If you're satisfied, push the branch and open a pull request:
164+
165+
```console
166+
$ git push -u origin my-feature
167+
$ gh pr create
168+
```
169+
170+
Branch mode is especially useful when running multiple agents on the same
171+
repository — each gets its own branch and can't overwrite the other's changes.
172+
See [Branch mode](usage.md#branch-mode) for more options, including
173+
`--branch auto` and multiple branches per sandbox.
174+
175+
## Manage network access
176+
177+
Your network policy controls what the sandbox can reach. If the agent fails to
178+
connect to an API or service, it's likely blocked by the policy.
179+
180+
Check which rules are in effect:
181+
182+
```console
183+
$ sbx policy ls
184+
```
185+
186+
To allow a specific host:
187+
188+
```console
189+
$ sbx policy allow network registry.npmjs.org
190+
```
191+
192+
With **Locked Down**, even your model provider API is blocked unless you
193+
explicitly allow it. With **Balanced**, common development services are
194+
permitted by default. See [Policies](security/policy.md) for the full rule
195+
set and how to customize it.
196+
197+
## Clean up
198+
199+
Sandboxes persist after the agent exits. To stop a sandbox without deleting it:
200+
201+
```console
202+
$ sbx stop my-sandbox
203+
```
204+
205+
Installed packages, Docker images, and configuration changes are preserved
206+
across restarts. When you're done with a sandbox, remove it to reclaim disk
207+
space:
208+
209+
```console
210+
$ sbx rm my-sandbox
211+
```
100212

101-
> [!CAUTION]
102-
> Your network policy controls what the sandbox can reach. With **Locked
103-
> Down**, even your model provider API is blocked. With **Balanced**, a broad
104-
> set of common development services is allowed by default — add other hosts
105-
> with `sbx policy allow`. See [Policies](security/policy.md) for details.
213+
Removing a sandbox deletes everything inside it — installed packages, Docker
214+
images, and any branch mode worktrees under `.sbx/`. Files in your main
215+
working tree are unaffected.
106216

107217
## Next steps
108218

109-
- [Usage guide](usage.md) — common patterns and workflows
219+
- [Usage guide](usage.md) — sandbox management, reconnecting, multiple
220+
workspaces, port forwarding, and more
110221
- [Agents](agents/) — supported agents and configuration
111222
- [Custom environments](agents/custom-environments.md) — build your own sandbox
112223
images
224+
- [Credentials](security/credentials.md) — credential storage and management
225+
- [Workspace trust](security/workspace.md) — review agent changes safely
113226
- [Policies](security/policy.md) — control outbound access
143 KB
Loading

0 commit comments

Comments
 (0)