A lightweight bash wrapper that runs the Crush CLI in a Docker sandbox with persistent package manager caches. Perfect for isolating your development environment while keeping tools and dependencies cached per workspace.
- macOS (primary target)
- Docker Desktop installed and running
The recommended installation method uses npm to install crush-sandbox globally:
npm install -g crush-sandboxAutomatic installation:
curl -fsSL https://raw.githubusercontent.com/wireless25/crush-sandbox/main/docker-sandbox-crush | sudo tee /usr/local/bin/crush-sandbox > /dev/null
sudo chmod +x /usr/local/bin/crush-sandbox
ln -s /usr/local/bin/crush-sandbox /usr/local/bin/crushboxManual installation:
-
Download the script:
curl -fsSL https://raw.githubusercontent.com/wireless25/crush-sandbox/main/docker-sandbox-crush -o docker-sandbox-crush
-
Make it executable:
chmod +x docker-sandbox-crush
-
Move it to your PATH:
sudo mv docker-sandbox-crush /usr/local/bin/crush-sandbox
Install using the script itself:
If you've cloned the repository, you can use the built-in install command:
./docker-sandbox-crush installThis will:
- Validate Docker is available
- Install the script to
/usr/local/bin/crush-sandbox - Create a
crushboxalias symlink - Display version information for installed tools
Note: gitleaks Docker image will be pulled automatically on first use for credential scanning. No additional installation is required.
- Workspace isolation: Each workspace directory gets its own sandbox container
- Persistent caches: npm and pnpm caches persist per workspace for faster subsequent runs
- Automatic Crush CLI installation: Crush CLI is installed automatically on first use
- Git config injection: Your Git user.name and user.email are passed into the container
- Container reuse: Containers are stopped but not removed, enabling fast restarts
- Debugging support: Use
--shellflag to get an interactive shell instead of Crush CLI - Configuration support: Automatically mounts and merges Crush configuration from host
The Docker sandbox automatically provides Crush CLI configuration:
Host configuration (global defaults):
~/.config/crush/
Workspace configuration (workspace-specific):
.crush.jsonorcrush.json(relative to workspace root)
If you maintain global Crush config with commands, skills, or settings, this will be mounted into the container. Any workspace-specific config will override these settings.
Config files in the workspace are mounted into the container with the rest of the code and take precedence over host config by default in Crush. Make sure to configure your skills
and commands accordingly. If you want to use global configured skills, add the /tmp/crush-config/merged/skills path to the skills option in the config (global on host or in workspace) to make Crush pick them up.
Example to include skills from global host in the config:
{
"$schema": "https://charm.land/crush.json",
"options": {
"skills_paths": [
"~/.config/crush/skills",
"/tmp/crush-config/merged/skills"
]
}
}With this configuration, you can still use crush on your host machine with the same setup.
- Host configuration is copied to the container
- Workspace configuration is mounted with the workspace, overwriting host config (Crush default behavior)
- Host configuration is available at
/tmp/crush-config/mergedinside the container CRUSH_GLOBAL_CONFIGenvironment variable is set to this location
This means workspace-specific settings always override global defaults.
- All configuration mounts are read-only (
:roflag) - The container cannot modify your host configuration files
You can control configuration behavior with these flags:
| Flag | Description |
|---|---|
--no-host-config |
Skip mounting host Crush config directory |
Examples:
# Skip host configuration
crush-sandbox run --no-host-config
# Or use alias:
crushbox run --no-host-config~/.config/crush/ # Host configuration (global)
├── crush.json # Main Crush config
└── skills # Skills directory
└── commands # Commands directory
If you have a crush.json or .crush.json already in the workspace root, this will take precedence over the .config/crush/ directory by Crush CLI's own behavior.
Navigate to your workspace directory and run:
crush-sandbox runOr use the alias:
crushbox runThis will:
- Create (or reuse) a sandbox container for your workspace
- Mount your workspace at the same absolute path
- Install Crush CLI if not already installed
- Install pnpm for package management
- Start the Crush CLI
If you need to debug or run manual commands:
crush-sandbox run --shellOr with the alias:
crushbox run --shellThis gives you an interactive shell in the sandbox container instead of running Crush CLI.
To remove the container and cache volume for the current workspace:
crush-sandbox cleanOr with the alias:
crushbox cleanAdd --force to skip confirmation:
crush-sandbox clean --forcecrush-sandbox --versioncrush-sandbox updateThis will:
- Check for the latest version on GitHub
- Compare with your current version
- Prompt for confirmation if a newer version is available
- Download and replace the script automatically
- Validate the downloaded script before installing
crush-sandbox helpThe docker-sandbox-crush tool implements several security controls to make AI-assisted development safe(er). However, the tool requires you to follow certain security practices to ensure safe operation.
Crush asks for your permission before performing any operation, but if you use --yolo mode or use it programmatically with crush run in a ralph loop, you must be aware of the security implications.
The Crush agent inside the container has full read-write access to your workspace files. This is intentional and necessary for the agent to:
- Read and modify source code files
- Run build commands and tests
- Create new files and directories
- Install packages and dependencies
- Execute git operations
Security Implications:
- Trust the AI agent: The agent can modify any file in your workspace
- Credential exposure risk: Never store secrets (API keys, passwords, tokens) in your workspace files
- Review all changes: Always review agent-generated changes
- Use version control: Git provides a safety net - you can revert any unwanted changes
Best Practices:
- Store credentials in:
- Environment variables
- Secret management tools
- CI/CD pipeline secrets (GitHub Actions Secrets, GitLab CI Variables)
.envfiles that are gitignored
- Never commit credentials to git
- Use
.gitignoreto exclude files with secrets - Rotate credentials if they were ever committed accidentally
When planning to use --yolo mode or use it programmatically with crush run, you should configure git branch protection to prevent direct pushes to production branches. This ensures:
- All agent-generated code goes through a pull request process
- Code review is required before merging
- CI/CD checks must pass before merging
- Unauthorized direct commits are blocked
The Crush agent inside the sandbox container can:
✅ Read and write workspace files
- Full access to all files in the mounted workspace
- Can create, modify, delete any file
- Can execute any command within the workspace
✅ Run commands and scripts
- Execute build commands (npm build, cargo build, etc.)
- Run tests (npm test, pytest, etc.)
- Install packages (npm install, pip install, etc.)
✅ Make git operations
- Create commits
- Create branches
- Stage files
- Push to remote repositories
✅ Access network resources
- Download dependencies from npm, PyPI, etc.
- Make HTTP requests (if in code)
- Clone other git repositories
The Crush agent cannot:
❌ Access files outside the workspace
- Container is limited to mounted workspace directory
- Cannot access your home directory (except workspace subdirectories)
- Cannot access system files or other projects
❌ Run with elevated privileges
- Container runs as non-root user
- Cannot install system packages globally
- Cannot modify Docker host
❌ Escalate privileges
- Docker capabilities are dropped (except CHOWN and DAC_OVERRIDE)
- Cannot gain root access
- Cannot modify container configuration
❌ Access host resources directly
- No direct access to host network
- No access to host filesystem beyond workspace
- Cannot interact with other containers
The tool implements these security controls:
-
Resource limits - Prevents resource exhaustion attacks:
- Memory limited to 4GB
- CPU limited to 2 cores
- Process count limited to 100 PIDs
-
Non-root user - Limits attack surface:
- Container runs as your UID/GID
- Cannot perform privileged operations
-
Capability dropping - Reduces Linux capabilities:
- All capabilities dropped by default
- CHOWN and DAC_OVERRIDE added back (required for cache and workspace access)
-
Credential scanning - Warns about exposed secrets:
- Scans workspace with gitleaks before starting
- gitleaks is automatically installed when you run
crush-sandbox run --cred-scan - Prompts you to continue or abort if credentials detected
- Can be bypassed with
--no-cred-scanflag (use with caution)
-
Workspace isolation - Prevents cross-project contamination:
- Each workspace has its own container
- Caches are per-workspace
- No shared state between workspaces
Each workspace directory (your current working directory) gets its own:
- Container: Named
crush-sandbox-<hash>where<hash>is derived from your workspace path - Cache volume: Named
crush-cache-<hash>for persistent package manager caches
This means different projects have completely isolated sandbox environments.
- Create: Container is created from
node:18-alpinebase image - Configure: Workspace and cache volumes are mounted, environment variables are set
- Start: Container is started
- Use: Crush CLI or shell runs inside the container
- Stop: Container is stopped when you exit (kept for reuse)
Containers are not removed automatically, so subsequent starts are instant.
The cache volume stores:
- npm cache:
/workspace-cache/npm - pnpm store:
/workspace-cache/pnpm/store - pnpm cache:
/workspace-cache/pnpm/cache
This means:
- Packages downloaded once stay cached
- Switching workspaces switches cache volumes
- Faster installs after the first run
On container startup:
- Crush CLI: Installed via
npm install -g @charmland/crush(cached after first install) - pnpm: Installed via
npm install -g pnpm(uses npm cache)
Installation happens automatically and silently on every container start, with fast-path checks to skip re-installation.
# Navigate to your project
cd ~/projects/my-app
# Start Crush CLI in sandbox
crush-sandbox run
# Or use alias:
# crushbox run
# ... work with Crush CLI ...
# When done, Crush CLI exits and container stops
# Next time, container is reused (instant start)cd ~/projects/project-a
crush-sandbox run # Uses crush-sandbox-<hash-a>
cd ~/projects/project-b
crush-sandbox run # Uses crush-sandbox-<hash-b>Each workspace has its own isolated environment.
# Get a shell to check installation
crush-sandbox run --shell
# Or:
crushbox run --shell
# Inside the container:
which crush # Check if Crush CLI is installed
pnpm --version # Check pnpm version
npm --version # Check npm versionProblem: Docker Desktop is not running.
Solution: Start Docker Desktop and wait for it to be ready. Verify with:
docker infoProblem: Git user configuration is missing.
Solution: This is a warning, not an error. Add to ~/.gitconfig if Crush CLI needs git operations:
git config --global user.name "Your Name"
git config --global user.email "your.email@example.com"Problem: Crush CLI installation failed.
Solution: Run with --shell flag to debug:
crush-sandbox run --shell
# Then manually install:
npm install -g @charmland/crushProblem: Packages are re-downloaded every time.
Solution: Verify cache volume exists:
docker volume ls | grep crush-cacheCheck if volume is mounted:
docker inspect <container-name> | grep MountsProblem: No write permissions to /usr/local/bin.
Solution: Run with sudo:
sudo ./docker-sandbox-crush installOr choose a different installation directory in your PATH.
Problem: Different containers for the same project.
Solution: Ensure you're in the same workspace directory. Container names are based on the current working directory (pwd).
This project is licensed under the MIT License - see the LICENSE file for details.
Contributions are welcome! Please feel free to submit a Pull Request.
If you encounter issues or have questions:
- Check the Troubleshooting section above
- Search existing GitHub Issues
- Open a new issue with details
- Crush CLI - The AI-powered CLI assistant
- Docker Desktop for Mac - Container runtime
Made with ❤️ for developers who love isolated environments