ClaudeDetails
UpdatesGuidesModelsMCPToolsLearning PathsFAQ
UpdatesGuidesModelsMCPToolsLearning PathsFAQ

On this page

Two memory systems, two authorsWhen to add something to CLAUDE.mdWhere CLAUDE.md files can liveSetting up a project CLAUDE.mdAuto memory in briefA note on this guideFAQ
Home/Guides/Claude Code
Claude CodeBEGINNER

How Claude Code Remembers Your Project: CLAUDE.md Files and Auto Memory

Needs reviewLast verified August 12, 2026·5 min read

Every Claude Code session starts with a fresh context window, so persistent knowledge has to come from somewhere. This guide explains the two mechanisms that carry knowledge across sessions: CLAUDE.md files, which you write to give Claude standing instructions, and auto memory, notes Claude writes itself based on your corrections. It covers where CLAUDE.md files can live, what to put in them, how to generate one with /init, and how to verify your files loaded.

Two memory systems, two authors

Each Claude Code session begins with a fresh context window. Two mechanisms carry knowledge across sessions:

  • CLAUDE.md files: instructions you write to give Claude persistent context
  • Auto memory: notes Claude writes itself based on your corrections and preferences

Both are loaded at the start of every conversation. An important caveat from the docs: Claude treats these as context, not enforced configuration. If you need to block an action regardless of what Claude decides, use a PreToolUse hook instead. The more specific and concise your instructions, the more consistently Claude follows them.

A quick comparison:

CLAUDE.md filesAuto memory
Who writes itYouClaude
What it containsInstructions and rulesLearnings and patterns
ScopeProject, user, or orgPer repository, shared across worktrees
Loaded intoEvery sessionEvery session (first 200 lines or 25KB)
Use forCoding standards, workflows, project architectureBuild commands, debugging insights, preferences Claude discovers

Use CLAUDE.md when you want to guide Claude's behavior deliberately. Auto memory lets Claude learn from your corrections without manual effort. Subagents can also maintain their own auto memory, configured separately.

When to add something to CLAUDE.md

Treat CLAUDE.md as the place you write down what you'd otherwise re-explain. The documentation suggests adding to it when:

  • Claude makes the same mistake a second time
  • A code review catches something Claude should have known about this codebase
  • You type the same correction or clarification into chat that you typed last session
  • A new teammate would need the same context to be productive

Keep it to facts Claude should hold in every session: build commands, conventions, project layout, "always do X" rules. If an entry is a multi-step procedure or only matters for one part of the codebase, the docs recommend moving it to a skill or a path-scoped rule instead.

Where CLAUDE.md files can live

CLAUDE.md files can exist at several scopes. They load from broadest to most specific, so a project instruction appears in context after a user instruction:

ScopeLocationShared with
Managed policymacOS: /Library/Application Support/ClaudeCode/CLAUDE.md; Linux and WSL: /etc/claude-code/CLAUDE.md; Windows: C:\Program Files\ClaudeCode\CLAUDE.mdAll users in organization
User instructions~/.claude/CLAUDE.mdJust you (all projects)
Project instructions./CLAUDE.md or ./.claude/CLAUDE.mdTeam members via source control
Local instructions./CLAUDE.local.md (add to .gitignore)Just you (current project)

Managed policy files are meant for organization-wide instructions managed by IT/DevOps, such as company coding standards, security policies, and compliance requirements. User instructions hold personal preferences that apply to all your projects. Local instructions are for personal, project-specific preferences like sandbox URLs or preferred test data.

CLAUDE.md and CLAUDE.local.md files in the directory hierarchy above the working directory are loaded in full at launch. Files in subdirectories load on demand when Claude reads files in those directories.

For large projects, you can break instructions into topic-specific files using project rules under .claude/rules/, which let you scope instructions to specific file types or subdirectories.

Setting up a project CLAUDE.md

A project CLAUDE.md can be stored in either ./CLAUDE.md or ./.claude/CLAUDE.md. Add instructions that apply to anyone working on the project: build and test commands, coding standards, architectural decisions, naming conventions, and common workflows. Because these files are shared through version control, keep them focused on project-level standards rather than personal preferences.

To confirm the file loaded, run /context in a session and check the list under Memory files.

Generate a starting point with /init

Run /init to generate a starting CLAUDE.md automatically. Claude analyzes your codebase and creates a file with build commands, test instructions, and project conventions it discovers. If a CLAUDE.md already exists, /init suggests improvements rather than overwriting it. From there, refine it with instructions Claude wouldn't discover on its own.

