CLAUDE.md and Auto Memory
Level 3 · Telling it how you work
How CLAUDE.md gives Claude Code your rules as each session starts. How imports, rule files and auto memory fit in around it.
Course contentsLesson 7 of 16
Level 1 · Starting out
Level 2 · Asking before it acts
Level 3 · Telling it how you work
Level 4 · The tools it uses
Level 5 · Growing past one chat
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
11 mincovers 5 glossary entries
Worth reading first: Permission Rules and Sandbox
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.
# 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.mdWorked 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.
The words for this lesson5
Check yourself
Who writes the notes in auto memory?
Finished this lesson?
Marking it complete also marks its 5 glossary entries learned, which updates your roadmap and your saved page. 0 are already marked.