Run OpenCode (default) or Claude Code in a secure, sandboxed Docker environment. The sandbox blocks code pushes and restricts network access to prevent data leaks.
-
Setup Configuration:
cp .env.example .env # (Optional) Edit .env to set your git user/email -
Start the Sandbox: Run this from your project root (or provide the path as an argument):
/path/to/ai-sandbox .This starts OpenCode by default.
-
Authenticate (First Run Only): Credentials persist across restarts.
- GitHub: Run
gh auth logininside the sandbox. - OpenCode / Gemini:
- The tool will prompt you to login and show a URL.
- Open that URL in your host browser and follow the workflow.
- Final Step: The browser will eventually show a "connection refused" error on
localhost:8085. This is expected. - Copy the URL of that error page (the one starting with
http://localhost:8085/...). - Open a new terminal on your host and run:
./ai-sandbox-auth "http://localhost:8085/..." - The script will complete the login for you.
- GitHub: Run
# Start with OpenCode (Default)
./ai-sandbox /path/to/project
# Start with Claude Code
./ai-sandbox /path/to/project --claudeCommon Options:
--build: Rebuild the container (use if you updated the sandbox code).--unrestricted: Disable network allowlist (use with caution).--stop-proxy: Stop the shared network proxy.
Exit: Press Ctrl+D or type /exit. Containers are cleaned up automatically.
Traffic is restricted to domains in proxy/allowlist.txt.
- Defaults: GitHub, Anthropic, OpenCode, PyPI, NPM.
- Add Domains: Edit
proxy/allowlist.txtand run./ai-sandbox-reload(while the sandbox/proxy is running).
- Linux: Run
xhost +local:dockeron your host to enable copy/paste. - WSL: Works automatically with WSLg.
Add this to your shell config (~/.bashrc or ~/.zshrc) to run oc from any directory:
alias oc='/path/to/ai-sandbox/ai-sandbox . --opencode'