Works with the AI Agents you already use
Claude Code Safety Hooks: Block rm -rf, Force Push & Leaked Keys
Installs two tested PreToolUse hooks that stop destructive commands and API keys before Claude Code runs or writes them.
Free
Claude Code Safety Hooks: Block rm -rf, Force Push & Leaked Keys
Example session with this skill installed
install safety hooks
- Read your context and instructions
- Compiled the claude code safety
Installed .claude/hooks/block-dangerous-commands.sh and .claude/hooks/detect-secrets.sh (executable) and merged the PreToolUse block into .claude/settings.json.
Verification
- git push origin +main → exit 2 (blocked)
- git push --force-with-lease → exit 0 (allowed)
- content with an AWS key → exit 2 (blocked)
Note: these hooks are an early warning. For real protection, enable branch protection on main with force pushes disabled.
Connects securely to your tools. The creator never sees your data.
About this skill
Say "install safety hooks" and your agent adds two bash hooks to your project and verifies them:
- block-dangerous-commands: blocks
rm -rf /and~,git push --force(while allowing--force-with-lease), force pushes hidden asgit push origin +main,-uforgit -C dir push --force,git reset --hard,git clean -f,DROP/TRUNCATE TABLE,mkfs,dd of=/dev/,chmod -R 777, fork bombs andcurl | bash. - detect-secrets: blocks writing AWS, Anthropic, OpenAI, GitHub, Slack, Stripe and Google keys, private keys and JWTs into files.
Exit code 2 makes Claude Code block the call and tells Claude why, so it explains instead of retrying. No dependencies beyond bash and grep. The patterns were hardened against real bypasses a reader found (the +main refspec, reset -q --hard, git -C, combined flags) and are covered by tests.
Free. Hooks are an early warning, not a guarantee: also protect main on your remote.
Unofficial. Not affiliated with Anthropic.
Pattern-based: a determined user or obfuscated command (eval, base64) can bypass it. Covers Claude Code hooks only; other agents need their own hook setup.
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 buying a skill.
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
Free to use
No account required to browse
Trust & safety
Security scan
Security scan passed 4 days ago
- Free with an Agensi account
- Software
- Claude Codebash and grep
Permissions
File Scopes
Copies two scripts into .claude/hooks/, merges a hooks block into .claude/settings.json and runs them with sample input. No network access.
What's inside
Frequently Asked Questions
New in Security
Find more skills like this on the Claude Skills Marketplace, the Codex Skills Marketplace and the Gemini Skills Marketplace, or browse Claude Skills for Security.