Skip to content

Support -e/--env and --env-file flags in sbx run #64

@kkyr

Description

@kkyr

Description

sbx exec supports Docker-style environment flags:

  • -e, --env to set environment variables
  • --env-file to read environment variables from a file

It would be useful for sbx run to support the same flags when starting an agent sandbox.

Current Behavior

The sbx exec command can pass environment variables into a command that runs inside an existing sandbox:

sbx exec -e NODE_ENV=development my-sandbox node script.js
sbx exec --env-file .env my-sandbox node script.js

However, sbx run does not currently provide equivalent flags for passing environment variables when creating or starting an agent sandbox.

Requested Behavior

Allow environment variables to be passed when creating or starting a sandbox through sbx run, for example:

sbx run -e NODE_ENV=development claude . 
sbx run --env-file .env claude .

This would make sbx run more consistent with sbx exec and Docker-style workflows, and would avoid needing a separate sbx create / sbx exec step just to inject environment configuration.

Use Cases

  • Passing API keys or tokens into agent sandboxes
  • Loading project-specific .env files
  • Setting language/runtime configuration such as NODE_ENV, PYTHONPATH, RUST_LOG, etc.
  • Keeping sandbox startup behavior consistent with sbx exec

Suggested Behavior

  • -e/--env KEY=VALUE may be provided multiple times
  • --env-file PATH may be provided multiple times, or follow the same behavior as docker run --env-file
  • Environment variables should apply when the sandbox is run (not only created) and be available to the initial agent process

This would make sbx run more ergonomic for common development and agent workflows.

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