Skip to content

API Reference parrot.sdd.scripts.dangerous_actions

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

parrot.sdd.scripts.dangerous_actions

View source

Portable PreToolUse guard that blocks destructive actions and names the safe alternative (FEAT-633 C32).

A stdlib port of ai-parrot's .claude/hooks/dangerous-actions-blocker.sh that needs neither bash, jq, python3 on PATH, GNU grep nor pgrep, so it behaves the same on Linux, macOS and Windows. It is served through the parrot launcher (parrot sdd hooks dangerous-actions --hook) and registered in a repository's .claude/settings.json by parrot sdd install.

The decision travels in the JSON written to stdout (main always exits 0), like the worktree guard: {"hookSpecificOutput": {... "permissionDecision": "deny" ...}} blocks, {"systemMessage": ...} warns and {} allows. PARROT_ALLOW_DANGEROUS=1 disables every check. This module imports nothing from parrot at import time (a hook runs on every tool call); parrot.sdd.config is loaded lazily and guarded.

Attribute ESCAPE_ENV

Class Verdict

Outcome of :func:evaluate.

Parameter Type Default Description
decision Literal['allow', 'deny', 'warn']
reason str ''

Fields:

Field Type Default Description
decision Literal['allow', 'deny', 'warn']
reason str ''

Function evaluate

Pure decision for one PreToolUse payload. PARROT_ALLOW_DANGEROUS=1 allows everything.

evaluate(payload: dict[str, Any], *, root: Path | None) -> Verdict

Parameter Type Default Description
payload dict[str, Any]
root Path | None

Returns: Verdict

Function find_root

Walk up from cwd to the directory holding a .git entry (no subprocess); cwd when none.

find_root(cwd: str | Path | None) -> Path | None

Parameter Type Default Description
cwd str | Path | None

Returns: Path | None

Function main

Serve a PreToolUse hook: read the payload on stdin, write one JSON line, always exit 0.

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

Parameter Type Default Description
argv Sequence[str] | None None

Function protected_branches

The protected branches: dev, main, master, staging always, plus base_branch, staging_branch and hotfix_base from sdd/config.json when it is present and valid.

The defaults stay protected even when the config names other lanes (FEAT-792 D2): over-protecting is the safe direction, and a repo whose base branch is trunk usually still cares about dev or staging.

protected_branches(root: Path | None) -> tuple[str, ...]

Parameter Type Default Description
root Path | None

Returns: tuple[str, ...]

Function strip_quoted

Blank out quoted spans so text about a command is not mistaken for the command.

When the line hands a quoted string to something that executes it (bash -c, eval, ssh, pwsh -Command, cmd /c) the quoted content IS the command: only the quote characters are neutralized.

strip_quoted(raw: str) -> str

Parameter Type Default Description
raw str

Returns: str

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