ClawKit Logo
ClawKitReliability Toolkit
Back to Registry
Official Verified

writing-rules

Create markdown-based behavioral rules to prevent unwanted actions and block dangerous commands

skill-install — Terminal

Install via CLI (Recommended)

clawhub install openclaw/skills/skills/athola/nm-hookify-writing-rules
Or

Night Market Skill — ported from claude-night-market/hookify. For the full experience with agents, hooks, and commands, install the Claude Code plugin.

Table of Contents

  • Overview
  • Quick Start
  • Rule File Format
  • Frontmatter Fields
  • Event Types
  • Advanced Conditions
  • Operators
  • Field Reference
  • Pattern Writing
  • Regex Basics
  • Examples
  • Test Patterns
  • Example Rules
  • Block Destructive Commands
  • Warn About Debug Code
  • Require Tests
  • Protect Production Files
  • Management
  • Related Skills
  • Best Practices

Hookify Rule Writing Guide

When To Use

  • Creating behavioral rules to prevent unwanted actions
  • Defining persistent guardrails for Claude Code sessions

When NOT To Use

  • Complex multi-step workflows - use agents instead
  • One-time operations that do not need persistent behavioral 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.

Quick Start

Create .claude/hookify.dangerous-rm.local.md:

---
name: dangerous-rm
enabled: true
event: bash
pattern: rm\s+-rf
action: block
---

šŸ›‘ **Dangerous rm command detected!**

This command could delete important files.

Verification: Run the command with --help flag to verify availability.

The rule activates immediately - no restart needed!

Rule File Format

Frontmatter Fields

name (required): Unique identifier (kebab-case) enabled (required): true or false event (required): bash, file, stop, prompt, or all action (optional): warn (default) or block pattern (simple): Regex pattern to match

Event Types

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

Advanced Conditions

For multiple field checks:

---
name: warn-env-edits
enabled: true
event: file
action: warn
conditions:
  - field: file_path
    operator: regex_match
    pattern: \.env$
  - field: new_text
    operator: contains
    pattern: API_KEY
---

šŸ” **API key in .env file!**
Ensure file is in .gitignore.

Operators

  • regex_match: Pattern matching
  • contains: Substring check
  • equals: Exact match
  • not_contains: Must NOT contain
  • starts_with: Prefix check
  • ends_with: Suffix check

Field Reference

Metadata

Author@athola
Stars4473
Views0
Updated2026-05-01
View Author Profile
AI Skill Finder

Not sure this is the right skill?

Describe what you want to build — we'll match you to the best skill from 16,000+ options.

Find the right skill
Add to Configuration

Paste this into your clawhub.json to enable this plugin.

{
  "plugins": {
    "official-athola-nm-hookify-writing-rules": {
      "enabled": true,
      "auto_update": true
    }
  }
}
Safety NoteClawKit audits metadata but not runtime behavior. Use with caution.