On this page
Sandbox and permission policy types for Claude Code sessions, defining allow, deny, and approval rules for tool execution requests.
#claudestream.policy
#claudestream.policy
Sandbox and permission policy types for Claude Code sessions, defining allow, deny, and approval rules for tool execution requests.
#Allow
Allow the tool to execute.
#Deny
Deny the tool execution.
#Sandbox
Declarative sandbox configuration for a Claude Code session.
Controls which tools are available, filesystem scope, and behavior flags.
#create_sandbox
def create_sandbox(*, tools: list[str] | None=None, bare: bool=False, write_paths: list[str] | None=None, log_violations: bool=False, skip_permissions: bool=False) -> SandboxCreate a validated Sandbox configuration.
Raises:
ValueError: If any tool name is empty or not a string.
#sandbox_to_flags
def sandbox_to_flags(sandbox: Sandbox | None) -> list[str]Convert a Sandbox to CLI flags for Claude Code.
None means no sandbox flags (use defaults).
#_resolve_path
def _resolve_path(path: str, cwd: str) -> strResolve a path to an absolute, symlink-free canonical form.
#_is_within
def _is_within(target: str, allowed: str) -> boolCheck if target is within allowed directory (both must be realpath'd).
Uses string-prefix comparison with a trailing separator to avoid '/src/foo' matching '/src/foobar'.
#sandbox_decide
def sandbox_decide(sandbox: Sandbox, tool_name: str, tool_input: dict, cwd: str) -> Allow | DenyDecide whether a tool call is allowed under the given Sandbox.
The Sandbox is the complete authority -- this always returns Allow or Deny, never None.