CLAUDE.md: what it is, what to put in it, and examples
CLAUDE.md is a markdown file of instructions that Claude Code reads at the start of every session. You write it, and Claude treats it as context for the project: build commands, conventions and rules it cannot work out from the code. Keep it short, specific and checked into git. What is a CLAUDE.md file? Each Claude Code session starts with a fresh context window. Two things carry knowledge from…
Claude Code reads a markdown file named CLAUDE.md at the beginning of every session. This file contains instructions and context that Claude uses throughout the session. To create a CLAUDE.md file, you can run the /init command. The location of CLAUDE.md can vary, depending on the scope: it can be managed policy, user-specific, or project-specific.
By default, Claude loads both CLAUDE.md and CLAUDE.local.md from the current directory and any higher directories. If there are conflicts between instructions in different files, Claude will not override one with another. Instead, it will leave both files and let the user resolve the conflicts. A CLAUDE.md file can import other files using the @path/to/file syntax, but this does not save context for Claude.
The file should be kept short, specific, and checked into git. It should include build commands, test instructions, and project conventions that cannot be inferred from the code. Best practices recommend keeping the file under 200 lines, being specific enough to verify, using headers and bullets, and emphasizing important instructions with "IMPORTANT".
When a correction repeats, it should be added to the file. A CLAUDE.md example is provided for a small TypeScript API, including build commands, dev server instructions, and test runner details.
Written by urgent.news from Dev.to's reporting — not their text. Machine-written — may contain errors; check the original before relying on it.