# CLAUDE.md and Auto Memory

> How CLAUDE.md gives Claude Code your rules as each session starts. How imports, rule files and auto memory fit in around it.

**Course:** [Claude Code Basics](https://learn.benibix.com/learn/ai-claude-code)  
**Time:** 11 min

**After this lesson you can:**

- Write a short CLAUDE.md with /init
- Split rules with imports and path rules
- Tell CLAUDE.md and auto memory apart

## How Claude learns about your project

CLAUDE.md is a plain text file of rules that Claude Code reads at the start of every session. It holds things like your build command, your test command and the style you want. The docs say to keep each file under 200 lines. Run /init and Claude writes a first one by reading your code.

There can be more than one. A CLAUDE.md in ~/.claude/ applies to all your projects. One at the top of the project is shared with the team through git. Files in folders above where you start are all loaded, and their text is joined, not swapped. Files in sub-folders load once Claude works in them.

CLAUDE.local.md is the personal one. It sits beside CLAUDE.md and loads the same way, but you add it to .gitignore so only you get it. Put things there that are true for you alone, such as the address of your own test server.

A CLAUDE.md can pull in another file with an @ and its path, such as @docs/testing.md. That file then loads beside it. An imported file can import more, up to four steps deep. This keeps the main file short while the detail lives where it belongs.

Rules can also be split into small files in a rules folder inside .claude, one topic each. A rule file can list paths at its top. Then it only loads when Claude reads or edits a file that matches. A rule about the API, say, loads only for API files. That saves room in all the other sessions.

Auto memory is the other half. These are notes Claude writes for itself as it works with you: your choices, corrections you gave it, and facts the code does not show. They live under ~/.claude/projects/ for each repo. The first 200 lines or 25 kilobytes of the index, MEMORY.md, load at the start of each session.

Both are read as advice, not as hard rules. Claude follows short, clear lines best. A rule that must never be broken, such as never push to main, belongs in a deny rule or a hook, where Claude Code enforces it whatever the model decides.

```markdown
# Project rules

- Run npm test before you say a task is done.
- Use 2 spaces, not tabs.
- Never edit files in dist/. They are built.

How we test: @docs/testing.md
```
A short CLAUDE.md: three rules and one import for the long part.

![Three CLAUDE.md files feed one session: ~/.claude/CLAUDE.md for you in every project, ./CLAUDE.md for the team in this project, and ./src/CLAUDE.md when Claude works in src. A note says /init writes a first version for you.](https://learn.benibix.com/diagrams/cc-claude-md.svg)

### Example: Jack stops repeating himself

Jack has told Claude 5 times this week to run the linter before saying it is done. Each new session forgets.

He adds one line to the project's CLAUDE.md. The next 3 sessions run the linter without being asked, and his team gets the same rule through git.

**Words in this lesson:** [CLAUDE.md](https://learn.benibix.com/term/ai/claude-md), [CLAUDE.local.md](https://learn.benibix.com/term/ai/claude-local-md), [CLAUDE.md Import](https://learn.benibix.com/term/ai/claude-md-import), [Claude Code Rules](https://learn.benibix.com/term/ai/claude-code-rules), [Auto Memory](https://learn.benibix.com/term/ai/auto-memory)

> **CLAUDE.md and auto memory have different authors.** You write CLAUDE.md, and it holds rules. Claude writes auto memory, and it holds what it learned working with you. Both load at the start of each session. Edit CLAUDE.md to change how Claude must work. Run /memory to see or switch off what Claude chose to remember.

**Question:** Who writes the notes in auto memory?

**Answer:** Claude, as it works with you. Auto memory is Claude's own notes about your choices and the project. You write CLAUDE.md. Both load at the start of each session.

---

Source: https://learn.benibix.com/learn/ai-claude-code/claude-md-and-auto-memory
Author: Behnia Zarei (a developer in Vienna, Austria, who builds and teaches data, AI and business intelligence at BENIBIX)
Publisher: BENIBIX Learn (https://learn.benibix.com/)
Last updated: 2026-11-18
Licence: CC BY 4.0 (https://creativecommons.org/licenses/by/4.0/). Quote freely with attribution.
