Engineering
Writing Hookify Rules avatar

Writing Hookify Rules

Create and configure Hookify rules to watch for specific patterns in files, bash commands, or user prompts.

Introduction

The Hookify Rules skill is a specialized utility for defining guardrails and custom automated responses within Claude Code. It allows developers to create markdown files with YAML frontmatter that monitor real-time activity, including bash command executions, file modifications (edit/write), and agent lifecycle events like 'stop' or 'prompt' submission. This is essential for enforcing repository-specific standards, preventing the introduction of dangerous code patterns, or providing contextual guidance during development workflows.

  • Define rule patterns using Python regex syntax for granular matching against commands, file paths, or content snippets.

  • Supports multiple event types: bash, file, stop, prompt, and all for flexible trigger conditions.

  • Advanced configuration via multiple condition fields including regex_match, contains, equals, not_contains, starts_with, and ends_with.

  • Enables reactive automation by defining clear action modes: 'warn' for suggestions or 'block' to prevent unsafe operations (PreToolUse).

  • Integrated with Claude Code's file system, storing configurations in .claude/hookify.{rule-name}.local.md files for easy version control and toggle-ability via the 'enabled' boolean flag.

  • Rules are highly effective for catching common pitfalls such as hardcoded API keys in .env files, dangerous bash commands like rm -rf, or improper console.log statements in production code.

  • Provide helpful, actionable feedback by defining custom message bodies in markdown, allowing you to explain the problem and suggest specific alternatives or best practices to the agent.

  • Use the provided python-based testing tips to validate your regex patterns before deploying them as active rules.

  • Ideal for team leads and infrastructure engineers who need to enforce security policies and coding standards across a project codebase without building custom plugins from scratch.

  • Remember that all conditions in an advanced configuration must match for a rule to trigger, allowing for very specific, high-precision safety enforcement.

Repository Stats

Stars
119,460
Forks
19,809
Open Issues
10,822
Language
Shell
Default Branch
main
Sync Status
Idle
Last Synced
Apr 30, 2026, 04:06 PM
View on GitHub