
If Claude Code forgets context between sessions, it is working as designed: every new session, and every /clear, starts with a fresh context window. What you said in the chat is not carried forward. Only files on disk come back automatically, mainly your CLAUDE.md files and Claude’s own auto memory.
The quick fix: to pick up the same conversation, run claude --continue (latest session) or claude --resume (choose one). To make a fact stick for every future session, tell Claude “Remember that…” so it saves the note to auto memory, or say “add this to CLAUDE.md” for a rule the whole team should share. Then check what loaded with /context all or /memory.
We tested every reset in a real session below: exit and continue, /clear, a brand-new session, and a saved memory that came back the next time.
Browse all our Claude Code tutorials for more fixes and how-tos.
Tested with Claude Code v2.1.332 on macOS on November 29, 2026. We used a throwaway demo project called tidy-notes with one tiny Python file, a short CLAUDE.md and a fresh Git repository. We started Claude Code with project and local settings only, and pointed auto memory to a folder inside the demo, so our personal setup stayed out of the test.
We tested on macOS; the Windows and Linux steps follow Anthropic’s official instructions, and the commands and file names work the same way there.
Quick Summary: What Survives in Claude Code
| What you do | Your chat | CLAUDE.md | Auto memory | Tested by us? |
|---|---|---|---|---|
Exit, then claude --continue | Restored | Loaded | Loaded | Yes |
/clear | Gone from context | Loaded | Loaded | Yes |
Start a new claude session | Not loaded | Loaded | Loaded | Yes |
/compact or auto-compact | Replaced by a summary | Re-read from disk | Re-read from disk | From the docs |
| A different computer | Not there | Only if committed to Git | Not there (machine-local) | From the docs |
Why Claude Code Forgets Context
Claude Code keeps everything it knows about your current session in one context window. That window holds the system prompt, your instruction files, the files Claude read, and the whole back-and-forth of your chat. When the session ends or you clear it, that window starts over.
Anthropic’s memory documentation says it plainly: each session begins with a fresh context window, and two things carry knowledge across sessions. Those are CLAUDE.md files, which you write, and auto memory, which Claude writes for itself.
So when it feels like Claude Code “forgot” something, ask one question first: was that fact ever saved to a file? If you only typed it into the chat, it lived in the context window and nowhere else.
Chat is short-term memory. Files are long-term memory. Claude Code only reloads the files.
The two kinds of long-term memory
| CLAUDE.md files | Auto memory | |
|---|---|---|
| Who writes it | You (or Claude when you ask) | Claude |
| What goes in it | Rules and instructions | Learnings, corrections, preferences |
| Where it lives | ./CLAUDE.md, ~/.claude/CLAUDE.md and others | ~/.claude/projects/<project>/memory/ |
| How much loads | The whole file at launch | First 200 lines or 25KB of MEMORY.md |
| Shared with teammates | Yes, if you commit it | No, it stays on this machine |
If you want the full tour of both systems, our memory system guide goes deeper into MEMORY.md, and this post sticks to the “why did it forget?” side.
What We Tested: Four Resets, One Fact
To see what really persists, we gave Claude one fact that lived only in the chat: “our launch date is December 5.” Then we reset the session in different ways and asked for the date again. We kept every prompt tiny, so the whole test used just a handful of short messages.
Test 1: Exit and resume with claude –continue
We told Claude the launch date, typed /exit, and then started again with claude --continue. That flag reopens the most recent session in the current folder, so the old chat came back with it.

Claude answered “December 5.” right away. Resuming does not create memory; it simply reloads the saved transcript, which Claude Code writes to disk as you work.
Test 2: /clear wipes the chat
Next we started a fresh session, gave the same fact, ran /clear, and asked again. This time Claude said we had never given a launch date, and that it found no saved memory of one.

Notice the small “Listed 1 directory” line. Before answering, Claude checked its auto memory folder, which was still empty at that point.
Test 3: Ask Claude to remember
In the same session we typed: “Remember for future sessions: our launch date is December 5.” Claude Code showed “Wrote 2 memories” and confirmed the save. It also added the year on its own and said so, which is a good reason to read what it saved.
Here are the two files it created. MEMORY.md is a one-line index, and the topic file holds the details with a type: project label, matching the four note types in the docs (user, feedback, project and reference).

Test 4: A brand-new session remembers
Finally we exited and started a plain claude session with no resume flag. We asked, “What launch date are we working toward?” and Claude answered “December 5, 2026” instantly, without reading any extra files.

That is the whole fix in one picture. The fact survived because it now lives in a file that Claude Code loads at the start of every session.

How to Fix Claude Code Forgetting Context
Pick the fix that matches what you lost. Fixes 1 to 3 were tested in our session; the rest come from Anthropic’s official docs, and we say so in each one.
Fix 1: Resume the session instead of starting a new one
If you just want yesterday’s conversation back, don’t start a blank session. Use one of these (tested):
claude --continuereopens the most recent session in the current folder.claude --resumeopens a picker of saved sessions;claude --resume <name>jumps straight to a named one./resumeswitches sessions from inside Claude Code./renameorclaude -n <name>gives a session a name you can find later.

The picker also lists sessions you left with /clear, since the docs say sessions are saved continuously and you can return after exiting or clearing. Our guide to resuming Claude sessions covers naming and branching, and if the picker can’t find one, see the failed to load fix.
Fix 2: Ask Claude to remember it
For a personal fact or preference you want in every future session, say “Remember that…” (tested). According to the docs, Claude saves it to auto memory, and the first 200 lines or 25KB of MEMORY.md load at the start of each session.
If nothing gets saved, check that auto memory is on. Open /memory and look at the toggle at the top. You can also turn it off per project with "autoMemoryEnabled": false in .claude/settings.json, or everywhere with the CLAUDE_CODE_DISABLE_AUTO_MEMORY=1 environment variable, so make sure neither is set by accident.

