CLAUDE.md Project Memory: Configuration Locations and How to Verify It Works

    CLAUDE.md gives Claude Code persistent project memory across sessions. This guide covers where memory files live, a minimal template, how to handle rule conflicts, splitting long files with @imports, and how to verify your memory is actually loaded.

    In AI-assisted development, coding assistants start every new session with no knowledge of your project. Developers end up repeatedly explaining the tech stack, directory structure, and coding conventions, and results are inconsistent. CLAUDE.md is a Markdown file placed in your project that Claude Code reads at startup and uses as session context. It stores long-lived conventions that apply to every session.

    1. Where CLAUDE.md Files Get Loaded

    Claude Code reads several types of memory files, each with a different scope.

    The user-level file lives at ~/.claude/CLAUDE.md and applies to all projects on your machine. It is a good place for personal preferences, such as reply language or commit message format.

    Project-level files usually sit in the project root as ./CLAUDE.md or ./.claude/CLAUDE.md. These are typically committed to version control and shared with the team, recording the tech stack, build commands, directory responsibilities, and coding conventions.

    A local private file, CLAUDE.local.md, lives in the project root and belongs only to the current developer. Use it for machine-specific paths, personal debugging habits, and similar notes. Add it to .gitignore before use so it never gets committed.

    CLAUDE.md files in subdirectories are loaded differently. At startup, Claude Code reads memory files from the current directory and its parents. Files in subdirectories are loaded on demand, when Claude reads files inside that directory—not all at startup. This means frontend rules can live in frontend/CLAUDE.md and only apply when working on frontend code.

    2. A Minimal, Usable CLAUDE.md

    You don’t need to write much to get started. Here’s a minimal template suitable for most projects:

    1. # Project Overview
    2. E-commerce backend service built with Python 3.11 and FastAPI, currently in a performance optimization phase.
    3. # Common Commands
    4. - Install dependencies: `uv sync`
    5. - Run tests: `uv run pytest`
    6. - Lint: `uv run ruff check .`
    7. # Directory Responsibilities
    8. - `app/api/`: HTTP routes, only parameter validation and response assembly
    9. - `app/services/`: business logic
    10. - `app/repositories/`: all database access goes through this layer
    11. # Coding Conventions
    12. - Public functions must have type annotations.
    13. - No global mutable state in business logic.
    14. - No database queries inside loops.
    15. # Don'ts
    16. - Never put secrets, tokens, or credentials in code or logs.
    17. - Never modify published migration files in `migrations/`.

    Every rule should be specific and verifiable. Instead of “ensure code quality,” write “public functions must have type annotations.” When stating a rule, include the reason—models understand boundaries better this way and can make reasonable judgments when they hit cases the template doesn’t cover.

    You can run /init in the project root first to have Claude Code generate an initial file from your codebase. The generated content usually needs manual editing, especially to remove anything that doesn’t match how you actually work.

    3. Handling Conflicting Rules

    Consider this scenario: the root file says “this project uses pnpm for dependencies,” while frontend/CLAUDE.md says “use npm to install dependencies.” The two rules contradict each other, and the model may follow one sometimes and the other other times.

    The official documentation notes that memory content is provided to the model as context, not enforced as configuration. When rules conflict, model behavior may be inconsistent. So don’t rely on implicit “which level overrides which” rules—instead, spell out the scope of each rule. The example above could be fixed by writing “dependencies are managed with pnpm” in the root file, and “frontend exception: use npm only inside frontend/; all other directories use pnpm” in frontend/CLAUDE.md.

    Regularly reviewing files and deleting outdated or duplicated rules is the most direct way to reduce conflicts.

    4. Splitting Long Files with @ Imports

    When content grows, move topic-specific documentation into separate Markdown files, such as docs/api-conventions.md. Then reference it from the main CLAUDE.md using the import syntax:

    1. See @docs/api-conventions.md for API design conventions.

    Imported files enter the context along with the main file. There is a limit on import depth, so avoid nesting too deeply.

    Whether or not you split files, keep them concise. The shorter the file, the more reliably the model follows it. Only information that genuinely affects decisions is worth including.

    5. How to Verify the File Is Working

    1. Start claude in the project root, enter /memory to see which memory files are currently loaded. You can also edit them directly from there.
    2. Ask the model to restate a few key rules—for example, “what practices are forbidden in this project?”—and check that the answer matches the file.
    3. Enter a subdirectory, read a file inside it, then run /memory again to confirm the subdirectory’s CLAUDE.md has been loaded.
    4. If the restated rules don’t match the file, first check that the file paths are correct, then look for duplicate or contradictory rules.

    Command names and behavior may change between versions. If /memory isn’t available, refer to the official documentation for the current command.

    6. Maintenance and Security

    CLAUDE.md should be updated along with your project. After framework upgrades, directory restructuring, or convention changes, sync the file promptly. Adding it to code review, with every change confirmed by someone else, prevents rules from being altered arbitrarily.

    When the AI repeats the same class of mistake, writing the error pattern and the correct approach into the file is more durable than correcting it in every conversation.

    File contents are loaded into the model’s context and shared through version control. Never put API keys, database passwords, account credentials, or other sensitive information in them. Store secrets in environment variables or a secrets management service, and reference only the variable names in the file.