How to Give Claude Code Context: CLAUDE.md, /init & Memory
What Claude Code loads on its own, what it reads on demand, and how to give it the context it can't find in your code.

Claude Code doesn't read your whole repository when a session starts. It loads your CLAUDE.md files and its own auto memory, then opens files one by one as the task needs them.
So the context you give it comes down to three things: what you write in CLAUDE.md, what Claude saves to auto memory, and what you point at in the prompt. Here's how to set up each, and what none of them cover.
Does Claude Code automatically read all your files for context?
No. At startup it loads CLAUDE.md, auto memory, MCP tool names and skill descriptions, and nothing else from your codebase (Claude Code docs). Everything else enters the context window when Claude reads a file, runs a search or you reference something.
Two details matter in practice:
CLAUDE.mdfiles in the directories above where you launched Claude load at startup. Files in subdirectories load only once Claude reads or edits something in that subdirectory.- Run
/contextin a session to see exactly what loaded, including whichCLAUDE.mdand memory files.
That's why a good CLAUDE.md matters: it's the only project context guaranteed to be there before you type.
How do you give Claude Code context about your project?
Write a CLAUDE.md, a Markdown file of instructions Claude Code reads at the start of every session. Put it at the repo root as ./CLAUDE.md or ./.claude/CLAUDE.md, commit it, and everyone on the project gets the same baseline: build and test commands, conventions, architecture decisions, the gotchas a new teammate would trip on.
You don't attach or mention it. If it's in the right place, Claude has read it. Personal preferences that apply to every project go in ~/.claude/CLAUDE.md, and private notes for one project in a git-ignored CLAUDE.local.md. The full guide, with an example file and every location, is in CLAUDE.md: what it is, best practices and examples.
How do you generate a CLAUDE.md with /init?
Run /init in your project. Claude analyzes the codebase and writes a starting CLAUDE.md with the build commands, test instructions and conventions it finds; if a file already exists, it suggests improvements instead of overwriting it (Claude Code docs).
Useful extras:
/initalso reads other tools' rule files, such as.cursor/rules/,.cursorrulesand.github/copilot-instructions.md, and folds the relevant parts in.- Set
CLAUDE_CODE_NEW_INIT=1first for an interactive flow that asks questions and shows a proposal before writing anything. - On a checked-in file,
/doctorproposes cuts for content Claude can work out from the code itself.
Treat the output as a draft. It captures structure; you add intent, the "we do X because Y" that no scan can find.
What is Claude Code's auto memory?
Auto memory is a set of notes Claude Code writes for itself as you work: your role and preferences, corrections you've given it, decisions and deadlines it can't see in the code, and where outside information lives. It skips anything it could derive from the codebase or that your CLAUDE.md already says.
How it works, per the Claude Code memory docs:
- Where:
~/.claude/projects/<project>/memory/, one folder per git repository, shared across its worktrees. AMEMORY.mdfile indexes one topic file per memory. - What loads: the first 200 lines or 25KB of
MEMORY.md, whichever comes first, at the start of every session. Topic files are read on demand. - Control: it's on by default in local sessions. Toggle it or browse the files with
/memory; setautoMemoryEnabled: falsein a project's settings to turn it off there. - Machine-local: the notes don't sync to other machines or cloud sessions.
Saying "remember to use pnpm, not npm" saves to auto memory. Saying "add this to CLAUDE.md" writes it to the file your team shares.
Does Claude Code keep context between sessions?
Each session starts with a fresh context window, so only CLAUDE.md, auto memory and resumed conversations carry over. Run claude --continue to pick up your last conversation, or claude --resume to choose from a list; Claude Code saves conversations locally, so a task can span several sittings.
Within a session, Claude keeps everything it has read and decided, and compacts the history automatically as the window fills. After compaction, the project-root CLAUDE.md and auto memory are re-read from disk, but an instruction you only gave in chat survives only as part of the summary (Claude Code docs). If it matters, put it in CLAUDE.md. Run /clear between unrelated tasks so old context doesn't crowd out the files you need next.
How else can you add context in a prompt?
Point at things directly instead of describing them:
@references:@src/auth/session.tsmakes Claude read that file before it answers.- Rules: markdown files in
.claude/rules/with apaths:field load only when Claude touches matching files, which keeps folder-specific rules out of every session. - Skills: a
SKILL.mdin.claude/skills/holds a workflow or domain guide that loads only when it's relevant. - Pasted material: screenshots, URLs, or piped data like
cat error.log | claude -p "explain this error".
The docs' rule for size applies to all of it: target under 200 lines per CLAUDE.md, because longer files consume more context and reduce adherence. More on trimming in how to optimize context in Claude Code and how to keep your CLAUDE.md from going stale.
What about context that isn't project-specific?
Every method above describes the project. None of them carries who you are, the client the work is for, or the standards you bring to every repo, and that's why people still re-explain themselves to Claude Code.
Take a freelancer working on three client codebases. Each repo's CLAUDE.md says "TypeScript, Prisma, run pnpm test". None says who the client is, what they care about, or what was agreed on last week's call. ~/.claude/CLAUDE.md helps a little, but it's machine-local, Claude Code only, and written by hand, so it drifts.
That context belongs in a layer above any single project. Unabyss builds it from Gmail, Google Calendar, Slack, GitHub and Linear, keeps it current, and serves it over MCP to Claude Code, Cursor and the Claude app alike. In an August 2026 Unabyss benchmark of 20 tasks run 60 times in Claude Code, a hand-written CLAUDE.md barely moved cost or time, while Unabyss cut cost by 36% and time by 38% (What Structured AI Context Is Worth). Keep CLAUDE.md for the codebase; let the context layer handle everything that should follow you between repos. To share it with Cursor too, see Claude Code and Cursor: one shared context.
→ Connect your apps to Unabyss and give Claude Code your context