hook-rules

Scaffold and validate hookify rule files that turn prose guidelines into pattern-matched hook messages.

Updated Jun 28, 2026
One-click install
npx skills add https://github.com/JaviMontano/claude-plugins --skill hook-rules-javimontano
Or copy as Structured Prompt for Agent▼
Please help me install this Agent Skill.
Skill: hook-rules
Source: https://github.com/JaviMontano/claude-plugins/tree/main/plugins/claude-native-toolkit/skills/hook-rules
Command: npx skills add https://github.com/JaviMontano/claude-plugins --skill hook-rules-javimontano

SYSTEM DOCUMENTATION & REQUIREMENTS

💡 This Skill includes scripts (resource) and references (resource) and assets (resource) components.

What problem does it solve? Writing hookify rules by hand is error-prone: invalid regex, wrong event names, or mixing the two matching modes silently breaks enforcement. This Skill generates and validates .claude/hookify.<name>.local.md rule files so a prose guideline becomes a correctly structured, pattern-matched hook message. ## Core Features & Use Cases - Rule scaffolding: scripts/scaffold_rule.py emits a complete rule (YAML frontmatter plus message body) from parameters, in simple mode (single regex pattern) or advanced mode (AND-ed conditions on fields like file_path and new_text). - Rule validation: scripts/validate_rule.py checks required keys, event/action/operator enums, kebab-case names, pattern-vs-conditions mutual exclusion, and regex compilability, using only the Python standard library. - Self-test gate: scripts/check.sh runs a green/red determinism check over the schema, examples, and scaffold-validate round-trips. - Use Case: Warn whenever an API key is written into a .env file by scaffolding a file-event rule with conditions file_path matches \.env$ and new_text contains API_KEY, then validating it before installing it under .claude/. ## Quick Start Ask the assistant to scaffold and validate a hookify rule that warns when a Bash command matches a dangerous pattern such as recursive deletes.

Frequently Asked Questions about hook-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 hooks?▼

Run scripts/scaffold_rule.py with --name, --event, and either --pattern (simple mode) or repeated --condition flags (advanced mode), plus a --message. Write the output to .claude/hookify.<name>.local.md and validate it with scripts/validate_rule.py.

What is the difference between pattern and conditions in a hookify rule?▼

pattern is simple mode: one regex matched against the event's default field. conditions is advanced mode: a list of field/operator/pattern entries that must all match (logical AND). The two modes are mutually exclusive; a rule must use exactly one.

Which hook events and actions does a hookify rule support?▼

Rules support five events: bash, file, stop, prompt, and all. Actions are warn (show the message but allow the operation) or block (prevent the operation or stop the session); warn is the default when action is omitted.

Does validate_rule.py require PyYAML or other dependencies?▼

No. Both scaffold_rule.py and validate_rule.py use only the Python 3.9+ standard library. The validator parses the frontmatter with a minimal built-in parser, so no pip installs, jq, or PyYAML are needed.

Why does my hookify rule fail validation?▼

Common causes are a non-kebab-case name, an invalid event or operator value, defining both pattern and conditions, an uncompilable regex, or missing required keys (name, enabled, event). Run scripts/validate_rule.py on the file to see each ERROR line.

When should I use raw settings.json hooks instead of hookify rules?▼

Hookify rules are a higher-level, message-oriented abstraction over hook events. If you need raw hook configuration blocks in settings.json rather than pattern-matched guidance messages, use a raw hook authoring skill such as hook-creator instead.