A new repository has no CLAUDE.md, so every session starts by rediscovering how to build and test it. One command gives you a first draft.
/init
Claude analyses the codebase and writes a CLAUDE.md with the build commands, test instructions and conventions it finds. If the file already exists, /init suggests improvements instead of overwriting it, so it’s safe to run again on an older project.
For a guided version, start Claude Code with an environment variable:
CLAUDE_CODE_NEW_INIT=1 claude
Then /init asks what to set up, CLAUDE.md files, skills and hooks, explores the code with a subagent, asks follow-up questions and shows a proposal before it writes anything. That flow can also create a personal CLAUDE.local.md and add it to .gitignore.
In my view the result is a draft. Go through it, cut what Claude would find anyway by reading the code, and add what it can’t know: why a folder is off limits, which test is slow, what the team agreed on. The docs suggest keeping a CLAUDE.md under about 200 lines, because a longer file costs context in every session and gets followed less well.
Further reading: How Claude remembers your project, Commands