~10 min

T1 · Project memory

Give Claude what it cannot see: initialise project memory, refine it, and verify it loaded.

Knowledge refresher — CLAUDE.md, memory hierarchy, and slash commands

  • What CLAUDE.md is — read at the start of every Claude Code session; the project’s permanent memory. Claude infers a lot from code, but conventions, run commands, known issues, and team decisions are invisible without it. — Memory overview
  • Memory scope levels — CLAUDE.md loads in layers, each scoped differently:
    1. Path-scoped rules — load only when Claude touches matching files (e.g. tests/CLAUDE.md for test-only conventions).
    2. Project CLAUDE.md — loads for everyone who opens this repo. Lives at the project root.
    3. User-level rules — apply across every project on your machine. Stored in ~/.claude/CLAUDE.md.
    4. Auto-memory notes — managed automatically by Claude from your conversations.

    Each layer adds context; later layers can override earlier ones. The same layered-scope principle reappears in T2 for MCP servers.

    — Memory types
  • Slash commands as first-class tools — /init, /doctor, and /memory are built-in commands. They are the primary interface for setting up and verifying project memory — not footnotes. — Slash commands

Before you start

This task has no dependency on Setup beyond having a project open. If your environment is not ready, follow along and complete it afterwards.


Steps

1

Type /init in the Claude Code chat panel and press Enter.

Claude scans the project and generates CLAUDE.md at the project root.

signup-api/ ← VS Code workspace root
└── CLAUDE.md ← created by /init
Sample project or your own project
Using signup-api: /init will find the FastAPI project and generate a CLAUDE.md that covers the Python stack. Using your own project: the same flow applies — Claude scans whatever project is open. The file lands at your project root.
Done when
CLAUDE.md exists in the project root and is open in the editor.

Want Claude to manage its own notes automatically going forward? → Appendix 1: Auto memory

Docs: [1]

2

Open CLAUDE.md and audit it against this checklist.

signup-api/ ← VS Code workspace root
└── CLAUDE.md ← open and edit this
  • Concrete + precise — “Use 2-space indentation” not “format code properly”; “API handlers live in src/api/handlers/” not “keep files organised”.
  • Short — target under 200 lines. Longer means more context used every session, not better guidance.
  • Structured — group related instructions under Markdown headers and bullets.
  • Consistent — contradicting instructions → Claude picks one arbitrarily.

For help trimming CLAUDE.md, consider the following:

  • Already inferrable from code? — if Claude can consistently derive it by reading the codebase, it may not need stating. Test: remove the line and ask Claude the question it was answering. If Claude still gets it right, the line can go. Add it back if issues come up later.
  • Only relevant to a sub-directory or sub-project? — rules scoped to one area of a larger repo belong in a nested CLAUDE.md inside that folder, not in the root file. — Nested CLAUDE.md files
  • Only relevant for specific file types or paths? — conventions that apply only to Python files, test files, or a particular directory are better placed as path-scoped rules — they load only when Claude touches those files. — Path-scoped rules

Then ask Claude to refine it. Use this prompt as a starting point:

Review this CLAUDE.md. Add any missing sections from: build commands, test commands, lint/format commands, code conventions, key file locations, known issues. Remove anything already inferrable from the code. Keep it under 200 lines.
Done when
CLAUDE.md covers build/test commands and at least one real code convention. It is under 200 lines.

Instructions that only apply to a sub-folder → Appendix 2

Personal conventions across all your projects → Appendix 3

Finding yourself repeating the same guidance? → Appendix 4

Docs: [2]  ·  [3]

3

(Optional) Audit your instruction files with /doctor prompt-audit.

/doctor prompt-audit does more than a standard /doctor run — it audits your actual instruction files specifically. Claude looks for problems such as instructions written for older models, references to files or commands that don’t exist, and files that contradict each other. You get a report of findings with proposed edits — nothing in your files changes until you ask Claude to apply them.

/doctor prompt-audit
This may take a while
/doctor prompt-audit can be slow on larger codebases. You can let it run in the background and continue to the next step while it works.

Review the report when it finishes. Apply edits that make sense — Claude will not change anything automatically.

Docs: [4]

4

