claude-code-hooks

by karanb192

Pending

🪝 A growing collection of useful Claude Code hooks. Copy, paste, customize.

123stars
9forks
JavaScript
Added 1/27/2026
CLI Toolsai-toolsanthropicautomationclaudeclaude-codeclaude-code-hooksclideveloper-toolshooksnotificationssecurity
Installation
# Add to your Claude Code skills
git clone https://github.com/karanb192/claude-code-hooks
README.md

claude-code-hooks

🪝 Ready-to-use hooks for Claude Code — safety, automation, notifications, and more.

GitHub stars License: MIT Tests

🎬 Quick Demo

<table> <tr> <th align="center">Protecting Secrets</th> <th align="center">Blocking Dangerous Commands</th> </tr> <tr> <td valign="bottom" align="center"><img src="assets/block-secrets.png" alt="Hook blocking .env read" width="400"></td> <td valign="bottom" align="center"><img src="assets/block-dangerous-commands.png" alt="Hook blocking dangerous commands" width="400"></td> </tr> </table>

A growing collection of tested, documented hooks you can copy, paste, and customize.


📑 Table of Contents


🪝 Hooks

Pre-Tool-Use

Runs before Claude executes a tool. Can block or modify the operation.

| Hook | Matcher | Description | |------|---------|-------------| | block-dangerous-commands | Bash | Blocks dangerous shell commands (rm -rf ~, fork bombs, curl|sh) | | protect-secrets | Read\|Edit\|Write\|Bash | Prevents reading/modifying/exfiltrating sensitive files |

Post-Tool-Use

Runs after Claude executes a tool. Can react to results.

| Hook | Matcher | Description | |------|---------|-------------| | auto-stage | Edit\|Write | Automatically git stages files after Claude modifies them |

Notification

Fires when Claude needs user attention.

| Hook | Matcher | Description | |------|---------|-------------| | notify-permission | permission_prompt\|idle_prompt | Sends Slack alerts when Claude needs input |

Utils

Tools to help you build and debug hooks.

| Tool | Language | Description | |------|----------|-------------| | event-logger | Python | Logs all hook events to inspect payload structures |

💡 Building a new hook? Use event-logger.py to discover what data Claude Code provides for each event before writing your own hooks.


🚀 Quick Start

1. Copy the hook script:

mkdir -p ~/.claude/hooks
cp hook-scripts/pre-tool-use/block-dangerous-commands.js ~/.claude/hooks/

2. Add to .claude/settings.json:

{
  "hooks": {
    "PreToolUse": [
      {
        "matcher": "Bash",
        "hooks": [
          {
            "type": "command",
            "command": "node ~/.claude/hooks/block-dangerous-commands.js...