# 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.

Claude Code Safety Hooks: Block rm -rf, Force Push & Leaked Keys is a free AI agent skill on Agensi by luijhy michael guerra flores, in Security. It loads into your AI agent through the Agensi MCP server, always in its latest approved version.

- Price: Free
- Creator: [luijhy michael guerra flores](https://www.agensi.io/creators/luijhy-michael-guerra-flores)
- Category: [Security](https://www.agensi.io/skills/security)
- Version: 1.0
- Last updated: 2026-11-30
- Security: scan passed (2026-11-30); every new listing is also reviewed by a person
- Listing: https://www.agensi.io/skills/claude-code-safety-hooks-block-rm-rf-force-push-leaked-keys
- Tags: security, claude-code, git, developer-tools

## 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 as `git push origin +main`, `-uf` or `git -C dir push --force`, `git reset --hard`, `git clean -f`, `DROP`/`TRUNCATE TABLE`, `mkfs`, `dd of=/dev/`, `chmod -R 777`, fork bombs and `curl | 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.

## Requires

- Claude Code
- bash and grep

## Known limitations

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 this skill

1. Connect your AI agent to Agensi once: add the MCP server https://mcp.agensi.io/mcp/auth and sign in with your Agensi account (OAuth, no API key). Steps for Claude, ChatGPT, Claude Code, Codex, Cursor, VS Code and other agents: https://www.agensi.io/docs/mcp-setup
2. Ask your agent: "Use the Claude Code Safety Hooks: Block rm -rf, Force Push & Leaked Keys skill from Agensi" and describe your task.
3. Your agent loads the skill from Agensi when it needs it. Nothing is downloaded.

## Frequently asked questions

### What does Claude Code Safety Hooks: Block rm -rf, Force Push & Leaked Keys do?

Installs two tested PreToolUse hooks that stop destructive commands and API keys before Claude Code runs or writes them.

### Which AI agents support Claude Code Safety Hooks: Block rm -rf, Force Push & Leaked Keys?

This skill uses the open SKILL.md standard. Use it through an MCP-compatible agent connected to Agensi, and check the compatibility information on this page for confirmed agents and required capabilities.

### How do I use Claude Code Safety Hooks: Block rm -rf, Force Push & Leaked Keys?

Connect your AI agent to Agensi through MCP, then ask it to use Claude Code Safety Hooks: Block rm -rf, Force Push & Leaked Keys on your task. Your agent loads the latest approved version each time. Paid skills require a purchase or active subscription. Skill files are not available for download; your licence does not allow you to save, copy or export any part of a skill.

---

Source: [Agensi](https://www.agensi.io), the marketplace of skills for AI agents. Any MCP-compatible agent (Claude, ChatGPT, Claude Code, Codex, Cursor, VS Code and more) connects at https://mcp.agensi.io/mcp/auth and signs in with an Agensi account; setup for every agent: https://www.agensi.io/docs/mcp-setup. Append .md to any skill, guide or docs address on agensi.io for its markdown version.
