Created
July 7, 2026 13:57
-
-
Save rigtorp/4ecb4a3008473196845ae0abad9c2d06 to your computer and use it in GitHub Desktop.
Sandbox suitable for coding agents
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| #!/usr/bin/bash | |
| # Run arbitrary commands inside the bubblewrap sandbox for agy, codex, gemini, etc. | |
| if [ $# -lt 1 ]; then | |
| echo "Usage: sandbox-exec <command> [args...]" >&2 | |
| exit 1 | |
| fi | |
| exec bwrap \ | |
| --unshare-user --uid "$(id -u)" --gid "$(id -g)" \ | |
| --unshare-pid --unshare-uts --hostname bubblewrap \ | |
| --dev /dev \ | |
| --proc /proc \ | |
| --tmpfs /tmp \ | |
| --ro-bind /usr /usr \ | |
| --symlink /usr/bin /bin \ | |
| --symlink /usr/lib /lib \ | |
| --symlink /usr/lib64 /lib64 \ | |
| --ro-bind-try /sys /sys \ | |
| --ro-bind-try /etc/resolv.conf /etc/resolv.conf \ | |
| --ro-bind-try /etc/hosts /etc/hosts \ | |
| --ro-bind-try /etc/nsswitch.conf /etc/nsswitch.conf \ | |
| --ro-bind-try /etc/crypto-policies /etc/crypto-policies \ | |
| --ro-bind-try /etc/ssl /etc/ssl \ | |
| --ro-bind-try /etc/pki /etc/pki \ | |
| --ro-bind-try /etc/ca-certificates /etc/ca-certificates \ | |
| --ro-bind-try /etc/mime.types /etc/mime.types \ | |
| --ro-bind-try /etc/passwd /etc/passwd \ | |
| --ro-bind-try /etc/group /etc/group \ | |
| --ro-bind-try /etc/alternatives /etc/alternatives \ | |
| --ro-bind-try "$HOME/.gitconfig" "$HOME/.gitconfig" \ | |
| --bind-try "$HOME/.npm" "$HOME/.npm" \ | |
| --bind-try "$HOME/.cache" "$HOME/.cache" \ | |
| --bind-try "$HOME/.gemini" "$HOME/.gemini" \ | |
| --bind-try "$HOME/.codex" "$HOME/.codex" \ | |
| --ro-bind /nix /nix \ | |
| --ro-bind-try "$HOME/.local/state/nix" "$HOME/.local/state/nix" \ | |
| --symlink "$HOME/.local/state/nix/profiles/profile" "$HOME/.nix-profile" \ | |
| --ro-bind-try "$HOME/.local/bin" "$HOME/.local/bin" \ | |
| --bind "$PWD" "$PWD" \ | |
| -- "$@" |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment