/rollcage:debug-sandboxfrom rollcage
Fix sandbox-exec denials and permission errors. Use when a command fails with "deny", "Operation not permitted", or "sandbox" errors.
Ships in rollcage. Installing the plugin adds it to Claude Code.
What the skill costs in Claude's context, stage by stage
Name and description: Claude knows it exists.
SKILL.md joins the conversation and stays.
None: SKILL.md is the whole skill.
rollcage claude wraps Claude Code in sandbox-exec with a strict SBPL profile. By default
everything is denied. The base profile allows what Claude Code itself needs (system
binaries, Claude config, project directory read/write, tmp, network). Users add
project-specific permissions in a .rollcage file at the project root.
The .rollcage file is trust-gated: new or changed configs require explicit user
approval (sha256-verified) before they take effect.
Four directives only. No raw SBPL. No deny rules.
tool <name> # Activate a bundled toolchain
allow-read <path> # Grant file-read-data (subpath)
allow-write <path> # Grant file-read-data + file-write* (subpath)
allow-exec <path> # Grant file-read-data + process-exec (subpath)
Path prefixes:
~/ expands to $HOME (e.g. ~/.cargo)./ expands to $PROJECT_DIR (e.g. ./data/cache)/ is absolute (e.g. /opt/custom)Comments start with #. Blank lines are ignored.
| Name | What it grants |
|---|---|
node | NVM, npm/npx, Corepack; pnpm macOS ~/Library/pnpm/{store,package-manager-store,.tools/pnpm} read+write+exec, engine lockfile and atomic temps in global/v11, ~/.pnpm-state read+write; legacy/XDG stores; pnpm config (~/.config/pnpm, ~/Library/Preferences/pnpm) read-only. Global apps/bins are not granted by the macOS rules. See docs/pnpm.md. |
bun | Bun runtime and install cache (~/.bun) |
uv | uv/uvx, cache (~/Library/Caches/uv, ~/.local/share/uv). ~/.local/bin is read+exec only |
python | pyenv (~/.pyenv) and python.org Framework interpreters (/Library/Frameworks/Python.framework, read/exec only) |
metal | Metal compiler cache: allows issuing a read-write sandbox extension only for CACHE_DIR/com.apple.metalfe; direct cache writes are already in the base profile. For xcrun with full Xcode, add allow-exec /Applications/Xcode.app/Contents/Developer in project config. |
rust | Cargo (~/.cargo), rustup (~/.rustup read+exec; distribution state writable for pinned toolchain installs, settings read-only), and the C linker (clang/ld via Xcode.app + Command Line Tools, read+exec) that cargo build invokes to link native binaries |
go | Go toolchain (/usr/local/go, ~/go), build cache (~/.cache/go-build) |
swift | SwiftPM via Xcode or Command Line Tools, caches/config (~/Library/{Caches/,}org.swift.swiftpm, ~/.swiftpm), narrow TMPDIR exec for the manifest binary. Requires --disable-sandbox on swift commands (macOS forbids nested sandbox-exec) |
deno | Deno runtime and cache (~/.deno) |
postgres | Local PostgreSQL servers: SysV shared memory and semaphores required on macOS, plus Intel Homebrew PostgreSQL/libpq execution. Data, logs, and sockets must stay under PROJECT_DIR or TMPDIR; Homebrew's persistent cluster remains read-only |
gh | GitHub CLI auth tokens (~/.config/gh, read-only) |
huggingface | Model cache, auth tokens (~/.cache/huggingface) |
seshi | Claude Code session indexer hook. Venv (~/.local/share/uv/tools/seshi), uv-managed cpython (~/.local/share/uv/python), data dir (~/.local/share/seshi read+write). Pair with tool huggingface for embedding downloads |
cmux | cmux app bundle (/Applications/cmux.app), runtime state (~/Library/Application Support/cmux), caches (~/Library/Caches/cmux) |
playwright | Browser downloads and binaries (~/Library/Caches/ms-playwright read+write+exec) |
playwright-chromium | Chromium-specific macOS paths: locale, input methods, spelling, crash reporter, branding. Requires tool playwright |
chrome | Google Chrome (/Applications/Google Chrome.app read+exec), macOS integration (locale, input methods, spelling), crash reporter (~/Library/Application Support/Google/Chrome). Use --no-sandbox --user-data-dir=./profile |
electron-ghostty | Electron apps embedding libghostty: pseudo-tty operation (PTY alloc), Electron support/cache/log/saved-state dirs (~/Library/{Application Support,Caches,Logs,Saved Application State}/...Electron), IME/keyboard/spelling reads. No sugid exec — app must spawn $SHELL directly, not via /usr/bin/login. Embedded only, not standalone Ghostty.app |
Always prefer a tool directive over manual allow-* rules when a toolchain exists.
Toolchains are vetted for least privilege (e.g. node makes ~/.nvm read-only,
only ~/.npm is writable).
Do NOT add rules for these — they are always available:
Exec: /bin, /usr/bin, /opt/homebrew, ~/.local/bin/claude, ~/.local/share/claude, project scripts
Read: System paths (/System, /Library, /usr, /bin, /opt/homebrew), project directory, Claude config (~/.claude), Rollcage user config (~/.config/rollcage/config), packs, and Claude trust snapshots, git config, shell rc files, tmp dirs, keychain. All launchers can read the shared user config file ~/.config/rollcage/config; symlink targets still need explicit read grants.
Write: Project directory, Claude state (~/.claude), tmp dirs, CACHE_DIR (/private/var/folders/.../C/ — direct Metal cache writes), and VOLATILE_DIR (.../X/ — code-signing clones). Metal's compiler service also needs tool metal to issue a scoped cache extension.
Other: dynamic-code-generation (JIT/WASM), all network/POSIX IPC/Mach, TMPDIR + CACHE_DIR + VOLATILE_DIR (parameterized per-session). System V IPC remains opt-in through toolchains such as postgres
Protected (final denies after all grants): .rollcage, user rules/packs/trust under ~/.config/rollcage, resolved config and referenced pack targets and their ancestor directory entries, .env* files, .git/hooks/
The list above is for
rollcage claude(Claude Code).rollcage codexswaps in~/.codex(read+write),~/.agents/skills(read-only), its install paths under~/.nvm,~/.bun,~/.local/bin,/usr/local/{bin,lib/node_modules}/codex, and the two ChatGPT-bundled Node REPL executables plus their read-onlynode_modulestree.rollcage piswaps in~/.pi(read+write) withprocess-execscoped narrowly to~/.pi/agent/{npm,git,extensions}, plus install paths under~/.nvm,~/.local/bin,~/.local/share/pi-node, and/usr/local/{bin,lib/node_modules}/@earendil-works/pi-coding-agent.rollcage ompswaps in~/.omp(read+write), keeps OMP's SQLite credential store there, and scopes execution to documented OMP installs, plugins/extensions/hooks/tools, the managed Python environment, OMP-downloaded browsers under~/.omp/puppeteer, and Apple debugger binaries. System Google Chrome remains opt-in throughtool chrome. It does not grant~/.codexor Keychain access because OMP's Codex OAuth flow persists independently in~/.omp/agent/agent.db.rollcage opencodegrants read+write only to OpenCode's default config/data/state/cache roots, read-only cross-agent skill discovery, exact execution of the resolved CLI, and execution under~/.cache/opencode/bin; it does not grant Codex auth or Keychain access. Project.rollcageis the shared trust-gated config for all five.
If a denial is for a path under /private/var/folders, it is likely already covered by TMPDIR (.../T/), CACHE_DIR (.../C/), or VOLATILE_DIR (.../X/). Do NOT suggest project rules for these paths. For com.apple.metalfe/monolithic_metal.pcm, check whether tool metal is active; direct cache writes alone do not grant the file-issue-extension operation used by Metal's compiler service.
These cause errors — never generate rules that violate them:
~ or ~/ — too broad, must specify a subdirectory./ or . — too broad, must specify a subdirectory~/, ./, or /allow-read on /System/*, /Library/*, /usr/*, /bin/*, /sbin/*, /opt/homebrew/* — rejected, base already reads themallow-write on those same roots — rejected (system paths must not be writable)allow-exec — only /bin/*, /usr/bin/*, /opt/homebrew/* are rejected as base-covered; allow-exec /Library/Java/..., /usr/libexec/*, /usr/local/*, /sbin/* are accepted for tools the base doesn't exec.rollcage as the basename — config is protectedSome failures look like permission errors but are NOT rollcage permission issues. Check for these signatures BEFORE starting Phase 1, and short-circuit if matched.
sandbox-exec: sandbox_apply: Operation not permitted)If the failing command's stderr contains sandbox_apply: Operation not permitted (or sandbox-exec: sandbox_apply), the cause is Claude Code's built-in sandbox trying to nest inside rollcage's sandbox. The macOS kernel hard-blocks nested sandbox-exec regardless of profile content — there is no SBPL operation that can allow it. This is NOT a path-permission problem and CANNOT be fixed by widening .rollcage.
Do not proceed to Phase 1. Tell the user:
Claude Code's built-in sandbox (
sandbox.enabled: true) is incompatible with rollcage. Disable it by adding"sandbox": { "enabled": false }to.claude/settings.local.json(project, gitignored) or~/.claude/settings.json(user). Then restart the session. rollcage already provides filesystem isolation — Claude's built-in sandbox is redundant when running under rollcage.
Stop. Do not draft .rollcage rules. Do not invoke any of the later phases for this signature.
Before drafting any rules, think through alternatives:
npm install not npm install -g, pip install --target . not pip install --user)~/?If an alternative exists that works within current permissions, recommend it and stop. Do not widen permissions unnecessarily.
If permissions must be widened, examine what's already configured and what the project needs:
~/.config/rollcage/config if it exists. All five launchers load this same file. It contains toolchains and rules that apply to ALL projects (e.g. tool cmux, shell config symlink targets). Do not duplicate or re-suggest rules that are already in user config..rollcage — read it if present (this may be a revision)For each path you're considering granting access to, think through:
allow-write ~/.nvm exposes the entire node installation to modification. Is a narrower subpath sufficient?~/.nvm/versions/node/v22.17.1/...) that break on upgrades. Use the toolchain directive instead which handles this correctly.tool <name> over manual allow-* rules.Map each need to the narrowest directive:
toolallow-read over allow-write — only grant write if the tool actually writes thereallow-read over allow-exec — only grant exec if binaries live there~/.config/myapp not ~/.configBefore presenting the config, verify:
Present the .rollcage file with comments explaining each rule.
Lifecycle instructions — always include these when presenting changes:
.rollcage is write-protected inside the sandbox. The user must exit rollcage claude to create or edit it..rollcage, invoke /reload-sandbox then /exit. rollcage will automatically restart with the updated profile and resume the conversation via --continue.! prefix or any other in-session workaround.<non_negotiables>
allow-write when allow-read sufficestool directive when a matching toolchain existsallow-read ~/.config/myapp
</output>
<reasoning>
- `tool node` covers ~/.nvm (read+exec) and ~/.npm (read+write+exec)
- .env files are already write-protected by base-claude.sb
- Project directory read/write is already in base-claude.sb, no rule needed
- Only the custom config path needs an explicit rule
</reasoning>
</example>
<example>
<scenario>Python project using uv, with a shared data directory</scenario>
<output>
```sh
# Runtime — uv package manager, uvx
tool uv
# Data — shared datasets read by training scripts
allow-read ~/datasets/nlp
# Cache — model checkpoints written during training
allow-write ./output/checkpoints
- `tool uv` covers uv/uvx binaries, cache, and tool environments
- ~/datasets/nlp is read-only because scripts only read training data
- ./output/checkpoints needs write because the project writes there
- ./output/checkpoints is inside PROJECT_DIR but uses allow-write for clarity
(actually redundant since project dir is already writable — should be removed)
./output/checkpoints is inside the project directory which is already writable.
That rule should be removed. Only paths OUTSIDE the project need explicit rules.
User says "give it access to my home directory"
Bare `~/` is rejected by rollcage — it's too broad and would expose sensitive
files like ~/.ssh, ~/.aws, and ~/.gnupg. What specific directories or files
does your project need to access? For example:
- Config files? → `allow-read ~/.config/yourapp`
- A data directory? → `allow-read ~/data/yourproject`
- A cache? → `allow-write ~/.cache/yourapp`
User wants to use a tool that has no toolchain (e.g. terraform)
```sh
# Terraform binary
allow-exec ~/.local/bin/terraform
allow-read ~/.terraform.d allow-write ~/.terraform.d/plugin-cache
</output>
<reasoning>
- No `tool terraform` exists, so manual rules are needed
- Exec is limited to the specific binary, not all of ~/.local/bin
- Plugin directory is read-only except the cache subdirectory
- State files live in the project directory (already writable)
</reasoning>
</example>
<example>
<scenario>Rust project that also uses GitHub CLI for releases</scenario>
<output>
```sh
# Runtime — cargo, rustup
tool rust
# GitHub CLI — auth tokens (read-only)
tool gh
- Two toolchains, no manual rules needed
- `tool rust` covers ~/.cargo, rustup-managed distributions under ~/.rustup (settings stay read-only), and the C linker (Xcode/CLT) for native builds
- `tool gh` covers ~/.config/gh (read-only)
- Build artifacts go to ./target/ which is inside PROJECT_DIR (already writable)
<self_check> Before presenting the final .rollcage file, verify:
tool directive matches an available toolchain nameallow-* path starts with ~/, ./, or /~, ~/, ./, or ./System, /Library, /usr, /bin, /sbin, or /opt/homebrew.rollcage as its basenameallow-write where allow-read would sufficetool directive existsWhat SKILL.md sets; muted values are Claude Code's defaults
2 skills in this plugin
Other plugins' skills for the same job
npx claudepluginhub codewithcheese/rollcage --plugin rollcage