Skip to content

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
View on GitHub

Own this plugin? Claim it

What it does

  • Adds the /hookify, /hookify:list, /hookify:configure, and /hookify:help commands plus the writing-rules skill
  • 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-kit

Run it inside Claude Code once, then install the plugin below.

Install

/plugin install hookify@crouton-kit

Run it inside Claude Code after adding the marketplace.

Files

Discovered from source

Writing 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 active
  • false: Rule is disabled (won't trigger)
  • Can toggle without deleting rule

event (required): Which hook event to trigger on

  • bash: Bash tool commands
  • file: Edit, Write, MultiEdit tools
  • stop: When agent wants to stop
  • prompt: When user submits a prompt
  • teammate_idle: When a teammate is about to go idle
  • task_completed: When a task is marked complete
  • all: 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
  • operator: How to match
    • regex_match: Regex pattern matching
    • contains: Substring check
    • equals: Exact match
    • not_contains: Substring must NOT be present
    • starts_with: Prefix check
    • ends_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

  • rm matches "rm"
  • console.log matches "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: \s works 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.md
  • hookify.console-log.local.md
  • hookify.require-tests.local.md
  • hookify.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 commands
  • file - File edits
  • stop - Completion checks
  • prompt - User input
  • teammate_idle - Teammate about to idle
  • task_completed - Task marked complete
  • all - 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:

  1. .claude/hookify.*.local.md (current directory and all parents)
  2. ~/.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

FieldRequiredValuesDescription
nameYeskebab-case stringUnique identifier (e.g., warn-dangerous-rm)
enabledYestrue | falseWhether rule is active
eventYesbash | file | diff | stop | prompt | teammate_idle | task_completed | allWhich lifecycle events to match
actionNowarn | blockDefault: warn. Block prevents operation
patternNoregex stringSimple pattern for single-condition rules
conditionsNoarrayComplex 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

EventTriggers OnAvailable FieldsUse Cases
bashBash tool executioncommandBlock dangerous commands (rm -rf, chmod 777)
fileEdit/Write/MultiEditfile_path, new_text, old_text, contentWarn on code patterns (console.log), sensitive files
diffEdit tooldiff, file_path, old_string, new_stringMatch changes in unified diff format (+added, -removed)
stopAgent attempts to stopreason, transcriptRequire tests before completion
promptUser submits promptpromptContext injection based on user input
teammate_idleTeammate about to go idlecontentForce continuation until artifacts produced
task_completedTask marked completecontentGate completion with verification checks
allAll eventsField depends on toolCross-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 pattern
  • contains - Substring present
  • equals - Exact match
  • not_contains - Substring absent
  • starts_with - Prefix match
  • ends_with - Suffix match

All conditions must match for rule to trigger (AND logic).

Field Mapping by Event

EventSimple Pattern ChecksAvailable Fields
bashcommandcommand
filenew_textfile_path, new_text, old_text, content
diffdiffdiff, file_path, old_string, new_string
promptpromptprompt
stopcontentreason, transcript
teammate_idlecontentcontent
task_completedcontentcontent
allcontentContext-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 stop events: 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: block rules before tool execution
  • PostToolUse: Shows matching action: warn rules after tool execution
  • Stop: Evaluates event: stop rules when agent attempts to stop
  • UserPromptSubmit: Injects context from event: prompt rules
  • TeammateIdle: Evaluates event: teammate_idle rules when a teammate is about to idle
  • TaskCompleted: Evaluates event: task_completed rules 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 - Block rm -rf commands
  • console-log-warning.local.md - Warn on console.log in code
  • sensitive-files-warning.local.md - Warn when editing .env or credentials files
  • require-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

  1. Create rule: /hookify Don't use console.log in production code
  2. Verify rule: /hookify:list
  3. Test trigger: Try operation that matches pattern
  4. Toggle if needed: /hookify:configure
  5. Refine pattern: Edit .claude/hookify.{name}.local.md directly

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: bash for Bash tool)

Wrong action (block vs warn):

  • action: warn shows message after operation (PostToolUse)
  • action: block prevents operation (PreToolUse)
  • Default is warn if 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 19