Agent skill

Writing Rules

by xiaolai in xiaolai/nlpm

How to write .claude/rules/ files: golden format, enforceability, budget, scope.

ISCAuto-check passedAgent Workflows

Install Writing Rules

skills CLI
$ npx skills add xiaolai/nlpm --skill writing-rules -a claude-code

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

GitHub CLI
$ gh skill install xiaolai/nlpm 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/xiaolai/nlpm.git skills-src && mkdir -p .claude/skills && cp -r skills-src/skills/nlpm/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
146
Token cost
~2.5k tokens
SKILL.md length
913 words
Files
1
Skills in repo
15
Repo updated
First seen
Licence
ISC

At a glance

How to write .claude/rules/ files: golden format, enforceability, budget, scope.

  • Works in 8 steps: The Golden Format → Positive Framing (Pink Elephant Effect) → Enforceability Test → …
  • Tasks that involve Brand voice and tone
  • SKILL.md covers 1. The Golden Format, 2. Positive Framing (Pink…, 3. Enforceability Test and 4. Budget Discipline, plus 4 more sections
  • Calls eslint and pnpm

What it does

Writing Rules is an agent skill from xiaolai/nlpm. How to write .claude/rules/ files: golden format, enforceability, budget, scope.

Its SKILL.md is about 2.5k 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 Agent Workflows, covering Brand voice and tone and Agent instruction files. The repository describes itself as: Natural-Language Programming Manager — scan, lint, and score NL artifacts with Claude-native quality scoring. The licence is ISC.

When your agent uses it

  • Tasks that involve Brand voice and tone
  • Tasks that involve Agent instruction files

Example prompts

  • “/writing-rules”

Workflow steps

8 steps, taken from the step headings in SKILL.md.

  1. The Golden Format
  2. Positive Framing (Pink Elephant Effect)
  3. Enforceability Test
  4. Budget Discipline
  5. Path Scoping
  6. Conflict Prevention
  7. Worked Example
  8. Quality Checklist

What it can do on your machine

Read from SKILL.md and the folder at commit 6fdbd05. 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:

    • eslint
    • pnpm

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

  • Network

    No URLs in SKILL.md. Its commands use pnpm, which can reach the network depending on how they are called.

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

  • Credentials

    Names no API keys, tokens, secrets or passwords.

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

Context cost

Writing Rules loads about 2.5k tokens when it runs. Until then it costs about 24 tokens; SKILL.md has 913 words of instructions outside code blocks.

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

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 passed

The automated check found no risky patterns in SKILL.md.

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 xiaolai/nlpm at commit 6fdbd05, republished under its ISC licence (© xiaolai). 913 words, ~2,506 tokens.

Download SKILL.mdSave it as .claude/skills/writing-rules/SKILL.md (or your agent's skills folder).
name
writing-rules
description
How to write .claude/rules/ files: golden format, enforceability, budget, scope.
version
0.2.0
user-invocable
false

Writing Rules

Scope: covers .claude/rules/ file authoring — a Claude-Code-specific concept (path-scoped, always-loaded instruction files with paths: glob frontmatter). Codex CLI and Antigravity have no exact .claude/rules/ equivalent; their always-on project instructions live in the hierarchical memory file (AGENTS.md for Codex, GEMINI.md for Antigravity — both can be pointed at the canonical AGENTS.md; see [[nlpm:conventions-codex]] / [[nlpm:conventions-antigravity]]). The bold-imperative-plus-rationale writing technique here applies to any tool's instruction files. For CLAUDE.md / AGENTS.md conventions, see [[writing-plugins]]. For system prompts generally, see [[writing-prompts]].

1. The Golden Format

Every rule should have three parts:

**Use X, not Y.** Without X, [concrete bad thing happens]. Y causes [specific problem] because [mechanism].
PartPurposeExample
ImperativeWhat to doUse Result<T, AppError> for all API handler returns.
ConsequenceWhat goes wrong without itWithout it, errors propagate as 500s with no context.
MechanismWhy it failsRaw panics bypass the error middleware and crash the worker.
One-Line Rules (when mechanism is obvious)
markdown
**Use `const`/`let`, never `var`.** `var` hoists to function scope, causing stale-reference bugs.
Multi-Line Rules (when mechanism needs explanation)
markdown
**Use database transactions for multi-table writes.** Without transactions, partial writes leave the database in an inconsistent state. The ORM's `save()` method does not auto-wrap related writes -- you must explicitly call `db.transaction()`.

2. Positive Framing (Pink Elephant Effect)

Claude fixates on prohibited things. Saying "Don't use X" makes Claude think about X.

Before (negative framing -- score 60)
markdown
- Don't use var
- Don't mutate function parameters
- Don't use console.log in production code
After (positive framing -- score 90)
markdown
- **Use `const` for all bindings; use `let` only when reassignment is required.**
- **Return new objects instead of mutating function parameters.**
- **Use the `logger` service for all logging.** `console.log` is stripped in production builds.
Conversion Pattern
Negative (avoid)Positive (use instead)
Don't use XUse Y (where Y is the correct alternative)
Never do XAlways do Y
Avoid X because...Use Y because... (flip the rationale)
X is deprecatedUse Y, which replaced X in version N

3. Enforceability Test

Before writing a rule, ask: "Can I check compliance in a 30-second code review?" If no, it is not a rule.

Enforceable (specific, testable)
RuleTest
Use Result<T, AppError> for all API handler returns.Grep for handler functions, check return types
All API endpoints require @auth decorator.Grep for route definitions, check for decorator
Database queries use parameterized statements, not string concatenation.Grep for SQL strings, check for + or template literals
Not Enforceable (subjective, unmeasurable)
RuleWhy it fails
"Write clean, maintainable code"What is "clean"? No objective test.
"Keep functions small"How small? 10 lines? 20? 50?
"Use meaningful variable names""Meaningful" is subjective.
"Follow best practices"Which practices? Says nothing specific.
Making Vague Rules Enforceable
VagueEnforceable version
"Keep functions small"Functions must be under 40 lines. Reference: enforced by eslint max-lines-per-function
"Use meaningful names"Variable names must be >= 3 characters except loop indices (i, j, k).
"Handle errors properly"Every catch block must either re-throw, log + return error response, or call reportError().

4. Budget Discipline

All rules across .claude/rules/ must total under 500 lines. Every line costs tokens on every Claude interaction -- rules are always loaded.

Token Cost
Rule linesApprox tokens per interactionAnnual cost at 100 interactions/day
100~400Negligible
300~1,200Noticeable
500~2,000Budget line
800+~3,200+Over budget -- consolidate
Line Reduction Strategies
StrategyExampleLines saved
Defer to linter"Reference: enforced by pnpm lint" instead of re-stating lint rules10-30
Merge related rulesCombine 3 files about error handling into 115-25
Delete training knowledgeRemove rules Claude follows without being told5-15
Use tables instead of lists10 rules as list = 20 lines; as table = 12 lines5-10
Rules Claude Already Follows (safe to delete)

These are part of Claude's training and do not need rules:

  • "Use descriptive variable names" (Claude already does this)
  • "Add comments to complex code" (Claude already does this)
  • "Handle null/undefined checks" (Claude already does this)
  • "Use async/await instead of callbacks" (Claude already prefers this)

Only write rules for things specific to your project that Claude would not know.

Show full SKILL.md (351 more words)Show less

5. Path Scoping

Rules without path scoping apply to every file -- expensive and often wrong.

yaml
---
paths: ["src/api/**/*.ts"]
---
Scoping Strategy
Rule typeScopeExample paths
API conventionsAPI routes onlysrc/api/**/*.ts, src/routes/**/*.ts
Database rulesData layer onlysrc/db/**/*.ts, src/models/**/*.ts
Test conventionsTest files only**/*.test.ts, **/*.spec.ts
Universal rulesNo scope (apply everywhere)(omit paths field)

Rule: if a rule mentions a specific directory, technology, or layer -- scope it.

Cost Impact of Scoping
ScenarioToken cost
Unscoped: 200-line rules file loaded on every interaction800 tokens always
Scoped: same rules split into 4 files with path scoping200 tokens per interaction (only relevant rules load)

6. Conflict Prevention

Two rules must never contradict. If they could, put them in the same file with explicit conditions.

Bad (separate files, contradictory)

rules/api.md:

markdown
**Return raw JSON objects from API handlers.**

rules/error-handling.md:

markdown
**Wrap all returns in Result<T, AppError>.**
Good (same file, explicit conditions)

rules/api-returns.md:

markdown
**Return `Result<T, AppError>` from API handler functions.** This ensures consistent error formatting through the error middleware.

**Return raw JSON from internal service functions.** Services are called by handlers, not directly by clients, so they do not need the Result wrapper.
Conflict Detection Checklist

Before adding a new rule, check:

  1. Search all existing rules for the same keywords
  2. Does any existing rule say the opposite?
  3. Does any existing rule cover a broader case that includes yours?
  4. If conflict found: merge into the same file with explicit conditions

7. Worked Example

Before (score 45/100) -- 800 lines, 12 files
.claude/rules/
  naming.md          (80 lines -- mostly restates ESLint rules)
  errors.md          (90 lines -- contradicts exceptions.md)
  exceptions.md      (70 lines -- contradicts errors.md)
  logging.md         (60 lines -- unscoped, only relevant to src/api/)
  testing.md         (85 lines -- includes Jest tutorial content)
  database.md        (95 lines -- unscoped, only relevant to src/db/)
  api.md             (70 lines -- overlaps with errors.md)
  security.md        (55 lines -- restates OWASP basics Claude already knows)
  performance.md     (45 lines -- vague advice like "write fast code")
  imports.md         (30 lines -- restates ESLint import rules)
  comments.md        (25 lines -- Claude already adds good comments)
  types.md           (95 lines -- half is TypeScript tutorial)
Total: 800 lines, 12 files
After (score 92/100) -- 180 lines, 4 files
.claude/rules/
  api.md             (55 lines, scoped to src/api/**)
  database.md        (45 lines, scoped to src/db/**)
  testing.md         (40 lines, scoped to **/*.test.ts)
  universal.md       (40 lines, unscoped -- truly universal rules)
Total: 180 lines, 4 files

What was removed:

  • naming.md: deleted (ESLint handles this, Claude defaults are fine)
  • errors.md + exceptions.md: merged into api.md with explicit conditions
  • logging.md: merged into api.md, scoped to src/api/**
  • security.md: deleted (Claude already knows OWASP basics)
  • performance.md: deleted (vague, unenforceable)
  • imports.md: deleted (ESLint handles this)
  • comments.md: deleted (Claude already writes good comments)
  • types.md: reduced to 10 lines of project-specific type rules in universal.md

Savings: 800 -> 180 lines = 78% reduction. Token cost per interaction dropped from ~3,200 to ~720.

8. Quality Checklist

Before shipping rules, verify:

  • Every rule follows the golden format: imperative + consequence + mechanism
  • Positive framing (no "Don't..." as the primary instruction)
  • Every rule passes the 30-second enforceability test
  • Total across all rule files < 500 lines
  • Rules scoped via paths: frontmatter (e.g., paths: ["src/api/**/*.ts"]) when not universally applicable
  • No contradictions between rule files
  • No rules that Claude follows by default from training
  • No rules that a linter already enforces (reference the linter instead)

© xiaolai, ISC. 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 skills/nlpm/writing-rules of xiaolai/nlpm.

Open the folder on GitHubat commit 6fdbd05

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 skillxiaolai/nlpm146—~2.5kAutomated safety check: PassISC
Docs Writing Styleinkline/inkline1.5k—~1.2kAutomated safety check: PassNone
Johnny Suede WriteJasonColapietro/suede-creator-skills127—~7.8kAutomated safety check: PassMIT
Audit Session Metricscentminmod/my-claude-code-setup2.7k—~2.1kAutomated safety check: PassMIT
Ponylang Prose Reviewponylang/ponylang-website160—~2.9kAutomated safety check: PassBSD-2-Clause
Inherit Legacy Styleaffaan-m/ECC275k1 repos~2.1kAutomated safety check: NotesMIT

Similar skills

  • Docs Writing Style

    inkline/inkline

    How Inkline documentation is written and kept true — the doc surface, pointers-not-duplicates, the drift watch with its current inventory, voice rules, and the future docs website.

    1.5k GitHub stars~1.2k tokensUpdated 27 days ago
    Agent WorkflowsAuto-check passed
  • Johnny Suede Write

    JasonColapietro/suede-creator-skills

    Suede Labs full writing stack: sharper copy for docs, pages, email, social, headlines, CTAs, product listings, and public explainers, with an SEO/AEO/AI EO pass, persona and framework selection…

    127 GitHub stars~7.8k tokensUpdated yesterday
    Marketing & SEOAuto-check passed
  • Audit Session Metrics

    centminmod/my-claude-code-setup

    Audit a session-metrics JSON export for token-usage waste and produce a plain-English findings report.

    2.7k GitHub stars~2.1k tokensUpdated today
    Agent WorkflowsAuto-check passed
  • Ponylang Prose Review

    ponylang/ponylang-website

    Ensemble review of ponylang blog and Last Week in Pony prose.

    160 GitHub stars~2.9k tokensUpdated 4 days ago
    Agent WorkflowsAuto-check passed
  • Prevent AI style drift on legacy projects by scanning the codebase for implicit conventions, resolving conflicts with the operator one at a time, and writing an enforceable .ai-style-rules.md…

    275k GitHub starsUsed in 1 repo~2.1k tokens
    Agent WorkflowsAuto-check: notes
  • Unslop File

    sickn33/agentic-awesome-skills

    Humanize natural-language memory files (CLAUDE.md, todos, preferences, docs) by removing AI-isms and adding burstiness while preserving every code block, URL, path, command, and heading exactly.

    47k GitHub starsUsed in 1 repo~2.9k tokens
    Agent WorkflowsAuto-check: warnings

More from xiaolai/nlpm

All 15 skills in this repo
  • Conventions

    xiaolai/nlpm

    Universal NL conventions: SKILL.md open spec, AGENTS.md, vague quantifiers, naming.

    146 GitHub stars~3.6k tokensUpdated today
    Auto-check passed
  • Antigravity and Gemini CLI artifact schemas: .gemini/ paths, extensions, hooks.

    146 GitHub stars~3.1k tokensUpdated today
    Auto-check passed
  • Conventions Codex

    xiaolai/nlpm

    Codex CLI artifact schemas: config.toml, .codex-plugin, skills, hooks, AGENTS.md.

    146 GitHub stars~4.9k tokensUpdated today
    Auto-check passed
  • Orchestration

    xiaolai/nlpm

    Multi-agent workflow patterns: parallel dispatch, pipelines, QC gates, retries.

    146 GitHub stars~3k tokensUpdated today
    Auto-check passed
  • Patterns

    xiaolai/nlpm

    NL artifact anti-patterns: vague quantifiers, bare prohibitions, oversized skills.

    146 GitHub stars~3.9k tokensUpdated today
    Auto-check passed
  • Scoring

    xiaolai/nlpm

    100-point NL artifact rubric: penalty tables per artifact type, calibration cases.

    146 GitHub stars~5.3k tokensUpdated today
    Auto-check passed

Questions about Writing Rules

What does Writing Rules do?

How to write .claude/rules/ files: golden format, enforceability, budget, scope. Writing Rules is an agent skill from xiaolai/nlpm.claude/rules/ files: golden format, enforceability, budget, scope.

When should I use Writing Rules?

Writing Rules fits situations like: tasks that involve Brand voice and tone; tasks that involve Agent instruction files.

How do I install Writing Rules in Claude Code?

Run `npx skills add xiaolai/nlpm --skill writing-rules -a claude-code`. Or copy the skill folder (skills/nlpm/writing-rules in xiaolai/nlpm) 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 xiaolai/nlpm --skill writing-rules -a codex`. Or copy the skill folder (skills/nlpm/writing-rules in xiaolai/nlpm) 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 xiaolai/nlpm --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 (eslint and pnpm).

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 no risky patterns, such as piping downloads into a shell, reading credential files or hidden Unicode. It is not a guarantee. Review the folder before installing.

What licence does Writing Rules use?

Writing Rules is published under the ISC 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 2.5k tokens (SKILL.md is roughly 10k 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: Docs Writing Style (inkline/inkline, 1.5k stars), Johnny Suede Write (JasonColapietro/suede-creator-skills, 127 stars), Audit Session Metrics (centminmod/my-claude-code-setup, 2.7k stars) and Ponylang Prose Review (ponylang/ponylang-website, 160 stars). The comparison table on this page puts their stars, adoption, token cost, safety result and licence side by side.

Who maintains Writing Rules?

xiaolai (a GitHub user) maintains it in xiaolai/nlpm, which has 146 GitHub stars. The repository holds 15 skills in this directory. The repository was last updated on October 8, 2026.

Source: xiaolai/nlpm on GitHub. Facts on this page come from the repository at the commit we read; the author's words are quoted as theirs.