← All How-tos

How-to⁠ · ⁠ · Claude Code · 4 steps

Claude Code CLAUDE.md: Set project rules in 4 steps

Explaining your build commands to Claude Code every session?

Write them into a CLAUDE.md once and Claude reads it at the start of every session.

You need: Claude Code with a Pro, Max, Ultra, Team, Enterprise or Console account (or a supported cloud provider), started in your project folder. Plan source: Claude Code docs: account requirements

Steps

  1. Run /init. Claude looks through your codebase and writes a starting CLAUDE.md with the build commands, test steps and conventions it finds. If the file already exists, /init suggests improvements instead of overwriting it.
  2. Open the file with /memory (or your editor) and add what Claude can’t work out from the code. Make each rule easy to check, like Run npm test before committing, and aim for under 200 lines.
  3. Optional: put personal notes for this project in CLAUDE.local.md at the project root, and add that file to .gitignore.
  4. In your next session, run /context all and check that CLAUDE.md is listed under Memory files.

Heads-up

  • CLAUDE.md is context, not enforced configuration. To block an action whatever Claude decides, use a PreToolUse hook.
  • Already have an AGENTS.md? Claude Code reads it only while there’s no CLAUDE.md, .claude/CLAUDE.md or CLAUDE.local.md, so put @AGENTS.md at the top of your new CLAUDE.md to keep it.
  • If two instructions contradict each other, Claude may pick one arbitrarily, so prune old rules now and then.

Source: Claude Code docs: how Claude remembers your project⁠ · Claude Code docs: account requirements