Works with the AI Agents you already use

    Claude Code Safety Hooks: Block rm -rf, Force Push & Leaked Keys

    by luijhy michael guerra flores

    1

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

    Free

    Security scanned
    Claude Code Safety Hooks: Block rm -rf, Force Push & Leaked Keys

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

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

      Sign in to Agensi

      Your agent shows a sign-in link. Sign in and click Allow.

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

    Terminal / Shell
    Read Files
    Write Files

    File Scopes

    .claude/hooks/**
    .claude/settings.json

    Copies two scripts into .claude/hooks/, merges a hooks block into .claude/settings.json and runs them with sample input. No network access.

    Listed4 days ago

    What's inside

    Frequently Asked Questions

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

    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.

    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.

    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.

    Free