Complete AI Training

Skill · Writing

Writing rules

Guides users in writing Hookify rule files that watch for patterns and show messages when they match. Use when creating a new Hookify rule, refining an existing rule's pattern, or learning Hookify rule syntax, event types, and conditions.

Complete AI SkillsLicense: MITAdded Sep 29, 2026

How to use it

  1. Start your plan and connect your AI once
  2. Ask for the task in your own words, or say it directly:
Use the Writing rules skill to help me with this.

Without a connection: copy the SKILL.md below into your AI's project instructions.

SKILL.md

Writing Hookify Rules

This skill helps users create, refine, and understand Hookify rule files: markdown files with YAML frontmatter that define patterns to watch for and messages to show when those patterns match. It is for anyone setting up or tuning Hookify rules in a project's .claude/ directory.

When to use

  • The user wants to create a new Hookify rule.
  • The user wants to refine or fix the pattern in an existing rule.
  • The user asks how Hookify rule files are structured or named.
  • The user asks for examples of rules or a quick reference for event types, fields, and operators.

Workflows

Explain rule structure

Inputs: The user's question about rule structure or syntax.

  1. Explain that a Hookify rule is a markdown file with YAML frontmatter.
  2. List the frontmatter fields: name, enabled, event, pattern or conditions, and optional action.
  3. State the file naming convention: .claude/hookify.{name}.local.md.
  4. List the available event types: bash, file, stop, prompt, all.
  5. Describe what the message body of the file is for: the message shown when the pattern matches.

Check: The user can name the frontmatter fields, the file naming convention, and the event types. Output: A plain explanation of the structure, naming convention, and event types.

Guide rule creation

Inputs: Interview the user once to gather: the unwanted behavior to catch, the tool involved (Bash, Edit, etc.), the event type, and the pattern or conditions.

  1. Ask the user for the unwanted behavior, the tool involved, the event type, and the pattern or conditions.
  2. Confirm the event type matches the tool and behavior.
  3. Generate the complete rule file content: YAML frontmatter with name, enabled, event, and pattern or conditions, plus the message body.
  4. Remind the user to save the file in the .claude/ directory using the naming convention .claude/hookify.{name}.local.md.

Check: The generated frontmatter includes all required fields, the event type matches the described tool, and the pattern targets the stated behavior. Output: The full rule file content, plus the save location and file name.

Help refine patterns

Inputs: The current pattern and what the user wants to change.

  1. Ask for the current pattern and the intended change.
  2. Provide regex pattern suggestions that match the intended change.
  3. Explain common pitfalls: patterns that are too broad, too specific, or have escaping issues.
  4. Recommend testing the pattern with python3 or regex101.
  5. Remind the user that changes take effect on the next tool use.

Check: The suggested pattern matches the intended behavior and avoids the named pitfalls. Output: The revised pattern, an explanation of the change, and testing guidance.

Provide examples and quick reference

Inputs: The event type or category the user asks about.

  1. Show a minimal viable rule for each requested event type.
  2. Show rules with multiple conditions when relevant.
  3. Show common patterns for dangerous commands, debug code, security risks, and sensitive files.
  4. Provide the quick reference for event types, field options, and operators.

Check: Each example is a complete rule file with frontmatter and message body. Output: Example rule files and the quick reference.

Tools and data

  • Use python3 or regex101 when the user needs to test a pattern; guide them to run the test themselves.

Guardrails

  • Never create, modify, or delete actual rule files on the user's system. Only provide the file content and instructions.
  • Never execute commands or run regex tests. Only guide the user on how to test patterns themselves.
  • Never assume the user's project structure or tools. Always ask for context when needed.
  • Never provide patterns that could cause harm or bypass security measures.
  • Do not create rules without user input.
  • Do not modify existing rules without an explicit user request.

Getting started

Ask the user what they want to do with Hookify rules: create a new rule, refine an existing one, or learn about rule syntax and patterns.

Credits

Adapted from an open-source original (MIT): https://www.aitmpl.com/component/skills/productivity/writing-rules