claude-code-hooks Collection
A tested library of Claude Code hook scripts covering safety, automation, and notifications. Current hooks: block-dangerous-commands (blocks rm -rf ~, fork bombs, curl|sh), protect-secrets (prevents reading/exfiltrating .env and key files), git-safety (branch-aware git guardrails), auto-stage (git-adds files after edits), format-code (runs ruff/Prettier after writes), and notify-permission (Slack alerts).
View on GitHubWhat it does
- block-dangerous-commands (PreToolUse)
Blocks catastrophic Bash commands — rm -rf ~, fork bombs, curl|sh pipes — before Claude executes them. Configurable safety level: critical, high, or strict.
- protect-secrets (PreToolUse)
Intercepts Read, Edit, Write, and Bash tool calls targeting .env files, private keys, and credential files to prevent accidental exfiltration.
- git-safety (PreToolUse)
Branch-aware git guardrails that block destructive git and gh CLI operations based on the current branch.
- auto-stage (PostToolUse)
Automatically runs git add on files Claude has written or edited, keeping the staging area in sync without manual intervention.
- format-code (PostToolUse)
Runs ruff on Python files and Prettier on JS/TS/JSON/YAML/Markdown automatically after every Write or Edit.
- notify-permission (Notification)
Sends a Slack webhook alert when Claude Code is idle waiting for permission or user input.