diff --git a/content/manuals/ai/sandboxes/cloud/usage.md b/content/manuals/ai/sandboxes/cloud/usage.md index 2eafc97acb..6f5da08f64 100644 --- a/content/manuals/ai/sandboxes/cloud/usage.md +++ b/content/manuals/ai/sandboxes/cloud/usage.md @@ -241,6 +241,20 @@ $ sbx --cloud rm cloud-project Removal asks for confirmation, deletes the cloud sandbox, and can't be undone. Use `--force` to skip the prompt in scripts. +### Remove a sandbox when the agent exits + +Pass `--rm` to an interactive `run` to remove the sandbox when the agent +session ends: + +```console +$ sbx --cloud run --rm claude +``` + +The detach gesture is turned off for that session, and you can't combine +`--rm` with `--detached`. If the session ends without completing, for example +because the connection drops, the sandbox is kept and the CLI prints the +command to remove it. + ## Use persistent volumes Cloud volumes are experimental and preserve data independently of a sandbox. diff --git a/content/manuals/ai/sandboxes/usage.md b/content/manuals/ai/sandboxes/usage.md index 98578619f2..6ddc9f5459 100644 --- a/content/manuals/ai/sandboxes/usage.md +++ b/content/manuals/ai/sandboxes/usage.md @@ -67,6 +67,23 @@ such as `168h`, an RFC 3339 timestamp, or a Unix timestamp. The older Run `sbx prune` without flags to confirm and remove all stopped sandboxes. +### Remove a sandbox when the agent exits + +Pass `--rm` to `sbx run` for a throwaway session. The sandbox is removed when +the agent exits, without a confirmation prompt: + +```console +$ sbx run --rm claude +``` + +The sandbox is removed however the agent exits, and `sbx run` exits with the +agent's exit status. If `sbx run` created the sandbox and the agent fails +to start, the sandbox is also removed. If you reattach to an existing sandbox +with `--rm`, that sandbox is removed only after its agent session finishes. + +`--rm` needs an attached agent session to know when to remove the sandbox, so +you can't combine it with `--detached` or `--detach-keys`. + ## Choose a workspace `sbx run` mounts the current directory when you don't pass a workspace path.