Skip to content

Sandbox

Base classes

Name Children Inherits
ClaudeCodeBaseModel
clawd_code_sdk.models.base
Base model for all Claude Code Pydantic models.

â‹” Inheritance diagram

graph TD
  1564171539["settings.Sandbox"]
  2604142835["base.ClaudeCodeBaseModel"]
  3879467795["main.BaseModel"]
  2751680898["builtins.object"]
  2604142835 --> 1564171539
  3879467795 --> 2604142835
  2751680898 --> 3879467795

🛈 DocStrings

Bases: ClaudeCodeBaseModel

Sandbox execution configuration. See https://code.claude.com/docs/en/sandboxing.

Source code in src/clawd_code_sdk/models/settings.py
class Sandbox(ClaudeCodeBaseModel):
    """Sandbox execution configuration. See https://code.claude.com/docs/en/sandboxing."""

    model_config = ConfigDict(
        extra="forbid",
    )
    network: Network | None = None
    """
    Configures network isolation settings for the sandboxed bash environment, including domain restrictions, Unix socket access, and custom proxy configuration.
    """
    ignore_violations: dict[str, list[str]] | None = Field(None, alias="ignoreViolations")
    """
    Map of command patterns to filesystem paths to ignore violations for. Use "*" to match all commands
    """
    excluded_commands: list[str] | None = Field(None, alias="excludedCommands")
    """
    Commands that should never run in the sandbox (e.g., ["git", "docker"]). See https://code.claude.com/docs/en/sandboxing#configure-sandboxing
    """
    auto_allow_bash_if_sandboxed: bool | None = Field(True, alias="autoAllowBashIfSandboxed")
    """
    Automatically allow bash commands without prompting when they run in the sandbox. Only applies to commands that will run sandboxed. See https://code.claude.com/docs/en/sandboxing#sandbox-modes
    """
    enable_weaker_network_isolation: bool | None = Field(
        False, alias="enableWeakerNetworkIsolation"
    )
    """
    macOS only. Allow access to the system TLS trust service (com.apple.trustd.agent) in the sandbox. Required for Go-based tools like gh, gcloud, and terraform to verify TLS certificates when using httpProxyPort with a MITM proxy and custom CA. Reduces security by opening a potential data exfiltration path. Default: false. See https://code.claude.com/docs/en/sandboxing
    """
    enable_weaker_nested_sandbox: bool | None = Field(None, alias="enableWeakerNestedSandbox")
    """
    Enable weaker sandbox mode for unprivileged docker environments where --proc mounting fails. This significantly reduces the strength of the sandbox and should only be used when this risk is acceptable. Default: false (secure). See https://code.claude.com/docs/en/sandboxing#limitations
    """
    allow_unsandboxed_commands: bool | None = Field(None, alias="allowUnsandboxedCommands")
    """
    Allow commands to run outside the sandbox via the dangerouslyDisableSandbox parameter. When false, the dangerouslyDisableSandbox parameter is completely ignored and all commands must run sandboxed. Default: true. See https://code.claude.com/docs/en/sandboxing#limitations
    """
    enabled: bool | None = None
    """
    Enable sandboxed bash. See https://code.claude.com/docs/en/sandboxing#enable-sandboxing
    """
    filesystem: Filesystem | None = None
    """
    Filesystem access control for sandboxed commands. See https://code.claude.com/docs/en/sandboxing#filesystem-isolation
    """
    ripgrep: Ripgrep | None = None
    """
    Custom ripgrep configuration for Claude Code's bundled ripgrep support. Overrides the bundled binary and arguments.
    """
    bwrap_path: str | None = Field(None, alias="bwrapPath", min_length=1)
    """
    (Managed setting only) Path to custom bubblewrap (bwrap) binary for Linux/WSL sandbox. Overrides default. See https://code.claude.com/docs/en/server-managed-settings
    """
    socat_path: str | None = Field(None, alias="socatPath", min_length=1)
    """
    (Managed setting only) Path to custom socat binary for Linux/WSL network proxying. Overrides default. See https://code.claude.com/docs/en/server-managed-settings
    """
    fail_if_unavailable: bool | None = Field(None, alias="failIfUnavailable")
    """
    When true, make sandbox startup a hard failure if required sandbox dependencies are missing. Default: false (sandbox is skipped with a warning). See https://code.claude.com/docs/en/sandboxing#enable-sandboxing
    """
    enabled_platforms: list[Literal["macos", "linux", "wsl", "windows"]] | None = Field(
        None, alias="enabledPlatforms"
    )
    """
    Limit the entire sandbox configuration to the listed platforms. On platforms not in the list the sandbox config is inert: no sandbox, no auto-allow, no startup warning, and no failIfUnavailable exit. When omitted, all supported platforms are included. Only honored from managed (policy) settings.
    """
    credentials: Credentials | None = None
    """
    Block sandboxed commands from reading credential files and secret environment variables (v2.1.187+). Entries merge across settings scopes. See https://code.claude.com/docs/en/sandboxing#protect-credentials
    """
    allow_apple_events: bool | None = Field(None, alias="allowAppleEvents")
    """
    Allow sandboxed commands to send Apple Events on macOS (v2.1.181+). Honored only from user, managed, or CLI settings; project settings cannot enable it. See https://code.claude.com/docs/en/sandboxing#limitations
    """

