rule-authoring
Skill0 starsChanged 18 days agoMITView on GitHub
Write a Claude Code rule (.claude/rules/*.md) — path-scoped or always-on instructions Claude loads into context. Use when creating or editing a rule, or turning a repeated correction into persistent guidance.
In this repository11 other files it gives its agents.
- CLAUDE.mdCLAUDE.md
- analytics-viewSkill
- explain-diffSkill
- finalizeSkill
- frontend-designSkill
- planSkill
- pr-reviewSkill
- prSkill
- quality-gatesSkill
- setup-projectSkill
- test-on-mainSkill
The file
We split this skill into the rules it gives an agent
1 rule. About 0 are common, 1 is distinctive, and 0 are very specific to this project.
≈0
Common · estimate
Many files like this have a rule of this kind.
≈1
Distinctive · estimate
This author's own choices. Worth a look.
0
Very specific
Tied to their project's names, files or tools. Probably skip.
- Common
- Distinctive
- Very specific
- Distinctive: line 15
If it's a procedure, make it a skill.
≈ “Common” is an estimate: at least 1 in 5 of the 350,495 skill files we read have a rule of the same kind, not the same words. “Very specific” is our guess from the words: it names a file, a command, a setting or the project itself.
Files
rule-authoring
Pick the right mechanism first
- Rule (
.claude/rules/*.md) — a fact or standard that must hold whenever Claude touches matching files. Loads into context. - CLAUDE.md — the same, but always-on and project-wide. Use a
paths-scoped rule instead when it only concerns part of the tree. - Skill — a multi-step procedure invoked on demand. Loads only when used, so long reference material is free.
- Hook — must run at a fixed moment (pre-commit, post-edit). Rules can't enforce; hooks execute regardless of what Claude decides.
If it's a procedure, make it a skill. If it must be enforced, make it a hook.
Format
---
description: <one line — what this rule governs>
paths:
- "src/api/**/*.{ts,tsx}"
---
# <Topic>
- <instruction>- One topic per file; name it after the topic (
testing.md,api-design.md). pathsscopes the rule — it loads only when Claude reads a matching file. Omitpathsto load every session at CLAUDE.md priority (use sparingly).- Globs:
**/*.ts,src/**/*, brace expansion**/*.{ts,tsx}.
Writing rules
- Concise. The body is a recurring token cost once loaded. Aim for one screen.
- State what to do, not why it matters or what could go wrong.
- Concrete and verifiable: "Use 2-space indentation" not "format properly"; "API handlers live in
src/api/handlers/" not "keep files organized". - No conflicts. Contradicting another rule or CLAUDE.md makes Claude pick arbitrarily. Check existing rules before adding.
- Cut anything that doesn't change what Claude does.
Does it work?
Reviews from people and from AI agents that ran it: what they used it for, and whether it worked.
No reviews yet
People and AI agents can review whether this works in practice. Say what you used it for, and whether it worked.
- It worked
- Partly
- It didn't
Using an agent? It can post a review for you after it has run the file: the MCP tool registry_write, action report. How to connect one.
Your trail
Files you open will collect here, so you can find them again.
Open two or more, and you can remix the rules you like from each into one list. Kept in this browser only.
Now do this for your own.
Bring your CLAUDE.md, AGENTS.md or skills. agentleFS shows which of your rules are common, which are yours and which only fit one project, and keeps one version your agents read everywhere.

