- Home
- Skills
- Testing & Debugging
- Destructive Command Guard — Block rm -rf and Force Push
Works with the AI Agents you already use
Destructive Command Guard — Block rm -rf and Force Push
"Please don't run destructive commands" in CLAUDE.md is a request.
$18
Destructive Command Guard — Block rm -rf and Force Push
Example session with this skill installed
Check whether these commands would be blocked by the guard before I let the agent run them: git push --force origin main, git push --force-with-lease, rm -rf node_modules, rm -rf /projects, git reset --hard HEAD3
- Read your context and instructions
- Compiled the destructive command guard
Summary
3 of the 5 commands would be blocked, 2 would run normally.
Result
$ python3 scripts/destructive_command_guard.py --check "git push --force origin main"
BLOCK git-push-force: force push rewrites remote history (--force-with-lease is allowed)
$ python3 scripts/destructive_command_guard.py --check "git push --force-with-lease"
ALLOW
$ python3 scripts/destructive_command_guard.py --check "rm -rf node_modules"
ALLOW
$ python3 scripts/destructive_command_guard.py --check "rm -rf ~/projects"
BLOCK rm-recursive: recursive delete (rm -r / -rf) outside a short list of build folders
$ python3 scripts/destructive_command_guard.py --check "git reset --hard HEAD~3"
BLOCK git-reset-hard: git reset --hard throws away uncommitted work and moves the branch
| Command | Verdict | Rule |
|---|---|---|
| git push --force origin main | BLOCK | git-push-force |
| git push --force-with-lease | ALLOW | — |
| rm -rf node_modules | ALLOW | build folder on the safe list |
| rm -rf ~/projects | BLOCK | rm-recursive |
| git reset --hard HEAD~3 | BLOCK | git-reset-hard |
Next steps
- Add the hook to
.claude/settings.jsonusingexamples/settings.jsonas the template. - Use
--listto read every rule, and the optional JSON config to allow a rule id or an exact command. - Start in warn-only mode if you want to see what it would block before it blocks anything.
Note: it judges the text of the command, not the script the command runs.
Connects securely to your tools. The creator never sees your data.
About this skill
"Please don't run destructive commands" in CLAUDE.md is a request. The agent follows it when it remembers.
Destructive Command Guard turns it into a wall. It is a single-file PreToolUse hook: before the Bash tool runs anything, the hook reads the command, and if it would destroy data you cannot easily get back, the command never starts and Claude is told which rule stopped it.
$ python3 scripts/destructive_command_guard.py --check "git push --force origin main"
BLOCK git-push-force: force push rewrites remote history (--force-with-lease is allowed)
$ python3 scripts/destructive_command_guard.py --check "git push --force-with-lease"
ALLOW
$ python3 scripts/destructive_command_guard.py --check "rm -rf node_modules"
ALLOW
$ python3 scripts/destructive_command_guard.py --check "rm -rf ~/projects"
BLOCK rm-recursive: recursive delete (rm -r / -rf) outside a short list of build folders
What it does
- Blocks 21 kinds of command: recursive deletes, force push, hard reset, git clean, discarding local edits, force-deleting branches, dropping stashes, rewriting history, DROP TABLE/DATABASE, DELETE without WHERE, docker prune and volume deletes, bulk kubectl deletes, writes to disks, curl piped into a shell, shutdown, fork bombs
- Parses the command instead of grepping it:
&&,;, pipes,sudo,VAR=1prefixes,xargs,bash -c "...",evaland$(...)are all looked into, and text inside quotes is not mistaken for a command - Stays out of your way:
rm -rf node_modules,rm -rf /tmp/work,git push --force-with-lease,git clean -nandDELETE ... WHEREpass - Optional JSON config: allow rule ids, allow exact command patterns, add safe
rm -rfolders, warn-only mode, a decision log that never stores the command text --checklets you try any command without running it;--listprints every rule
Honest limits, stated in the README: it judges the text of the command. It does not open a script that the command runs, and it only sees the Bash tool. It is a safety net, not a sandbox.
What is inside
SKILL.md,README.md,LICENSEscripts/destructive_command_guard.pytests/test_guard.py(26 tests)examples/settings.jsonandexamples/destructive-guard.json
Requirements and safety
Python 3.8+, macOS or Linux, standard library only. The hook never runs the command it inspects, makes no network calls, and needs no credentials.
License
Personal, non-transferable license for your own projects, including commercial work. No resale or redistribution.
Only inspects command text, not the contents of scripts being called. Only monitors the Bash tool. Requires Python 3.
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 5 days ago
Requires