Change control for AI agents: every tool call is checked against your team's rules, risky ones wait for someone else to approve, and everything lands in a tamper-evident audit trail your auditor can check.
pip install squidbrake==0.9.0 Copy PIP instructions
Change control for AI agents. Your agents run commands, edit code, send emails, issue refunds and change databases. Squidbrake keeps the record of every one of those changes: which agent, what it changed, who approved it, and what led to it. Risky changes wait for someone other than the requester to sign off; routine ones run on their own and are still recorded. The record is tamper-evident, readable by people who don't write code (a weekly summary, an evidence pack for your auditor), and destructive changes keep an undo. One policy for every agent your company runs (Claude Code, Cursor, Codex, Gemini CLI, VS Code Copilot, Antigravity and your MCP tools), and a record that sits outside them: the agents can't quietly change it, or switch Squidbrake off, without a person.
Free and open source (Apache 2.0). Runs on your laptop or your own server. What your agents do (commands, files, prompts, the audit trail) never leaves it; usage counts go out only if you say yes when it asks (Enter means yes).
See SHOWCASE.md for a 5-minute demo with a sandbox company, and incidents/ for 10 real AI-agent incidents replayed against the shipped rules (Replit, the Railway volume deletion, GitHub MCP, Supabase MCP, Postmark MCP, Claude Code and Antigravity deletes...): 12 of 13 harmful actions stopped, checked in CI. The same steps through two other guards (destructive_command_guard, Microsoft's Agent Governance Toolkit), plus everyday coding work: bench/compare/.
Click the button and the live demo starts in your browser (free with a GitHub account): a sandbox company's AI support agent works its inbox while you watch. A scam wire is blocked, refunds wait for a person, and a demo manager approves or rejects them. If the editor asks whether to allow tasks that run automatically, click Allow: that's the demo starting. On your own machine: pip install -r requirements.txt then python demo/live_demo.py.
One line installs it, runs it in the background, connects every AI agent on this computer and opens the dashboard:
curl -fsSL https://pilots.squidbrake.com/install.sh | SQUIDBRAKE_REF=github sh # macOS / Linux $env:SQUIDBRAKE_REF="github"; irm https://pilots.squidbrake.com/install.ps1 | iex # Windows With pip instead (SQUIDBRAKE_REF only tells the usage stats, if you say yes to them, that you came from here):
pip install squidbrake # or: pipx install squidbrake squidbrake setup # the same as the line above: background, every agent connected, dashboard setup connects the agents you have (Claude Code, Cursor, Codex, Gemini CLI, VS Code Copilot, Antigravity) and the MCP servers they already use, and routes them all through Squidbrake. It prints your dashboard key the first time, backs up every config it changes, and squidbrake connect all --remove undoes it. Restart the agents, then ask one to run rm -rf ~/ and watch it get blocked. squidbrake connect status shows which agents are covered, and catches the one step people miss (Codex runs a new hook only after you approve it in /hooks).
Your rules, keys and data live in ~/.squidbrake; edit ~/.squidbrake/rules.yaml and changes apply at once.
Only Claude Code? It's also a plugin, installed from inside Claude Code (see plugin/): /plugin marketplace add batrapulkit/squidbrake, then /plugin install squidbrake@squidbrake.
From a clone instead: git clone https://github.com/batrapulkit/squidbrake && cd squidbrake, then ./start.sh (Windows: start.bat) and ./connect.sh claude-code (Windows: connect.bat claude-code).
Or with Docker: docker run -d -p 8080:8080 -v squidbrake-data:/app/data --name squidbrake ghcr.io/batrapulkit/squidbrake (keys: docker logs squidbrake).
The first start installs everything, prints an admin key (for the dashboard) and an agent key (shown once, so save them), and opens http://localhost:8080/dashboard. No configuration needed; every setting in .env.example is optional.
Keys: python server.py add-key NAME [--approver], python server.py remove-key NAME, python server.py keys. Changes apply immediately, no restart needed. (Inside Docker, prefix with docker compose exec gateway.)
With the gateway running, one command per agent (installed with pip, type squidbrake connect ... instead; from a clone, use the .venv Python that start.bat / start.sh created):
.venv/Scripts/python connect.py all # every agent at once (Windows; macOS/Linux: .venv/bin/python) .venv/Scripts/python connect.py claude-code # or one at a time .venv/Scripts/python connect.py mcp --name antigravity # also: claude-desktop, cursor Agent What's checked One at a time Claude Code every tool call (Bash, PowerShell, edits, reads, web, MCP) connect claude-code Cursor terminal commands, file reads, file edits and deletes (Cursor's preToolUse, in recent versions), and MCP tools connect agents --agent cursor, connect guard --agent cursor Codex shell commands, edits and MCP tools. Approve the hook once in Codex with /hooks: until then Codex skips it connect agents --agent codex Gemini CLI shell commands, reads, writes and edits, plus its MCP servers connect agents --agent gemini-cli VS Code Copilot agent-mode commands, reads and edits, plus its MCP servers connect agents --agent vscode Antigravity terminal commands, reads and writes, plus its MCP servers connect agents --agent antigravity Windsurf, Kiro, Claude Desktop their MCP servers connect guard --agent windsurf Claude Code: a hook sends every tool call (Bash, PowerShell, Edit, Write, Read, WebFetch, MCP tools) through the gateway before it runs. Blocked calls are refused with the reason, and calls held for approval wait until you decide in the dashboard. It also adds the database tools below. Add --project DIR to limit it to one project; --remove undoes it. If the gateway is down, Claude Code's tool calls are blocked (fail closed) and it says why. Antigravity, Claude Desktop, Cursor, any MCP client: prints the config block to paste in. The agent gets list_tables, describe_table, query and execute tools on a SQLite database (data/shop.db, created with sample customers / products / orders; set DB_PATH to use your own). Reads run immediately, UPDATE/DELETE/INSERT/ALTER wait for your approval, and DROP/TRUNCATE are blocked. Wrapping a GitHub, Stripe, Slack or Postgres / Supabase MCP server? Start with the commented example policies in examples/rules/ and adjust their tool-name patterns to the server's tool list. Running an agent with nobody watching (a nightly loop, a cron job, a Routine)? Start from unattended-agent.yaml: a step cap, an allowlist, no redoing work, and no deletes or money movement, enforced from outside the agent instead of promised in its prompt.
Things to ask the agent, then watch the dashboard:
Make a clean copy (no keys, no history): python pack.py -> dist/squidbrake.zip.
Any MCP server - put Squidbrake in front of it, in any MCP client. The agent sees the app's normal tools, and each call is checked first (with GATEWAY_URL and GATEWAY_API_KEY set in the client's MCP config):
squidbrake proxy --app linear --url https://mcp.linear.app/mcp # a remote MCP server squidbrake proxy --app github --url https://api.githubcopilot.com/mcp/ --header 'Authorization: Bearer ${GITHUB_TOKEN}' squidbrake proxy --app stripe -- npx -y @stripe/mcp --tools=all # one started by a command squidbrake connect guard does this for the servers your agents already use, including remote ones with their own auth headers.
Agents that connect to MCP by URL (ChatGPT and claude.ai connectors, Devin, n8n, cloud agents) - easiest: in the dashboard, Settings → Agents that connect by URL, add the app's MCP server (its URL, and the header its auth needs). The agent then uses https:// /mcp/ and signs in with one of its agent keys (Authorization: Bearer gw_..., or ?key=gw_... for apps that take only a URL). Every call is checked and recorded as that agent; the app's own token stays on the gateway and is never shown again. Hosted dashboards take servers by URL; servers started by a command need a self-hosted gateway with SQUIDBRAKE_MCP_COMMANDS=1.
Apps whose MCP server signs in only through a browser (OAuth: Slack, HubSpot, Notion, Asana, ClickUp, Grafana Cloud): choose Sign in to the app (OAuth), add it, click Connect and sign in once. The gateway keeps the session and refreshes it before it runs out. Apps that only let in OAuth apps registered with them (Slack, HubSpot) need your own OAuth app's client ID and secret, with the redirect URL the dashboard shows.
Or run the proxy yourself and serve it over HTTP. The agent adds https://your-host:9000/mcp as its MCP server and sends the token (Authorization: Bearer, X-Squidbrake-Token, or ?token= for clients that take only a URL):
squidbrake proxy --app github --serve 0.0.0.0:9000 --token "$PROXY_TOKEN" -- npx -y @modelcontextprotocol/server-github Each connected conversation is checked on its own, so one agent's chain never mixes with another's. A caller can name its conversation with an X-Squidbrake-Session header. Put HTTPS in front of it (Caddy, a tunnel) before exposing it.
Python agent frameworks - OpenAI Agents SDK, LangChain / LangGraph, CrewAI, PydanticAI, smolagents, Google ADK: put all of an agent's tools behind it in one line. A call Squidbrake stops doesn't run, and the model gets a "NOT RUN: ..." message as the tool's result:
from squidbrake.client import Gateway # pip install squidbrake (or drop client.py into your project) gw = Gateway("https://gateway.example.com", api_key="...", source="support-agent", session_id=run_id) agent = Agent(name="support", tools=gw.guard_tools([lookup_order, refund, send_email])) # OpenAI Agents SDK graph = create_react_agent(llm, gw.guard_tools(tools)) # LangGraph Or one function at a time (raises Denied when it's stopped):
@gw.guard(name="shell.exec") def shell_exec(command: str): ... Any language - two HTTP calls (header X-Gateway-Key: ):
POST /v1/events {"name": "shell.exec", "input": {...}, "source": "...", "session_id": "..."} -> {"event_id": "...", "decision": "allow" | "deny", "reason": "...", "rule_id": ...} POST /v1/events/{id}/result {"output": ..., "error": null, "duration_ms": 12} Record an action that already happened in one call by including output/error in the first POST.
HTTP proxy - no code changes: define upstreams in rules.yaml, then point the client at http://gateway:8080/proxy/ /.... Optional headers: X-Gateway-Source, X-Gateway-Session. Denied requests get 403; every response carries X-Gateway-Event-Id.
Set mode: shadow in rules.yaml (or shadow_agents: ["new-bot*"] for some agents) and Squidbrake blocks and holds nothing: it records what it would have done. Reports then shows would block and would hold counts, and each event is tagged, so a team can see a week of real decisions before switching mode: enforce on. Stops and catastrophic commands (rm -rf /, wiping a drive) are enforced even in shadow mode.
Shell tools (Claude Code's Bash and PowerShell, or any tool matching command_checks.tools) are read by commands.py before the rules decide: the line is split on &&, ;, | (outside quotes), and sudo, xargs, bash -c, powershell -Command and $(...) are looked inside. Nothing is ever run or expanded.
Command checks apply even when a rule allows the tool, and read_only: allow only relaxes the default (never a rule or a warning). Configure them under command_checks: in rules.yaml.
Commands people paste from ChatGPT, a forum or a README never pass an agent hook. This puts the same command reader (commands.py) in front of your own shell: catastrophic lines are blocked, irreversible or unreadable ones (git push --force, curl ... | sh) ask Run it anyway? [y/N], everything else runs without a word. It works offline, nothing is sent anywhere, and if the guard itself fails your command still runs.
squidbrake shell-guard install --shell bash >> ~/.bashrc # then open a new terminal squidbrake shell-guard install --shell zsh >> ~/.zshrc if (!(Test-Path $PROFILE)) { New-Item -ItemType File -Force $PROFILE } squidbrake shell-guard install --shell powershell | Add-Content $PROFILE install only prints the snippet; it never edits a file, so read it first. Scripts and CI (non-interactive shells) are never blocked or prompted. Each Enter starts Python, which adds about 150 ms. If bash already has a DEBUG trap (VS Code's shell integration, bash-preexec), the snippet leaves it alone and prints a warning. Check one line by hand: squidbrake shell-guard check "rm -rf ~/" (exit code 0 run, 1 block, 2 ask).
The attacks that actually happened to agents (a GitHub issue, a support ticket or a web page telling the agent to send data somewhere) share one shape: the destination comes from content someone else wrote. Squidbrake records what you ask (Claude Code prompts, via the hook) and which tools bring in outside content (WebFetch, inboxes, issues, tickets...). When an action sends something to an email address, URL, bank account or repo that appears in that outside content but not in what you asked or in your own systems' results, it's held with the reason:
This sends to keys@evil.io (to), which appears in WebFetch (2 minutes ago) but not in anything you asked or in your own systems. Content from outside can carry hidden instructions (prompt injection).
Uploads from the shell count too (curl -d @.env https://..., scp, git push). Anything sent out after outside content was read gets a warning for the approver. Configure it under taint_checks: in rules.yaml.
Agents copy what they read: a ticket's customer ends up in a pull request description or a public issue. When an agent puts text where other people read it (a PR, an issue or comment, a gist, a chat post, a page, and gh pr|issue|gist ... create|comment|edit), it waits for a person if the text:
Looking things up (list_issues, search_issues) doesn't count, and email has its own rule. The approver sees which customer it named, or which kind of data; the data itself isn't repeated. Configure it under data_checks: in rules.yaml (block, review, warn, off).
Some actions are only dangerous because of what came before them. sequences: in rules.yaml judges an action by the steps before it and names the step that caused the decision:
sequences: - id: destroy-after-recovery-removed # turn off backups, then delete the database action: review reason: Destroying data right after its backups or deletion protection were turned off match: { input_regex: 'delete[-_ ]?db[-_ ]?instance|terraform\s+destroy|drop\s+(table|database)' } after: match: { input_regex: 'backup[-_ ]?retention[-_ ]?period\W{0,4}0|deletion[-_ ]?protection\W{0,4}false' } within_hours: 24 - id: runaway-refunds # an agent stuck in a loop action: deny reason: Too many refunds in a short time match: { name: ["*refund*"] } count: { more_than: 10, within_hours: 1, scope: agent } The approver then sees, for example: Destroying data right after its backups were turned off. Because earlier: Bash aws rds modify-db-instance --backup-retention-period 0 (12 minutes ago). after: looks at steps in the same conversation that went ahead (same_target: true = on the same charge, file or account); count: counts earlier matching actions per session, agent or all. Actions: deny, review or warn.
Rules with action: review hold the call until a person approves or rejects it:
- id: approve-payments action: review reason: Money movement needs a human timeout_seconds: 600 # default APPROVAL_TIMEOUT (300) on_timeout: deny # or allow approvers: [alice, bob] # optional; default = any approver key match: { name: "payments.*" } The first POST /v1/events returns "decision": "review". The Python client handles this for you: check() and @gw.guard block until the call is decided, then run the tool or raise Denied. Other clients long-poll GET /v1/events/{id}/decision?wait=25 until decision is allow or deny. To decide, use the Needs approval queue at the top of the dashboard, or call POST /v1/events/{id}/approve / .../reject with an optional {"note": "..."}. Only approver keys (python server.py add-key NAME --approver, and the rule's approvers if set) can decide, and a key can never approve its own request. So give people their own keys, separate from the agents' keys. If nobody decides before the deadline, on_timeout applies and decided_by is recorded as timeout. Every decision is stored on the event with who decided, when, and their note. Set APPROVAL_WEBHOOK_URL (plus PUBLIC_URL) to get a Slack- or Discord-formatted message with a link to the event whenever something needs approval. Microsoft Teams and email: in Settings, paste a Teams Workflows webhook ("Post to a channel when a webhook request is received"), or an SMTP server and the addresses to send to. Each approval links to the one-tap review page; an email never decides anything by being opened, since mail scanners open links. Every Monday, what it caught: Slack, Discord, Teams and email get the week's summary: what was blocked, rejected, or (in shadow mode) would have been, why, and what it would have changed. Reports → What it caught shows it any time, with Copy weekly report. Stop asking about what you always approve: Settings → Rules suggests an allow rule for anything people approved 5+ times in 30 days and never rejected (never for money, an agent's own setup, or what the command, data or chain checks held). Allow it adds the rule right before the one that held it, with a backup. Starter packs for a support, finance or ops agent add a block of rules after the read rule, so blocks above still win. To your SIEM: Settings → Send to your SIEM streams every decision to Splunk (HEC), Datadog (logs) or any HTTP endpoint, in batches in the background. Or set SIEM_URL, SIEM_TOKEN, SIEM_FORMAT. Approve and Reject right in Slack: in Settings, open Approve and Reject right in Slack, create the Slack app from the manifest shown there, install it to your approvals channel, and paste its webhook URL and signing secret. Each click is checked against the signing secret and carries that one event's signed token; the message then says who decided. Through the HTTP proxy, a held request stays open until it's decided, so the caller's HTTP timeout must be longer than the rule's timeout_seconds. Undo copies, spend limits, proof of work and signed approvals Undo copies (snapshots: in rules.yaml, default required). Before an action that waits for a person, or a command that can't be undone, runs, Squidbrake keeps a copy of what it changes: files and git changes on the agent's computer (squidbrake undo; Claude Code's Write and Edit too), the record behind an API call through /proxy (read with a GET first), or what your client.py snapshot function returns (@gw.guard(snapshot=lambda args: db.get_order(args["order_id"]))). If a copy is required and can't be made, the action doesn't run. A rule can set snapshot: required | best_effort | off; required on a rule also blocks paths that can't make a copy (MCP tools). The dashboard shows each copy and how to restore it. Kill switch. Stop agents in the dashboard or on the phone page stops one agent, one conversation or all of them. Phone notifications also carry a Stop agent button, and the one-tap approval page a Stop button. Spend limits (budgets:). Pause an agent once it has used N model tokens (or usd:) in a day or month, each on its own or several together. Claude Code's hook reports its tokens from the transcript; other agents send them to POST /v1/usage (gw.usage(...)). Reports shows each limit and what's used. Proof of work (proof_checks:). When an agent says an action is done, Squidbrake looks in the real system (Stripe, GitHub, a SQL database, or any HTTP API) with read-only credentials from the gateway's environment, and records confirmed or not actually done; a mismatch notifies a person. Approvals signed by Face ID or fingerprint. Register a phone or laptop as a passkey (Settings, or the phone page). Each approval made with it is signed by the device over exactly that decision and kept in the audit trail. Settings can require it for every approval (rejecting never needs it). Access levels. Owner, admin, approver and viewer. Viewers see everything and change nothing; only owners make admins and owners, and a team always keeps one owner. Teams such as finance still work for approvers: [role:finance]. AI approval briefs. Off until an admin adds the team's own Anthropic key: a short, plain-English risk note on each held action, written from what the dashboard shows (redacted). Advice only. Dashboard Open http:// :8080/dashboard and paste your admin key (or any key made with add-key). It is stored only in that browser. The page shows:
Claude Code's built-in permissions control actions for an individual agent. Squidbrake provides centralized rules for a whole team, with approvals from your phone or Slack, history checks, an audit trail, and support across multiple agents.
Squidbrake fails closed. Guarded tool calls are blocked if the gateway is unreachable, rather than being allowed through. Each rule can choose otherwise with when_unreachable: allow (and the top-level when_unreachable: sets the default). The hooks, MCP connectors and client.py keep a copy of these answers while the gateway answers, so they follow them while it's down. What runs then isn't recorded. GATEWAY_FAIL_OPEN=1 on a machine still lets everything through there.
What your agents do doesn't: commands, files, prompts, tool inputs and outputs, and the audit trail stay on your laptop or your server. What can leave is usage counts, and only after a yes: the first run asks once (Enter means yes) to send the command name, version, OS, how many actions were allowed, held and blocked, and for each held or blocked one the program (like rm) and the rule. See Usage sharing.
No. Squidbrake uses deterministic rules and checks. There is no LLM in the decision path. The optional AI brief (Settings → AI approval briefs, your own Anthropic key, pip install "squidbrake[ai]") writes a short risk note for the person deciding on a held action; nothing reads it to decide.
Squidbrake is built for the common case: a cooperative agent that makes a mistake or follows instructions it found in an email, a web page or an issue. It is not a sandbox against an agent that is deliberately trying to escape. Here's what that means in practice:
Every decision is written to a hash-chained audit trail together with the fingerprint of the rules.yaml version that made it, and each version's text is kept. Reports > Tamper check > Download evidence (or GET /v1/audit/export.json) gives one file that anyone can check on their own machine, without trusting the server:
python verify.py squidbrake-evidence-20261001-0930.json It confirms the chain is unbroken, that every recorded action still matches the fingerprint taken when it happened (so rows edited in the database are caught, not just edits to the log), and that every decision's rules version is in the file. verify.py needs only the Python standard library. The dashboard's tamper check runs the same checks live. Add --json for one machine-readable object (ok, the number of records checked, and a list of problems with the record each one was found in) for CI; the exit code stays 0/1 either way.
Signed checkpoints. Every 50 entries the gateway signs the chain's fingerprint with its ledger key (Ed25519, kept in data/ledger.key or SQUIDBRAKE_LEDGER_KEY). The public half is published, without a key, at GET /v1/audit/public-key. Publish it somewhere you control (your site, your auditor's ticket); then
pip install pytest && pytest -q python tests/e2e_business_scenario.py Usage sharing (asked first) Squidbrake shares nothing about you or your agents without asking first. The one request it makes on its own is the daily update check below, which only asks for the newest version number.
Anonymous usage stats. The first time you run squidbrake in a terminal, it asks once whether to send anonymous stats (Enter means yes): the command name (e.g. doctor, never its arguments), version, OS, Python version and country, plus the gateway's usage counts described below (what it allowed, held and blocked). After a yes it asks where you heard about Squidbrake (pick from a list, or Enter to skip); if you installed from a named link, that name (SQUIDBRAKE_REF, e.g. linkedin) answers it instead. Never commands an agent ran, files, prompts, rules, keys or the audit trail. The agent hooks never send anything, and scripts, CI and --yes are never asked. squidbrake telemetry off (or SQUIDBRAKE_TELEMETRY=0, or DO_NOT_TRACK=1) stops it; squidbrake telemetry status shows exactly what is sent. Update check. Once a day, running squidbrake in a terminal asks pypi.org for the newest version number, and the next time says if there's a newer one. That request carries nothing about you beyond the request itself; never in hooks, scripts or CI; off with SQUIDBRAKE_NO_UPDATE_CHECK=1 or DO_NOT_TRACK=1.
If you'd like the team to know who you are, squidbrake register you@company.com (asks first). Details: telemetry.py.
Usage counts. There are three ways to share counts of what Squidbrake did:
What is shared is usage counts: actions allowed, held, approved and blocked per day, and which agents and rules. Never commands, code, prompts or keys. squidbrake pilot leave stops it. Details: pilot.py and insights/.
Tell us what you need most: 👍 or comment on the issues.
ai-agents approval audit claude-code guardrails human-in-the-loop mcp security
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
PyPI verified that this artifact, at this checksum, originated from the publisher listed below.
Signed by GitHub Actions, verified by PyPI on Oct 11, 2026.




