writing-hookify-rules

Create hookify rule files with YAML frontmatter and regex patterns for Claude Code hooks.

2|Updated Mar 21, 2026
One-click install
npx skills add https://github.com/ghoshsam/claude-code-skills --skill writing-hookify-rules-ghoshsam
Or copy as Structured Prompt for Agent
Please help me install this Agent Skill.
Skill: writing-hookify-rules
Source: https://github.com/ghoshsam/claude-code-skills/tree/main/skills/hookify/writing-rules
Command: npx skills add https://github.com/ghoshsam/claude-code-skills --skill writing-hookify-rules-ghoshsam

SYSTEM DOCUMENTATION & REQUIREMENTS

What problem does it solve? Writing hookify rules requires knowing the exact frontmatter schema, event types, condition operators, and regex syntax, and mistakes in any of these cause rules to silently fail or misfire. ## Core Features & Use Cases - Rule File Authoring: Guides creation of .claude/hookify.{name}.local.md files with correct frontmatter fields including name, enabled, event, action, and pattern. - Event and Condition Coverage: Documents bash, file, stop, prompt, and all event types plus multi-condition rules using operators like regex_match, contains, and starts_with. - Regex Pattern Guidance: Provides tested pattern examples for dangerous commands, console.log detection, sensitive file edits, and completion checklists. - Use Case: You want Claude Code to warn whenever a rm -rf command is run. Use this Skill to generate a properly formatted bash-event rule with the pattern rm\s+-rf and a warning message, saved to .claude/hookify.dangerous-rm.local.md. ## Quick Start Ask the AI to create a hookify rule that warns when console.log is added to TypeScript files.

Frequently Asked Questions about writing-hookify-rules

High-intent search queries and answers about installing and using this skill.

FAQPage Schema
How do I create a hookify rule for Claude Code?

Create a markdown file named .claude/hookify.{rule-name}.local.md with YAML frontmatter containing name, enabled, event, and pattern fields. The markdown body after the frontmatter is the message shown when the rule triggers.

What event types can hookify rules match?

Hookify rules support bash, file, stop, prompt, and all event types. Bash matches commands, file matches Edit/Write/MultiEdit operations, stop matches completion attempts, and prompt matches user input.

How do I write a hookify rule with multiple conditions?

Use the conditions array in frontmatter instead of a single pattern field. Each condition specifies a field, an operator like regex_match or contains, and a pattern; all conditions must match for the rule to trigger.

Can a hookify rule block a command instead of just warning?

Yes, set action: block in the frontmatter to prevent the operation on PreToolUse events or stop the session on Stop events. If omitted, the action defaults to warn, which shows the message but allows the operation.

Why is my hookify regex pattern not matching?

Common causes are unescaped special characters like dots and parentheses, overly broad patterns, or YAML quoting issues. Use unquoted patterns in YAML and test with python3 -c "import re; print(re.search(r'pattern', 'text'))" before saving.

How do I disable a hookify rule without deleting it?

Set enabled: false in the rule's frontmatter to deactivate it while keeping the file. Changes take effect immediately on the next tool use since rules are read dynamically.