hooks.json files. Create lightweight markdown configuration files that define patterns to watch for and messages to show when those patterns match.
Overview
Hookify allows you to:- ๐ฏ Analyze conversations to find unwanted behaviors automatically
- ๐ Create simple markdown configuration files with YAML frontmatter
- ๐ Use regex pattern matching for powerful rules
- ๐ No coding required - just describe the behavior
- ๐ Enable/disable rules without restarting
Quick Start
No restart needed! Rules take effect on the very next tool use.
Commands
/hookify
Main command for creating hook rules. With arguments:/hookify:list
List all hookify rules:- Rule names and status (enabled/disabled)
- Event types
- Patterns being matched
/hookify:configure
Configure rules interactively:/hookify:help
Get help with hookify:Rule Configuration Format
Simple Rule (Single Pattern)
.claude/hookify.dangerous-rm.local.md:
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:
All conditions must match for the rule to trigger.
Event Types
| Event | Triggers On |
|---|---|
bash | Bash tool commands |
file | Edit, Write, MultiEdit tools |
stop | When Claude wants to stop (for completion checks) |
prompt | User prompt submission |
all | 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 |
- 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
Example 2: Warn About Debug Code
Example 3: Require Tests Before Stopping
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:Operators Reference
| Operator | Description |
|---|---|
regex_match | Pattern must match (most common) |
contains | String must contain pattern |
equals | Exact string match |
not_contains | String must NOT contain pattern |
starts_with | String starts with pattern |
ends_with | String ends with pattern |
Field Reference
For bash events:command: The bash command string
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)
user_prompt: The userโs submitted prompt text
- 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:
Delete Rules
Simply delete the.local.md file:
View All Rules
Agent
conversation-analyzer
Specialized agent that analyzes conversation transcripts to find behaviors worth preventing with hooks. Triggered when:- Running
/hookifywithout arguments - Asking to analyze conversation for mistakes
- Reads user messages to find frustration signals
- Identifies explicit correction requests
- Detects repeated issues
- Extracts actionable patterns
- Categorizes issues by severity
Skill
writing-rules
Provides guidance on hookify rule syntax and patterns. Automatically loaded when using/hookify command.
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
Best Practices
Start Simple
Begin with simple patterns and add complexity as needed
Test Immediately
Test rules right after creating them
Use Warnings First
Start with
action: warn before using blockDescriptive Names
Use clear, descriptive names for your rules
Plugin Information
Author: Daisy Hollman ([email protected])Version: 0.1.0
License: MIT