Writing Hookify Rules
When to Use
- User asks to create, write, or configure hookify rules
- User wants to prevent specific behaviors in Claude Code
Process
- Identify the behavior to prevent
- Choose the event type (bash, file, stop, prompt, all)
- Write the pattern (regex or conditions)
- Create the rule file in
.claude/hookify.{name}.local.md
- Test immediately — rules take effect on next tool use
Rule File Format
---
name: rule-identifier
enabled: true
event: bash|file|stop|stopfailure|prompt|all
pattern: regex-pattern-here
---
Message shown to Claude when rule triggers.
Event Types
| Event |
Matches Against |
Use For |
bash |
Command text |
Dangerous commands, privilege escalation |
file |
File path + content |
Debug code, sensitive files, security risks |
stop |
Always (use .*) |
Completion checklists, required steps |
stopfailure |
error_type, error_message |
API error alerts, rate limit handling |
prompt |
User prompt text |
Deployment gates, process enforcement |
all |
All events |
Cross-cutting concerns |
Actions
warn (default): Show message, allow operation
block: Prevent operation entirely
Advanced: Multiple Conditions
conditions:
- field: file_path
operator: regex_match
pattern: \.env$
- field: new_text
operator: contains
pattern: API_KEY
Operators: regex_match, contains, equals, not_contains, starts_with, ends_with
Fields: bash → command | file → file_path, new_text, old_text, content | prompt → user_prompt
All conditions must match for the rule to trigger.
File Organization
- Location:
.claude/hookify.{descriptive-name}.local.md
- Gitignore: Add
.claude/*.local.md to .gitignore
- Naming: Start with verb:
warn-dangerous-rm, block-console-log, require-tests
See references/ for regex patterns, examples, and common pitfalls.
If Connectors Available
github Commit generated rule files and open a PR for team review
slack Notify the team when a new blocking rule is added to the project
linear Track rule creation as a task linked to the behavior it guards against
Converted and distributed by TomeVault — claim your Tome and manage your conversions.
1---2name: ancplua-ancplua-claude-plugins-writing-rules3description: Writing Hookify Rules4---56# Writing Hookify Rules78## When to Use910- User asks to create, write, or configure hookify rules11- User wants to prevent specific behaviors in Claude Code1213## Process14151. **Identify the behavior** to prevent162. **Choose the event type** (bash, file, stop, prompt, all)173. **Write the pattern** (regex or conditions)184. **Create the rule file** in `.claude/hookify.{name}.local.md`195. **Test immediately** — rules take effect on next tool use2021## Rule File Format2223```markdown24---25name: rule-identifier26enabled: true27event: bash|file|stop|stopfailure|prompt|all28pattern: regex-pattern-here29---3031Message shown to Claude when rule triggers.32```3334## Event Types3536| Event | Matches Against | Use For |37|-------|----------------|---------|38| `bash` | Command text | Dangerous commands, privilege escalation |39| `file` | File path + content | Debug code, sensitive files, security risks |40| `stop` | Always (use `.*`) | Completion checklists, required steps |41| `stopfailure` | `error_type`, `error_message` | API error alerts, rate limit handling |42| `prompt` | User prompt text | Deployment gates, process enforcement |43| `all` | All events | Cross-cutting concerns |4445## Actions4647- `warn` (default): Show message, allow operation48- `block`: Prevent operation entirely4950## Advanced: Multiple Conditions5152```yaml53conditions:54 - field: file_path55 operator: regex_match56 pattern: \.env$57 - field: new_text58 operator: contains59 pattern: API_KEY60```6162**Operators:** `regex_match`, `contains`, `equals`, `not_contains`, `starts_with`, `ends_with`6364**Fields:** bash → `command` | file → `file_path`, `new_text`, `old_text`, `content` | prompt → `user_prompt`6566All conditions must match for the rule to trigger.6768## File Organization6970- **Location:** `.claude/hookify.{descriptive-name}.local.md`71- **Gitignore:** Add `.claude/*.local.md` to `.gitignore`72- **Naming:** Start with verb: `warn-dangerous-rm`, `block-console-log`, `require-tests`7374See `references/` for regex patterns, examples, and common pitfalls.7576## If Connectors Available7778- ~~github~~ Commit generated rule files and open a PR for team review79- ~~slack~~ Notify the team when a new blocking rule is added to the project80- ~~linear~~ Track rule creation as a task linked to the behavior it guards against8182---83> Converted and distributed by [TomeVault](https://tomevault.io/claim/ancplua) — claim your Tome and manage your conversions.84<!-- tomevault:4.0:skill_md:2026-04-13 -->