hookify
claude-code-plugins · 156.7k stars
Plugin Easily create custom hooks to prevent unwanted behaviors by analyzing conversation patterns or from explicit instructions. Define rules via simple markdown files.
Install
/plugin marketplace add anthropics/claude-code /plugin install hookify@claude-code-plugins
Run inside Claude Code. Add its marketplace first. Check the repo's README before you run it.
What it adds
4 commands · 1 agent · 1 skill · 4 hooks
Commands 4
/configureEnable or disable hookify rules interactively/helpGet help with the hookify plugin/hookifyCreate hooks to prevent unwanted behaviors from conversation analysis or explicit instructions/listList all configured hookify rules
Agents 1
conversation-analyzerUse this agent when analyzing conversation transcripts to find behaviors worth preventing with hooks.
Skills 1
Writing Hookify RulesThis skill should be used when the user asks to "create a hookify rule", "write a hook rule", "configure hookify", "add a hookify rule", or needs guidance on hookify rule syntax and patterns.
Hooks 4
PreToolUsepython3 ${CLAUDE_PLUGIN_ROOT}/hooks/pretooluse.pyPostToolUsepython3 ${CLAUDE_PLUGIN_ROOT}/hooks/posttooluse.pyStoppython3 ${CLAUDE_PLUGIN_ROOT}/hooks/stop.pyUserPromptSubmitpython3 ${CLAUDE_PLUGIN_ROOT}/hooks/userpromptsubmit.py
Hooks run on your machine at these points in a session. Read them before you install.
Files
Hookify Plugin
Easily create custom hooks to prevent unwanted behaviors by analyzing conversation patterns or from explicit instructions.
Overview
The hookify plugin makes it simple to create hooks without editing complex hooks.json files. Instead, you create lightweight markdown configuration files that define patterns to watch for and messages to show when those patterns match.
Key features:
- 🎯 Analyze conversations to find unwanted behaviors automatically
- 📝 Simple markdown configuration files with YAML frontmatter
- 🔍 Regex pattern matching for powerful rules
- 🚀 No coding required - just describe the behavior
- 🔄 Easy enable/disable without restarting
Quick Start
1. Create Your First Rule
/hookify Warn me when I use rm -rf commands
This analyzes your request and creates .claude/hookify.warn-rm.local.md.
2. Test It Immediately
No restart needed! Rules take effect on the very next tool use.
Ask Claude to run a command that should trigger the rule:
Run rm -rf /tmp/test
You should see the warning message immediately!
Usage
Main Command: /hookify
With arguments:
/hookify Don't use console.log in TypeScript files
Creates a rule from your explicit instructions.
Without arguments:
/hookify
Analyzes recent conversation to find behaviors you've corrected or been frustrated by.
Helper Commands
List all rules:
/hookify:list
Configure rules interactively:
/hookify:configure
Enable/disable existing rules through an interactive interface.
Get help:
/hookify:help
Rule Configuration Format
Simple Rule (Single Pattern)
.claude/hookify.dangerous-rm.local.md:
--- name: block-dangerous-rm enabled: true event: bash pattern: rm\s+-rf action: block --- ⚠️ **Dangerous rm command detected!** This command could delete important files. Please: - Verify the path is correct - Consider using a safer approach - Make sure you have backups
Action field:
warn: Shows warning but allows operation (default)block: Prevents operation from executing (PreToolUse) or stops session (Stop events)
Advanced Rule (Multiple Conditions)
.claude/hookify.sensitive-files.local.md:
---
name: warn-sensitive-files
enabled: true
event: file
action: warn
conditions:
- field: file_path
operator: regex_match
pattern: \.env$|credentials|secrets
- field: new_text
operator: contains
pattern: KEY
---
🔐 **Sensitive file edit detected!**
Ensure credentials are not hardcoded and file is in .gitignore.
All conditions must match for the rule to trigger.
Event Types
bash: Triggers on Bash tool commandsfile: Triggers on Edit, Write, MultiEdit toolsstop: Triggers when Claude wants to stop (for completion checks)prompt: Triggers on user prompt submissionall: Triggers on all events
Pattern Syntax
Use Python regex syntax:
| Pattern | Matches | Example |
|---|---|---|
rm\s+-rf |
rm -rf | rm -rf /tmp |
console\.log\( |
console.log( | console.log("test") |
(eval|exec)\( |
eval( or exec( | eval("code") |
\.env$ |
files ending in .env | .env, .env.local |
chmod\s+777 |
chmod 777 | chmod 777 file.txt |
Tips:
- Use
\sfor whitespace - Escape special chars:
\.for literal dot - Use
|for OR:(foo|bar) - Use
.*to match anything - Set
action: blockfor dangerous operations - Set
action: warn(or omit) for informational warnings
Examples
Example 1: Block Dangerous Commands
--- name: block-destructive-ops enabled: true event: bash pattern: rm\s+-rf|dd\s+if=|mkfs|format action: block --- 🛑 **Destructive operation detected!** This command can cause data loss. Operation blocked for safety. Please verify the exact path and use a safer approach.
This rule blocks the operation - Claude will not be allowed to execute these commands.
Example 2: Warn About Debug Code
--- name: warn-debug-code enabled: true event: file pattern: console\.log\(|debugger;|print\( action: warn --- 🐛 **Debug code detected** Remember to remove debugging statements before committing.
This rule warns but allows - Claude sees the message but can still proceed.
Example 3: Require Tests Before Stopping
---
name: require-tests-run
enabled: false
event: stop
action: block
conditions:
- field: transcript
operator: not_contains
pattern: npm test|pytest|cargo test
---
**Tests not detected in transcript!**
Before stopping, please run tests to verify your changes work correctly.
This blocks Claude from stopping if no test commands appear in the session transcript. Enable only when you want strict enforcement.
Advanced Usage
Multiple Conditions
Check multiple fields simultaneously:
---
name: api-key-in-typescript
enabled: true
event: file
conditions:
- field: file_path
operator: regex_match
pattern: \.tsx?$
- field: new_text
operator: regex_match
pattern: (API_KEY|SECRET|TOKEN)\s*=\s*["']
---
🔐 **Hardcoded credential in TypeScript!**
Use environment variables instead of hardcoded values.
Operators Reference
regex_match: Pattern must match (most common)contains: String must contain patternequals: Exact string matchnot_contains: String must NOT contain patternstarts_with: String starts with patternends_with: String ends with pattern
Field Reference
For bash events:
command: The bash command string
For file events:
file_path: Path to file being editednew_text: New content being added (Edit, Write)old_text: Old content being replaced (Edit only)content: File content (Write only)
For prompt events:
user_prompt: The user's submitted prompt text
For stop events:
- Use general matching on session state
Management
Enable/Disable Rules
Temporarily disable:
Edit the .local.md file and set enabled: false
Re-enable:
Set enabled: true
Or use interactive tool:
/hookify:configure
Delete Rules
Simply delete the .local.md file:
rm .claude/hookify.my-rule.local.md
View All Rules
/hookify:list
Installation
This plugin is part of the Claude Code Marketplace. It should be auto-discovered when the marketplace is installed.
Manual testing:
cc --plugin-dir /path/to/hookify
Requirements
- Python 3.7+
- No external dependencies (uses stdlib only)
Troubleshooting
Rule not triggering:
- Check rule file exists in
.claude/directory (in project root, not plugin directory) - Verify
enabled: truein frontmatter - Test regex pattern separately
- Rules should work immediately - no restart needed
- Try
/hookify:listto see if rule is loaded
Import errors:
- Ensure Python 3 is available:
python3 --version - Check hookify plugin is installed
Pattern not matching:
- Test regex:
python3 -c "import re; print(re.search(r'pattern', 'text'))" - Use unquoted patterns in YAML to avoid escaping issues
- Start simple, then add complexity
Hook seems slow:
- Keep patterns simple (avoid complex regex)
- Use specific event types (bash, file) instead of "all"
- Limit number of active rules
Contributing
Found a useful rule pattern? Consider sharing example files via PR!
Future Enhancements
- Severity levels (error/warning/info distinctions)
- Rule templates library
- Interactive pattern builder
- Hook testing utilities
- JSON format support (in addition to markdown)
License
MIT License
{
"name": "hookify",
"version": "0.1.0",
"description": "Easily create hooks to prevent unwanted behaviors by analyzing conversation patterns",
"author": {
"name": "Daisy Hollman",
"email": "daisy@anthropic.com"
}
}{
"description": "Hookify plugin - User-configurable hooks from .local.md files",
"hooks": {
"PreToolUse": [
{
"hooks": [
{
"type": "command",
"command": "python3 ${CLAUDE_PLUGIN_ROOT}/hooks/pretooluse.py",
"timeout": 10
}
]
}
],
"PostToolUse": [
{
"hooks": [
{
"type": "command",
"command": "python3 ${CLAUDE_PLUGIN_ROOT}/hooks/posttooluse.py",
"timeout": 10
}
]
}
],
"Stop": [
{
"hooks": [
{
"type": "command",
"command": "python3 ${CLAUDE_PLUGIN_ROOT}/hooks/stop.py",
"timeout": 10
}
]
}
],
"UserPromptSubmit": [
{
"hooks": [
{
"type": "command",
"command": "python3 ${CLAUDE_PLUGIN_ROOT}/hooks/userpromptsubmit.py",
"timeout": 10
}
]
}
]
}
}Facts
- Kind
- Plugin
- Marketplace
- claude-code-plugins
- Group
- Productivity
- Stars
- 156.7k
- Version
- 0.1.0
- Author
- Daisy Hollman
- Category
- productivity
- Marketplace repo
- anthropics/claude-code
- Files
- 24
Same repo on other shelves
Skills
From the same marketplace
- 18learning-output-styleclaude-code-pluginsInteractive learning mode that requests meaningful code contributions at decision points (mimics the unshipped Learning output style)156.7k
- 19plugin-devclaude-code-pluginsComprehensive toolkit for developing Claude Code plugins. Includes 7 expert skills covering hooks, MCP integration, commands, agents, and best practices. AI-assisted plugin creation and validation.156.7k
- 20pr-review-toolkitclaude-code-pluginsComprehensive PR review agents specializing in comments, tests, error handling, type design, code quality, and code simplification156.7k
- 21ralph-wiggumclaude-code-pluginsInteractive self-referential AI loops for iterative development. Claude works on the same task repeatedly, seeing its previous work, until completion.156.7k
- 22security-guidanceclaude-code-pluginsSecurity reminder hook that warns about potential security issues when editing files, including command injection, XSS, and unsafe code patterns156.7k
- 10agent-sdk-devclaude-code-pluginsDevelopment kit for working with the Claude Agent SDK156.7k