A Claude Code plugin that compiles declarative YAML rule files into native hooks.json entries. Define hook behavior as simple YAML rules — the plugin automatically rebuilds when rules change.
~/.config/hooksmith/rules/*.yaml → hooksmith build → hooks.json
Each YAML rule becomes a native hook entry:
| Mechanism | hooks.json type | Runtime behavior |
|---|---|---|
regex |
type: command |
Thin bash wrapper tests a field against a pattern |
script |
type: command |
Your bash script runs directly |
prompt |
type: prompt |
LLM evaluates the prompt natively — zero script overhead |
claude plugin add ugudlado/hooksmithOr install locally:
git clone https://github.com/ugudlado/hooksmith.git
claude --plugin-dir /path/to/hooksmithhooksmith list [--json] [--scope user|project|all] # Show registered rules
hooksmith run <id> # Execute a rule by id
hooksmith build # Rebuild hooks.json from rules
hooksmith start # SessionStart: rebuild if rules changed
hooksmith convert [--apply] [--scope user|project] # Migrate settings.json hooks to YAMLIf you already have hooks in settings.json, convert them to YAML rules first:
# Preview what will be converted (dry-run)
hooksmith convert
# Write the YAML rule files
hooksmith convert --apply
# Build hooks.json and activate immediately
hooksmith build
/reload-pluginsThen remove the converted entries from settings.json — hooksmith owns them now.
- Create a rule file (filename must match
id):
# ~/.config/hooksmith/rules/block-rm.yaml
id: block-rm
event: PreToolUse
matcher: Bash
mechanism: regex
field: command
pattern: 'rm[[:space:]]+-rf[[:space:]]+(/|~|\$HOME)'
result: deny
message: "Blocked: destructive rm targeting system or home directory."- Build and activate:
hooksmith build
/reload-pluginsAuto-build:
hooksmith startruns at each session start and rebuildshooks.jsononly when rules have changed.
- User-level (
~/.config/hooksmith/rules/): Applies to all projects - Project-level (
.hooksmith/rules/): Applies to that project only
Project rules override user rules with the same filename.
Every rule requires an id field matching the filename (without .yaml):
id: my-rule # Required — must match filename my-rule.yaml
event: PreToolUse # Hook event
matcher: Bash # Tool filter (optional)
mechanism: regex # regex, script, or prompt
field: command # Field to test (regex only)
pattern: 'dangerous' # Regex pattern (regex only)
result: deny # deny, ask, warn, or context
message: "Blocked." # Output message (optional)
fail_mode: open # open (default) or closed
enabled: true # false to exclude from build
timeout: 10 # SecondsUse regex when... |
Use script when... |
Use prompt when... |
|---|---|---|
| Matching a pattern in a known field | Logic is complex or stateful | Condition requires judgment |
| Zero overhead | You have an existing .sh script |
Natural language evaluation |
| Result | Effect |
|---|---|
deny |
Block the action |
ask |
Prompt user for approval |
warn |
Inject a warning into context |
context |
Inject information into context |
bash tests/run-tests.shCovers CLI commands, deny/ask/allow behaviors across multiple hooks. Zero dependencies — pure bash.
jqbash3.2+
See examples/ for sample rules covering all three mechanisms.
Ask Claude to "create a hook rule" or "add a regex rule" — the hooksmith skill provides the full field reference, result-event compatibility table, and guided rule creation workflow.
- Hooks reference — Full event list, JSON payload shapes, decision fields by event
- Automate workflows with hooks — Guide to hook patterns and use cases
- Plugins reference — Plugin structure,
hooks.jsonloading,/reload-plugins
- Hookify — Official Anthropic hook management plugin
- Hookify on GitHub
- Writing Hookify rules