claudeers.

πŸ”“ unclaimed β€” this page was auto-generated from GitHub. Are you the creator?

Claim this page β†’
// Developer Tools

claude-code-hooks

πŸͺ A growing collection of useful Claude Code hooks. Copy, paste, customize.

// Developer Tools[ cli ][ api ][ web ][ mobile ][ claude ]#claude#ai-tools#anthropic#automation#claude-code#claude-code-hooks#cli#developer-tools#devtoolsβ—· MIT$open-sourceupdated 11 days ago
Actively maintained
100/100
last commit 4 days ago
last release none
releases 0
open issues 1
// install
git clone https://github.com/karanb192/claude-code-hooks

claude-code-hooks

πŸͺ Ready-to-use hooks for Claude Code β€” safety, automation, notifications, and more.

🎬 Quick Demo

Protecting SecretsBlocking Dangerous Commands
Hook blocking .env readHook blocking dangerous commands

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.

HookMatcherDescription
block-dangerous-commandsBashBlocks dangerous shell commands (rm -rf ~, fork bombs, curl|sh)
protect-secretsRead|Edit|Write|BashPrevents reading/modifying/exfiltrating sensitive files

Post-Tool-Use

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

HookMatcherDescription
auto-stageEdit|WriteAutomatically git stages files after Claude modifies them

Notification

Fires when Claude needs user attention.

HookMatcherDescription
notify-permissionpermission_prompt|idle_promptSends Slack alerts when Claude needs input

Utils

Tools to help you build and debug hooks.

ToolLanguageDescription
event-loggerPythonLogs 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"
          }
        ]
      }
    ]
  }
}

3. Restart Claude Code β€” the hook is now active.

πŸ’‘ Tip: Use multiple hooks together. Combine block-dangerous-commands + protect-secrets for comprehensive safety.


πŸ›‘οΈ Safety Levels

Security hooks support configurable safety levels:

LevelWhat's BlockedUse Case
criticalCatastrophic only (rm -rf ~, fork bombs, dd to disk)Maximum flexibility
high+ Risky (force push main, secrets exposure, git reset --hard)Recommended
strict+ Cautionary (any force push, sudo rm, docker prune)Maximum safety

To change: Edit the SAFETY_LEVEL constant at the top of each hook.

const SAFETY_LEVEL = 'strict'; // or 'critical', 'high'

πŸ§ͺ Testing

All hooks include comprehensive tests:

# Run all tests
npm test

# Run specific hook tests
node --test hook-scripts/tests/pre-tool-use/block-dangerous-commands.test.js

Test coverage:

  • βœ… Unit tests for core functions
  • βœ… Integration tests for stdin/stdout flow
  • βœ… Config validation tests

πŸ“– Configuration Reference

See the official Claude Code hooks documentation for:

  • All hook events and their lifecycles
  • Input/output JSON formats
  • Matcher patterns
  • Environment variables

🀝 Contributing

Contributions welcome! See CONTRIBUTING.md for guidelines.

Ideas for new hooks:

HookEventDescription
protect-testsPreToolUseBlock test deletion/disabling
auto-formatPostToolUseRun prettier/black/gofmt after edits
branch-guardPreToolUseBlock changes on main/master branch
context-snapshotPreCompactPreserve context before compaction
session-summaryStopGenerate summary on session end
ntfy-notifyNotificationFree mobile push via ntfy.sh
discord-notifyNotificationDiscord webhook alerts
cost-trackerPostToolUseTrack token usage and estimate costs
tts-alertsNotificationVoice notifications via say/espeak
rules-injectorUserPromptSubmitAuto-inject CLAUDE.md rules
rate-limiterPreToolUseLimit tool calls per minute
context-injectorSessionStartInject project context on session start

πŸ“„ License

MIT Β© karanb192

// compatibility

Platformscli, api, web, mobile
Operating systemsβ€”
AI compatibilityclaude
LicenseMIT
Pricingopen-source
LanguageJavaScript

// faq

What is claude-code-hooks?

πŸͺ A growing collection of useful Claude Code hooks. Copy, paste, customize.. It is open-source on GitHub.

Is claude-code-hooks free to use?

claude-code-hooks is open-source under the MIT license, so it is free to use.

What category does claude-code-hooks belong to?

claude-code-hooks is listed under devtools in the Claudeers registry of Claude-compatible tools.

0 views
β˜… 435 stars
unclaimed
updated 11 days ago

// embed badge

claude-code-hooks on Claudeers
[![Claudeers](https://claudeers.com/api/badge/claude-code-hooks-2.svg)](https://claudeers.com/claude-code-hooks-2)

// retro hit counter

claude-code-hooks hit counter
[![Hits](https://claudeers.com/api/counter/claude-code-hooks-2.svg)](https://claudeers.com/claude-code-hooks-2)

// reviews

// guestbook

0/500

// related in Developer Tools

πŸ”“

The agent harness performance optimization system. Skills, instincts, memory, security, and research-first development for Claude Code, Codex, Opencode, Curs…

// devtoolsaffaan-m/⟨JavaScriptβŸ©β˜… 225,699β—· MIT[ claude ]
πŸ”“

Use Garry Tan's exact Claude Code setup: 23 opinionated tools that serve as CEO, Designer, Eng Manager, Release Manager, Doc Engineer, and QA

// devtoolsgarrytan/⟨TypeScriptβŸ©β˜… 119,234β—· MIT[ claude ]
πŸ”“

AI coding assistant skill (Claude Code, Codex, OpenCode, Cursor, Gemini CLI, and more). Turn any folder of code, SQL schemas, R scripts, shell scripts, docs,…

// devtoolssafishamsi/⟨PythonβŸ©β˜… 80,484β—· MIT[ claude ]
πŸ”“

πŸ™Œ OpenHands: AI-Driven Development

// devtoolsOpenHands/⟨PythonβŸ©β˜… 79,324β—· NOASSERTION[ claude ]
β†’ see how claude-code-hooks connects across the ecosystem