Agent skill

Writing Rules

by athola in athola/claude-night-market

Creates behavioral rules in markdown to block dangerous commands or restrict AI behavior.

MITAuto-check: notesAI & LLM Engineering

Install Writing Rules

skills CLI
$ npx skills add athola/claude-night-market --skill writing-rules -a claude-code

Project install by default; add -g for ~/.claude/skills/.

GitHub CLI
$ gh skill install athola/claude-night-market writing-rules --agent claude-code

Project scope by default; add --scope user for a personal install. Needs GitHub CLI 2.90.0 or later (public preview).

Manual copy
$ git clone --depth 1 https://github.com/athola/claude-night-market.git skills-src && mkdir -p .claude/skills && cp -r skills-src/plugins/hookify/skills/writing-rules .claude/skills/writing-rules && rm -rf skills-src

Use ~/.claude/skills/ instead of .claude/skills for a personal install. The folder must contain SKILL.md.

Claude Code skills documentation · loads skills from .claude/skills/

Facts

Skill name
writing-rules
GitHub stars
341
Token cost
~1.4k tokens
SKILL.md length
427 words
Files
1
Skills in repo
154
Repo updated
First seen
Licence
MIT

At a glance

Creates behavioral rules in markdown to block dangerous commands or restrict AI behavior.

  • Works in 6 steps: Start with simple patterns → Test regex thoroughly → Use clear, helpful messages → …
  • Adding safety guardrails
  • SKILL.md covers When To Use, When NOT To Use, Overview and Quick Start, plus 8 more sections
  • Calls python3; needs API_KEY

What it does

Writing Rules is an agent skill from athola/claude-night-market. Creates behavioral rules in markdown to block dangerous commands or restrict AI behavior. Use when adding safety guardrails or preventing specific commands.

Its SKILL.md is about 1.4k tokens, which your agent loads only when the skill is triggered. It is a single SKILL.md file with no bundled scripts.

It sits in AI & LLM Engineering, covering Brand voice and tone, Hooks and plugins and LLM guardrails. It works with Bash. The repository describes itself as: 23 Claude Code plugins: TDD enforcement hooks, git/PR workflows, spec-driven development, code review, project lifecycle, fix-from-error, maintenance automation, context… The licence is MIT.

When your agent uses it

  • Adding safety guardrails
  • Preventing specific commands

Example prompts

  • “Use the writing-rules skill to create behavioral rules in markdown to block dangerous commands or restrict AI behavior”
  • “/writing-rules”

Requirements

  • Python 3
  • A credential in API_KEY

Workflow steps

6 steps, taken from the first numbered list in SKILL.md.

  1. Start with simple patterns
  2. Test regex thoroughly
  3. Use clear, helpful messages
  4. Prefer warnings over blocks initially
  5. Name rules descriptively
  6. Document intent in messages

What it can do on your machine

Read from SKILL.md and the folder at commit 9f3eb00. It shows what the files ask for, not the result of running them.

  • Tool permissions

    Pre-approves nothing: there is no allowed-tools line, so your agent's usual permission prompts apply.

    From allowed-tools in the SKILL.md frontmatter.

  • Runs code

    Shell commands in SKILL.md call:

    • python3

    From the folder's file list and the shell code blocks in SKILL.md.

  • Network

    No URLs in SKILL.md.

    From URLs in SKILL.md, links to its own repository left out.

  • Credentials

    Names these keys or tokens, usually read from environment variables:

    • API_KEY

    From names ending in _API_KEY, _TOKEN, _SECRET, _KEY or _PASSWORD in SKILL.md.

Context cost

Writing Rules loads about 1.4k tokens when it runs. Until then it costs about 43 tokens; SKILL.md has 427 words of instructions outside code blocks.

Always · name and description, kept in context so the agent knows when to use it
~43
When it runs · the whole SKILL.md, loaded when a task matches
~1.4k

Estimates: characters ÷ 4, the usual rule of thumb; real counts depend on the model's tokenizer. Scripts and assets cost tokens only if the agent reads them.

Safety

Auto-check: notes

The automated check noted patterns worth knowing about, such as sudo or a known installer.

  • NoteMentions a .env fileSKILL.md:104
    🔐 **API key in .env file!**

Automated static check — not a guarantee. Review scripts before installing. It scans the text of SKILL.md for risky patterns (piping downloads into a shell, reading credential files, hidden Unicode, destructive commands); files beside SKILL.md are not scanned.

SKILL.md

The full file from athola/claude-night-market at commit 9f3eb00, republished under its MIT licence (© athola). 427 words, ~1,387 tokens.

