Skip to main content

Documentation Index

Fetch the complete documentation index at: https://mintlify.com/VineeTagarwal-code/claude-code/llms.txt

Use this file to discover all available pages before exploring further.

Claude Code has a layered memory system that lets you give Claude persistent context — coding standards, project architecture, personal preferences — without repeating yourself in every session. Memory is stored in plain Markdown files that Claude reads at startup.

Memory types

Files are loaded in order from lowest to highest priority. Later files override earlier ones.
TypeFile locationDescription
Managed/etc/claude-code/CLAUDE.mdOrganization-wide instructions set by administrators. Users cannot edit these.
User~/.claude/CLAUDE.mdYour personal global instructions applied to every project.
ProjectCLAUDE.md, .claude/CLAUDE.md, .claude/rules/*.mdInstructions checked into the project repository. Shared with everyone who works on the project.
LocalCLAUDE.local.mdYour private project instructions. Not checked into version control (add to .gitignore).
AutoMem~/.claude/MEMORY.mdAuto-extracted memory that Claude builds up over time (when the feature is enabled).
Files closer to the current directory take precedence over files higher up the directory tree. Claude reads all discovered memory files and presents their contents in the system prompt.
The maximum recommended size for a single memory file is 40,000 characters. Files beyond this limit may be truncated before being injected into the context window.

CLAUDE.md

CLAUDE.md is the primary memory file for a project. Place it in the root of your repository to give Claude standing instructions for every session in that project.

Example CLAUDE.md

# Project: Acme API

## Architecture
- This is a Node.js REST API using Express and TypeScript.
- Database access goes through the `src/db/` module — never write raw SQL elsewhere.
- All new routes must have a corresponding integration test in `tests/routes/`.

## Coding conventions
- Use `const` by default; `let` only when the variable must be reassigned.
- All async functions must handle errors with `try/catch` — no unhandled promise rejections.
- Import order: Node built-ins → third-party → internal (enforced by ESLint).

## Running the project
- `npm run dev` — start development server with hot reload
- `npm test` — run unit and integration tests
- `npm run lint` — lint and type-check

## Important files
- `src/config/index.ts` — all environment variable access goes through here
- `src/middleware/auth.ts` — authentication middleware; do not bypass

Where to put CLAUDE.md

Claude Code traverses the directory tree from the current working directory up to the filesystem root, loading memory files at each level. You can have multiple CLAUDE.md files in nested directories; files nearer to the working directory take higher priority.
~/projects/acme/
├── CLAUDE.md                   ← project-level instructions
├── backend/
│   ├── CLAUDE.md               ← backend-specific additions
│   └── src/
└── frontend/
    └── CLAUDE.md               ← frontend-specific additions

.claude/CLAUDE.md

An alternative placement is .claude/CLAUDE.md inside the project root. This is useful when you want to keep the repository root clean or when your team’s convention reserves the root directory.

.claude/rules/*.md

You can split instructions into multiple focused files in .claude/rules/. All .md files in this directory (and its subdirectories) are loaded as project memory. This is useful for organizing rules by topic:
.claude/rules/
├── coding-style.md
├── testing.md
└── architecture.md
Rule files support a paths frontmatter field to make them conditional — they are only injected when Claude is working on files matching the glob pattern:
---
paths:
  - "src/api/**"
  - "tests/api/**"
---

All API handlers must validate inputs with Zod before processing.

User memory (~/.claude/CLAUDE.md)

Your user memory file applies to every project on your machine. Use it for personal preferences:
## My preferences
- Always use British English spelling in prose.
- When suggesting variable names, prefer descriptive names over abbreviations.
- If I ask you to "tidy" code, fix formatting and naming without changing behavior.
This file is private — it is never committed to any repository.

The /memory command

Use /memory to open an interactive file selector that lets you choose which memory file to view or edit:
/memory
Claude Code lists all discovered memory files grouped by type (Managed, User, Project, Local). Select a file to open it in your $EDITOR (or $VISUAL). The file is created if it does not yet exist. After you save and close the editor, Claude Code refreshes its in-memory cache so the changes take effect immediately in the current session.

@include directives

Memory files can include other files using @ notation:
@./docs/architecture.md
@./docs/api-conventions.md
Supported path forms:
  • @./relative/path — relative to the including file
  • @~/home/path — relative to your home directory
  • @/absolute/path — absolute path
Includes are processed recursively up to five levels deep. Circular references are detected and skipped. Only text files are included (binary files such as images and PDFs are silently skipped).
By default, Claude Code only follows @include paths that stay within the project’s working directory. References to files outside the project prompt a one-time approval dialog before loading external content.

HTML comment stripping

Block-level HTML comments (<!-- ... -->) in memory files are stripped before the content is injected into the context. You can use this to add authorial notes visible when editing the file but invisible to Claude:
<!-- TODO: update this section after the refactor in Q3 -->
## Database conventions
...
Comments inside code fences and inline code spans are preserved.

Memory and context

All loaded memory files are concatenated and prepended to Claude’s system prompt with the instruction:
Codebase and user instructions are shown below. Be sure to adhere to these instructions. IMPORTANT: These instructions OVERRIDE any default behavior and you MUST follow them exactly as written.
The label next to each file’s content tells Claude where it came from:
  • (project instructions, checked into the codebase) — Project type
  • (user's private project instructions, not checked in) — Local type
  • (user's private global instructions for all projects) — User type

Excluding memory files

You can exclude specific memory files from being loaded using the claudeMdExcludes setting. This accepts glob patterns:
{
  "claudeMdExcludes": ["/tmp/**", "**/generated/**"]
}
Managed, AutoMem, and team memory files are never excluded regardless of this setting.

Team memory (AutoMem)

When the auto-memory feature is enabled, Claude Code maintains a ~/.claude/MEMORY.md file that it updates automatically as you work. This file stores facts Claude has learned about your preferences and workflows that are worth remembering across sessions. The AutoMem file is truncated to a line and byte cap before injection to stay within context limits.

Build docs developers (and LLMs) love