
Writing Hookify Rules
- 167 installs
- 404 repo stars
- Updated August 5, 2026
- aiskillstore/marketplace
Author Hookify rule files that pattern-match agent inputs or tool usage and trigger automated responses, blocks, or transformations during Claude Code sessions.
About
Explains how to write Hookify rules for Claude Code: expressive matchers, prioritized rule lists, safe actions on matched events, and testing strategies so teams encode policy, formatting, and workflow nudges as versioned agent configuration.
- Define match patterns for messages and tools
- Specify actions: allow, deny, rewrite, notify
- Organize rules for maintainability
- Test rules against realistic session transcripts
- Iterate rules without redeploying application code
Writing Hookify Rules by the numbers
- 167 all-time installs (skills.sh)
- Ranked #3,181 of 16,546 AI & Agent Building skills by installs in the Skillselion catalog
- Data as of Aug 5, 2026 (Skillselion catalog sync)
npx skills add https://github.com/aiskillstore/marketplace --skill writing-hookify-rulesAdd your badge
Show developers this skill is listed on Skillselion. Paste this into your README.
| Installs | 167 |
|---|---|
| repo stars | ★ 404 |
| Last updated | August 5, 2026 |
| Repository | aiskillstore/marketplace ↗ |
What it does
Author Hookify rule files that pattern-match agent inputs or tool usage and trigger automated responses, blocks, or transformations during Claude Code sessions.
Files
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|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 promptall: All events
action (optional): What to do when rule matches
warn: Show message but allow operation (default)block: Prevent operation (PreToolUse) or stop session (Stop events)- 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+-rfAdvanced 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 matchregex_match: Regex pattern matchingcontains: Substring checkequals: Exact matchnot_contains: Substring must NOT be presentstarts_with: Prefix checkends_with: Suffix checkpattern: 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 buildsEvent 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 updatedUse 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 pathBetter: 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
Location: All rules in .claude/ directory Naming: .claude/hookify.{descriptive-name}.local.md Gitignore: Add .claude/*.local.md to .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)
Workflow
Creating a Rule
1. Identify unwanted behavior 2. Determine which tool is involved (Bash, Edit, etc.) 3. Choose event type (bash, file, stop, etc.) 4. Write regex pattern 5. Create .claude/hookify.{name}.local.md file in project root 6. Test immediately - rules are read dynamically on next tool use
Refining a Rule
1. Edit the .local.md file 2. Adjust pattern or message 3. Test immediately - changes take effect on next tool use
Disabling a Rule
Temporary: Set enabled: false in frontmatter Permanent: Delete the .local.md file
Examples
See ${CLAUDE_PLUGIN_ROOT}/examples/ for complete examples:
dangerous-rm.local.md- Block dangerous rm commandsconsole-log-warning.local.md- Warn about console.logsensitive-files-warning.local.md- Warn about editing .env files
Quick Reference
Minimum viable rule:
---
name: my-rule
enabled: true
event: bash
pattern: dangerous_command
---
Warning message hereRule with conditions:
---
name: my-rule
enabled: true
event: file
conditions:
- field: file_path
operator: regex_match
pattern: \.ts$
- field: new_text
operator: contains
pattern: any
---
Warning messageEvent types:
bash- Bash commandsfile- File editsstop- Completion checksprompt- User inputall- 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
{
"schema_version": "2.0",
"meta": {
"generated_at": "2026-01-17T07:00:49.647Z",
"slug": "writing-hookify-rules",
"source_url": "https://github.com/anthropics/claude-code/tree/main/plugins/hookify/skills/writing-rules",
"source_ref": "main",
"model": "claude",
"analysis_version": "3.0.0",
"source_type": "official",
"content_hash": "44338fd531fab78125fbcb0ad3d1bb4ba2b33f5fa640f4af5770ade2c858d48f",
"tree_hash": "f81274109d032c69fb18a6356334d9571bcb939e251c8be3a3ea0e7ffc085644"
},
"skill": {
"name": "writing-hookify-rules",
"description": "This skill should be used when the user asks to \"create a hookify rule\", \"write a hook rule\", \"configure hookify\", \"add a hookify rule\", or needs guidance on hookify rule syntax and patterns.",
"summary": "This skill should be used when the user asks to \"create a hookify rule\", \"write a hook rule\", \"confi...",
"icon": "🪝",
"version": "0.1.0",
"author": "anthropics",
"license": "MIT",
"category": "coding",
"tags": [
"hookify",
"rules",
"patterns",
"claude-code",
"configuration"
],
"supported_tools": [
"claude",
"codex",
"claude-code"
],
"risk_factors": [
"scripts",
"external_commands",
"network",
"env_access"
]
},
"security_audit": {
"risk_level": "safe",
"is_blocked": false,
"safe_to_publish": true,
"summary": "Official Anthropic documentation skill containing only markdown content. No executable code, scripts, network operations, or filesystem access. Pure educational content for creating Hookify rules in Claude Code.",
"risk_factor_evidence": [
{
"factor": "scripts",
"evidence": [
{
"file": "skill-report.json",
"line_start": 88,
"line_end": 88
},
{
"file": "SKILL.md",
"line_start": 249,
"line_end": 249
},
{
"file": "SKILL.md",
"line_start": 249,
"line_end": 249
}
]
},
{
"factor": "external_commands",
"evidence": [
{
"file": "skill-report.json",
"line_start": 83,
"line_end": 83
},
{
"file": "SKILL.md",
"line_start": 249,
"line_end": 259
},
{
"file": "SKILL.md",
"line_start": 11,
"line_end": 11
},
{
"file": "SKILL.md",
"line_start": 17,
"line_end": 27
},
{
"file": "SKILL.md",
"line_start": 27,
"line_end": 32
},
{
"file": "SKILL.md",
"line_start": 32,
"line_end": 32
},
{
"file": "SKILL.md",
"line_start": 32,
"line_end": 37
},
{
"file": "SKILL.md",
"line_start": 37,
"line_end": 38
},
{
"file": "SKILL.md",
"line_start": 38,
"line_end": 42
},
{
"file": "SKILL.md",
"line_start": 42,
"line_end": 43
},
{
"file": "SKILL.md",
"line_start": 43,
"line_end": 44
},
{
"file": "SKILL.md",
"line_start": 44,
"line_end": 45
},
{
"file": "SKILL.md",
"line_start": 45,
"line_end": 46
},
{
"file": "SKILL.md",
"line_start": 46,
"line_end": 49
},
{
"file": "SKILL.md",
"line_start": 49,
"line_end": 50
},
{
"file": "SKILL.md",
"line_start": 50,
"line_end": 51
},
{
"file": "SKILL.md",
"line_start": 51,
"line_end": 59
},
{
"file": "SKILL.md",
"line_start": 59,
"line_end": 62
},
{
"file": "SKILL.md",
"line_start": 62,
"line_end": 68
},
{
"file": "SKILL.md",
"line_start": 68,
"line_end": 83
},
{
"file": "SKILL.md",
"line_start": 83,
"line_end": 86
},
{
"file": "SKILL.md",
"line_start": 86,
"line_end": 87
},
{
"file": "SKILL.md",
"line_start": 87,
"line_end": 88
},
{
"file": "SKILL.md",
"line_start": 88,
"line_end": 88
},
{
"file": "SKILL.md",
"line_start": 88,
"line_end": 88
},
{
"file": "SKILL.md",
"line_start": 88,
"line_end": 88
},
{
"file": "SKILL.md",
"line_start": 88,
"line_end": 89
},
{
"file": "SKILL.md",
"line_start": 89,
"line_end": 90
},
{
"file": "SKILL.md",
"line_start": 90,
"line_end": 91
},
{
"file": "SKILL.md",
"line_start": 91,
"line_end": 92
},
{
"file": "SKILL.md",
"line_start": 92,
"line_end": 93
},
{
"file": "SKILL.md",
"line_start": 93,
"line_end": 94
},
{
"file": "SKILL.md",
"line_start": 94,
"line_end": 95
},
{
"file": "SKILL.md",
"line_start": 95,
"line_end": 96
},
{
"file": "SKILL.md",
"line_start": 96,
"line_end": 111
},
{
"file": "SKILL.md",
"line_start": 111,
"line_end": 125
},
{
"file": "SKILL.md",
"line_start": 125,
"line_end": 133
},
{
"file": "SKILL.md",
"line_start": 133,
"line_end": 140
},
{
"file": "SKILL.md",
"line_start": 140,
"line_end": 143
},
{
"file": "SKILL.md",
"line_start": 143,
"line_end": 143
},
{
"file": "SKILL.md",
"line_start": 143,
"line_end": 143
},
{
"file": "SKILL.md",
"line_start": 143,
"line_end": 144
},
{
"file": "SKILL.md",
"line_start": 144,
"line_end": 144
},
{
"file": "SKILL.md",
"line_start": 144,
"line_end": 145
},
{
"file": "SKILL.md",
"line_start": 145,
"line_end": 145
},
{
"file": "SKILL.md",
"line_start": 145,
"line_end": 151
},
{
"file": "SKILL.md",
"line_start": 151,
"line_end": 158
},
{
"file": "SKILL.md",
"line_start": 158,
"line_end": 161
},
{
"file": "SKILL.md",
"line_start": 161,
"line_end": 174
},
{
"file": "SKILL.md",
"line_start": 174,
"line_end": 177
},
{
"file": "SKILL.md",
"line_start": 177,
"line_end": 177
},
{
"file": "SKILL.md",
"line_start": 177,
"line_end": 177
},
{
"file": "SKILL.md",
"line_start": 177,
"line_end": 178
},
{
"file": "SKILL.md",
"line_start": 178,
"line_end": 178
},
{
"file": "SKILL.md",
"line_start": 178,
"line_end": 178
},
{
"file": "SKILL.md",
"line_start": 178,
"line_end": 179
},
{
"file": "SKILL.md",
"line_start": 179,
"line_end": 179
},
{
"file": "SKILL.md",
"line_start": 179,
"line_end": 179
},
{
"file": "SKILL.md",
"line_start": 179,
"line_end": 180
},
{
"file": "SKILL.md",
"line_start": 180,
"line_end": 180
},
{
"file": "SKILL.md",
"line_start": 180,
"line_end": 180
},
{
"file": "SKILL.md",
"line_start": 180,
"line_end": 186
},
{
"file": "SKILL.md",
"line_start": 186,
"line_end": 196
},
{
"file": "SKILL.md",
"line_start": 196,
"line_end": 207
},
{
"file": "SKILL.md",
"line_start": 207,
"line_end": 220
},
{
"file": "SKILL.md",
"line_start": 220,
"line_end": 227
},
{
"file": "SKILL.md",
"line_start": 227,
"line_end": 228
},
{
"file": "SKILL.md",
"line_start": 228,
"line_end": 231
},
{
"file": "SKILL.md",
"line_start": 231,
"line_end": 231
},
{
"file": "SKILL.md",
"line_start": 231,
"line_end": 232
},
{
"file": "SKILL.md",
"line_start": 232,
"line_end": 232
},
{
"file": "SKILL.md",
"line_start": 232,
"line_end": 232
},
{
"file": "SKILL.md",
"line_start": 232,
"line_end": 232
},
{
"file": "SKILL.md",
"line_start": 232,
"line_end": 233
},
{
"file": "SKILL.md",
"line_start": 233,
"line_end": 233
},
{
"file": "SKILL.md",
"line_start": 233,
"line_end": 233
},
{
"file": "SKILL.md",
"line_start": 233,
"line_end": 233
},
{
"file": "SKILL.md",
"line_start": 233,
"line_end": 236
},
{
"file": "SKILL.md",
"line_start": 236,
"line_end": 237
},
{
"file": "SKILL.md",
"line_start": 237,
"line_end": 238
},
{
"file": "SKILL.md",
"line_start": 238,
"line_end": 239
},
{
"file": "SKILL.md",
"line_start": 239,
"line_end": 240
},
{
"file": "SKILL.md",
"line_start": 240,
"line_end": 241
},
{
"file": "SKILL.md",
"line_start": 241,
"line_end": 242
},
{
"file": "SKILL.md",
"line_start": 242,
"line_end": 243
},
{
"file": "SKILL.md",
"line_start": 243,
"line_end": 246
},
{
"file": "SKILL.md",
"line_start": 246,
"line_end": 252
},
{
"file": "SKILL.md",
"line_start": 252,
"line_end": 258
},
{
"file": "SKILL.md",
"line_start": 258,
"line_end": 260
},
{
"file": "SKILL.md",
"line_start": 260,
"line_end": 267
},
{
"file": "SKILL.md",
"line_start": 267,
"line_end": 269
},
{
"file": "SKILL.md",
"line_start": 269,
"line_end": 270
},
{
"file": "SKILL.md",
"line_start": 270,
"line_end": 273
},
{
"file": "SKILL.md",
"line_start": 273,
"line_end": 275
},
{
"file": "SKILL.md",
"line_start": 275,
"line_end": 276
},
{
"file": "SKILL.md",
"line_start": 276,
"line_end": 279
},
{
"file": "SKILL.md",
"line_start": 279,
"line_end": 279
},
{
"file": "SKILL.md",
"line_start": 279,
"line_end": 280
},
{
"file": "SKILL.md",
"line_start": 280,
"line_end": 285
},
{
"file": "SKILL.md",
"line_start": 285,
"line_end": 286
},
{
"file": "SKILL.md",
"line_start": 286,
"line_end": 287
},
{
"file": "SKILL.md",
"line_start": 287,
"line_end": 287
},
{
"file": "SKILL.md",
"line_start": 287,
"line_end": 290
},
{
"file": "SKILL.md",
"line_start": 290,
"line_end": 291
},
{
"file": "SKILL.md",
"line_start": 291,
"line_end": 292
},
{
"file": "SKILL.md",
"line_start": 292,
"line_end": 293
},
{
"file": "SKILL.md",
"line_start": 293,
"line_end": 296
},
{
"file": "SKILL.md",
"line_start": 296,
"line_end": 297
},
{
"file": "SKILL.md",
"line_start": 297,
"line_end": 298
},
{
"file": "SKILL.md",
"line_start": 298,
"line_end": 308
},
{
"file": "SKILL.md",
"line_start": 308,
"line_end": 313
},
{
"file": "SKILL.md",
"line_start": 313,
"line_end": 319
},
{
"file": "SKILL.md",
"line_start": 319,
"line_end": 320
},
{
"file": "SKILL.md",
"line_start": 320,
"line_end": 324
},
{
"file": "SKILL.md",
"line_start": 324,
"line_end": 325
},
{
"file": "SKILL.md",
"line_start": 325,
"line_end": 326
},
{
"file": "SKILL.md",
"line_start": 326,
"line_end": 327
},
{
"file": "SKILL.md",
"line_start": 327,
"line_end": 332
},
{
"file": "SKILL.md",
"line_start": 332,
"line_end": 341
},
{
"file": "SKILL.md",
"line_start": 341,
"line_end": 344
},
{
"file": "SKILL.md",
"line_start": 344,
"line_end": 359
},
{
"file": "SKILL.md",
"line_start": 359,
"line_end": 362
},
{
"file": "SKILL.md",
"line_start": 362,
"line_end": 363
},
{
"file": "SKILL.md",
"line_start": 363,
"line_end": 364
},
{
"file": "SKILL.md",
"line_start": 364,
"line_end": 365
},
{
"file": "SKILL.md",
"line_start": 365,
"line_end": 366
},
{
"file": "SKILL.md",
"line_start": 366,
"line_end": 369
},
{
"file": "SKILL.md",
"line_start": 369,
"line_end": 370
},
{
"file": "SKILL.md",
"line_start": 370,
"line_end": 370
},
{
"file": "SKILL.md",
"line_start": 370,
"line_end": 370
},
{
"file": "SKILL.md",
"line_start": 370,
"line_end": 370
},
{
"file": "SKILL.md",
"line_start": 370,
"line_end": 371
},
{
"file": "SKILL.md",
"line_start": 371,
"line_end": 374
},
{
"file": "SKILL.md",
"line_start": 374,
"line_end": 374
},
{
"file": "SKILL.md",
"line_start": 374,
"line_end": 374
},
{
"file": "SKILL.md",
"line_start": 374,
"line_end": 374
},
{
"file": "SKILL.md",
"line_start": 374,
"line_end": 374
},
{
"file": "SKILL.md",
"line_start": 374,
"line_end": 374
}
]
},
{
"factor": "network",
"evidence": [
{
"file": "skill-report.json",
"line_start": 6,
"line_end": 6
}
]
},
{
"factor": "env_access",
"evidence": [
{
"file": "skill-report.json",
"line_start": 110,
"line_end": 110
},
{
"file": "SKILL.md",
"line_start": 79,
"line_end": 79
},
{
"file": "SKILL.md",
"line_start": 251,
"line_end": 251
},
{
"file": "SKILL.md",
"line_start": 251,
"line_end": 251
},
{
"file": "SKILL.md",
"line_start": 251,
"line_end": 251
}
]
}
],
"critical_findings": [],
"high_findings": [],
"medium_findings": [],
"low_findings": [],
"dangerous_patterns": [],
"files_scanned": 1,
"total_lines": 375,
"audit_model": "claude",
"audited_at": "2026-01-17T07:00:49.647Z"
},
"content": {
"user_title": "Create Hookify Rules for Claude Code",
"value_statement": "Claude Code executes commands and edits files automatically. Hookify rules let you add custom checks to warn about or block dangerous patterns before they run. Create rules that match bash commands, file edits, prompts, or agent stop events.",
"seo_keywords": [
"Hookify rules",
"Claude Code",
"Claude Code rules",
"pattern matching",
"command filtering",
"file edit safety",
"agent hooks",
"custom rules",
"Claude Code configuration",
"Hookify syntax"
],
"actual_capabilities": [
"Create markdown files with YAML frontmatter to define custom Hookify rules",
"Match patterns against bash commands, file edits, user prompts, or agent stop events",
"Configure warn or block actions when patterns match",
"Use simple regex patterns or advanced multi-condition rules with field operators",
"Write effective warning messages that explain detected patterns and suggest alternatives"
],
"limitations": [
"Rules apply only to Claude Code, not to other Claude products",
"Pattern matching uses Python regex syntax only",
"Rules are read dynamically but require a new tool invocation to trigger",
"Cannot execute code or make network requests directly"
],
"use_cases": [
{
"target_user": "Security teams",
"title": "Block dangerous commands",
"description": "Create rules that detect and block dangerous bash commands like rm -rf, sudo usage, or chmod 777 before execution"
},
{
"target_user": "Development leads",
"title": "Enforce coding standards",
"description": "Set up rules that warn when developers add console.log statements, eval(), or other prohibited patterns"
},
{
"target_user": "DevOps engineers",
"title": "Protect sensitive files",
"description": "Configure rules that alert when editing .env files, credentials, or other sensitive configuration files"
}
],
"prompt_templates": [
{
"title": "Create basic warn rule",
"scenario": "Block dangerous rm command",
"prompt": "Create a Hookify rule named warn-dangerous-rm that watches bash events, matches rm -rf patterns, and shows a warning message"
},
{
"title": "Block console logs",
"scenario": "Prevent console.log in production",
"prompt": "Create a Hookify rule that blocks console.log additions to TypeScript files in the src directory"
},
{
"title": "Multi-condition rule",
"scenario": "Protect environment files",
"prompt": "Write a Hookify rule with multiple conditions that warns when editing .env files that contain API_KEY patterns"
},
{
"title": "Stop event checklist",
"scenario": "Verify completion before exit",
"prompt": "Create a Hookify stop event rule that shows a checklist asking about tests, build status, and documentation before the agent stops"
}
],
"output_examples": [
{
"input": "Create a Hookify rule that warns about dangerous rm commands",
"output": [
"Rule file: .claude/hookify.warn-dangerous-rm.local.md",
"This rule triggers on bash events matching: rm\\s+-rf",
"When triggered, shows warning message with alternatives",
"Action: warn (allows command but shows guidance)"
]
},
{
"input": "Create a rule to prevent editing .env files with secrets",
"output": [
"Rule file: .claude/hookify.sensitive-env.local.md",
"Conditions check file_path matches \\.env$ and new_text contains API_KEY",
"Shows warning about adding secrets to environment files",
"Suggests adding the file to .gitignore"
]
},
{
"input": "Add a completion checklist before the agent stops",
"output": [
"Rule file: .claude/hookify.require-tests.local.md",
"Stop event rule with pattern .* to match all stop attempts",
"Shows markdown checklist for tests, build, and documentation",
"Agent sees reminder before stopping work"
]
}
],
"best_practices": [
"Use descriptive rule names with kebab-case like warn-console-log or block-dangerous-rm",
"Test regex patterns with Python regex tester or online tools before creating rules",
"Add rules to .gitignore as .claude/*.local.md to prevent committing project-specific rules"
],
"anti_patterns": [
"Using overly broad patterns like 'log' that match unintended text like login or catalog",
"Creating rules without clear warning messages that explain what was detected and why",
"Forgetting to escape special regex characters like dots, parentheses, and brackets"
],
"faq": [
{
"question": "What event types can Hookify rules match?",
"answer": "Rules can match bash commands, file edits, user prompts, agent stop events, or all events combined."
},
{
"question": "How many conditions can a rule have?",
"answer": "Rules support multiple conditions using the conditions array. All conditions must match for the rule to trigger."
},
{
"question": "Can I use Hookify rules with other Claude products?",
"answer": "No. Hookify is a feature specific to Claude Code and does not work with Claude, Codex, or other Claude products."
},
{
"question": "Are my Hookify rules stored securely?",
"answer": "Rules are stored as local markdown files in the .claude directory. Add them to .gitignore for project-specific rules."
},
{
"question": "Why is my new rule not triggering?",
"answer": "Rules are read dynamically but only trigger on the next tool use after the rule file is created or modified."
},
{
"question": "What is the difference between warn and block actions?",
"answer": "Warn shows a message but allows the operation. Block prevents the operation for PreToolUse events or stops the session for Stop events."
}
]
},
"file_structure": [
{
"name": "SKILL.md",
"type": "file",
"path": "SKILL.md",
"lines": 375
}
]
}