

How Claude Uses Context and Memory
Context, Compaction, and Memory: Where Claude Gets Information to Answer You
Claude's answers come from three sources: knowledge learned during training, information in the current conversation (called context), and notes saved for later (called memory). When Claude answers wrong, it's almost always because the context is incomplete, wrong, or low quality, not because it's trying to deceive you. Understanding these three sources helps you predict where AI might fail, see where your tokens go, and know when starting a fresh conversation is faster and cheaper.
New to Claude? Start with What is Claude AI?.
Understand with a Real-World Example
Imagine Claude is an expert advisor sitting at a desk:
- In their mind is knowledge built from thousands of books read. Common topics they remember well, rare topics they remember vaguely.
- On their desk is a file you just handed over: your question, documents, notes. The desk has limited space. If files pile up, they summarize into one page and file away the originals.
- In their notebook are a few lines about you: your profession, how you like to discuss things. Next time you visit, the advisor reads the notebook first.
These three correspond to Claude's three information sources.
How It Works
Source 1: Knowledge Built Into the Model
Sometimes Claude simply knows something because that knowledge was in the model from training. But nobody aimed to build an encyclopedia. Remembering facts is only a side effect of learning to predict the next word. Since it's a side effect it's uneven: common topics are thick and accurate, rare or new topics are thin and error-prone. Read more in 4 Traits of Generative AI.
Source 2: Context, the Desk with Limits
Context is everything in your conversation: your question, files you attach, search results pulled in. Giving more documents is the easiest way to turn a hard problem into an easy one. Generally giving everything you might need works, but you hit a limit called the context window.
The strongest Claude models hold up to about one million tokens, roughly three thick novels. So why do some people hit the limit before using one percent of that? Because most context isn't words you typed. A small example on a 1,000-token window:
| Context Element | Token Count |
|---|---|
| Your question | 28 |
| System instructions included beforehand | 345 |
| Search results Claude pulled in | 184 |
Real numbers are larger but the ratio is similar: most of what you pay for is context you didn't write. To understand how tokens are counted, see What is a Token?.
One important point: every message you send includes the entire conversation from the start, including hidden context you don't see. So a short question at the end of a long session costs more than that exact question in a fresh session.
When the Desk Fills Up: Summarize to Keep Going (Compaction)
When context approaches its limit, the app doesn't send right away but does three things:
- Notices it's nearly full: holds your new question.
- Asks Claude to summarize: feeds the entire conversation with a request to summarize everything that happened.
- Continues from the summary: the summary replaces old history, then your held question gets sent.
Early versions of this lost detail noticeably: instructions from before summarizing usually didn't survive. Now it's much better, but a summary is still a summary, details can still slip away. That's why long work should split into sessions, and repeat key requests in each new part.
Source 3: Memory, Notebook Across Many Sessions
Summarizing helps one session go further. Memory helps important information go across many sessions.
Simple mechanism: Claude writes a few things to a place, and in the next session those notes get inserted into context before your first message. Tuesday you mention you like brief reports, Claude notes it. Friday you start fresh, say nothing, Claude still knows.
Every product sets this up differently. On claude.ai, memory is in settings. Claude Code (Claude's programming tool) reads instruction files on your machine:
CLAUDE.mdin the project folder: project-wide conventions, can share with team..claude/rules/folder in the project: more detailed rule groups.~/.claude/CLAUDE.mdin your home: personal preferences, applies to all projects.- Session history is also saved in
~/.claudefolder.
Different locations, same process: write it down, read it again next time. Security note: session history can contain file contents Claude read and text you pasted, so don't have the tool read or print passwords and secret keys when you don't need them.
What This Means for You
Choose the right things for memory. Worth saving: things that last: your project, conventions, how you like to work, who's on your team. Don't save things that change quickly: party RSVP counts, supplier quotes. Those should be looked up fresh next time, don't write and hope they haven't changed.
Understand preset context vs self-fetched context. Before Claude sees your first word, many things are in context: system instructions, tool descriptions, memory notes. Then each turn, Claude decides to answer from what exists or go fetch more (web search, read files, use tools). When you pick high effort level, it searches and checks more, answers are better but use more context. Low level answers directly.
Four habits to take:
- Put important context at the top, don't bury instructions in long documents.
- Split long work into sessions, independent questions get fresh sessions instead of continuing old ones.
- Build permanent context for recurring work: Projects on claude.ai,
CLAUDE.mdin code projects, template files attached beforehand. - Don't count on it remembering your edit. If it's not in context, it's not there.
Example opening a new session to continue unfinished work:
I'm writing a quarterly report for the business department. Sections 1 and 2 are done (summary attached). Keep these rules: formal tone, each section max 300 words, numbers from attached file. Now writing section 3 on [topic].
Common Misunderstandings
Misunderstanding 1: "Claude remembers everything I've ever said." Truth: in one session it only sees what's still in context, and long sessions may have been summarized. In a different session it only knows what's in memory.
Misunderstanding 2: "Short questions use few tokens." Truth: each message sends the whole conversation. A short question at the end of a long session still costs many tokens.
Misunderstanding 3: "With a million-token window I should cram everything in." Truth: more isn't always better. Key instructions buried in large blocks of text get overlooked. Lean, focused context usually works better.
Frequently Asked Questions
What is Claude's context?
Everything Claude sees in your conversation: your question, attachments, search results, plus system instructions included beforehand.
What is compaction?
When an app summarizes your conversation as the context window fills, so the session can continue. The summary may lose details.
How is memory different from context?
Context lives only in one session. Memory is notes saved and inserted at the start of future sessions, helping Claude remember lasting information about you.
Why start a new session instead of asking more?
A new session doesn't resend long history, so it's faster, cheaper, and less affected by old instructions interfering.
What should I write in memory or CLAUDE.md?
Lasting information: your project, conventions, how you like to work. Don't write quick-changing data like prices or temporary lists. Look those up fresh next time.
Related: Context Windows Explained | Understanding Tokens | 4 Traits of Generative AI
More articles

Why Japan Is Building Its Own AI Instead of Just Using ChatGPT or Gemini

Use AI to Write Trending Captions Without Losing Your Brand Voice

Use Claude to Write a Freelancer Job Post on Upwork and Fiverr in 15 Minutes

AI Builds Software From a Raw Idea: Inside Cole Medin's "AI Software Factory"

What Is PII Redaction in AI? How Chatbots Mask Your Personal Data

Use Claude to Check and Fix Citations in Your Essay or Report in 15 Minutes