Rules
Instruction files in .claude/rules/ that load with CLAUDE.md. See what it is, how it works, how it is used and what to watch for, with pictures and examples.
What it is
Rules are small files you keep in the .claude/rules/ folder. Instead of writing one very long CLAUDE.md, you give each topic its own file, such as testing.md or security.md, which is easier for a team to keep up to date. A rule without paths loads at the start of every session, with the same priority as .claude/CLAUDE.md. A rule with paths in its frontmatter loads only when reads, writes or edits a matching file, so it takes no space until it is needed.
How it works
-
Make a .claude/rules/ folder
-
Write one Markdown file per topic
-
Add paths to limit when it loads
-
Claude reads it when it matters
How to use it
-
.claude/rules/testing.mdone topic per file. like
frontend/also work, because every.mdfile inside is found. -
pathswith"src/api/**/*.ts"the rule loads only when Claude works on a matching file, for example with the Read or Edit tool, or with
caton that file. -
~/.claude/rules/your personal rules for every project on this computer. They load before project rules.
-
ln -s ~/shared-claude-rules .claude/rules/sharedshare one set of rules across projects with a . A link that points outside the project needs your approval once.
Watch out
paths is the only frontmatter field reads in a rule, and if the is broken the rule loads as if it had no paths. If a user rule and a project rule disagree, Claude may follow either one, so keep them consistent. For instructions needed only for one kind of task, a is often better, because skills load only when called or relevant.
Related terms
Original and official docs
This page explains the term in plain words. The original is the authority: if they differ, follow the original.
- See this term in the originalClaude Code Docs — Glossary Anthropic · checked 2026-10-19
- Anthropic — Claude Code docs: How Claude remembers your project — Organize rules with claude/rules/(opens in a new window)
- Anthropic — Claude Code docs: How Claude remembers your project — Path specific rules(opens in a new window)
- Anthropic — Claude Code docs: How Claude remembers your project — User level rules(opens in a new window)
- Anthropic — Claude Code docs: Explore the .claude directory — File reference(opens in a new window)