This XDA Developers article by Anurag Singh explains how a **CLAUDE.md** file at the root of a repository solves the problem of Claude Code repeatedly asking the same setup questions in every new session.
**The problem:** Each Claude Code session starts with a fresh context window, so it has no memory of previous conversations. It must re-inspect the repo and re-infer project conventions (package manager, test commands, directory rules, etc.), wasting time and tokens—and sometimes reaching different conclusions.
**The solution:** A `CLAUDE.md` file that Claude Code automatically loads at the start of every session. It acts as a persistent onboarding document containing:
- **Commands** (e.g., "Use pnpm," "Run `pnpm test` before completing a task")
- **Project structure rules** (e.g., "Reusable components go in `src/components/`," "Do not edit `src/generated/`")
- **Working rules** (e.g., "Reuse existing components," "Ask before installing a dependency," "Make the smallest change required")
**How to create it:** Either write it manually or run `/init` inside Claude Code, which auto-generates a starting file from the repo. If one already exists, `/init` suggests changes rather than overwriting.
**Best practices:**
- Keep it under ~200 lines (treat as a ceiling, not a target).
- Be specific—avoid vague instructions like "write clean code."
- Don't duplicate content Claude can discover by reading the repo (don't make it another README).
- Watch for conflicting rules across multiple instruction files.
**File hierarchy:**
| File | Scope |
|---|---|
| `~/.claude/CLAUDE.md` | Global, all projects |
| `CLAUDE.md` (repo root) | Project-level, commit to version control |
| `CLAUDE.local.md` | Personal, add to `.gitignore` |
The author notes that Claude Code's built-in "auto memory" is unreliable for critical rules because Claude decides what to save there; a hand-written CLAUDE.md is exact and shareable.