New Tool Radar

AI Agents & Automation

How to Write a Project CLAUDE.md File for Claude Code

Write a project CLAUDE.md file so Claude Code loads the same rules and context at the start of every session.

Schematic with three steps: Write the file at the project root; Commit it and start a fresh session; Trim anything it got wrong or ignored.

CLAUDE.md is persistent project memory: a Markdown file at the project root that Claude Code reads at the start of every session. Treat it like the onboarding document for a new hire: the tech stack, the commands that matter, the architectural decisions, and the do’s and don’ts. Keep it short and specific, and review changes to it like code, because every session will follow what it says.

What you need

  • Claude Code installed and a project folder open
  • The project’s stack, commands and conventions written down
  • A teammate willing to read the file and check it makes sense

Step 1: Write the file at the project root

Create CLAUDE.md in the project root with the stack, the commands for building and testing, and the rules that matter. Leave out anything obvious from reading one file or derivable from the git log.

Step 2: Commit it and start a fresh session

Commit the file to the repo, then start a fresh Claude Code session and ask it to describe the project setup. Confirm it states the rules from the file.

Step 3: Trim anything it got wrong or ignored

If the session missed a rule or stated something the file does not say, tighten the wording and re-test. A CLAUDE.md that is too long gets skimmed, so cut what did not change the answer.

Worked example: synthetic CLAUDE.md check

The table below is a synthetic example. It shows the expected result of project memory; no file was written.

Check Expected Result
File read at session start Yes Pass
Build command stated correctly Yes Pass
Forbidden pattern avoided Yes Pass

Expected result (UNTESTED). a fresh session states the stack, the build command and the rules from CLAUDE.md without being told again. This check was not run live; the table shows the expected result for the synthetic example.

Limits

  • CLAUDE.md is read at the start of every session, so a wrong rule there misleads every session until it is fixed.
  • Keep it short and specific; generic advice and obvious facts dilute the rules that matter.
  • Project scope overrides a global CLAUDE.md on conflicts, so check both files agree.

Sources

See all