--sandbox flag runs the CLI with OS-level isolation, enforcing the active Read and Write permission scopes at the operating-system level and optionally restricting network traffic.
How the sandbox works
When the sandbox is active:- Writable paths are derived from granted
Write(...)permission scopes plus the workspace directory - Readable paths are derived from granted
Read(...)scopes (platform defaults like/usr/binare always readable) - Scopes granted mid-session dynamically expand the sandbox for subsequent commands
Network filtering
Configure domain-level network filtering for the sandbox in thesandbox section of your config file (user config only). When --sandbox is active and domain filtering is configured, a managed network proxy starts on loopback and the sandbox restricts all child traffic to route through it.
Domain pattern syntax:
Example:
Domain filtering applies when the sandbox is active (
--sandbox). Without --sandbox, the sandbox section is ignored.Excluded commands
Sometimes a specific command needs to run outside the sandbox — for examplegit commands that must access credentials or hooks the sandbox blocks. The sandbox.excluded config section lets you exclude matching commands from sandbox isolation using the same Exec(...) rule syntax as permissions:
Example:
Exec(git push *) beats Exec(git *)), and when both user config and team settings match, the more restrictive verdict wins (deny > ask > allow). Commands with no matching rule — including when sandbox.excluded is not configured at all — always run inside the sandbox.
- Only
Exec(...)rules are supported insandbox.excluded; any other rule type (e.g.,Read(...),Write(...)) is ignored with a warning. - Exclusion is fail-closed: if a command can’t be safely resolved (e.g., it can’t be parsed), it stays inside the sandbox.
- Exclusions apply to the default per-command exec path. Commands run through a persistent PTY shell (interactive sessions, or when
pty_for_noninteractive_execis enabled) always stay inside the sandbox.
Enterprise enforcement
Enterprise admins can control sandbox behavior for their entire organization via Team Settings.Sandbox enforcement mode
Set the enforcement level for the--sandbox flag across your organization:
- Optional (default) — Users choose whether to pass
--sandbox. No enforcement. - Required — The
--sandboxflag is forced on for all users, even if they don’t pass it on the command line. All CLI sessions run with OS-level file system sandboxing that enforces Read/Write permission scopes.
Enterprise domain filtering
Admins can also configure organization-wide domain allowlists and denylists:- Domain allowlist — When set, only the domains in this list are reachable through the sandbox network proxy. This list is authoritative: it completely replaces any user-configured
allowed_domains. Users cannot add additional domains to bypass admin restrictions. - Domain denylist — Domains that are always blocked. Enterprise denied domains are additive: they are merged with the user’s local
denied_domains, making the combined list more restrictive.
Because the user’s local
denied_domains are preserved and merged additively, a user could deny a domain that appears in the enterprise allowlist. This is intentional: the combined effect is always more restrictive, never less. If this causes access issues, the user should remove the conflicting entry from their local config.Enterprise excluded commands
Admins can also set organization-wide excluded command rules in team settings:- Excluded allow / ask —
Exec(...)rules for commands that may run outside the sandbox across the organization, automatically or after a prompt. - Excluded deny —
Exec(...)rules for commands that must never run outside the sandbox. A teamdenyoverrides any user-levelalloworaskfor matching commands, so users cannot exclude commands their admins have locked down.
deny > ask > allow).
Example: lock down all exclusions except gh. A wildcard deny with an allow carve-out keeps every command inside the sandbox except gh, regardless of what users configure locally. These values go into the team-settings excluded-commands configuration (not the user config file, so there is no enclosing sandbox key):
Exec(gh *) rule beats the wildcard Exec(**), gh commands run outside the sandbox while everything else stays inside — and the team-level wildcard deny overrides any user-level allow or ask rules for other commands.
Further reading
- Team Settings — enterprise sandbox enforcement and domain filtering
- Config file reference — the user-level
sandboxconfig section - Permissions — permission scopes that drive sandbox path resolution

