This chapter covers how to build isolated environments for safe experimentation and risky operations.
The --dangerously-skip-permissions flag is convenient but risky. ykdojo compares it to "unprotected sex" and strongly recommends using a safety mechanism: containers.
Docker container setup:
FROM ubuntu:22.04
# install basics
RUN apt-get update && apt-get install -y \
curl git tmux vim \
nodejs npm python3 python3-pip
# install Claude Code
RUN curl -fsSL https://claude.ai/install.sh | sh
# install Gemini CLI (optional)
RUN npm install -g @google/generative-ai-cli
# workspace
WORKDIR /workspace
CMD ["/bin/bash"]
Run the container:
# build image
docker build -t claude-sandbox .
# run container (mount host directory)
docker run -it --rm \
-v $(pwd):/workspace \
-e ANTHROPIC_API_KEY=$ANTHROPIC_API_KEY \
claude-sandbox
# inside the container
claude --dangerously-skip-permissions
A workflow where your local main Claude uses tmux to direct a "worker" Claude inside the container and collect results:
# main Claude:
# 1. starts container via docker run
# 2. creates a tmux session
# 3. runs worker Claude
# 4. sends prompts via tmux send-keys
# 5. reads output via tmux capture-pane
# 6. returns results to the main session
ykdojo's real example:
Whenever a new Claude Code version is released, ykdojo delegates updating system prompt patches to a containerized worker Claude. The worker Claude:
The whole process runs autonomously and the main Claude only reviews final results.
With /sandbox, you define a boundary once and let Claude work freely within it.
Example sandbox setup:
/sandbox
# Claude asks:
"Which commands should be auto-approved?"
> "Auto-approve npm install, npm test, git status, git diff"
# These commands now run automatically
Wildcard support:
> "Auto-approve all MCP tools matching mcp__server__*"
Ado's advice:
"Sandbox gives both speed and security. Use Sandbox for trusted work, and containers for experimental work."
claude --dangerously-skip-permissions
This flag automatically answers "yes" to every permission request.
When to use YOLO Mode:
When NOT to use YOLO Mode: