Backend Foundation

Memory System

Global vs local memory, the ~/.claude/ directory, and how Claude persists knowledge across sessions without ballooning your context.

Two Scopes

Global memory vs project memory

Claude Code's memory system has two layers. Global memory lives in ~/.claude/ and applies to every session on your machine. Project memory lives in .claude/ inside your repo and applies only when you're in that project.

LocationWhat it holds
~/.claude/Global: your preferences, cross-project skills, personal shortcuts
.claude/Project: repo-specific rules, team conventions, project context
PriorityProject memory wins over global when they conflict
Mental model: Global memory is your personal IDE settings. Project memory is the .editorconfig that overrides them for a specific repo.
~/.claude/ Structure

What lives in your global config

~/.claude/
├── CLAUDE.md              # Global instructions for every session
├── settings.json          # Plugins, model preferences, feature flags
├── skills/                # Personal skill library
│   ├── advisor.md
│   ├── systematic-debug.md
│   └── ...
├── projects/              # Per-project memory indexes
│   └── my-project/
│       └── MEMORY.md      # Index of project memories
└── memory/                # Persistent facts across sessions
    ├── user-preferences.md
    ├── project-context.md
    └── ...
What NOT to put in global CLAUDE.md: Project-specific paths, team names, or repo conventions. Those belong in the project .claude/CLAUDE.md. Global instructions should be universally true.
Memory Types

Four types of memory Claude can store

TypePurpose
userYour role, expertise level, preferences — helps Claude tailor responses to you
feedbackCorrections and confirmations — what to avoid and what worked. Most important type.
projectGoals, decisions, deadlines — non-obvious context behind the work
referenceWhere information lives: Linear project IDs, Grafana dashboards, Slack channels
What NOT to save in memory: Code patterns, file paths, git history, architecture decisions that are visible in the code. Memory is for things not derivable from the repo. If it's in the code, don't duplicate it in memory — that creates stale copies.
Practical Usage

When Claude reads and writes memory

Memory is read at session start when it seems relevant and written when Claude learns something worth persisting. For the memory system to work well, you need to close the loop on feedback actively.

OperationBehaviour
ReadingAt session start when memories seem relevant to the task
WritingWhen you correct Claude or explicitly ask it to remember something
ExpiryNo automatic expiry — you own stale memory cleanup
VerificationAlways verify a recalled memory against current code before acting on it
55 Tech practice: At the end of every major backend session, say "what did you learn this session that's worth remembering?" Claude will propose memories for you to confirm or reject. This 2-minute habit compounds into a dramatically better-calibrated assistant over months.
Check your understanding
1. When global and project memory conflict, which wins?
Correct.Not quite. Project memory (.claude/) wins over global memory (~/.claude/) when they conflict — like .editorconfig overriding global IDE settings.
2. Which memory type should you use for "Claude got burned last quarter when mocked tests passed but the prod migration failed"?
Correct.Not quite. This is a feedback memory — a correction about testing approach with a reason. Feedback memories prevent the same mistake from happening in future sessions.
3. What should you NOT store in the memory system?
Correct.Not quite. Don't duplicate what's in the code. Code patterns, file paths, and architecture visible in the repo go stale in memory and cause confusion. Memory is for things not derivable by reading the codebase.