allow_apple_events class-attribute instance-attribute

allow_apple_events: bool | None = Field(None, alias='allowAppleEvents')

Allow sandboxed commands to send Apple Events on macOS (v2.1.181+). Honored only from user, managed, or CLI settings; project settings cannot enable it. See https://code.claude.com/docs/en/sandboxing#limitations

allow_unsandboxed_commands class-attribute instance-attribute

allow_unsandboxed_commands: bool | None = Field(None, alias='allowUnsandboxedCommands')

Allow commands to run outside the sandbox via the dangerouslyDisableSandbox parameter. When false, the dangerouslyDisableSandbox parameter is completely ignored and all commands must run sandboxed. Default: true. See https://code.claude.com/docs/en/sandboxing#limitations

auto_allow_bash_if_sandboxed class-attribute instance-attribute

auto_allow_bash_if_sandboxed: bool | None = Field(True, alias='autoAllowBashIfSandboxed')

Automatically allow bash commands without prompting when they run in the sandbox. Only applies to commands that will run sandboxed. See https://code.claude.com/docs/en/sandboxing#sandbox-modes

bwrap_path class-attribute instance-attribute

bwrap_path: str | None = Field(None, alias='bwrapPath', min_length=1)

(Managed setting only) Path to custom bubblewrap (bwrap) binary for Linux/WSL sandbox. Overrides default. See https://code.claude.com/docs/en/server-managed-settings

credentials class-attribute instance-attribute

credentials: Credentials | None = None

Block sandboxed commands from reading credential files and secret environment variables (v2.1.187+). Entries merge across settings scopes. See https://code.claude.com/docs/en/sandboxing#protect-credentials

enable_weaker_nested_sandbox class-attribute instance-attribute

enable_weaker_nested_sandbox: bool | None = Field(None, alias='enableWeakerNestedSandbox')

Enable weaker sandbox mode for unprivileged docker environments where --proc mounting fails. This significantly reduces the strength of the sandbox and should only be used when this risk is acceptable. Default: false (secure). See https://code.claude.com/docs/en/sandboxing#limitations

enable_weaker_network_isolation class-attribute instance-attribute

enable_weaker_network_isolation: bool | None = Field(False, alias='enableWeakerNetworkIsolation')

macOS only. Allow access to the system TLS trust service (com.apple.trustd.agent) in the sandbox. Required for Go-based tools like gh, gcloud, and terraform to verify TLS certificates when using httpProxyPort with a MITM proxy and custom CA. Reduces security by opening a potential data exfiltration path. Default: false. See https://code.claude.com/docs/en/sandboxing

enabled class-attribute instance-attribute

enabled: bool | None = None

Enable sandboxed bash. See https://code.claude.com/docs/en/sandboxing#enable-sandboxing

enabled_platforms class-attribute instance-attribute

enabled_platforms: list[Literal["macos", "linux", "wsl", "windows"]] | None = Field(
    None, alias="enabledPlatforms"
)

Limit the entire sandbox configuration to the listed platforms. On platforms not in the list the sandbox config is inert: no sandbox, no auto-allow, no startup warning, and no failIfUnavailable exit. When omitted, all supported platforms are included. Only honored from managed (policy) settings.

excluded_commands class-attribute instance-attribute

excluded_commands: list[str] | None = Field(None, alias='excludedCommands')

Commands that should never run in the sandbox (e.g., ["git", "docker"]). See https://code.claude.com/docs/en/sandboxing#configure-sandboxing

fail_if_unavailable class-attribute instance-attribute

fail_if_unavailable: bool | None = Field(None, alias='failIfUnavailable')

When true, make sandbox startup a hard failure if required sandbox dependencies are missing. Default: false (sandbox is skipped with a warning). See https://code.claude.com/docs/en/sandboxing#enable-sandboxing

filesystem class-attribute instance-attribute

filesystem: Filesystem | None = None

Filesystem access control for sandboxed commands. See https://code.claude.com/docs/en/sandboxing#filesystem-isolation

ignore_violations class-attribute instance-attribute

ignore_violations: dict[str, list[str]] | None = Field(None, alias='ignoreViolations')

Map of command patterns to filesystem paths to ignore violations for. Use "*" to match all commands

network class-attribute instance-attribute

network: Network | None = None

Configures network isolation settings for the sandboxed bash environment, including domain restrictions, Unix socket access, and custom proxy configuration.

ripgrep class-attribute instance-attribute

ripgrep: Ripgrep | None = None

Custom ripgrep configuration for Claude Code's bundled ripgrep support. Overrides the bundled binary and arguments.

socat_path class-attribute instance-attribute

socat_path: str | None = Field(None, alias='socatPath', min_length=1)

(Managed setting only) Path to custom socat binary for Linux/WSL network proxying. Overrides default. See https://code.claude.com/docs/en/server-managed-settings

:fa-brands-github: Show source on GitHub