Writing Hookify Rules

Create and configure custom hookify rules using YAML frontmatter and regular expressions.

Updated Feb 18, 2026
One-click install
npx skills add https://github.com/zach-source/claude-plugins --skill writing-hookify-rules-zach-source
Or copy as Structured Prompt for Agent
Please help me install this Agent Skill.
Skill: Writing Hookify Rules
Source: https://github.com/zach-source/claude-plugins/tree/main/plugins/plugin-dev/skills/writing-rules
Command: npx skills add https://github.com/zach-source/claude-plugins --skill writing-hookify-rules-zach-source

SYSTEM DOCUMENTATION & REQUIREMENTS

💡 This Skill includes references (resource) components.

What problem does it solve?

This Skill helps users create and configure custom rules (hooks) for the AI's behavior, allowing for fine-grained control over its interactions and preventing unwanted actions.

Core Features & Use Cases

  • Rule Creation Guidance: Provides clear syntax and examples for defining hookify rules.
  • Event Triggering: Explains how rules can be triggered by different AI events (bash commands, file edits, stop signals, user prompts).
  • Pattern Matching: Details how to use regular expressions for precise condition matching.
  • Use Case: You want to ensure that no sensitive API keys are ever accidentally committed to a .env file. This Skill guides you in creating a rule that blocks any file edit operation on .env files containing API_KEY.

Quick Start

Use the writing hookify rules skill to create a new rule that warns about dangerous rm commands.

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 custom AI guardrails to block dangerous bash commands?

To create custom AI guardrails, you define hookify rules using YAML frontmatter and regular expressions to match and intercept dangerous bash commands before execution. This allows fine-grained control over AI behavior and prevents unwanted actions.

Can I use pattern matching to prevent an AI from editing specific files like .env?

Yes, you can use regular expression pattern matching within hookify rules to restrict file operations. By configuring rules to target specific file paths and content patterns like API_KEY, you can successfully prevent an AI from editing sensitive files.

What events can trigger custom rules for AI behavior modification?

Custom rules for AI behavior modification can be triggered by bash commands, file operations, stop events, and user prompts. This provides multiple intervention points to apply guardrails across different stages of AI interaction and execution.

Do I need to know regular expressions to configure hookify rules?

Yes, understanding regular expressions is required to configure hookify rules for precise condition matching. You also need familiarity with YAML frontmatter to properly structure the rule definitions and define the desired AI behavior modifications.

What is the best way to stop an AI from accidentally committing sensitive API keys?

The best way to stop an AI from committing sensitive API keys is to configure a hookify rule that blocks file edit operations on targeted files like .env if they contain patterns matching API_KEY. This prevents unauthorized data exposure.