Claude Corner

Need a Starter CLAUDE.md for a New Repo? Start With /init.

By ยท 26 Nov 2026

A flat straight-on view of one small blank matte stone charcoal rounded square joined by a short plain dark line to one taller blank charcoal page shape with a folded corner, on a bright fern field, with no people or text.

At a glance

  • One built in command reads your codebase and writes a starter CLAUDE.md with the build commands, test steps and conventions it finds.
  • Running it again on a repo that already has the file suggests improvements instead of writing over your work.
  • A quick check in your next session confirms the file actually loaded, so you are not guessing.

Here is a familiar example, not a documented case: you open Claude Code in a repo it has never seen, and the first stretch of the session goes to the same questions, such as which command runs the tests. A project CLAUDE.md is meant to hold that context, and Claude Code can write the first draft for you.

Why it matters

Anthropic's memory guide says /init has Claude analyze your codebase and create a CLAUDE.md with the build commands, test instructions and project conventions it discovers. If a CLAUDE.md already exists, the guide says /init suggests improvements rather than overwriting it. The same guide says Claude loads that file as context at launch. The commands reference puts it first in its setup list for a new repo: run /init, then refine the result with /memory. A project file can live at ./CLAUDE.md or ./.claude/CLAUDE.md.

How to give a repo a starter CLAUDE.md

These steps follow Anthropic's docs and have not been run in a live session.

  1. Run /init. Claude reads the codebase and writes the starter file. The guide says it also reads Cursor rules in .cursor/rules/ or .cursorrules and Copilot rules in .github/copilot-instructions.md.
  2. Open the file with /memory and add what Claude could not find on its own, for example a team decision or a command that only works with one flag.
  3. Rewrite vague lines into ones you can check. One of the guide's examples swaps "Test your changes" for "Run npm test before committing".
  4. Commit the file so the whole team shares it. Personal settings belong in a CLAUDE.local.md at the project root, which the guide says to add to .gitignore.
  5. Start a new session and run /context all. The guide says the file should appear in the list under Memory files.
# We have not run this script end to end on every platform.
# Draft, refine, then confirm the file loaded.
claude

# Inside the session, draft the starter file.
/init

# Open the memory file to add what Claude could not find.
/memory

# In your next session, confirm the file loaded.
/context all

Gotchas

  • It guides, it does not enforce. The guide says Claude treats CLAUDE.md as context, not enforced configuration, so concrete instructions get followed more reliably than vague ones.
  • Keep it short. The guide suggests staying under 200 lines per file, because longer files use more context and reduce how well Claude follows them. Imports do not lower that cost.
  • Watch for contradictions. If two instructions disagree, the guide says Claude may pick one arbitrarily, so review nested files and rules now and then.
  • Already have a file? Running /init again suggests improvements rather than overwriting, so review what it proposes before you accept it.

When some of your instructions only matter for one part of the codebase, move them out of CLAUDE.md with Claude Applying Your React Rules to Python Files? Scope Each Rule With paths.

Sources:

Recommended AI prompt

Copy this paragraph into ChatGPT, Claude, Gemini, Grok, or whatever AI you use.

Prompt

I just ran /init in Claude Code and it wrote a starter CLAUDE.md for my repository, which I will paste below. Review it line by line and mark anything vague that Claude could not check, anything that contradicts another line, and anything that only matters for one folder and belongs in a scoped rule instead. Then ask me what my team knows that the code does not show, such as release steps or commands that need a special flag, and suggest short, concrete lines to add while keeping the whole file under 200 lines.