
writing-rules
Writes hookify rules in markdown that block dangerous commands or restrict AI behavior. Use when adding guardrails.
- Installs
- 113
- Last 24h
- —
- Trending rank
- —
- Security
- Not audited
Install
Works with every agent the skills CLI supports.
npx skills add https://github.com/athola/claude-night-market --skill writing-rules- 01
Install
Run the command in your project. The CLI asks which agents to install for.
- 02
Describe the task
Ask your agent for something this skill covers. It loads writing-rules automatically when relevant.
- 03
Review the result
The agent follows the SKILL.md steps, scripts and references bundled with the skill.
SKILL.md
The instructions your agent reads when the skill is triggered.
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 matchingcontains: Substring checkequals: Exact matchnot_contains: Must NOT containstarts_with: Prefix checkends_with: Suffix check
Field Reference
bash events: command
file events: file_path, new_text, old_text, content
prompt events: user_prompt
stop events: transcript
Pattern Writing
Regex Basics
\s- whitespace\d- digit\w- word character.- any character (use\.for literal dot)+- one or more*- zero or more|- OR
Examples
rm\s+-rf → rm -rf
console\.log\( → console.log(
chmod\s+777 → chmod 777
Test Patterns
python3 -c "import re; print(re.search(r'pattern', 'text'))"
Example Rules
Block Destructive Commands
---
name: block-destructive
enabled: true
event: bash
pattern: rm\s+-rf|dd\s+if=|mkfs
action: block
---
🛑 **Destructive operation blocked!**
Can cause data loss.
Warn About Debug Code
---
name: warn-debug
enabled: true
event: file
pattern: console\.log\(|debugger;
action: warn
---
🐛 **Debug code detected!**
Remove before committing.
Require Tests
---
name: require-tests
enabled: true
event: stop
action: warn
conditions:
- field: transcript
operator: regex_match
pattern: \A(?![\s\S]*(?:pytest|npm test))
---
⚠️ **Tests not run!**
Please verify changes.
Protect Production Files
---
name: protect-prod
enabled: true
event: file
action: block
conditions:
- field: file_path
operator: regex_match
pattern: /production/|\.prod\.
---
🚨 **Production file!**
Requires review.
Management
Enable/Disable:
Edit .local.md file: enabled: false
Delete:
rm .claude/hookify.my-rule.local.md
List:
/hookify:list
Related Skills
- abstract:hook-scope-guide - Hook placement decisions
- abstract:hook-authoring - SDK hook development
- abstract:hooks-eval - Hook evaluation
Best Practices
- Start with simple patterns
- Test regex thoroughly
- Use clear, helpful messages
- Prefer warnings over blocks initially
- Name rules descriptively
- Document intent in messages
Troubleshooting
Common Issues
If a rule doesn't trigger, verify that the event type matches the tool being used (e.g., use bash for command line tools). Check that the regex pattern is valid and matches the target text by testing it with a short Python script. If you encounter permission errors when creating rule files in .claude/, ensure that the directory is writable by your user.
Exit Criteria
- Rule file exists at
.claude/hookify.<rule-name>.local.mdwith all required frontmatter fields present:name(kebab-case),enabled,event, and eitherpatternorconditions - Regex pattern validated with `python3 -c "import re; print(re.search(r'<pattern>', '<test>'))" before the rule is saved; no untested patterns shipped
- Rule triggers correctly on a matching input:
warnaction shows the message body,blockaction prevents the operation - Rule does not fire on a non-matching input; false positive tested with at least one known-safe example
FAQ
What does the writing-rules skill do?
Writes hookify rules in markdown that block dangerous commands or restrict AI behavior. Use when adding guardrails.
How do I install writing-rules?
Run npx skills add https://github.com/athola/claude-night-market --skill writing-rules in your project. The skills CLI detects the agents you use and copies the skill into the right folder. For Claude Code you can also place the skill folder at ~/.claude/skills/writing-rules/ (personal) or .claude/skills/writing-rules/ (project).
Which AI agents can use writing-rules?
Any agent that supports the open Agent Skills format (a folder with a SKILL.md file), including Claude Code, Codex, Cursor, GitHub Copilot, Gemini CLI, Windsurf, Cline, OpenCode and more.
Is writing-rules safe to install?
No partner security audit is available yet. Skills can run commands and scripts, so read the SKILL.md and any bundled files before installing.
Who maintains writing-rules?
It is published by athola in athola/claude-night-market. It has 113 recorded installs.
More from athola/claude-night-market
project-planning
athola/claude-night-market
Converts a specification into a phased, dependency-ordered implementation plan. Use after specification is complete and before execution begins.
code-quality-principles
athola/claude-night-market
Applies KISS, YAGNI, and SOLID principles for clean code with reduced complexity. Use when refactoring or reviewing code for over-engineering.
slop-detector
athola/claude-night-market
Detects AI-generated writing patterns in prose. Use when reviewing docs for slop, vague language, or identity leaks before publishing.
bloat-detector
athola/claude-night-market
Detects codebase bloat via dead code, duplication, complexity, and doc bloat scans. Use when codebase feels large or before a release.
doc-generator
athola/claude-night-market
Generates or remediates documentation with human-quality writing. Use when creating new docs, rewriting AI-generated content, or applying style profiles.
project-brainstorming
athola/claude-night-market
Guides project ideation via Socratic questioning to produce a validated brief. Use before specification when requirements are unclear.
Popular docs & writing skills
grill-with-docs
mattpocock/skills
A relentless interview to sharpen a plan or design, which also creates docs (ADR's and glossary) as we go.
lark-markdown
open.feishu.cn
飞书 Markdown:查看、创建、上传、编辑和比较飞书中的原生 Markdown 文件。当用户要操作飞书 Markdown 文件,或比较其远端版本及本地草稿时使用。纯本地 Markdown 文件操作不触发本 skill。不负责将 Markdown 导入为飞书在线文档,也不负责文件搜索、权限、评论、移动、删除等云空间管理操作。
writing-for-agents
mattpocock/skills
Writing documents for agents. Use when creating or editing skills, or modifying AGENTS.md or CLAUDE.md.
slideshow
heygen-com/hyperframes
Build a HyperFrames slideshow to present live - slides, fragment reveals, branching hotspots and presenter mode with speaker notes, served by hyperframes present - or turn an existing page into one. Use when the person wants a deck or presentation rather than a rendered video.
writing-beats
mattpocock/skills
Writing, exploit; assemble raw material into a journey of beats, grounding each term before a beat leans on it.
writing-shape
mattpocock/skills
Writing, exploit: shape raw material into an article, paragraph by paragraph.