What actually sticks across sessions
The Claude Code memory system automatically creates structured notes about projects and user preferences that persist across individual sessions, independent of the current context window. Unlike a manually maintained CLAUDE.md file, memory often emerges incidentally from feedback and recurring corrections, which makes control, traceability, and privacy central questions.
Table of Contents
- 1. What the memory system is and how it differs
- 2. How memories are created and updated automatically
- 3. Structure of memory files: layout and storage location
- 4. When Claude Code remembers something and when it does not
- 5. Deliberately steering and correcting your own memories
- 6. Memory across several projects and sessions
- 7. Privacy and control: what ends up in memory
- 8. Limits of the memory system in practice
- 9. Memory compared with CLAUDE.md and the context window
- 10. Summary
- 11. FAQ
1. What the memory system is and how it differs
The memory system in Claude Code describes the ability to automatically create structured notes about projects, user preferences, and recurring corrections, and keep them available across sessions. This differs fundamentally from a manually written CLAUDE.md file: while CLAUDE.md is deliberately authored by the developer and committed to the repository, memory often emerges incidentally, from a correction in a conversation or from repeated feedback about a certain approach.
The key difference from a single session's context window is persistence. A conversation's context window is lost once it ends, everything that was not explicitly saved must be explained again in the next session. The memory system solves exactly this problem by extracting relevant information from a session and storing it in a form accessible again in upcoming, completely new sessions, without the user having to state it again.
2. How memories are created and updated automatically
A memory in the memory system typically emerges from a recurring pattern: if a user corrects the same aspect of a response repeatedly, such as a preferred formatting or a certain technical approach, the system recognizes this pattern and records it as a note. Unlike a one-off correction within a session, which only applies to the current context, a repeated pattern becomes a lasting preference that gets automatically taken into account in future sessions.
The update logic matters here: an existing memory in the memory system does not simply get duplicated when a preference changes, instead the original note gets overwritten or refined. If a new observation clearly contradicts an old memory, for instance when a project switches from one framework to another, the outdated information should be replaced rather than letting both contradictory notes exist in parallel. This is exactly one of the points where manual review and deliberate correction remain worthwhile.
# Simplified illustration of the update logic behind the memory system
# 1. A pattern repeats across several turns in a conversation
# 2. The system checks whether a related memory note already exists
# 3. Existing note found -> refine or overwrite it, do not duplicate
# 4. No note found -> create a new one with a timestamp and source context
# Example: a preference gets confirmed for the third time
echo "User confirmed again: prefers Repository pattern over direct Model access"
# -> existing note in project_seosuite.md gets updated, not duplicated
3. Structure of memory files: layout and storage location
Technically, memories are stored as simple, readable Markdown files, similar to CLAUDE.md, but at a separate storage location outside the project repository. This is deliberate: while CLAUDE.md gets shared with the team and version controlled, the memory system usually stays personal and cross project, it belongs to the user, not to the repository. Every note is readable in plain text, there is no hidden database or proprietary binary format.
This readability has a practical benefit: anyone who wants to know exactly what is stored in the memory system about a specific project can open the corresponding file directly and review it, instead of relying on a black box. The excerpt below shows, as an example, how such an automatically maintained memory note can be structured, with a clear source reference and timestamp for traceability.
# Inspecting where Claude Code stores memory notes
ls -la ~/.claude/projects/*/memory/
# Example structure of a memory file for a specific project
cat ~/.claude/projects/-home-user-projects-mironsoft/memory/project_seosuite.md
# Project: Mironsoft_SeoSuite
## Current status (last updated 2026-07-28)
- Core module structure done: ViewModels, Repositories, ACL, system.xml
- Missing: hreflang tag generation for category pages
- Next step: add unit tests for the meta description generator
## Recurring preference
- User always wants full file paths mentioned when creating new files
- User prefers Repository pattern over direct Model access
4. When Claude Code remembers something and when it does not
Not every statement in a conversation turns into a lasting memory in the memory system. One-off, context specific details, such as a particular error message relevant in exactly that moment, stay inside the respective session's context window and do not get persisted. What actually gets recorded as a memory are recurring patterns: preferences confirmed multiple times, project status information that remains relevant for future work, and explicit user instructions to remember something permanently.
The distinction between an incidental remark and an actual preference is decisive for the quality of the memory system. A one-off decision for this one task should not automatically become a general rule for all future tasks. Anyone who explicitly wants something remembered permanently should state that explicitly too, rather than trusting that every incidental remark automatically becomes a memory note.
5. Deliberately steering and correcting your own memories
Since memory files exist as readable Markdown files, they can be edited directly and manually, exactly like a CLAUDE.md file. If an automatically created memory in the memory system is outdated or simply wrong, it can be opened and corrected without waiting for an automatic update. This is especially important when a project changes fundamentally, such as a switch from one framework to another, and the old memory would otherwise keep feeding wrong assumptions into future sessions.
A second way of actively steering memory is an explicit instruction within a conversation, such as "remember for future sessions that this project exclusively uses the repository pattern instead of direct model access". Such explicit instructions get recorded more reliably in the memory system than incidental remarks, because the intent to store something permanently is clearly recognizable. Regular, deliberate review of memory files, similar to a code review, prevents outdated or contradictory notes from accumulating unnoticed.
# Manually correcting an outdated memory note after a framework switch
cd ~/.claude/projects/-home-user-projects-mironsoft/memory/
# Open the relevant file directly in an editor
$EDITOR project_seosuite.md
# Or correct it via a quick inline replacement
sed -i 's/uses Symfony Console commands/uses Magento CLI commands/' \
project_seosuite.md
# Verify the correction took effect
grep -n "CLI commands" project_seosuite.md
6. Memory across several projects and sessions
The memory system typically distinguishes between project specific notes relevant only to a particular repository and cross project preferences concerning a user's general working style. A note like "this project uses PHP 8.4 with constructor property promotion" clearly belongs to the respective project, while a preference like "explanations in German, code comments in English" applies across projects and should be taken into account in every session, regardless of the current repository.
This separation matters so that memory does not turn into an unmanageable pile of project specific details wrongly applied to a different project. Anyone working on several, technically different projects at once, such as a Magento project and a separate React project, benefits from the memory system correctly separating project specific details instead of wrongly carrying a technology preference from one project over to a technically completely different one.
7. Privacy and control: what ends up in memory
Because the memory system extracts information from conversations and stores it permanently, control over what actually gets stored is a legitimate privacy concern. Sensitive information, such as credentials, internal customer data, or confidential business details, should fundamentally never be part of a conversation from which memories get extracted, regardless of whether the memory system is active or not. This caution applies to any AI backed development environment, not specifically only to Claude Code.
Since memory files exist as readable plain text files on the local file system, they are subject to the same access permissions as any other local file. Anyone working on shared machines or in shared environments should include these storage locations in their own backup and access control considerations, just like other local configuration files. Regularly reviewing memory files therefore serves not only quality assurance but also control over what information has actually been permanently stored.
# Checking access permissions on the local memory directory
ls -ld ~/.claude/projects/*/memory/
stat -c "%A %U %n" ~/.claude/projects/*/memory/*.md
# Restricting access on a shared machine (owner-only read/write)
chmod 700 ~/.claude/projects/*/memory/
chmod 600 ~/.claude/projects/*/memory/*.md
8. Limits of the memory system in practice
The memory system does not replace deliberately maintained project documentation. While memory emerges incidentally from conversations, fundamental architecture decisions, coding standards, and team conventions should still be explicitly documented in CLAUDE.md, because that file is version controlled, shared with the team, and visible during pull request review when needed. Memory complements this deliberate documentation but does not replace it.
Another practical limit: the memory system can only recognize patterns that actually appear within conversations. A preference never explicitly stated or corrected also does not get remembered automatically, no matter how self-evident it might seem to the user. Anyone who wants a certain rule reliably followed should either have it explicitly recorded in the memory system or, for security critical rules, better implement it directly as a hook that takes effect deterministically, independent of memory state.
9. Memory compared with CLAUDE.md and the context window
Three different mechanisms carry information beyond a conversation or within it, with different reach and different degrees of control.
| Mechanism | Persistence | Control | Team visibility |
|---|---|---|---|
| Context window | Only during the session | Implicit through conversation | Not shared |
| Memory system | Across sessions | Automatic, manually correctable | Personal, not version controlled |
| CLAUDE.md | Permanent, version controlled | Fully manual | Shared in the repository |
The table shows the complementary roles: the context window covers the immediate moment, the memory system carries incidentally formed, personal preferences across sessions, and CLAUDE.md remains the deliberately maintained, version controlled place for everything the entire team should know and follow. Anyone who consciously uses all three levels instead of mixing them up gets an overall system where every piece of information ends up in the right place.
Mironsoft
Claude Code setup, context management and Magento/Hyva development with AI
Integrating Claude Code sensibly into your team setup?
We help you cleanly separate memory, CLAUDE.md, and the context window, so knowledge permanently ends up where it brings the most value to your team.
CLAUDE.md structure
Documenting team conventions cleanly instead of relying on memory
Privacy consulting
Keeping sensitive data out of conversations and memory files
Context audit
Reviewing existing memory files and cleaning up outdated notes
10. Summary
The Claude Code memory system automatically records recurring preferences and project status across individual sessions, stored as readable Markdown files outside the repository. Unlike CLAUDE.md, which is deliberately authored and shared with the team, memory often emerges incidentally from repeated corrections and explicit feedback, but stays personal and not version controlled.
Manual control remains important: outdated or wrong memories can be corrected directly in the memory files, sensitive information should never be part of conversations in the first place. For permanent, team wide rules, CLAUDE.md remains the right level, for security critical rules a deterministic hook. Anyone who consciously uses the context window, the memory system, and CLAUDE.md as three distinct tools uses Claude Code more efficiently and more traceably.
The Claude Code Memory System — The Essentials at a Glance
Core idea
Automatically created, readable Markdown notes that persist across sessions.
Distinction
Personal and incidentally formed, unlike deliberately maintained, shared CLAUDE.md.
Control
Direct manual editing of memory files and explicit instructions within the conversation.
Privacy
Sensitive information should never be part of conversations, regardless of memory state.