Skip to content

API Reference parrot.sdd.scripts.shell_prefix

github-actions[bot] edited this page Dec 2, 2026 · 2 revisions

parrot.sdd.scripts.shell_prefix

View source

Apply the SDD sandbox after auto mode has reviewed a shell command.

Claude Code invokes this prefix with exactly one argument: the command string. That lets known hook and MCP launch commands pass through while ordinary shell commands enter the configured sandbox. Any setup error exits with status 2, because a failed PreToolUse hook must block instead of allowing an unguarded command to proceed.

Attribute POLICY_ENV

Class PrefixDecision

The executable argv selected for a prefixed command.

Parameter Type Default Description
kind Literal['passthrough', 'wrap', 'run']
argv list[str]

Fields:

Field Type Default Description
kind Literal['passthrough', 'wrap', 'run']
argv list[str]

Class PrefixPolicy

The launcher's immutable policy for one shell-prefix session.

Parameter Type Default Description
schema_version int
mode str
worktree str
hook_commands tuple[str, ...]
mcp_argv tuple[tuple[str, ...], ...]
rtk bool

Fields:

Field Type Default Description
schema_version int
mode str
worktree str
hook_commands tuple[str, ...]
mcp_argv tuple[tuple[str, ...], ...]
rtk bool

Attribute TOKEN_ENV

Function decide

Choose whether a prefix invocation passes through or enters a sandbox.

decide(arg: str, policy: PrefixPolicy, cwd: Path) -> PrefixDecision

Parameter Type Default Description
arg str The sole command-string argument supplied by Claude Code.
policy PrefixPolicy The validated session policy.
cwd Path Current working directory used for the legacy sandbox.

Returns: PrefixDecision — The kind of execution and argv to execute.

Function load_policy

Load a secure prefix policy and return its content digest.

load_policy(path: str | Path) -> tuple[PrefixPolicy, str]

Parameter Type Default Description
path str | Path Policy JSON file supplied by the launcher.

Returns: tuple[PrefixPolicy, str] — The validated policy and SHA-256 digest of its original bytes.

Raises:

  • ValueError — If the file or its JSON schema is unsafe or invalid.
  • OSError — If the policy cannot be inspected or read.

Function main

Execute the one configured shell-prefix command or fail closed.

main(argv: Sequence[str] | None = None) -> NoReturn

Parameter Type Default Description
argv Sequence[str] | None None Command arguments excluding the program name; defaults to sys.argv[1:].

Returns: NoReturn

Function rtk_payload

Rewrite the one Claude Bash eval payload when RTK has an equivalent command.

rtk_payload(arg: str) -> str

Parameter Type Default Description
arg str Claude Code's complete Bash preamble passed to the shell prefix.

Returns: str — The preamble with only its eval word replaced, or the original bytes when it does not have exactly one supported payload or RTK cannot improve it.

Architecture

Clients

Bots & Agents

Memory

Knowledge

Tools & Toolkits

Flows

Experts

Skills

Stores & Loaders

MCP & A2A

Server & APIs

Integrations

Outputs & A2UI

Prompts

Security

Operations

Migration

SDD Tooling

LLM Wiki

Deployment

Decisions

API Reference

Clone this wiki locally