Download SKILL.mdSave it as .claude/skills/writing-rules/SKILL.md (or your agent's skills folder).
name
writing-rules
description
Creates behavioral rules in markdown to block dangerous commands or restrict AI behavior. Use when adding safety guardrails or preventing specific commands.
alwaysApply
false
category
hook-development
tags
hookify, rules, patterns, validation, safety
estimated_tokens
2500
complexity
beginner
model_hint
fast
provides.patterns
rule-writing, pattern-matching, condition-building
provides.infrastructure
rule-validation
usage_patterns
creating-rules, pattern-matching, behavioral-enforcement

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:

yaml
---
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:

yaml
---
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

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
bash
python3 -c "import re; print(re.search(r'pattern', 'text'))"

Example Rules

Block Destructive Commands
yaml
---
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
yaml
---
name: warn-debug
enabled: true
event: file
pattern: console\.log\(|debugger;
action: warn
---

🐛 **Debug code detected!**
Remove before committing.
Require Tests
yaml
---
name: require-tests
enabled: true
event: stop
action: warn
conditions:
  - field: transcript
    operator: not_contains
    pattern: pytest|npm test
---

⚠️ **Tests not run!**
Please verify changes.
Protect Production Files
yaml
---
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:

bash
rm .claude/hookify.my-rule.local.md

List:

bash
/hookify:list
  • abstract:hook-scope-guide - Hook placement decisions
  • abstract:hook-authoring - SDK hook development
  • abstract:hooks-eval - Hook evaluation
Show full SKILL.md (172 more words)Show less

Best Practices

  1. Start with simple patterns
  2. Test regex thoroughly
  3. Use clear, helpful messages
  4. Prefer warnings over blocks initially
  5. Name rules descriptively
  6. 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.md with all required frontmatter fields present: name (kebab-case), enabled, event, and either pattern or conditions
  • 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: warn action shows the message body, block action prevents the operation
  • Rule does not fire on a non-matching input; false positive tested with at least one known-safe example

© athola, MIT. Rendered from Markdown: HTML in the file is shown as text, images as links, and headings moved down two levels. Raw file

Files

Just SKILL.md in plugins/hookify/skills/writing-rules of athola/claude-night-market.

Open the folder on GitHubat commit 9f3eb00

Compare with similar skills

Writing Rules next to the 5 skills that share the most tags, products or categories with it. Stars are the repository's; “used in” counts other GitHub owners with a copy.

Writing Rules compared with similar skills
SkillStarsUsed inTokensAuto-checkLicenceRepo updated
Writing Rules this skillathola/claude-night-market341—~1.4kAutomated safety check: NotesMIT
Git Guardrails Claude Codefossasia/eventyay-interpretation1.6k12 repos~578Automated safety check: PassApache-2.0
Git Guardrails Claude Codevinvcn/mattpocock-skills-zh-CN4.7k—~461Automated safety check: PassMIT
GuardHouseofmvps/ultraship123—~790Automated safety check: NotesMIT
Guardrail PatternsZaxbyHub/opencode-swarm493—~3.5kAutomated safety check: PassMIT
Hook Development for Claude Code Pluginsanthropics/claude-plugins-official38k10 repos~4.1kAutomated safety check: NotesApache-2.0

Similar skills

  • Git Guardrails Claude Code

    fossasia/eventyay-interpretation

    Set up Claude Code hooks to block dangerous git commands (push, reset --hard, clean, branch -D, etc.) before they execute.

    1.6k GitHub starsUsed in 12 repos~578 tokens
    AI & LLM EngineeringAuto-check passed
  • Git Guardrails Claude Code

    vinvcn/mattpocock-skills-zh-CN

    设置 Claude Code hooks,在危险 git commands(push、reset --hard、clean、branch -D 等)执行前阻止它们。适用于用户想防止破坏性 git 操作、添加 git safety hooks,或在 Claude Code 中阻止 git push/reset 时。

    4.7k GitHub stars~461 tokensUpdated yesterday
    AI & LLM EngineeringAuto-check passed
  • Guard

    Houseofmvps/ultraship

    Safety guardrails — blocks destructive commands (rm -rf, DROP TABLE, force-push, git reset --hard) and optionally restricts file edits to a specific directory.

    123 GitHub stars~790 tokensUpdated 3 mo ago
    AI & LLM EngineeringAuto-check: notes
  • Guardrail Patterns

    ZaxbyHub/opencode-swarm

    Guardrail patterns for opencode-swarm — pattern structure, bypass surfaces, regex anti-patterns, and test conventions for checkDestructiveCommand()

    493 GitHub stars~3.5k tokensUpdated today
    AI & LLM EngineeringAuto-check passed
  • Hook Development for Claude Code Plugins

    anthropics/claude-plugins-official

    Official

    Explains how to write Claude Code plugin hooks, both prompt-based checks and bash commands, for events such as PreToolUse, Stop and SessionStart.

    38k GitHub starsUsed in 10 repos~4.1k tokens
    Agent WorkflowsAuto-check: notes
  • Plugin Settings Pattern

    anthropics/claude-plugins-official

    Official

    Shows how Claude Code plugins keep per-project settings and state in .claude/plugin-name.local.md files with YAML frontmatter and a markdown body.

    38k GitHub starsUsed in 7 repos~3k tokens
    Agent WorkflowsAuto-check passed

More from athola/claude-night-market

All 154 skills in this repo
  • Night Market Diagnostics Toolkit

    athola/claude-night-market

    Run and interpret repo diagnostic scripts (ratchets, validators, token stats).

    341 GitHub stars~3.4k tokensUpdated 3 days ago
    Auto-check passed
  • Skills Eval

    athola/claude-night-market

    Evaluate Claude skill quality through auditing. An agent skill from athola/claude-night-market.

    341 GitHub stars~1.6k tokensUpdated 3 days ago
    Auto-check passed
  • Agent Teams

    athola/claude-night-market

    Coordinates Claude agent teams via filesystem protocol. An agent skill from athola/claude-night-market.

    341 GitHub stars~2.5k tokensUpdated 3 days ago
    Auto-check passed
  • Delegation Core

    athola/claude-night-market

    Delegates execution to eight CLIs (Gemini, Qwen, MiniMax, GLM, Muse, Codex, OpenCode, Glimmer).

    341 GitHub stars~2.5k tokensUpdated 3 days ago
    Auto-check passed
  • Elegant Code

    athola/claude-night-market

    Guide minimal code via a decision ladder with full safety, edge, and negative-case coverage.

    341 GitHub stars~2.1k tokensUpdated 3 days ago
    Auto-check passed
  • Skill Library Mission

    athola/claude-night-market

    Build a project skill library in .claude/skills/ via discovery, parallel authoring, and review.

    341 GitHub stars~1.6k tokensUpdated 3 days ago
    Auto-check passed

Works with

Questions about Writing Rules

What does Writing Rules do?

Creates behavioral rules in markdown to block dangerous commands or restrict AI behavior. Writing Rules is an agent skill from athola/claude-night-market. Creates behavioral rules in markdown to block dangerous commands or restrict AI behavior.

When should I use Writing Rules?

Writing Rules fits situations like: adding safety guardrails; preventing specific commands.

How do I install Writing Rules in Claude Code?

Run `npx skills add athola/claude-night-market --skill writing-rules -a claude-code`. Or copy the skill folder (plugins/hookify/skills/writing-rules in athola/claude-night-market) into .claude/skills/writing-rules in your project. Claude Code loads it when a task matches its description.

How do I install Writing Rules in Codex?

Run `npx skills add athola/claude-night-market --skill writing-rules -a codex`. Or copy the skill folder (plugins/hookify/skills/writing-rules in athola/claude-night-market) into .agents/skills/writing-rules in your project. Codex loads it when a task matches its description.

Can I use Writing Rules in Cursor, Gemini CLI or GitHub Copilot?

Cursor, Gemini CLI, GitHub Copilot and OpenCode also load SKILL.md folders. With the skills CLI, run `npx skills add athola/claude-night-market --skill writing-rules -a cursor` (or -a gemini-cli, github-copilot or opencode for the others). To copy it by hand, put the folder in .cursor/skills/writing-rules, .gemini/skills/writing-rules, .github/skills/writing-rules and .opencode/skills/writing-rules in your project.

What does Writing Rules need to run?

Going by SKILL.md and its folder, Writing Rules needs the command-line tools its instructions call (python3) and credentials named API_KEY. Our summary lists: Python 3; A credential in API_KEY.

Does Writing Rules access the network?

SKILL.md contains no URLs. Any network use would come from the scripts or tools the agent runs. This is read from the text; nothing was executed.

Is Writing Rules safe to install?

Our automated static check of SKILL.md found notes only (mentions a .env file), nothing it rates as a warning. It is not a guarantee. Review the folder before installing.

What licence does Writing Rules use?

Writing Rules is published under the MIT licence (the repository's licence). It allows redistribution, so the full SKILL.md is shown on this page.

How many tokens does Writing Rules use?

About 1.4k tokens (SKILL.md is roughly 5.5k characters). Agents keep only the skill's name and description in context until a task matches; then they load SKILL.md in full.

What are the alternatives to Writing Rules?

Skills that share tags, products or a category with Writing Rules: Git Guardrails Claude Code (fossasia/eventyay-interpretation, 1.6k stars), Git Guardrails Claude Code (vinvcn/mattpocock-skills-zh-CN, 4.7k stars), Guard (Houseofmvps/ultraship, 123 stars) and Guardrail Patterns (ZaxbyHub/opencode-swarm, 493 stars). The comparison table on this page puts their stars, adoption, token cost, safety result and licence side by side.

Who maintains Writing Rules?

athola (a GitHub user) maintains it in athola/claude-night-market, which has 341 GitHub stars. The repository holds 154 skills in this directory. The repository was last updated on October 6, 2026.

Source: athola/claude-night-market on GitHub. Facts on this page come from the repository at the commit we read; the author's words are quoted as theirs.