Type /memory in the Claude Code chat panel and press Enter.

CLAUDE.md should appear in the loaded files list. Run /context to see the token breakdown — this shows exactly how much of the context window CLAUDE.md is consuming every session.

Done when
/memory lists CLAUDE.md as loaded.
5

Ask Claude something only your CLAUDE.md knows.

This confirms memory is actually being used, not just loaded. Pick something you added during refinement that Claude cannot clearly infer by reading the code — a known issue, a team convention, a decision that lives nowhere in the source files.

If Claude answers correctly and cites or paraphrases what you wrote — memory is working. If it guesses or says it doesn’t know, check /memory and make sure the session was restarted after /init.

Done when
Claude answers using information from CLAUDE.md — not by inferring it from the code.
Look around — read-only, ~1 min
/memory        — which CLAUDE.md files loaded and from where
/context       — full context window breakdown; see how much CLAUDE.md uses
/status        — which settings files are active this session

No changes needed. These commands are always safe to run.

After this task, you should be able to

  • Initialise project memory with /init and refine it against best-practice criteria
  • Know best practices to keep CLAUDE.md healthy — trimming instructions and when to use /doctor prompt-audit
  • Verify memory loaded and understand its context window cost with /memory and /context

To build on this

  • Auto memory — let Claude manage its own notes → Appendix 1
  • Path-based rules — instructions scoped to specific files or folders → Appendix 2
  • User-level rules — conventions that apply across all your projects → Appendix 3
  • Moving repeated conventions to a skill → Appendix 4

Appendix

1 — Auto memory — Claude-managed notes

Claude can automatically create and update memory notes as you chat. It records things like your preferences, corrections you gave it, and project decisions — and skips anything it can derive from the code.

  1. Check if auto memory is on: run /memory and look for an auto-memory folder. Or check .claude/settings.json for "autoMemoryEnabled": true.
  2. If enabled: chat with Claude about a convention, then explicitly ask it to “remember this”.
  3. Check result: /memory → “Open auto-memory folder”, or browse ~/.claude/projects/<project>/memory/.

The <project> path is derived from the project’s location on disk. See the storage location docs for how the slug is computed.

Docs: [5]  ·  [6]

2 — Path-based rules — load only when needed

A path-scoped rule loads only when Claude touches a matching file — not every session. This keeps context lean for large projects.

A path rule loads when:

  • Claude uses Read, Write, or Edit on a matching file
  • Claude runs a Bash command that reads a matching file (e.g. cat or head on a single file)
  1. Walk through the codebase with Claude — ask it to suggest path-based rules (e.g. conventions for test files, migration files, API handlers).
  2. Create the rule file at the right path (e.g. tests/CLAUDE.md for test-only conventions).
  3. Review it yourself before committing.

Docs: [7]

3 — User-level rules — your personal conventions across all projects

Rules in ~/.claude/CLAUDE.md load for every project you open. Use them for preferences that aren’t project-specific.

Good candidates:

  • Language-wide style you always follow (“always use type hints on public functions”)
  • Personal workflow preferences
  1. Open or create ~/.claude/CLAUDE.md.
  2. Add one or two personal conventions.
  3. Start a new Claude Code session, then run /memory to verify it is listed.

Docs: [8]

4 — When CLAUDE.md conventions belong in a skill instead

If you find yourself explaining the same conventions to Claude over and over — across different projects, sessions, or when onboarding teammates — those instructions may be more suitable as a skill.

A skill is a reusable instruction set you invoke on demand with a slash command (e.g. /pr-review, /house-checks). Unlike CLAUDE.md, which loads every session whether needed or not, a skill only loads when you ask for it. Good candidates:

  • A code review checklist you use on every PR
  • Conventions you want to apply only during refactoring sessions
  • Instructions you want to share identically across multiple projects

Rule of thumb: CLAUDE.md is for “always true about this project.” A skill is for “apply these when I ask.”

Docs: [9]


References

  1. Initializing memory with /init
  2. Keep CLAUDE.md short
  3. Write effective instructions
  4. Audit your instruction files
  5. Auto memory
  6. Storage location
  7. Path-specific rules
  8. User-level rules
  9. Slash commands and skills