CLAUDE.md is a markdown file Claude Code loads automatically at the start of every session, acting as its long-term memory for your project. Run /init to generate one, keep team rules in the project-level file, and personal preferences in ~/.claude/CLAUDE.md.
What CLAUDE.md is
Every new session, Claude starts fresh. CLAUDE.md fixes that: it's a plain markdown file that Claude Code reads automatically, so it always knows your project's essentials.
Good things to include:
- How to build, run and test the project (
npm run dev,npm test) - Coding conventions ("use British spelling in UI copy", "prefer async/await")
- Architecture notes ("API routes live in /server/routes")
- Gotchas ("never edit generated files in /dist")
Create one in seconds with /init
Inside a project, run:
/init
Claude explores the codebase and writes a starter CLAUDE.md. Review it, trim the fluff, and add what only you know. Use /memory to see which memory files are loaded and open them for editing.
The memory hierarchy
- User level:
~/.claude/CLAUDE.md. Your personal preferences across all projects. Not shared with anyone. - Project level:
CLAUDE.md(or.claude/CLAUDE.md) at the repo root. Committed to git and shared with the whole team. - Folder level: a
CLAUDE.mdin a subfolder, picked up when Claude works in that part of the project.
You can also keep things modular: import other files with @path/to/file.md syntax, or put topic-specific rules in .claude/rules/: including rules that only load for matching file paths.
Keep it lean
CLAUDE.md is loaded into context every time, so every line costs attention. Aim for short, specific, high-value instructions. Put long, task-specific procedures into skills or custom commands instead (covered later).
Check yourself
Three quick questions to check it stuck.
Ask the tutor
Stuck on something in this lesson? Ask the AI tutor. It answers from this lesson and points you to others that help. Answers are written by AI and can be wrong. Do not include personal details, passwords or company secrets.
Frequently asked
What is CLAUDE.md?
CLAUDE.md is a markdown memory file that Claude Code loads automatically at the start of each session. It holds project instructions such as build commands, conventions and architecture notes.
Where should I put CLAUDE.md?
Put team-wide rules in a CLAUDE.md at the project root so it is shared via git. Put personal preferences in ~/.claude/CLAUDE.md. Subfolders can have their own CLAUDE.md files too.
What does /init do in Claude Code?
/init analyses your codebase and generates a starter CLAUDE.md file describing the project, which you can then review and edit.