hookify
Markdown rule files that compile into lifecycle hooks blocking or warning on risky Claude Code actions.
- CCM score
- 62 of 100
- version
- 1.0.1
- GitHub stars
- 25
Own this plugin? Claim it
What it does
- Adds the
/hookify,/hookify:list,/hookify:configure, and/hookify:helpcommands plus thewriting-rulesskill - Covers pre-tool, post-tool, stop, prompt, teammate idle, and task completed events through eight hook scripts
- Enforces block or warn actions with regex and AND-ed conditions, and rules take effect without a restart
- Designed for teams that want guardrails on shell commands, file edits, and diffs written as editable markdown
Create configurable hooks from markdown rule files
Add marketplace
/plugin marketplace add CaptainCrouton89/crouton-kitRun it inside Claude Code once, then install the plugin below.
Install
/plugin install hookify@crouton-kitRun it inside Claude Code after adding the marketplace.
Files
Discovered from sourceWriting Hookify Rules
Overview
Hookify rules are markdown files with YAML frontmatter that define patterns to watch for and messages to show when those patterns match. Rules are stored in .claude/hookify.{rule-name}.local.md files.
Rule File Format
Basic Structure
---
name: rule-identifier
enabled: true
event: bash|file|stop|prompt|teammate_idle|task_completed|all
pattern: regex-pattern-here
---
Message to show Claude when this rule triggers.
Can include markdown formatting, warnings, suggestions, etc.
Frontmatter Fields
name (required): Unique identifier for the rule
- Use kebab-case:
warn-dangerous-rm,block-console-log - Be descriptive and action-oriented
- Start with verb: warn, prevent, block, require, check
enabled (required): Boolean to activate/deactivate
true: Rule is activefalse: Rule is disabled (won't trigger)- Can toggle without deleting rule
event (required): Which hook event to trigger on
bash: Bash tool commandsfile: Edit, Write, MultiEdit toolsstop: When agent wants to stopprompt: When user submits a promptteammate_idle: When a teammate is about to go idletask_completed: When a task is marked completeall: All events
action (optional): What to do when rule matches
warn: Show message but allow operation (default)block: Prevent operation (PreToolUse), stop session (Stop), force continuation (TeammateIdle), or reject completion (TaskCompleted)- If omitted, defaults to
warn
pattern (simple format): Regex pattern to match
- Used for simple single-condition rules
- Matches against command (bash) or new_text (file)
- Python regex syntax
Example:
event: bash
pattern: rm\s+-rf
Advanced Format (Multiple Conditions)
For complex rules with multiple conditions:
---
name: warn-env-file-edits
enabled: true
event: file
conditions:
- field: file_path
operator: regex_match
pattern: \.env$
- field: new_text
operator: contains
pattern: API_KEY
---
You're adding an API key to a .env file. Ensure this file is in .gitignore!
Condition fields:
field: Which field to check- For bash:
command - For file:
file_path,new_text,old_text,content
- For bash:
operator: How to matchregex_match: Regex pattern matchingcontains: Substring checkequals: Exact matchnot_contains: Substring must NOT be presentstarts_with: Prefix checkends_with: Suffix check
pattern: Pattern or string to match
All conditions must match for rule to trigger.
Message Body
The markdown content after frontmatter is shown to Claude when the rule triggers.
Good messages:
- Explain what was detected
- Explain why it's problematic
- Suggest alternatives or best practices
- Use formatting for clarity (bold, lists, etc.)
Example:
⚠️ **Console.log detected!**
You're adding console.log to production code.
**Why this matters:**
- Debug logs shouldn't ship to production
- Console.log can expose sensitive data
- Impacts browser performance
**Alternatives:**
- Use a proper logging library
- Remove before committing
- Use conditional debug builds
Event Type Guide
bash Events
Match Bash command patterns:
---
event: bash
pattern: sudo\s+|rm\s+-rf|chmod\s+777
---
Dangerous command detected!
Common patterns:
- Dangerous commands:
rm\s+-rf,dd\s+if=,mkfs - Privilege escalation:
sudo\s+,su\s+ - Permission issues:
chmod\s+777,chown\s+root
file Events
Match Edit/Write/MultiEdit operations:
---
event: file
pattern: console\.log\(|eval\(|innerHTML\s*=
---
Potentially problematic code pattern detected!
Match on different fields:
---
event: file
conditions:
- field: file_path
operator: regex_match
pattern: \.tsx?$
- field: new_text
operator: regex_match
pattern: console\.log\(
---
Console.log in TypeScript file!
Common patterns:
- Debug code:
console\.log\(,debugger,print\( - Security risks:
eval\(,innerHTML\s*=,dangerouslySetInnerHTML - Sensitive files:
\.env$,credentials,\.pem$ - Generated files:
node_modules/,dist/,build/
stop Events
Match when agent wants to stop (completion checks):
---
event: stop
pattern: .*
---
Before stopping, verify:
- [ ] Tests were run
- [ ] Build succeeded
- [ ] Documentation updated
Use for:
- Reminders about required steps
- Completion checklists
- Process enforcement
prompt Events
Match user prompt content (advanced):
---
event: prompt
conditions:
- field: user_prompt
operator: contains
pattern: deploy to production
---
Production deployment checklist:
- [ ] Tests passing?
- [ ] Reviewed by team?
- [ ] Monitoring ready?
Pattern Writing Tips
Regex Basics
Literal characters: Most characters match themselves
rmmatches "rm"console.logmatches "console.log"
Special characters need escaping:
.(any char) →\.(literal dot)()→\(\)(literal parens)[]→\[\](literal brackets)
Common metacharacters:
\s- whitespace (space, tab, newline)\d- digit (0-9)\w- word character (a-z, A-Z, 0-9, _).- any character+- one or more*- zero or more?- zero or one|- OR
Examples:
rm\s+-rf Matches: rm -rf, rm -rf
console\.log\( Matches: console.log(
(eval|exec)\( Matches: eval( or exec(
chmod\s+777 Matches: chmod 777, chmod 777
API_KEY\s*= Matches: API_KEY=, API_KEY =
Testing Patterns
Test regex patterns before using:
python3 -c "import re; print(re.search(r'your_pattern', 'test text'))"
Or use online regex testers (regex101.com with Python flavor).
Common Pitfalls
Too broad:
pattern: log # Matches "log", "login", "dialog", "catalog"
Better: console\.log\(|logger\.
Too specific:
pattern: rm -rf /tmp # Only matches exact path
Better: rm\s+-rf
Escaping issues:
- YAML quoted strings:
"pattern"requires double backslashes\\s - YAML unquoted:
pattern: \sworks as-is - Recommendation: Use unquoted patterns in YAML
File Organization
Locations: Rules can be in two places:
~/.claude/hookify.*.local.md- Global rules (apply to all projects).claude/hookify.*.local.md- Project rules (apply to current project only)
Naming: hookify.{descriptive-name}.local.md
Gitignore: Add .claude/*.local.md to project .gitignore
Good names:
hookify.dangerous-rm.local.mdhookify.console-log.local.mdhookify.require-tests.local.mdhookify.sensitive-files.local.md
Bad names:
hookify.rule1.local.md(not descriptive)hookify.md(missing .local)danger.local.md(missing hookify prefix)
Dynamic Command Interpolation
Messages can include shell commands that get executed and replaced with their output. Use the syntax !command`` (exclamation mark followed by backticks).
Example:
---
name: linear-reminder
enabled: true
event: prompt
pattern: \blinear\b
---
**Your Linear Issues:**
!`linear issue list --limit 5`
Notes:
- Commands timeout after 5 seconds
- Errors shown as
(error: ...) - Empty output shows as
(no output)
Quick Reference
Minimum viable rule:
---
name: my-rule
enabled: true
event: bash
pattern: dangerous_command
---
Warning message here
Event types:
bash- Bash commandsfile- File editsstop- Completion checksprompt- User inputteammate_idle- Teammate about to idletask_completed- Task marked completeall- All events
Field options:
- Bash:
command - File:
file_path,new_text,old_text,content - Prompt:
user_prompt
Operators:
regex_match,contains,equals,not_contains,starts_with,ends_with
Readme
hookify
Prevent unwanted behaviors through lifecycle hooks that check markdown-defined rules before and after tool execution.
How It Works
Hookify installs lifecycle hooks (PreToolUse, PostToolUse, Stop, UserPromptSubmit, TeammateIdle, TaskCompleted) that evaluate rules stored in markdown files. Rules define patterns to match and actions to take (warn or block).
Rules are discovered by walking up from CWD to home directory:
.claude/hookify.*.local.md(current directory and all parents)~/.claude/hookify.*.local.md(global rules)
Changes take effect immediately—no restart needed.
Commands
/hookify [behavior]- Create rules from conversation analysis or explicit instructions/hookify:list- Show all configured rules/hookify:configure- Toggle rules on/off interactively/hookify:help- Get help with hookify
Rule File Format
Location: .claude/hookify.{name}.local.md or ~/.claude/hookify.{name}.local.md
Basic Rule
---
name: warn-dangerous-rm
enabled: true
event: bash
pattern: rm\s+-rf
action: warn
---
⚠️ **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
Advanced Rule (Multiple Conditions)
---
name: warn-env-credentials
enabled: true
event: file
action: warn
conditions:
- field: file_path
operator: regex_match
pattern: \.env$
- field: new_text
operator: contains
pattern: API_KEY
---
🔐 **Credentials in .env file detected**
Ensure this file is in .gitignore and never committed to version control.
Diff-Based Rule (Inspect Changes)
---
name: warn-removed-tests
enabled: true
event: diff
action: warn
conditions:
- field: file_path
operator: regex_match
pattern: \.test\.(ts|js)$
- field: diff
operator: regex_match
pattern: ^-.*\b(it|test|describe)\s*\(
---
⚠️ **Test removal detected**
You're removing test cases. Make sure this is intentional and that test
coverage remains adequate.
The diff field contains a unified diff format where:
- Lines starting with
-were removed - Lines starting with
+were added - Use regex to match specific change patterns
Frontmatter Fields
| Field | Required | Values | Description |
|---|---|---|---|
name | Yes | kebab-case string | Unique identifier (e.g., warn-dangerous-rm) |
enabled | Yes | true | false | Whether rule is active |
event | Yes | bash | file | diff | stop | prompt | teammate_idle | task_completed | all | Which lifecycle events to match |
action | No | warn | block | Default: warn. Block prevents operation |
pattern | No | regex string | Simple pattern for single-condition rules |
conditions | No | array | Complex multi-condition rules (see below) |
Simple pattern is shorthand for a single condition. These are equivalent:
# Simple
event: bash
pattern: rm\s+-rf
# Expanded
event: bash
conditions:
- field: command
operator: regex_match
pattern: rm\s+-rf
Event Types
| Event | Triggers On | Available Fields | Use Cases |
|---|---|---|---|
bash | Bash tool execution | command | Block dangerous commands (rm -rf, chmod 777) |
file | Edit/Write/MultiEdit | file_path, new_text, old_text, content | Warn on code patterns (console.log), sensitive files |
diff | Edit tool | diff, file_path, old_string, new_string | Match changes in unified diff format (+added, -removed) |
stop | Agent attempts to stop | reason, transcript | Require tests before completion |
prompt | User submits prompt | prompt | Context injection based on user input |
teammate_idle | Teammate about to go idle | content | Force continuation until artifacts produced |
task_completed | Task marked complete | content | Gate completion with verification checks |
all | All events | Field depends on tool | Cross-cutting concerns |
Condition Structure
conditions:
- field: command # Which field to check
operator: regex_match # How to match
pattern: rm\s+-rf # What to match
Operators:
regex_match- Python regex patterncontains- Substring presentequals- Exact matchnot_contains- Substring absentstarts_with- Prefix matchends_with- Suffix match
All conditions must match for rule to trigger (AND logic).
Field Mapping by Event
| Event | Simple Pattern Checks | Available Fields |
|---|---|---|
bash | command | command |
file | new_text | file_path, new_text, old_text, content |
diff | diff | diff, file_path, old_string, new_string |
prompt | prompt | prompt |
stop | content | reason, transcript |
teammate_idle | content | content |
task_completed | content | content |
all | content | Context-dependent |
Actions
warn (default):
- Shows message to Claude after tool executes (PostToolUse)
- Operation proceeds normally
- Use for reminders, best practices, context
block:
- Prevents operation before tool executes (PreToolUse)
- For
stopevents: prevents stopping - Shows error message
- Use for dangerous operations, policy enforcement
Dynamic Command Interpolation
Messages can execute shell commands and substitute output using ! followed by backticks:
---
name: show-git-status
enabled: true
event: prompt
pattern: \bgit\b
---
**Current Git Status:**
!`git status --short`
**Uncommitted changes:**
!`git diff --stat`
- Commands timeout after 5 seconds
- Errors shown as
(error: ...) - Empty output shows as
(no output) - Runs in login shell (
/bin/zsh -l -c) for environment variables
Complete Working Example
---
name: block-production-deploy
enabled: true
event: bash
action: block
conditions:
- field: command
operator: regex_match
pattern: kubectl\s+apply|terraform\s+apply|aws\s+deploy
- field: command
operator: not_contains
pattern: --dry-run
---
🚨 **Production deployment detected without dry-run!**
You're about to deploy to production without `--dry-run`.
**Current environment:**
!`echo $ENVIRONMENT`
**Pre-deployment checklist:**
- [ ] Tests passing locally?
- [ ] Reviewed by team?
- [ ] Monitoring alerts configured?
- [ ] Rollback plan ready?
Add `--dry-run` first to verify changes, or use `/hookify:configure` to disable this check.
Hook Implementation
Hookify uses these Claude Code lifecycle hooks:
- PreToolUse: Blocks matching
action: blockrules before tool execution - PostToolUse: Shows matching
action: warnrules after tool execution - Stop: Evaluates
event: stoprules when agent attempts to stop - UserPromptSubmit: Injects context from
event: promptrules - TeammateIdle: Evaluates
event: teammate_idlerules when a teammate is about to idle - TaskCompleted: Evaluates
event: task_completedrules when a task is marked complete
Each hook script (hooks/*.py) loads rules matching the event type and evaluates them against input data using regex patterns or condition operators.
Example Rules
See examples/ directory:
dangerous-rm.local.md- Blockrm -rfcommandsconsole-log-warning.local.md- Warn onconsole.login codesensitive-files-warning.local.md- Warn when editing.envor credentials filesrequire-tests-stop.local.md- Block stopping if tests weren't run (disabled by default)
Pattern Writing Tips
Bash patterns:
# Dangerous commands
pattern: rm\s+-rf|chmod\s+777|dd\s+if=
# Package managers
pattern: npm\s+install|pip\s+install|cargo\s+add
File patterns:
# Code smells
pattern: console\.log\(|eval\(|innerHTML\s*=|debugger
# Sensitive files
pattern: \.env$|\.env\.|credentials|secrets|\.pem$
Remember to escape regex metacharacters: . → \., ( → \(, [ → \[
Rule Discovery Algorithm
# Searches in order:
1. /current/working/directory/.claude/hookify.*.local.md
2. /current/working/.claude/hookify.*.local.md
3. /current/.claude/hookify.*.local.md
4. ... (walk up to home)
5. ~/.claude/hookify.*.local.md
# Deduplicates by realpath
# Only loads enabled rules matching the event type
Usage Workflow
- Create rule:
/hookify Don't use console.log in production code - Verify rule:
/hookify:list - Test trigger: Try operation that matches pattern
- Toggle if needed:
/hookify:configure - Refine pattern: Edit
.claude/hookify.{name}.local.mddirectly
Changes apply immediately on next tool use.
Troubleshooting
Rule doesn't trigger:
- Verify
enabled: true - Check pattern with:
python3 -c "import re; print(re.search(r'pattern', 'test'))" - Confirm file is in
.claude/hookify.*.local.md(not plugin directory) - Verify event type matches tool (e.g.,
event: bashfor Bash tool)
Wrong action (block vs warn):
action: warnshows message after operation (PostToolUse)action: blockprevents operation (PreToolUse)- Default is
warnif omitted
Pattern too broad/narrow:
- Test with actual command/content from failed match
- Use regex101.com (Python flavor) to debug patterns
- Start broad, then narrow based on false positives
File path issues:
- Global rules:
~/.claude/hookify.*.local.md - Project rules:
.claude/hookify.*.local.md(relative to any parent of CWD) - Name must match pattern:
hookify.{identifier}.local.md
Details
- Marketplace
- CaptainCrouton89/crouton-kit
- Source
- plugins/hookify
- Category
- Community
- Keywords
- hooks, rules, automation
- Listed since
- Apr 7, 2026
Questions
What does the hookify plugin do for Claude Code?
Hookify installs lifecycle hooks such as PreToolUse, PostToolUse, Stop and UserPromptSubmit that check rules written as markdown files before and after tool execution. Rules can warn or block, and changes take effect immediately without a restart.
How do I write a hookify rule?
Create a file named hookify.{name}.local.md in the .claude directory of your project or in your home directory. Each rule has frontmatter with a name, an enabled flag, an event type and a regex pattern or conditions, followed by the message Claude sees when the rule fires.
How do I install hookify from the crouton-kit marketplace?
Run /plugin marketplace add CaptainCrouton89/crouton-kit inside Claude Code, then run /plugin install hookify@crouton-kit. Hookify then gives you the /hookify, /hookify:list, /hookify:configure and /hookify:help commands.
Where does hookify stand in the Skill & Plugin Building category?
Hookify is in the Skill & Plugin Building category, which is led by example-skills, prompts.chat, plugin-dev, ruflo-plugin-creator and mcp-builder. Hookify sets itself apart by letting you create hooks from plain markdown rule files instead of writing hook code.
More from CaptainCrouton89/crouton-kit
All 19Similar to hookify
More Skill & Plugin Buildinghooks-formattingPlugindavepoon/buildwithclaude3.8K starsFormatting Hooks - Event-driven automation hooks
hooks-developmentPlugindavepoon/buildwithclaude3.8K starsDevelopment Hooks - Event-driven automation hooks
authoringPluginCaptainCrouton89/crouton-kit25 starsGuides for authoring Claude Code artifacts — CLAUDE.md, hooks, rules, skills, commands, and scripts
sc-hooksPluginkylesnowschwartz/SimpleClaude116 starsSimpleClaude hooks for auto-formatting, lint checks, and tool monitoring
hooks-pluginPluginlaurigates/claude-plugins60 starsClaude Code hooks for enforcing best practices and workflow automation
writing-hookify-rulesSkillanthropics/claude-plugins-official8.1K installsGuide to writing hookify rule files, covering frontmatter fields, event types, and regex pattern tips.