locus sandbox
Create and manage provider Docker sandboxes, including auth, package installs, command execution, shell access, and logs.
Manage Docker-backed provider sandboxes used by Locus execution.
Usage
locus sandbox
locus sandbox <subcommand> [options]Subcommands
locus sandbox
Select a provider and create its sandbox
locus sandbox claude
Open an interactive Claude session in the Claude sandbox (for auth)
locus sandbox codex
Open an interactive Codex session in the Codex sandbox (for auth)
locus sandbox install <package...>
Install global npm package(s) inside sandbox(es)
locus sandbox shell <provider>
Open an interactive shell (sh) in a provider sandbox
locus sandbox logs <provider>
Show Docker sandbox logs for a provider sandbox
locus sandbox status
Show configured sandbox names and running state
locus sandbox rm
Remove provider sandboxes and disable sandbox mode
Providers
Provider values:
claudecodexall(supported byinstallonly)
Typical Setup Flow
install
Install one or more npm packages globally in sandbox environments.
Examples:
shell
Open an interactive shell in a provider sandbox.
Example:
logs
Show logs for a provider sandbox.
Examples:
status
Show whether sandbox mode is enabled, configured sandbox names, and running status for each provider.
rm
Remove all configured provider sandboxes and disable sandbox mode.
Custom Setup with sandbox-setup.sh
sandbox-setup.shLocus automatically runs .locus/sandbox-setup.sh inside each newly created sandbox after dependency installation. This hook lets you install additional toolchains, set environment variables, or perform any project-specific setup that the sandbox needs.
For JavaScript/TypeScript projects, Locus already handles package installation automatically. The setup script is most useful for non-JS projects or when you need extra tools beyond what the package manager provides.
How it works
After creating a sandbox, Locus detects your project ecosystem and installs JS dependencies if applicable.
If
.locus/sandbox-setup.shexists, Locus runs it inside the sandbox withsh.If no setup script exists and the project is non-JS, Locus prints a warning suggesting you create one.
Examples
Python project:
Rust project:
Go project:
JavaScript project with extra system dependencies:
Multi-language monorepo:
Tips
Keep the script idempotent — it may be re-run via
locus sandbox setup.The script runs as root inside the sandbox, so
sudois not needed.The working directory is set to your project root.
Use
set -eat the top if you want the script to fail fast on errors.
Shell Environment with sandbox-profile.sh
sandbox-profile.shWhen you open an interactive shell with locus sandbox shell <provider>, Locus automatically sets up the environment by adding common binary directories to PATH (node_modules/.bin, .venv/bin, .cargo/bin, go/bin, etc.) and configuring NODE_PATH.
If your project needs additional environment customization — extra PATH entries, environment variables, shell aliases, or functions — create a .locus/sandbox-profile.sh file. Locus sources this file at the end of shell initialization, so your customizations take effect on top of the auto-detected defaults.
How it works
Locus opens a shell inside the provider sandbox.
Common bin directories for all ecosystems are auto-detected and added to
PATH.NODE_PATHis configured for sandbox-installed dependencies.If
.locus/sandbox-profile.shexists, it is sourced (. <file>) in the shell context.The interactive shell starts.
When to use it
Your project uses tools installed in non-standard locations
You need project-specific environment variables available in the sandbox shell
You want shell aliases or helper functions for sandbox debugging
You have custom SDK paths, compiler flags, or runtime configuration
Examples
Custom environment variables and PATH:
Shell aliases for common tasks:
Multi-language environment setup:
Tips
This file is sourced, not executed as a subprocess — variables and aliases persist in the shell session.
It only runs during
locus sandbox shell, not during automated AI agent execution (locus run,locus exec).The working directory is set to your project root when the file is sourced.
Keep it lightweight — heavy initialization slows down shell startup.
Difference from sandbox-setup.sh
sandbox-setup.shsandbox-setup.sh
sandbox-profile.sh
Purpose
Install toolchains and dependencies
Customize shell environment
When
During sandbox creation (locus sandbox)
During interactive shell (locus sandbox shell)
Execution
Runs as a subprocess (sh <file>)
Sourced in shell context (. <file>)
Runs as
Root, non-interactive
Current user, interactive shell
Use for
apt-get install, pip install, cargo build
export, alias, PATH additions
Notes
Sandboxes must be created first with
locus sandbox.If a provider sandbox is missing or not running, subcommands return guidance to recreate it.
Locus enforces
.sandboxignorerules when syncing workspace content into sandbox execution.
Last updated