This is the single most important mental model for working with AI effectively, and most people get it wrong. Understanding the difference between the context window and memory explains almost every “why did Claude forget?” and “how did Claude know that?” moment.
The one-line version
- The context window is everything Claude can see right now — this session’s messages, files it read, outputs from commands.
- Memory is what Claude remembers across sessions — saved patterns, preferences, and notes.
Context window — the desk
Think of the context window as a desk. Everything Claude is working with right now is spread out on this desk:
- Your messages
- Claude’s responses
- Files it has read
- Command outputs
- Your
CLAUDE.md - System instructions
The desk has a fixed size. When it fills up, older things get pushed off (compressed or dropped). When you /clear, you sweep the desk completely clean.
Key properties:
- Finite size (measured in tokens)
- Session-scoped — wiped when the session ends
- Fills up as you work — long sessions degrade
- Managed with
/clearand/compact
Memory — the notebook
Memory is Claude’s private notebook that persists between sessions. It records patterns it notices about you:
- “This user prefers concise answers”
- “In this project, always use bun instead of npm”
- “When they say ‘deploy,’ they mean staging”
You can explicitly ask Claude to remember things, or it learns them over time. Either way, the notebook carries over to the next session.
Key properties:
- Persists across sessions
- Private to your machine
- Grows over time
- Managed by Claude (you can ask it to forget things)
Side by side
| Context window | Memory | |
|---|---|---|
| Lifetime | This session only | Across all sessions |
| Size | Fixed (fills up) | Grows over time |
| Contains | Messages, files, outputs | Learned preferences, patterns |
| Analogy | A desk | A notebook |
| When it’s gone | Session ends or /clear | Only when explicitly deleted |
| Who manages it | You (/clear, /compact) | Claude (you can ask) |
| Common problem | Fills up with noise → quality drops | Missing a preference → repeats a mistake |
Why this matters
Almost every “Claude got dumb” complaint is really one of two context problems:
-
The desk is cluttered. A long session filled the context window with stale information from earlier tasks. Fix:
/clearbetween tasks,/compactduring long ones. -
The right thing isn’t on the desk. Claude doesn’t have the file, the context, or the instruction it needs. Fix: point it at the right files, write a better
CLAUDE.md, use context engineering.
And almost every “how did Claude already know that?” moment is memory working as intended — it saved something from a previous session and brought it back.
The three persistence layers
Put them together and there are actually three layers:
| Layer | Lifetime | Who writes it | Shared? |
|---|---|---|---|
| Context window | This session | Both (messages + reads) | No |
| Memory | Across sessions | Claude | No (private) |
| CLAUDE.md | Permanent (in repo) | You | Yes (committed) |
The context window is your working desk. Memory is your private notebook. CLAUDE.md is the team’s shared manual. All three feed into what Claude sees, but at different timescales and for different audiences. Managing all three well is what context engineering is really about.