Browse and install pre-built Claude Code hooks with one command.
Claude Code hooks are shell commands that execute at lifecycle events (before/after tool use, session start/end, etc.). They're configured in settings.json but writing them by hand is tedious. Hooksmith gives you a curated registry of production-ready hooks you can install instantly.
Install
Or clone and link:
git clone https://github.com/elliotjl/hooksmith.git
cd hooksmith
npm install
npm linkUsage
Browse available hooks
hooksmith list hooksmith list --tag safety hooksmith list --event PreToolUse
Get details on a hook
hooksmith info block-dangerous-commands
Install a hook
# Install to project (.claude/settings.json) hooksmith install protect-secrets # Install globally (~/.claude/settings.json) hooksmith install notify-complete --global
See what's installed
hooksmith installed hooksmith installed --global
Remove a hook
hooksmith remove auto-stage hooksmith remove notify-complete --global
Available Hooks
Safety & Security
| Hook | Event | Description |
|---|---|---|
block-dangerous-commands |
PreToolUse [Bash] | Blocks rm -rf /, DROP TABLE, force push to main, and other dangerous commands |
protect-secrets |
PreToolUse [Write|Edit] | Scans for API keys, passwords, tokens, and private keys before writing files |
branch-protect |
PreToolUse [Bash] | Blocks direct commits to main/master, enforcing branch workflow |
Code Quality
| Hook | Event | Description |
|---|---|---|
lint-on-save |
PostToolUse [Write|Edit] | Auto-detects and runs eslint, ruff, rubocop, clippy after file changes |
auto-test |
PostToolUse [Write|Edit] | Finds and runs related tests (jest, pytest, rspec, go test) after edits |
auto-format |
PostToolUse [Write|Edit] | Runs prettier, black, gofmt, rustfmt after file changes |
commit-message-lint |
PreToolUse [Bash] | Validates commit messages follow conventional commits format |
Workflow
| Hook | Event | Description |
|---|---|---|
auto-stage |
PostToolUse [Write|Edit] | Auto git-adds files after Claude creates or edits them |
notify-complete |
Stop | Sends a macOS/Linux desktop notification when Claude finishes |
session-log |
SessionStart/End | Logs session timestamps to ~/.hooksmith/session-log.jsonl |
token-guard |
UserPromptSubmit | Warns if a prompt is suspiciously long (accidental paste detection) |
compact-summary |
PreCompact | Saves conversation context to a file before compaction |
How It Works
When you run hooksmith install <name>:
- The hook's bash script is copied to
.hooksmith/scripts/(project) or~/.hooksmith/scripts/(global) - Your
.claude/settings.jsonis updated with the hook configuration - Existing hooks are preserved — hooksmith appends, never clobbers
When you run hooksmith remove <name>:
- The hook entry is removed from
settings.json - The script file is deleted
- Other hooks remain untouched
Hook Format
Each hook is a standalone bash script that:
- Receives JSON context on stdin
- Exits 0 to allow (continue)
- Exits 2 to block (for Pre* events)
- Can output JSON to stdout for decisions
Claude Code hook configuration in settings.json:
{
"hooks": {
"PreToolUse": [
{
"matcher": "Bash",
"hooks": [
{
"type": "command",
"command": "/path/to/script.sh"
}
]
}
]
}
}Requirements
- Node.js >= 18
- Claude Code (for the hooks to actually run)
License
MIT