Bible Network Crypto DeFi Onchain RWA AI Agent Stablecoin Chain SAFU CryptoTax DeFAI AGI Claude Me Claude Skill Claude Design Claude Cowork
Independent Media
Not affiliated with any project
Learn Claude Skills. Do Everything Better.
claudeskill-me.com
LATEST
Watching Claude Code Compaction and Hooks Through OpenTelemetry: Reading the compaction, hook_execution_complete and precompute_reuse Fields  ·  Blind Spots in Bash Permission Rules: deny Misses /bin/rm, bash -c and git -C, and devbox run * Lets Any Inner Command Through  ·  CLAUDE.md Too Long? Use .claude/rules/ and paths So Rules Load Only When Claude Touches Matching Files  ·  Chromium Says No usable sandbox! Inside Claude Code's Sandbox: What --no-sandbox, excludedCommands and allowNestedUserNamespaces Each Give Up  ·  Claude Code v2.1.309 Fixes a Batch of Sandbox and Permission Gaps: Startup Files Outside the Sandbox, denyWrite Through Symlinks and More  ·  The auto mode $defaults Trap: Leave One String Out of autoMode.soft_deny and the Built-In Force-Push Rules Disappear
Glossary · Workflow

.claude/rules Directory

Workflow beginner

30-Second Version · For the impatient
Multiple Markdown rule files in .claude/rules/; those without paths load at launch, while those scoped with the paths frontmatter load only when Claude touches matching files, as an alternative to one ever-growing CLAUDE.md.
Full Explanation +
01 · What is this?

What is .claude/rules?

Per the official memory docs it is the .claude/rules/ directory in a project, where each .md file covers one topic (for example testing.md or api-design.md) and files are discovered recursively, so subdirectories work. The personal version lives in ~/.claude/rules/ and applies to every project on your machine.

02 · Why does it exist?

Why does it exist?

The docs advise about 200 lines for a single CLAUDE.md, since longer files use context and reduce adherence. Splitting into several rule files makes them easier for a team to maintain, and path scoping keeps rules relevant to only part of the code from occupying context in every session.

03 · How does it affect your decisions?

How does it work?

Rules without paths load at launch with the same priority as .claude/CLAUDE.md. Rules with paths (a YAML list or comma-separated string of globs) load when Claude uses Read, Write, Edit or a Bash command that counts as a read, such as cat or head on a single file, on a matching file. paths is the only frontmatter field read, and the frontmatter is removed before loading.

04 · What should you do?

So what does this mean for me?

Watch three things: if the frontmatter YAML fails to parse, the rule loads as if it had no paths, unconditionally (run claude --debug to see the error); a [ in a glob must be written [; and a symlink pointing outside the working directory needs external imports approved first, after which only rules without paths load.

Sources: How Claude remembers your project - Claude Code Docs
Real-World Example +

The docs' example: a rule file with paths: ["src/api/**/*.ts"] saying all API endpoints must validate input, use the standard error format and carry OpenAPI comments, which enters context only when Claude touches a TypeScript file under src/api.

Common Misconceptions +
✕ Misconception 1
× Misconception: a rule with broken frontmatter will not load, when actually: a parse failure makes it load as if it had no paths, so it loads in every session
✕ Misconception 2
× Misconception: rule files can use any frontmatter field, when actually: Claude Code reads only paths and ignores other fields without an error
The Missing Link +
Direct Impact

Pros: modular rules that take context only when relevant. Cons: one more load timing to keep track of, and broken YAML silently turns into unconditional loading.

Ask a Question
Please enter at least 10 characters
More Related Topics