CLI Reference
Complete command-line interface reference for Shai.
Commands
shai
Main command - starts a sandbox in the current directory.
1shai [flags] [-- command [args...]]shai generate
Generate a default .shai/config.yaml file.
1shai generateCreates .shai/config.yaml with sensible defaults.
shai version
Display version information.
1shai versionFlags
--read-write, -rw <path>
Repeatable: Yes
Mark a path as writable. Path must exist.
1shai -rw src/components
2shai -rw src -rw tests--resource-set, -rs <name>
Repeatable: Yes
Opt into additional resource sets beyond config’s apply rules.
1shai -rw src --resource-set gpu-access
2shai -rs tools-1 -rs tools-2--image, -i <image>
Override the container image.
1shai --image ghcr.io/my-org/custom:latestTakes precedence over config file and apply rules.
--user, -u <user>
Override the target container user.
1shai --user developerDefault: shai
--privileged
Run the container in privileged mode.
1shai --privileged--var, -v KEY=value
Repeatable: Yes
Provide template variables for config.
1shai --var TAG=v1.2.3 --var ENV=stagingUsed with ${{ vars.KEY }} in config.
--verbose, -V
Dump bootstrap details and resource decisions.
1shai --verboseShows:
- Bootstrap script
- Resolved resource sets
- Network filtering rules
- Mount points
--no-tty, -T
Disable TTY allocation.
1shai --no-tty -- npm testUseful for structured log output and CI/CD.
--config <path>
Override config file location.
1shai --config /path/to/custom-config.yamlDefault: .shai/config.yaml in workspace root
--help, -h
Show help message.
1shai --helpPost-Setup Command
Everything after -- is executed inside the sandbox after setup:
1shai -rw src -- npm test
2shai -rw backend -- go build ./...
3shai -rw . -- bash -c "echo hello && pwd"Without --, Shai drops you into an interactive shell.
Examples
Basic Usage
1# Interactive shell (read-only)
2shai
3
4# Interactive shell (src writable)
5shai -rw src
6
7# Run command
8shai -- npm test
9
10# Run command with write access
11shai -rw src -- npm run buildMultiple Paths
1# Multiple writable paths
2shai -rw src/auth -rw src/payments -rw tests
3
4# Run tests with write access to coverage output
5shai -rw coverage -- npm testResource Sets
1# Add resource sets
2shai -rw ml --resource-set gpu-access --resource-set wandb-api
3
4# Override image
5shai -rw src --image ghcr.io/my-org/dev:latest
6
7# Custom user
8shai -rw backend --user developerTemplate Variables
1# Provide template vars
2shai --var ENV=production --var REGION=us-west-2 -rw infrastructure
3
4# Multiple vars
5shai --var TAG=v2.0.0 --var DEBUG=trueDebugging
1# Verbose output
2shai -rw src --verbose
3
4# Inspect bootstrap without running
5shai -rw src --verbose -- /bin/true
6
7# No TTY for logs
8shai --no-tty -- ./run-tests.sh > test.logComplex Commands
1# Chain commands
2shai -- bash -c "npm install && npm test"
3
4# With environment
5shai -- env NODE_ENV=test npm test
6
7# Multiple commands
8shai -- sh -c "echo start && npm run build && echo done"Exit Codes
| Code | Meaning |
|---|---|
| 0 | Success |
| 1 | General error |
| 2 | Docker not available |
| 3 | Config invalid |
| 4 | Path doesn’t exist |
| 125 | Docker daemon error |
| 126 | Command cannot execute |
| 127 | Command not found |
| 130 | Terminated by Ctrl+C |
Environment Variables
DOCKER_HOST
Override Docker daemon location.
1export DOCKER_HOST=unix:///var/run/docker.sock
2shaiSHAI_CONFIG
Default config file location.
1export SHAI_CONFIG=/path/to/config.yaml
2shaiShell Completion
Bash
1shai completion bash > /etc/bash_completion.d/shaiZsh
1shai completion zsh > ~/.zsh/completions/_shaiFish
1shai completion fish > ~/.config/fish/completions/shai.fishTips
Quick Iteration
1# Use short flags
2shai -rw src -V -- npm test
3
4# Omit redundant flags
5shai -rw . # Entire workspace writableCombining Flags
1# All flags together
2shai \
3 --image custom:latest \
4 --user dev \
5 --resource-set tools \
6 --var TAG=v1.0.0 \
7 --verbose \
8 -rw src \
9 -- npm run buildDefault Behavior
1# No command = interactive shell
2shai -rw src
3
4# No -rw = read-only workspace
5shai
6
7# No config = uses embedded defaults
8shai # Works even without .shai/config.yamlSee Also
- Quick Start for getting started
- Configuration Reference for config options
- Examples for common patterns