diff --git a/content/manuals/ai/sandboxes/configuration/environment-files.md b/content/manuals/ai/sandboxes/configuration/environment-files.md index b4d8b78d88e..3d8b7a6ceb7 100644 --- a/content/manuals/ai/sandboxes/configuration/environment-files.md +++ b/content/manuals/ai/sandboxes/configuration/environment-files.md @@ -662,6 +662,11 @@ remote MCP server registrations are host-global and can be shared by multiple sandboxes. Local MCP commands declared by the environment belong to that environment and sandbox. +For a local environment, stop its sandbox with `sbx stop ` before +running `sbx env rm`. If the sandbox is running, removal is refused before +plan approval or cleanup. To remove it while running and skip approval, use +`sbx env rm --force`. + `sbx env rm` builds a destroy plan from the resources on the host. The plan includes all credentials stored at the sandbox's scope, including credentials that the environment file no longer declares. After approval, `sbx` removes diff --git a/content/manuals/ai/sandboxes/troubleshooting.md b/content/manuals/ai/sandboxes/troubleshooting.md index d354114de74..b4081c6df52 100644 --- a/content/manuals/ai/sandboxes/troubleshooting.md +++ b/content/manuals/ai/sandboxes/troubleshooting.md @@ -120,6 +120,7 @@ reuse the name of an existing mountless sandbox, first then remove and recreate it with a workspace path: ```console +$ sbx stop $ sbx rm $ sbx run --name ``` diff --git a/content/manuals/ai/sandboxes/usage.md b/content/manuals/ai/sandboxes/usage.md index 94b0f948406..d6743bb5a2d 100644 --- a/content/manuals/ai/sandboxes/usage.md +++ b/content/manuals/ai/sandboxes/usage.md @@ -38,13 +38,11 @@ $ sbx stop my-sandbox # pause it $ sbx rm my-sandbox # delete it entirely ``` -`sbx rm` asks for confirmation before deleting a sandbox. Use `--force` to -skip the prompt. This flag also permits removal when the sandbox has an active -session — an open attach, SSH connection, or in-flight SFTP transfer: +`sbx rm` asks for confirmation and requires the sandbox to be stopped. Use +`sbx stop` first, or use `--force` to skip confirmation and remove a running +sandbox. -```console -$ sbx rm --force my-sandbox -``` +### Recreate a sandbox If you need a clean slate, remove the sandbox and run it again: @@ -54,6 +52,8 @@ $ sbx rm my-sandbox $ sbx run claude ``` +### Remove multiple sandboxes + To remove all stopped local sandboxes, use `sbx prune`. Running sandboxes are never removed. Preview the sandboxes that would be removed, or filter out sandboxes stopped within the last week: @@ -69,6 +69,12 @@ 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. +To remove all local sandboxes, including running ones, and skip confirmation: + +```console +$ sbx rm --all --force +``` + ### Remove a sandbox when the agent exits Pass `--rm` to `sbx run` for a throwaway session. The sandbox is removed when