ع
Learn Tracks Reference Guides Saved
Compare & decide

Context window vs Memory in Claude

Understanding this distinction is the single most clarifying thing for anyone who's ever wondered why Claude 'forgot' something or why it 'knows' something you never told it this session.

4 min read · Updated 2026-06-16
Context window vs Memory in Claude

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 /clear and /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 windowMemory
LifetimeThis session onlyAcross all sessions
SizeFixed (fills up)Grows over time
ContainsMessages, files, outputsLearned preferences, patterns
AnalogyA deskA notebook
When it’s goneSession ends or /clearOnly when explicitly deleted
Who manages itYou (/clear, /compact)Claude (you can ask)
Common problemFills up with noise → quality dropsMissing a preference → repeats a mistake

Why this matters

Almost every “Claude got dumb” complaint is really one of two context problems:

  1. The desk is cluttered. A long session filled the context window with stale information from earlier tasks. Fix: /clear between tasks, /compact during long ones.

  2. 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:

LayerLifetimeWho writes itShared?
Context windowThis sessionBoth (messages + reads)No
MemoryAcross sessionsClaudeNo (private)
CLAUDE.mdPermanent (in repo)YouYes (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.

Topics

Questions people ask

If I told Claude something last session, does it remember?
Only if it saved it to memory or if it's in your CLAUDE.md. The context window is wiped between sessions. What persists is what was explicitly saved — memory, CLAUDE.md, and your files on disk.
Why does Claude seem to 'forget' things during a long session?
The context window is finite. In a long session, older messages get compressed or pushed out. That's why /compact (summarise) and /clear (reset) exist — to manage this limited space.
Is the context window the same as memory?
No, and this is the most common misconception. The context window is session-scoped working memory — like a desk you're working at. Memory is a notebook Claude keeps across sessions. They serve different purposes and have different lifetimes.
Put it into practice
Take the guided course
Start