Configure and manage Claude Code sandboxing for secure code execution. Use when user mentions sandboxing, security isolation, untrusted code, network restrictions, filesystem permissions, or wants to configure Claude Code security settings. Helps enable/disable sandbox mode, configure permissions, t
npx playbooks add skill djacobsmeyer/claude-skills-engineering --skill sandbox-manager
Helps users configure and manage Claude Code's sandboxing feature for secure, isolated code execution.
.claude/settings.json or ~/.claude/settings.jsonEnable sandboxing when:
Skip sandboxing when:
To enable sandboxing for the current session:
/sandbox
This activates with sensible defaults:
Edit .claude/settings.json (project-level) or ~/.claude/settings.json (global):
Basic configuration:
{
"sandbox": {
"enabled": true,
"allowedDirectories": [
"/path/to/project",
"/path/to/data"
],
"deniedDirectories": [
"/etc",
"/var",
"~/.ssh",
"~/.aws"
],
"allowedDomains": [
"github.com",
"api.example.com",
"*.trusted-cdn.com"
]
}
}
Choose a configuration template based on your use case (see [Configuration Templates](docs/configuration-templates.md)):
Docker conflicts:
dangerouslyDisableSandbox: true in tool calls if necessaryWatchman conflicts:
Network restrictions:
allowedDomains in settings*.cloudfront.netPermission denied errors:
allowedDirectoriesdeniedDirectoriesCheck if sandbox is active:
# Sandbox shows status when enabled
/sandbox
Test filesystem restrictions:
# Should succeed (working directory)
ls .
# May require permission (outside working directory)
ls /usr/local
Test network restrictions:
# Should prompt for permission (new domain)
curl https://example.com
{
"sandbox": {
"enabled": true,
"allowedDirectories": [
"${workspaceFolder}",
"~/.npm",
"~/.nvm",
"/tmp"
],
"allowedDomains": [
"registry.npmjs.org",
"*.npmjs.org",
"*.cloudflare.com",
"*.cloudfront.net",
"api.github.com"
]
}
}
{
"sandbox": {
"enabled": true,
"allowedDirectories": [
"${workspaceFolder}",
"~/.local/lib/python*",
"~/data",
"/tmp"
],
"allowedDomains": [
"pypi.org",
"*.pypi.org",
"files.pythonhosted.org",
"*.anaconda.org",
"raw.githubusercontent.com"
]
}
}
{
"sandbox": {
"enabled": true,
"allowedDirectories": [
"${workspaceFolder}/sandbox-only"
],
"deniedDirectories": [
"~/.ssh",
"~/.aws",
"~/.config",
"/etc",
"/var",
"/usr",
"/System"
],
"allowedDomains": []
}
}
{
"sandbox": {
"enabled": true,
"allowedDirectories": [
"${workspaceFolder}",
"/tmp"
],
"allowedDomains": [
"api.stripe.com",
"api.openai.com",
"*.your-api.com"
]
}
}
~/.ssh, ~/.aws, ~/.config*.cdn.com is broad - be specific when possible.claude/settings.json for project-specific needs~/.claude/settings.jsonSolution: Add project directory to allowedDirectories:
"allowedDirectories": ["${workspaceFolder}"]
Solution: Check Claude Code output for permission prompts, or add domains:
"allowedDomains": ["api.example.com"]
Solution: Sandboxing conflicts with Docker. Either:
dangerouslyDisableSandbox: true in Bash tool callsSolution: Add package registry to allowed domains:
"allowedDomains": [
"registry.npmjs.org",
"pypi.org",
"rubygems.org"
]
Solution: Check if using escape hatch. Disable in settings:
{
"sandbox": {
"allowUnsandboxedCommands": false
}
}
User: "I cloned a repo from GitHub that I don't fully trust. Can you help me run it safely?"
Response:
I'll help you set up sandboxing for secure execution:
1. First, let me enable sandbox mode:
/sandbox
2. I'll create a restricted configuration for this untrusted code:
[Creates .claude/settings.json with high-security template]
3. This configuration:
- Restricts filesystem access to this project only
- Blocks all network access by default
- Denies access to your credentials and config files
4. When you run the code, you'll be prompted for any permission requests.
Review each carefully before approving.
Would you like me to run the project's setup now, or would you like to
review the configuration first?
User: "I need to work on a Next.js project. How do I set up sandboxing?"
Response:
I'll configure sandboxing optimized for Next.js development:
[Edits .claude/settings.json with web development template including:]
- npm registry access
- Common CDN domains
- Your project directory
- node_modules and package cache locations
This allows:
- npm install and package downloads
- CDN resources for development
- API calls to common services
- Full access to your project files
The sandbox will still protect:
- Your SSH keys and credentials
- System configuration files
- Other projects on your machine
Sandbox is now configured. Run /sandbox to enable it for this session.
User: "I enabled sandbox but now docker commands don't work"
Response:
Docker and Claude Code's sandbox mode are incompatible. You have three options:
1. **Disable sandbox for this session** (if you trust the code):
Run commands without /sandbox enabled
2. **Use selective unsandboxing** (for specific docker commands):
I can pass dangerouslyDisableSandbox: true for docker-specific operations
3. **Use devcontainers instead** (recommended for untrusted code):
Set up a devcontainer which provides isolation + Docker access
Which approach fits your security needs?
User: "Sandbox keeps blocking my Python script from reading data files"
Response:
Let me help debug the permission issue:
1. First, where are your data files located?
[User provides: ~/datasets/]
2. I see the issue - your data directory isn't in allowedDirectories.
Let me update your settings:
[Edits settings.json to add ~/datasets/ to allowedDirectories]
3. The sandbox now allows:
- Read/write to your project directory
- Read/write to ~/datasets/
- Read-only to system libraries
Try running your script again. If it still fails, check for:
- Network requests (will need domain allowlist)
- Writing to /tmp (can add if needed)
- Other file locations being accessed
1.0.0 - Initial release with configuration templates and troubleshooting guide
Weekly roundup of top Claude Code skills, MCP servers, and AI coding tips.