Claude Code loses context between sessions: how to keep a project's decisions and tasks
Every Claude Code session starts with an empty context window: only your CLAUDE.md files and auto memory are loaded at launch, and a long session eventually gets compacted into a summary. To stop losing work, put durable rules in CLAUDE.md, the state of work in progress in a handoff file, and move anything that must be shared with other people or other tools out of the repo, for example into an MCP server.
On Monday, you spend two hours with Claude Code deciding how an online store should handle partial refunds. On Tuesday morning, you open a new session and Claude suggests the exact approach you ruled out the day before. Nothing is broken: this is how the tool normally works. Once you know what is kept and what isn’t, you can choose where to write each piece of information so it survives.
Why every session starts from scratch
The Claude Code docs are blunt about it: each new session starts with a fresh context window, without the history of previous conversations. The context window is everything the model “sees” at a given moment: your messages, its replies, the files it has read, command output, system instructions.
At launch, Claude Code loads only a few things into it:
- your CLAUDE.md files;
- the start of auto memory (the MEMORY.md file);
- information about the environment and the repo’s git status;
- the list of available tools and MCP servers.
Everything said in earlier conversations is not there. Monday’s decision no longer exists for Claude, unless it was written down somewhere Claude reads.
Compaction: when the session itself forgets
The problem also shows up inside a single session. The context window fills up fast, and the docs note that performance degrades as it fills: Claude may “forget” instructions given early on or make more mistakes.
As it nears the limit, Claude Code frees up space automatically. It first clears older tool output, then summarizes the conversation if needed. Your requests and key code snippets are kept, but detailed instructions from early in the conversation can be lost.
After compaction, here is what comes back and what gets lost:
| Item | After compaction |
|---|---|
| CLAUDE.md at the project root | Re-read from disk and re-injected |
| Auto memory, MCP tools | Reloaded automatically |
| Files read or edited during the session | Up to five re-read, most recently edited first; a file that is too long comes back as a reference only |
| CLAUDE.md in subdirectories, path-scoped rules | Summarized with everything else, reloaded when Claude reads, writes or edits a matching file |
| Instructions given only in the conversation | Replaced by the summary, and may be lost |
The docs draw a simple conclusion: a rule that must last goes in CLAUDE.md, not in the conversation.
What Claude Code offers today
CLAUDE.md files, at several levels
CLAUDE.md is a Markdown file you write and Claude reads at the start of every session. It exists at four levels, loaded from broadest to most specific:
- managed policy set by the organization (for example
/etc/claude-code/CLAUDE.mdon Linux), for every user on a machine; - user,
~/.claude/CLAUDE.md, for your preferences across all your projects; - project,
./CLAUDE.mdor./.claude/CLAUDE.md, shared with the team through git; - local,
./CLAUDE.local.md, your personal settings for this project, kept out of git.
The /init command generates a first file from your code, /memory lists and opens the loaded files, and /context shows what is taking up the window.
The limits are well known. Claude treats these files as context, not as enforced configuration. The docs advise staying under 200 lines per file: beyond that, the file costs more context and instructions are followed less reliably. They recommend including project-specific architecture decisions but leaving out information that changes often. A list of tasks in progress does not belong here.
Auto memory
On top of CLAUDE.md, Claude Code takes its own notes: your corrections, your preferences, commands it has learned. Auto memory is on by default in local sessions and is configured with /memory. Notes are stored in ~/.claude/projects/<project>/memory/, one folder per git repository; the first 200 lines or 25 KB of MEMORY.md are loaded every session.
The limits: Claude decides on its own what is worth remembering, and doesn’t write something every session. Above all, this memory stays on your machine: it is not shared across machines, with cloud environments or with your teammates.
Resuming a session
Claude Code saves every conversation to a local file, so you can pick up where you left off:
claude --continue # reopen the most recent conversation in this folder
claude --resume # open the session picker
claude -n refonte-paiement # start a named session
claude --resume refonte-paiement
A resumed session gets its full history back, tool calls included. That’s handy for a task spread over two days. But these transcripts are local, tied to a folder, and deleted after 30 days by default. On Pro and Max plans, when you resume a session of more than 100,000 tokens that has been idle for over an hour, Claude Code offers to restart from a summary: each turn then costs less, but you lose the same detail as with compaction. And the desktop app, claude.ai/code and the VS Code extension each keep their own session list.
Context management commands
/clearempties the context between two unrelated tasks; the previous conversation can still be resumed with/resume./compactreplaces the history with a summary, which you can steer:/compact focus on the API changes.- A “Compact Instructions” section in CLAUDE.md says what must always survive the summary, for example the list of modified files.
Practices that work
A handoff file at the end of each session
One practice is to end a session by asking Claude to write a handoff note. The template from ClaudeCodeLab covers the goal (and what is out of scope), the current state (branch, modified files), what changed and why, what was verified and above all what wasn’t, the risks, and the instruction to give the next session. Its script saves each dated note in a handoffs/ folder. The next session starts by comparing the note with git status, then picks up the checks that were left pending.
The split is clear: CLAUDE.md holds durable rules, the handoff file holds the temporary state of the task.
A decision log
A decision made during a session (“partial refunds stay in the back office, not in the API”) is lost as soon as the session ends. A docs/decisions.md file, with one dated entry per decision, its reason and the options ruled out, keeps you from reopening the debate. You can ask Claude to update it as you go and to re-read it before any change touching that topic.
Split the work
The docs recommend separating exploration, planning and implementation, and having Claude write a spec (SPEC.md) before opening a fresh session to implement it. Short sessions, one per topic and clearly named, get compacted less and leave a more readable trail than one catch-all session.
What’s missing when you’re a team
All these practices rely on files in the repo or on your disk. For one person on one repo, that is often enough. As soon as the team grows or the work spills beyond the code, gaps appear:
- Decisions made elsewhere don’t make it into the repo. The choice agreed with the client in a meeting, or in a conversation on claude.ai, lands in no CLAUDE.md unless someone remembers to copy it over.
- Auto memory and sessions are personal. What Claude learned with you doesn’t help your teammate, and their sessions aren’t yours.
- Handoff files contradict each other. Two people, two branches, two handoff notes: which one is right?
- Tasks have no owner and no shared status. A list in a Markdown file doesn’t say who is on it, or what has moved since yesterday.
- No shared history. It is hard to find out why a rule changed three months ago, or who decided it.
What you need is a place outside the repo, readable by every person and every assistant, where decisions and tasks are written once.
Plugging in shared memory over MCP
MCP (Model Context Protocol) connects Claude Code to an external service: Claude reads and writes there the way it reads your files. For a remote server, the command is:
claude mcp add --transport http <nom> <url>
By default, the server is only available to you in the current project. With --scope user, it is available in all your projects; with --scope project, the configuration is written to a .mcp.json at the repo root, shared through git. If the server requires an OAuth login, run /mcp in Claude Code and follow the steps in your browser.
There are several kinds of servers: open-source MCP memory servers that run on your machine, suited to individual use, or team tools that expose their data over MCP.
Tavimi, for teams
Tavimi is the shared working memory for your team and your AI assistants, over MCP. Each project gets its own space, and you invite people by email. Notes are versioned and filed by category (decision, pitfall, reference), each with its required headings. Tasks carry a status, a due date, an owner and a dated log. When the agent is missing a decision, it asks the question on the task instead of guessing, and a person answers it from the web interface.
The same space is read by Claude Code, by Claude on claude.ai and by Claude Desktop:
claude mcp add --transport http tavimi https://app.tavimi.com/mcp
You then sign in over OAuth with /mcp, checking the spaces the assistant is allowed to see. The How it works page covers the details, and the e-commerce page covers development teams. CLAUDE.md keeps its role for repo rules; Tavimi takes whatever has to be shared beyond it.
FAQ
What people ask us
Where does Claude Code store its auto memory?
In one folder per repository on your machine, under ~/.claude/projects/<project>/memory/, with a MEMORY.md index file. These are Markdown files you can read, edit or delete, and they are not shared across machines or with your teammates.
Should I put my task list in CLAUDE.md?
Better not. The Claude Code docs advise keeping this file short and leaving out information that changes often. A task list changes every day: it belongs in a handoff file, an issue tracker or a tool connected over MCP.
What is the difference between /clear and /compact?
/clear empties the context and starts a fresh conversation; the old one is still saved and can be picked up with /resume. /compact keeps the conversation but replaces it with a summary, which you can steer by adding an instruction after the command.
Can my teammates see an MCP server I add in Claude Code?
Not by default: local scope keeps it to you and the current project. With --scope project, the configuration is written to a .mcp.json file at the repo root, which the team shares through version control. Claude Code asks for approval before using a server declared in that file, and each person then connects to it themselves with /mcp.
Sources
- How Claude remembers your project (documentation Claude Code, Anthropic), accessed October 11, 2026
- How Claude Code works (documentation Claude Code, Anthropic), accessed October 11, 2026
- Explore the context window (documentation Claude Code, Anthropic), accessed October 11, 2026
- Manage sessions (documentation Claude Code, Anthropic), accessed October 11, 2026
- Best practices for Claude Code (documentation Claude Code, Anthropic), accessed October 11, 2026
- Connect Claude Code to tools via MCP (documentation Claude Code, Anthropic), accessed October 11, 2026
- Modèle de handoff Claude Code : garder le contexte pour la prochaine personne ou le prochain agent (ClaudeCodeLab), accessed October 11, 2026