rollcage
A macOS Seatbelt sandbox for agent CLIs — Claude Code via rollcage claude, Codex CLI via rollcage codex, the Pi coding agent via rollcage pi, Oh My Pi via rollcage omp, and OpenCode via rollcage opencode. Each adapter runs the underlying agent in sandbox-exec with a strict, layered SBPL profile so the agent can only read and write files you've explicitly allowed.
Why
By default Claude Code can read and write anywhere your shell can — including ~/.ssh, ~/.aws, browser profiles, shell history, and any document on disk. Anthropic ships a built-in sandbox option (sandbox.enabled in settings) but it has known issues on macOS: denyRead is ineffective, allowRead doesn't exist in the schema, and the generated SBPL profiles can crash the process silently.
rollcage replaces it with a hand-tuned Seatbelt profile that defaults to strict deny, lets you opt in to extra access via a tiny safe DSL, and ships with a Claude Code plugin so the agent helps you fix denials instead of working around them.
For Codex CLI, rollcage codex uses the same outer Seatbelt boundary and starts Codex with --dangerously-bypass-approvals-and-sandbox. That disables Codex's own approval/sandbox layer because the OS sandbox assembled by rollcage codex is the enforcement boundary.
For the Pi coding agent, rollcage pi uses the same outer Seatbelt boundary. Pi has no built-in approval/sandbox layer to disable, so the binary runs with whatever arguments you pass through — the OS sandbox is the only enforcement layer.
For Oh My Pi, rollcage omp passes --auto-approve to bypass OMP's application-level permission prompts while applying the same outer Seatbelt boundary. OMP's DeepSeek API keys and OpenAI Codex OAuth credentials stay in its own SQLite store under ~/.omp; rollcage omp does not expose Codex CLI's auth file or the macOS Keychain.
For OpenCode, rollcage opencode passes --auto to bypass OpenCode's application-level permission prompts while applying the outer Seatbelt boundary. OpenCode's credentials and session database remain in its app-specific data directory; unrelated agent credentials and the macOS Keychain stay blocked.
What it protects
The sandbox primarily enforces filesystem isolation. Network, POSIX IPC, and Mach ports are open; System V IPC remains blocked unless an opt-in toolchain grants it — see Known limitations for the trade-offs.
Reads, writes, exec
| Operation | Default policy |
|---|
file-read-data | Strict allowlist: system runtime, Claude config, project directory, declared toolchains |
file-write* | Project directory, Claude state files, tmp directories, code-signing clones — nothing else without an explicit rule |
process-exec | System binaries, Homebrew, Claude binary, project scripts, declared toolchains |
network*, mach*, ipc-posix* | All allowed |
Blocked by default
~/.ssh, ~/.aws, ~/.gnupg, ~/.docker, ~/Desktop, ~/Downloads, ~/Documents, ~/Library (except ~/Library/Keychains for OAuth), ~/.zsh_history, and anything else not explicitly listed.
Write-protected inside the project
The project directory is writable, but these paths are protected by deny-after-allow rules (SBPL last-match-wins) so the agent cannot tamper with them:
| Path | Why |
|---|
.rollcage | Sandbox config — prevents privilege escalation on next launch |
.env, .env.local, .env.development, .env.staging, .env.test, .env.production | Common locations for secrets and API keys |
.git/hooks/ | Prevents injection of code that runs on git operations |
Verified escape vectors
These attack patterns are all blocked by Seatbelt's kernel-level enforcement and covered by the test suite: symlink traversal, hardlinks, /tmp script execution, child process inheritance (python, node, bash), file descriptor redirects, and curl exfiltration of locally blocked files.
Quick start
-
Clone the repo and add it to your PATH:
git clone https://github.com/codewithcheese/rollcage.git
export PATH="$PWD/rollcage:$PATH" # add to your shell rc
Rollcage requires macOS with sandbox-exec; it refuses to launch without Seatbelt.
-
Run it from any project directory, selecting your agent:
cd /path/to/your/project
rollcage claude # Claude Code
rollcage codex # Codex CLI
rollcage pi # Pi coding agent
rollcage omp # Oh My Pi coding agent
rollcage opencode # OpenCode