There is also an interactive mode: set CLAUDE_CODE_NEW_INIT=1 to enable a multi-phase flow. In this mode, /init asks which artifacts to set up (CLAUDE.md files, skills, and hooks), explores your codebase with a subagent, fills in gaps via follow-up questions, and presents a reviewable proposal before writing any files.

Auto memory in brief

Auto memory is the complement to CLAUDE.md: Claude accumulates learnings automatically based on your corrections and preferences, without you writing anything. It is scoped per repository and shared across worktrees, and the first 200 lines or 25KB of it is loaded into every session. Typical contents include build commands, debugging insights, and preferences Claude discovers during your work together.

A note on this guide

This guide is based on Anthropic's documentation page "How Claude remembers your project" at code.claude.com. This site is an independent publication and is not affiliated with or endorsed by Anthropic. The source page also covers troubleshooting memory issues and further detail on load resolution order; consult the official docs for the complete reference.


claudedetails.com is an independent publication and is not affiliated with, endorsed by, or sponsored by Anthropic. "Claude" is a trademark of Anthropic, PBC, used here for identification purposes only. Product details can change — always confirm specifics on Anthropic's own site before making decisions based on this post.

FAQ

What is the difference between CLAUDE.md and auto memory in Claude Code?

CLAUDE.md files are instructions you write yourself — coding standards, workflows, and project architecture — scoped to a project, user, or organization. Auto memory is written by Claude itself, capturing learnings and patterns from your corrections, and is scoped per repository (shared across worktrees). Both are loaded at the start of every session, though auto memory is limited to the first 200 lines or 25KB.

Where should I put my CLAUDE.md file?

It depends on scope. Project instructions go in ./CLAUDE.md or ./.claude/CLAUDE.md and are shared with your team via source control. Personal preferences for all projects go in ~/.claude/CLAUDE.md. Personal project-specific preferences go in ./CLAUDE.local.md (add it to .gitignore). Organization-wide managed policy files live in system locations like /Library/Application Support/ClaudeCode/CLAUDE.md on macOS or /etc/claude-code/CLAUDE.md on Linux and WSL.

Does /init overwrite an existing CLAUDE.md?

No. If a CLAUDE.md already exists, /init suggests improvements rather than overwriting it. When no file exists, /init analyzes your codebase and creates one with build commands, test instructions, and project conventions it discovers.

How do I check that my CLAUDE.md file was actually loaded?

Run /context in a session and check the list under "Memory files". Files in the directory hierarchy above the working directory load in full at launch, while CLAUDE.md files in subdirectories load on demand when Claude reads files in those directories.

More in Claude Code

Claude CodeBEGINNER
Aug 12, 2026

Common Claude Code Workflows: Exploring Code, Fixing Bugs, Testing, and PRs

This guide walks through the everyday prompt patterns Anthropic documents for Claude Code: getting an overview of an unfamiliar codebase, locating relevant files, fixing bugs from error messages, refactoring legacy code safely, adding tests for uncovered code, creating pull requests, and generating documentation. It also notes related workflows the docs cover, such as resuming sessions, running parallel sessions with worktrees, planning before edits, delegating research to subagents, and piping Claude into scripts.

Read guide →
Claude CodeINTERMEDIATE
Aug 11, 2026

Using Claude Code on a React Project: CLAUDE.md, Permissions, and Workflow Tips

Claude Code has no React-specific mode — what actually makes it effective on a React codebase is the same CLAUDE.md and permissions setup that works on any project, applied deliberately. This guide walks through what to put in CLAUDE.md for a React app, which commands to allow, and how to structure a component or test-fixing session.

Read guide →
Claude CodeBEGINNER
Aug 11, 2026

How to Create Your First Claude Code Plugin: Manifest, Skills, and Local Testing

This guide explains how to create a custom Claude Code plugin from scratch. It covers when to use a plugin versus standalone configuration in the .claude directory, how to structure a plugin directory with a .claude-plugin/plugin.json manifest, how to add a skill using a SKILL.md file, how to test the plugin locally with the --plugin-dir flag, and how to make skills accept user input with the $ARGUMENTS placeholder. It is based on Anthropic's documentation for Claude Code plugins.

Read guide →
ClaudeDetails
UpdatesGuidesModelsMCPToolsLearning PathsFAQRSS
Get new guides and Claude updates by email

Occasional, no spam. Unsubscribe anytime.

claudedetails.com is an independent publication and is not affiliated with, endorsed by, or sponsored by Anthropic. "Claude" is a trademark of Anthropic, PBC, used here for identification purposes only. Product details can change — always confirm specifics on Anthropic's own site before making decisions based on this post.