Skip to content
BENIBIX Learn

Claude Code Rules

AI⌨️ Claude CodeClaude Code Concepts

Also known as .claude/rules, Path-scoped rules, Rules folder

Small rule files. Some load only for some files.

Think of it like

It is like a binder with a tab for each topic.

Example

Jack's API rules only matter in one folder. He moves them into a rule with a paths line, and his main CLAUDE.md gets shorter.

Why it matters

It keeps the context small, because a rule only costs space when it is needed.

Definition

Rules are small files of instructions in a project's .claude/rules/ folder. Each file covers one topic, such as tests or the API. They load beside CLAUDE.md. A rule can also list file paths at its top. Then it only loads when Claude reads or edits a file that matches. Rules in the ~/.claude/rules/ folder at home apply to every project.

Example code

markdown
---
paths: ["src/api/**"]
---
Every API route checks the user first.
This rule loads only for files in src/api.
A path rule waits until a matching file is touched.

Common mistake

Putting every rule in CLAUDE.md. A rule for just some files is better with a paths line.

Key takeaways

  1. 1
    One topic a file. In .claude/rules/.
  2. 2
    Path rules. Load when needed.
  3. 3
    Personal rules. In ~/.claude/rules/.

Learn it properly