Sandboxing - Claude Code
Filesystem and network isolation for Bash tool calls on Linux and macOS.
Sandboxing confines Bash tool execution to an allowlist of paths and hosts. It's how you let Claude run commands without granting the shell full reach into your machine.
What it does
On Linux and macOS, Claude Code can launch Bash calls inside a sandbox that restricts filesystem access to the project directory and network access to a configured allowlist. Commands that try to reach outside the allowed area fail fast with a clear error. This is the strongest containment option short of a full container.
When to use it
- Granting broad Bash access without worrying about rogue commands.
- Running untrusted or generated scripts safely.
- Multi-tenant environments where you can't trust every skill or prompt.
- Any setup where you want defense-in-depth on top of permission rules.
Gotchas
- Some tools need network access you might not have whitelisted. Watch for "blocked by sandbox" errors and allowlist specifically.
- Sandboxing has performance overhead - small for most work, noticeable for file-heavy tasks.
- Not available on Windows. Use WSL2 or a container instead.
Official docs: https://code.claude.com/docs/en/sandboxing.md
Technical content at the intersection of AI and development. Building with AI agents, Claude Code, and modern dev tools - then showing you exactly how it works.
Get the weekly deep dive
Tutorials on Claude Code, AI agents, and dev tools - delivered free every week.
Was this helpful?




