- Home
- Skills
- DevOps & Cloud
- Claude Code Safety Guard: Block Destructive Commands
More screenshots
Works with the AI Agents you already use
Claude Code Safety Guard: Block Destructive Commands
Turn rm -rf, git reset --hard and force pushes into a checked step: blocks destructive shell commands only when they would really lose work.
$9
About this skill
"The agent ran git reset --hard and I lost a day." Command Guard checks your repo before every shell command and blocks only what would destroy real work.
Measured: on a 61-command holdout set written after tuning, it scored precision 0.969 and recall 0.969. A typical regex guard scored 0.595 and 0.688 on the same set, with 15 false blocks out of 29 safe commands.
What it does
- A Claude Code
PreToolUsehook for Bash and PowerShell. It runsscripts/guard.py, a standard-library Python tool that parses the command the way the shell will:&&, pipes, subshells, heredocs,bash -c,eval,powershell -Command,-EncodedCommand,cmd /c,sudo,xargs,find -exec, and script files it can read. - Before it decides, it reads the real state with
git status,git clean -n, kubeconfig,.terraform/environmentand.env. - Blocks, and lists what would be lost:
reset --hard,checkout -- .,restoreandclean -fd, but only when uncommitted files exist.push --force(it suggests--force-with-lease).branch -Dof unpushed work.rm -rf,Remove-Item -Recurse,rd /sanddel /son home,/, system folders,.git, bare globs or paths outside the project.- DROP or TRUNCATE on a non-local database.
terraform destroyandkubectl deleteon prod.
- Asks you when the risk can't be checked from your machine, such as cloud deletes, non-prod destroys or unresolved variables.
- Allows what is safe:
rm -rf build, or a reset in a clean tree.
Benchmarks
| Test set | Command Guard | Regex guard |
|---|---|---|
| Holdout, 61 commands, run once | 1 false block, 1 miss | 15 false blocks, 10 misses |
| Tuned corpus, 306 commands | 0 false blocks, 0 misses (first run: 5 and 1) | 51 false blocks, 66 misses |
| psf/requests and django/django, 20 commands, clean tree | blocks 3 of 20 | blocks 15 of 20 |
| Same repos, after seeded uncommitted work | blocks 13 of 20 | the same 15 of 20 |
Across 32,587 tldr-pages example commands, 47 were blocked and 114 sent to you. The median decision took 0.9 ms.
What it does NOT do
- It can't see commands built at run time, such as
bash -c "$(printf ...)"orcurl | sh. - It doesn't simulate state changes inside one chain.
- It doesn't inspect remote hosts.
- It recognises production by name only (configurable).
- It doesn't guard file-edit or MCP tools.
Works in Claude Code, Cursor, Codex CLI, Copilot and any SKILL.md agent. The hook is Claude Code only; other agents run the check command.
Privacy: everything runs locally, with no network calls and no telemetry.
How to use
- 1
Connect your agent to the Agensi MCP
Copy the prompt and paste it into Claude, ChatGPT, Cursor or any agent that supports MCP. It sets up the connection for you. Manual setup
- 2
Sign in to Agensi
Your agent shows a sign-in link. Sign in and click Allow.
- 3
Ask for what you need
Your agent loads this skill and uses it on your task. It always asks before any payment.
Reviews
No reviews yet
Be one of the first to try it. Every listed skill goes through the trust checks below.
Security scanned
Checked by our 8-point scan before listing
Fresh listing
Recently published to Agensi
Money-back guarantee
Doesn't do what its page promises? You get your money back.
Trust & safety
Security scan
Security scan passed 27 days ago
Requires