Summary
Add a --rm flag to sbx create and/or sbx run that automatically removes the sandbox after the session or command exits — equivalent to docker run --rm.
Motivation
Running a one-shot command in a sandbox currently requires a manual 3-step workaround:
NAME=ephemeral-$$ && \
sbx create shell . --name $NAME --quiet && \
sbx exec $NAME echo "Hello" ; \
sbx rm $NAME
This is error-prone (forgetting cleanup leaves ghost sandboxes) and verbose for scripting / CI use cases.
Proposed API
# Create and exec, auto-remove on exit
sbx create --rm shell .
# Or on run
sbx run --rm shell . -- my-command
Expected behavior
- Sandbox is removed immediately after the command/session exits
- Removal happens even if the command fails (mirrors
docker run --rm semantics)
- Works with all agents:
shell, claude, codex, etc.
Current workaround
Chain with ; (not &&) to guarantee cleanup on both success and failure:
NAME=ephemeral-$$ && \
sbx create shell . --name $NAME --quiet && \
sbx exec $NAME <command> ; \
sbx rm $NAME
Environment
sbx version: v0.23.0
- OS: macOS (Darwin 25.2.0, aarch64)
Summary
Add a
--rmflag tosbx createand/orsbx runthat automatically removes the sandbox after the session or command exits — equivalent todocker run --rm.Motivation
Running a one-shot command in a sandbox currently requires a manual 3-step workaround:
This is error-prone (forgetting cleanup leaves ghost sandboxes) and verbose for scripting / CI use cases.
Proposed API
Expected behavior
docker run --rmsemantics)shell,claude,codex, etc.Current workaround
Chain with
;(not&&) to guarantee cleanup on both success and failure:Environment
sbxversion: v0.23.0