Run Claude Code with --dangerously-skip-permissions - safely - by isolating it inside a Docker container.
Claude Code's --dangerously-skip-permissions flag is powerful: it lets Claude run commands, edit files, and install packages without asking. But on your bare metal machine, that's a lot of trust. claude-safe gives you the best of both worlds: full autonomy for Claude, full isolation for you.
- Builds a Docker image with Node.js 22, git, Python 3, build-essential, and other common dev tools
- Mounts your project directory into the container (read-write)
- Links your
~/.claude/config (settings, memory, project context) - Passes your MAX account credentials read-only (or
ANTHROPIC_API_KEYif you use that instead) - Runs
claude --dangerously-skip-permissionsinside the container - Container auto-deletes when you exit — nothing lingers
Claude can go wild inside the container. It can't touch anything outside your mounted project directory.
# Download the script
curl -fsSL https://gist.githubusercontent.com/<YOUR_GIST_URL>/raw/claude-safe -o ~/.local/bin/claude-safe
# Make it executable
chmod +x ~/.local/bin/claude-safeMake sure ~/.local/bin is in your PATH. If it isn't, add this to your ~/.zshrc or ~/.bashrc:
export PATH="$HOME/.local/bin:$PATH"- Docker
- A Claude Code account (MAX or API key)
# Run in the current directory
claude-safe
# Run in a specific project
claude-safe ~/projects/my-app
# Pass arguments to claude
claude-safe . -- -p "refactor the auth module"
# Force rebuild the Docker image (e.g. after a new claude-code release)
claude-safe --rebuild
# Help
claude-safe --help| Tool | Version |
|---|---|
| Node.js | 22 (LTS) |
| Python | 3 |
| git | latest |
| build-essential | gcc, g++, make |
| cmake | latest |
| ripgrep, fd, jq, tree | latest |
| vim | latest |
| Claude Code | latest (via npm) |
The script auto-detects your auth method:
- MAX account: Mounts
~/.claude.jsoninto the container as read-only. Claude can authenticate but can't modify your tokens. - API key: Pass
ANTHROPIC_API_KEYas an env var and it gets forwarded into the container.
Can Claude break out of the container? Docker provides process and filesystem isolation. Claude can only access your mounted project directory and (read-only) config files. It cannot access your home directory, other projects, or system files.
Will my changes persist?
Yes — your project directory is mounted read-write, so all file changes Claude makes are written directly to your local filesystem. The container itself is ephemeral (--rm).
Can I customize the Docker image?
The Dockerfile is embedded in the script. Edit the build_image() function to add languages, tools, or dependencies you need.
Why UID 1000? The container user is created with UID 1000, which matches the default user ID on macOS and most Linux systems. This ensures volume-mounted files have correct ownership.