anthropics avatar

Writing Hookify Rules

This lets you set up guardrails for Claude Code by writing markdown files with YAML frontmatter that pattern match against bash commands, file edits, agent stops, or prompts. You drop these files in `.claude/hookify.{rule-name}.local.md` and define regex patterns that either warn or block when they match. The use cases are obvious: stop yourself from running `rm -rf /`, catch leftover `console.log` statements before commit, protect `.env` files, or require a checklist before the agent stops. It's straightforward regex matching with simple operators like `contains` and `starts_with`, nothing fancy. Worth setting up a few rules early so you don't have to babysit the agent as much later.

skills.sh installs
7.4K
GitHub stars
46.7K
last updated
Aug 21, 2026

Install

$ npx -y skills add anthropics/claude-plugins-official --skill writing-hookify-rules --agent claude-code

Installs into .claude/skills of the current project.

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 active
  • false: Rule is disabled (won't trigger)
  • Can toggle without deleting rule

event (required): Which hook event to trigger on

  • bash: Bash tool commands
  • file: Edit, Write, MultiEdit tools
  • stop: When agent wants to stop
  • prompt: When user submits a prompt
  • all: All events

Sponsors

Details

Repository
github.com/anthropics/claude-plugins-official
Category
Documentation
First seen
May 16, 2026

More from anthropics/claude-plugins-official

All 24
1vinvcn avatargrill-with-docsvinvcn/mattpocock-skills-zh-cn一个用来打磨计划或设计的持续追问式访谈,并在过程中创建文档(ADRs 和词汇表)。6.6Kskills.sh installs
2inferen-sh avatarlogo-design-guideinferen-sh/skills6.5Kskills.sh installs
3inferen-sh avatarcase-study-writinginferen-sh/skills6.3Kskills.sh installs
4inferen-sh avatarpress-release-writinginferen-sh/skills6.3Kskills.sh installs
5github avatarwinui3-migration-guidegithub/awesome-copilotUWP-to-WinUI 3 migration reference. Maps legacy UWP APIs to correct Windows App SDK equivalents with before/after code snippets. Covers namespace changes, threa5.7Kskills.sh installs
6thedotmack avatarlearn-codebasethedotmack/claude-memPrime a codebase by reading every source file in full. Use when starting work on a new or unfamiliar project, or when the user asks to "learn the codebase", "re5.7Kskills.sh installs