Guide
Sandbox modes in every AI coding agent: Claude Code, Cursor, Codex and Gemini CLI compared (2026)
How do I run an AI coding agent's commands in a sandbox, and how do I allow network access?
Claude Code: run /sandbox or set sandbox.enabled and list hosts in sandbox.network.allowedDomains. Cursor: configure .cursor/sandbox.json, where networkPolicy defaults to deny. Codex: pick read-only, workspace-write or danger-full-access with --sandbox or sandbox_mode. Gemini CLI: start with -s, set GEMINI_SANDBOX or tools.sandbox, and choose Docker, Podman, macOS Seatbelt, gVisor or LXC.
Coding agent settings change often
Get one email a week when a setting, flag or permission rule changes, checked against the vendor docs.
Quick answer: how to turn it on
- Claude Code: off by default. Run /sandbox, or set "sandbox": {"enabled": true} in ~/.claude/settings.json or .claude/settings.json.
- Cursor: sandbox.json in ~/.cursor/ (all workspaces) or <workspace>/.cursor/ (one workspace, higher priority). type is workspace_readwrite (default), workspace_readonly or insecure_none, which disables it.
- Codex: codex --sandbox read-only | workspace-write | danger-full-access, or sandbox_mode in config.toml. workspace-write is the default low-friction mode for local work.
- Gemini CLI: gemini -s (or --sandbox), GEMINI_SANDBOX=true|docker|podman|sandbox-exec|runsc|lxc, or tools.sandbox in settings.json. The flag wins over the variable, which wins over the settings file.
What each sandbox uses under the hood
- Claude Code: Seatbelt on macOS, bubblewrap and socat on Linux and WSL2. On native Windows commands run unsandboxed.
- Codex: Seatbelt on macOS, bubblewrap on Linux and WSL2 (the first bwrap on PATH), and a native Windows sandbox in PowerShell.
- Gemini CLI: Docker or Podman containers (default image ghcr.io/google/gemini-cli:latest), sandbox-exec (Seatbelt) on macOS, runsc (gVisor) or experimental LXC on Linux. runsc is never auto detected.
Network access
- Claude Code: commands reach the network only through a local proxy. Allowed domains start empty; add hosts to sandbox.network.allowedDomains, block with deniedDomains, or set strictAllowlist to refuse anything unlisted.
- Cursor: networkPolicy.default is deny unless you change it. allow and deny take exact domains, wildcards such as *.example.com (which also match example.com) or CIDR ranges. Deny always beats allow, URL paths are ignored, and private ranges, loopback and the cloud metadata IP are blocked by default.
- Gemini CLI on macOS: pick one of six Seatbelt profiles with SEATBELT_PROFILE (permissive, restrictive or strict, each in an -open and a -proxied variant). The default is permissive-open, which confines writes to the project directory.
Claude Code: .claude/settings.json
{
"sandbox": {
"enabled": true,
"network": {
"allowedDomains": ["github.com", "*.npmjs.org"]
}
}
}Cursor: .cursor/sandbox.json
{
"networkPolicy": {
"default": "deny",
"allow": ["registry.npmjs.org", "*.githubusercontent.com"]
}
}Codex and Gemini CLI: one run
codex --sandbox workspace-write --ask-for-approval on-request gemini -s -p "analyze the code structure"
Extra write paths and escape hatches
- Claude Code: sandbox.filesystem.allowWrite adds paths. sandbox.excludedCommands (for example docker compose *) runs trusted tools outside the sandbox. allowUnsandboxedCommands: false turns off the unsandboxed retry.
- Cursor: readBoundary "workspace" (Cursor 3.23 or later) asks before reading outside the workspace. disableTmpWrite: true removes write access to /tmp and temp directories.
- Codex: sandbox_workspace_write.writable_roots adds folders in workspace-write mode. danger-full-access removes the sandbox entirely.
- Gemini CLI: GEMINI_SANDBOX_IMAGE or tools.sandbox.image picks a custom container image.
Full sandbox guide for each agent
- Claude Code sandbox: /sandbox, allowedDomains and excludedCommands
- Cursor sandbox: sandbox.json, network allowlist and run modes
- Codex sandbox modes: read-only, workspace-write, danger-full-access
- Gemini CLI sandbox: Docker, Podman, Seatbelt or gVisor
- Compare: allow all commands in every AI coding agent
- Compare: headless mode for scripts and CI
Get coding agent settings changes by email
When a setting, flag or permission rule in this guide changes, it goes in the weekly AgentAtlas update, checked against the vendor docs. One email a week.
Sources
Other guides
Reviewed Oct 18, 2026. Settings change often; the linked vendor docs are the source of truth.