Skip to main content
The Hookify Plugin makes it simple to create hooks without editing complex 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
Key Feature: Rules take effect immediately - no restart needed!

Quick Start

1

Create Your First Rule

/hookify Warn me when I use rm -rf commands
This creates .claude/hookify.warn-rm.local.md
2

Test It Immediately

Ask Claude to run a command that should trigger the rule:
Run rm -rf /tmp/test
You should see the warning message immediately!
No restart needed! Rules take effect on the very next tool use.

Commands

/hookify

Main command for creating hook rules. 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.

/hookify:list

List all hookify rules:
/hookify:list
Shows:
  • Rule names and status (enabled/disabled)
  • Event types
  • Patterns being matched

/hookify:configure

Configure rules interactively:
/hookify:configure
Enable/disable existing rules through an interactive interface.

/hookify:help

Get help with hookify:
/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

EventTriggers On
bashBash tool commands
fileEdit, Write, MultiEdit tools
stopWhen Claude wants to stop (for completion checks)
promptUser prompt submission
allAll events

Pattern Syntax

Use Python regex syntax:
PatternMatchesExample
rm\s+-rfrm -rfrm -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+777chmod 777chmod 777 file.txt
Tips:
  • Use \s for whitespace
  • Escape special chars: \. for literal dot
  • Use | for OR: (foo|bar)
  • Use .* to match anything
  • Set action: block for 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

OperatorDescription
regex_matchPattern must match (most common)
containsString must contain pattern
equalsExact string match
not_containsString must NOT contain pattern
starts_withString starts with pattern
ends_withString ends with pattern

Field Reference

For bash events:
  • command: The bash command string
For file events:
  • file_path: Path to file being edited
  • new_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

Agent

conversation-analyzer

Specialized agent that analyzes conversation transcripts to find behaviors worth preventing with hooks. Triggered when:
  • Running /hookify without arguments
  • Asking to analyze conversation for mistakes
What it does:
  • 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

  1. Check rule file exists in .claude/ directory (in project root, not plugin directory)
  2. Verify enabled: true in frontmatter
  3. Test regex pattern separately
  4. Rules should work immediately - no restart needed
  5. Try /hookify:list to 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 block

Descriptive Names

Use clear, descriptive names for your rules

Plugin Information

Author: Daisy Hollman ([email protected])
Version: 0.1.0
License: MIT

Build docs developers (and LLMs) love