Auto memory is per repository and shared by all worktrees of the same Git repo. A folder outside Git gets its own memory, so moving a project to a new path can make it look empty.
Fix 3: Put project rules in CLAUDE.md
Team conventions, build commands and “always do X” rules belong in CLAUDE.md, not in the chat. Ask Claude “add this to CLAUDE.md” or open the file from /memory. The docs say Claude gets the whole of each CLAUDE.md that loads at launch (up to 4 MiB), and Anthropic suggests keeping each file under 200 lines.
To confirm both kinds of memory loaded, run /context all (tested). In our session the Memory files section listed CLAUDE.md and memory/MEMORY.md.

If a file you expect is missing from that list, read our fix for when Claude ignores CLAUDE.md, and check the right spot in our guide to every CLAUDE.md location.
Fix 4: Know what compaction keeps (from the docs)
Long sessions compact automatically, and you can run /compact yourself. Compaction replaces the conversation with a summary, so details you only said in chat can get squeezed out.
The context window docs list what comes back: the project-root CLAUDE.md and auto memory are re-injected from disk, and up to five recently used files are re-read. Rules with paths: frontmatter and nested CLAUDE.md files only return when Claude touches a matching file again.

Before a big compaction, steer it with /compact focus on the auth bug fix style instructions. Our comparison of clear versus compact explains when to use each, and you can also control auto-compact if it fires at bad moments.
Fix 5: Keep MEMORY.md short (from the docs)
Only the first 200 lines or 25KB of MEMORY.md load, whichever comes first. The docs say anything past that limit is dropped on the next load, and Claude Code warns Claude to tidy the index when it gets close.
Open the folder from /memory now and then. Delete stale lines and merge duplicates, because it is all plain markdown you can edit.
Fix 6: Pass your launch flags again when you resume (from the docs)
Sometimes the chat comes back but tools seem missing. The sessions docs say claude --continue and claude --resume don’t restore flags like --mcp-config, --plugin-dir, --add-dir, --settings or --allowedTools, so add them again.
Fix 7: Mind the other limits (from the docs)
- Old transcripts are deleted after the
cleanupPeriodDayssetting, but memory files are excluded from that cleanup. - Auto memory is machine-local, so a new laptop or a cloud session won’t see it. Commit
CLAUDE.mdto carry rules across machines. - Subagents don’t get the main session’s auto memory, except a fork, which inherits the parent conversation.
- Sessions run with
claude -pdon’t appear in the picker or inclaude --continue; resume them by session ID.
Where Should Each Fact Live?
Most “Claude Code forgets” problems disappear once each fact sits in the right place. Use this ladder when you’re about to type something important into the chat.

Remember that both CLAUDE.md and auto memory are context, not enforced settings. The docs point you to hooks or deny rules when something must happen every single time.
Try It Yourself
Make a small test folder, run git init, start claude, and paste this prompt. Then run /clear and ask about your stack again to see the memory at work.
Remember for future sessions: in this project we use pnpm, not npm,
and tests run with "pnpm test". Then tell me which memory file you saved it to.Next, open /memory, pick the auto memory folder and read the file Claude wrote. Edit one word yourself and start a new session to see your change loaded.
Common Mistakes
- Starting a blank
claudesession when you meant to continue; useclaude --continueinstead. - Typing team rules into chat every morning instead of saving them to
CLAUDE.md. - Assuming
/cleardeletes your history; it only clears the context, and the old session stays in/resume. - Letting
MEMORY.mdgrow past 200 lines, so the newest notes never load. - Expecting auto memory on a second computer; it never leaves the machine.
- Putting a must-keep rule in a
paths:rule file and losing it after compaction.
Pro Tips
- Name long-running work with
/rename, soclaude --resume auth-refactorfinds it in one step. - Before a long task, ask Claude to write its plan into a file; our guide to planning with files shows the pattern.
- Check your context budget with
/context; our walkthrough of the context window explains each line. - Use
autoMemoryDirectoryin settings if you want auto memory in a folder you back up. - Review saved memories weekly; Claude can guess details, like the year it added in our test.
Cheat Sheet

Frequently Asked Questions
Does Claude Code remember previous conversations?
Not on its own. A new session starts fresh, but the old conversation is saved, so claude --continue or claude --resume brings it back. For facts that should load every time, use auto memory or CLAUDE.md.
Does /clear delete my conversation?
No. It clears the context so Claude stops seeing the old chat, but the session stays saved and appears in the /resume picker. CLAUDE.md and auto memory still load after /clear.
Where does Claude Code store its memory?
Auto memory lives in ~/.claude/projects/<project>/memory/ by default, with a MEMORY.md index plus topic files. You can move it with the autoMemoryDirectory setting.
Why did Claude forget my instructions after compaction?
The instruction was probably only in the chat, or in a nested CLAUDE.md or paths: rule that hasn’t reloaded yet. Move it to the project-root CLAUDE.md, which is re-read from disk after compaction.
Can I turn auto memory off?
Yes. Use the toggle in /memory, set autoMemoryEnabled to false in a project’s settings, or set CLAUDE_CODE_DISABLE_AUTO_MEMORY=1. For other errors, see our list of common Claude errors.
Conclusion
Claude Code forgets context between sessions because each session, and each /clear, starts with a fresh context window, and only files on disk are loaded back in. In our test, claude --continue brought the old chat back, /clear lost the fact, and one “Remember that…” prompt saved it to auto memory so a brand-new session answered correctly. Keep team rules in CLAUDE.md, personal notes in auto memory, and must-happen rules in hooks, and Claude will stop forgetting what matters. For more on the model behind it, see our Claude AI overview.


