ptuf

日本語 README

ptuf is a deterministic guardrail for coding agents. It hooks into the
agent's PreToolUse event and blocks dangerous tool calls — destructive
rm, piping curl into a shell, leaking ~/.ssh over the network — using
rules, not LLM heuristics.
Supported hosts: Claude Code, Codex, GitHub Copilot, Kiro CLI, Cline, Cursor, Pi Coding Agent, OpenCode.
- Shell-aware — parses quotes, pipes,
bash -c, $(…) and variable
expansion, so rm -rf "/" and $(echo rm) -rf / are caught too.
- Bypass-tested — every known evasion is a versioned regression case,
backed by fuzzing and mutation testing.
- Self-protecting — the agent cannot edit ptuf's config, binary, or hook
registration to switch it off mid-session.
- Zero runtime — a single offline binary with a JSONL audit log.
Quick start
brew install watany-dev/tap/ptuf # or: npm install -g @watany-dev/ptuf
ptuf init claude-code # or codex / copilot / kiro / cline / cursor / pi / opencode
ptuf check --tool Bash 'rm -rf /' # Decision: deny
Other install methods (prebuilt installer, Windows, cargo, mise) are under
Install.
Why ptuf?
Most guardrails today are hand-rolled hook scripts that grep the command
for rm -rf. Those break the moment the agent writes rm -rf "/",
$(echo rm) -rf /, or bash -c 'rm -rf /'. ptuf takes a different
approach:
| DIY regex hook | Ask-the-LLM / permission prompts | Sandbox / container | ptuf |
|---|
| Deterministic (same input → same decision) | partly | no | yes | yes |
Understands shell syntax (quotes, pipes, bash -c, var expansion) | no | n/a | n/a | yes |
| Bypass resistance covered by versioned tests + fuzzing | no | no | n/a | yes (tests/bypass/corpus.jsonl) |
| One policy across Claude Code / Codex / Copilot / Kiro / Cline / Cursor / Pi / OpenCode | rewrite per host | no | no | yes (ptuf init) |
| Agent cannot disable it mid-session | rarely | no | yes | yes (core.self_protection.*) |
| Audit trail of what was blocked and why | rarely | no | no | yes (JSONL) |
| Works offline, no extra runtime | depends | no | heavy setup | yes (single binary) |
A sandbox is complementary, not competing: it limits blast radius, while
ptuf stops and audits the dangerous call itself — run both if you can.
Think you can sneak a dangerous call past it? Take the
bypass challenge.
What it stops
ptuf ships with built-in rules that block, ask, or audit before the agent
runs the call. A few examples of what fires by default: