by karanb192
🪝 A growing collection of useful Claude Code hooks. Copy, paste, customize.
# Add to your Claude Code skills
git clone https://github.com/karanb192/claude-code-hooksGuides for using cli tools skills like claude-code-hooks.
Last scanned: 5/23/2026
{
"issues": [],
"status": "PASSED",
"scannedAt": "2026-05-23T06:33:56.802Z",
"semgrepRan": false,
"npmAuditRan": true,
"pipAuditRan": true
}claude-code-hooks is an open-source cli tools skill for AI coding assistants such as Claude Code, Codex CLI, and ChatGPT, built by karanb192. 🪝 A growing collection of useful Claude Code hooks. Copy, paste, customize. It has 445 GitHub stars.
Yes. claude-code-hooks passed SkillsLLM's automated security scan — a dependency vulnerability audit plus prompt-injection heuristics — with no high-severity issues. You can read the full report in the Security Report section on this page.
Clone the repository with "git clone https://github.com/karanb192/claude-code-hooks" and add it to your Claude Code skills directory (see the Installation section above).
claude-code-hooks is primarily written in JavaScript. It is open-source under karanb192 on GitHub, so you can review or fork the full source.
Yes. SkillsLLM lists many other CLI Tools skills you can browse and compare side by side. Open the CLI Tools category from the badge at the top of this page, or use the Related Skills and comparison links further down to weigh claude-code-hooks against similar tools.
No comments yet. Be the first to share your thoughts!
Top skills in this category by stars
🪝 Ready-to-use hooks for Claude Code — safety, automation, notifications, and more.
A growing collection of tested, documented hooks you can copy, paste, and customize.
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 |
| git-safety | Bash |
Branch-aware git guardrails + destructive gh CLI protection |
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 |
| format-code | Write|Edit |
Auto-formats Python (ruff) and JS/TS/HTML/JSON/MD/YAML (prettier) after edits |
Fires when Claude needs user attention.
| Hook | Matcher | Description |
|---|---|---|
| notify-permission | permission_prompt|idle_prompt |
Sends Slack alerts when Claude needs input |
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.pyto discover what data Claude Code provides for each event before writing your own hooks.
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-secretsfor comprehensive safety.
Security hooks support configurable safety levels:
| Level | What's Blocked | Use Case |
|---|---|---|
critical |
Catastrophic 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'
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:
See the official Claude Code hooks documentation for:
Contributions welcome! See CONTRIBUTING.md for guidelines.
Ideas for new hooks:
| Hook | Event | Description |
|---|---|---|
protect-tests |
PreToolUse | Block test deletion/disabling |
context-snapshot |
PreCompact | Preserve context before compaction |
session-summary |
Stop | Generate summary on session end |
ntfy-notify |
Notification | Free mobile push via ntfy.sh |
discord-notify |
Notification | Discord webhook alerts |
cost-tracker |
PostToolUse | Track token usage and estimate costs |
tts-alerts |
Notification | Voice notifications via say/espeak |
rules-injector |
UserPromptSubmit | Auto-inject CLAUDE.md rules |
rate-limiter |
PreToolUse | Limit tool calls per minute |
context-injector |
SessionStart | Inject project context on session start |
MIT © karanb192