Skip to content

Feature request: --rm flag for ephemeral sandboxes #26

@DevOpsAIguru123

Description

@DevOpsAIguru123

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)

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions