A

agent-guard

Show HN: A pre-execution guard that stops AI agents running destructive commands

Visit Website
Related by shared tags and keywordsLeviathheadless-terminalToolbay Stack
show-hnagentaiai assistantautomation

Overview

agent-guard is a shell hook for coding agents that blocks destructive commands before they run. It is described as a ~60-line shell hook that stops commands you can't undo. It runs before every shell command the agent proposes, exits 2 to deny, and writes the reason to stderr, which agent CLIs feed back into the loop so the agent stops retrying and surfaces the command to the human instead. It works with Claude Code's PreToolUse hook and with any agent CLI that runs a shell hook before a tool call and respects its exit code. It requires bash, grep -E, and python3.

Blocked commands include git reset --hard, rm -rf, git clean -f/-x, git checkout ., git filter-branch, force-push to main/master/production, DROP TABLE, TRUNCATE, FLUSHALL, aws delete-* / terminate-*, kubectl delete, terraform destroy, docker … prune, chmod 777, curl … | sh, and raw writes to /dev/sd*. Rules live in one array at the top of the script as label@@regex pairs. Users can edit them and add a test case, including a benign command the new pattern must not catch.

The project states that it stops a confident agent proposing an irreversible command in plain text, but does not stop anything deliberately evading it, such as obfuscated commands, base64 payloads through eval, shell scripts, or aliases. It fails closed: if it can't read the command out of the hook payload, it blocks. It is not a substitute for server-side branch protection, least-privilege credentials, and backups. It is MIT licensed.

Pricing

Detailed plans have not been confirmed in our catalog. Check the official website for current limits and billing terms.

Visit Website

Prices and limits may change. Confirm the currency, billing period, seat minimum and usage caps on the official website.

Use Cases

  • Teams use agent-guard to stop a coding agent from running commands that cannot be undone.
  • Teams use agent-guard to deny a proposed shell command and return the reason to the agent loop.
  • Teams use agent-guard to block force-pushes to main, master, or production branches.
  • Teams use agent-guard to block destructive database commands such as DROP TABLE, TRUNCATE, and FLUSHALL.
  • Teams use agent-guard to block cloud and infrastructure destructive commands such as aws delete/terminate, kubectl delete, and terraform destroy.
  • Teams use agent-guard to add custom label@@regex rules and test them against benign commands.
  • Teams use agent-guard to fail closed when the hook payload cannot be read.
  • Teams use agent-guard alongside server-side branch protection, least-privilege credentials, and backups.

Features

Checks commands before agent execution

Blocks destructive shell commands

Returns exit code two on denial

Explains blocked commands through stderr

Feeds denial reasons back to agents

Tests commands in a browser

Runs rules locally without dependencies

Reviews

No reviews yet. Be the first to share your experience!

Rankings & collections