Portable Experience Memory Across Claude Sessions and Agents
Preflight Checklist
- [x] I have searched existing requests and this feature hasn't been requested yet
- [x] This is a single feature request (not multiple features)
Problem Statement
When working on large or long-running codebases, Claude Code can solve difficult problems and discover useful project-specific knowledge, but that experience is difficult to reuse across future sessions or different agents.
For example, an agent may spend significant time debugging a difficult issue, trying several approaches before finding the correct solution. The useful outcome is not just the final code change, but knowing what was tried, what failed, what worked, and why.
Today, developers often have to manually preserve this knowledge through CLAUDE.md files, documentation, git history, or by explaining the context again in a new session.
This becomes especially painful when multiple developers or different AI models work on the same project. The experience gained by one agent is effectively isolated instead of becoming reusable knowledge for future agents.
Proposed Solution
I would like Claude Code to support a structured, portable experience memory layer.
After completing a task, Claude Code could optionally extract useful experience such as:
- Problem and context
- Approaches that were attempted
- Approaches that failed
- The solution that worked
- Why it worked
- Relevant files/environment
- Confidence or evidence
This experience could then be stored in a project-level or user-level memory store.
When a future task is started, Claude Code could retrieve relevant previous experiences and use them as additional context.
The important distinction is that this would not be raw conversation history or hidden chain-of-thought. It would be validated, reusable experience derived from completed tasks.
Ideally, this experience should also be portable so that it could be reused by another Claude Code session, another project when appropriate, or even another compatible AI agent.
For example:
Developer A spends 2 hours solving a difficult database race condition.
Claude records:
"Attempted A → failed because X.
Attempted B → failed because Y.
Solution C → worked because Z."
Weeks later, Developer B encounters a similar problem.
Claude can surface that experience and avoid repeating the same failed approaches.
This would allow engineering knowledge to compound over time instead of being lost at the end of individual sessions.
Alternative Solutions
I have considered using CLAUDE.md files, project documentation, git history, and external memory systems.
CLAUDE.md and documentation work well for relatively stable project knowledge, but they require developers or agents to manually maintain them and do not naturally capture the history of failed and successful approaches.
Git history contains valuable information, but it is not structured specifically for agent experience and often does not explain why an approach was tried or rejected.
External memory systems and MCP tools can provide persistent storage, but they still require the agent to explicitly decide what to save and retrieve, and there is no standard representation for portable agent experience.
A first-party experience-memory mechanism in Claude Code could make this workflow much more seamless and provide a foundation for agents that improve from previous work.
Priority
Medium - Would be very helpful
Feature Category
MCP server integration
Use Case Example
A developer is working on a large production codebase with Claude Code.
- Claude Code encounters a difficult database connection bug.
- It tries several approaches. Two fixes fail, but the third approach resolves the issue.
- Instead of only keeping the final code change, Claude records the useful experience:
- What the original problem was
- Which approaches failed
- What ultimately worked
- Why the successful approach worked
- The relevant project/environment context
- Two weeks later, another developer encounters a similar database issue in the same project.
- Claude Code recognizes that a previous task contains relevant experience and retrieves it.
- Claude tells the developer:
"A similar issue was encountered previously. Two approaches were unsuccessful; the previous successful fix was X because Y."
- The developer can then verify the previous solution instead of spending another hour repeating the same failed approaches.
- If the new solution works, Claude can update the existing experience with the new evidence and increase its confidence.
Over time, the project develops a growing body of validated engineering experience that future Claude Code sessions can reuse.
The goal is for Claude Code to not only remember the project, but to learn from the work it has already done.
Additional Context
This feature is related to existing approaches such as CLAUDE.md, project documentation, git history, and external agent-memory systems, but the proposed capability is focused specifically on preserving and reusing validated experience from previous tasks.
A possible experience record could look like:
{
"problem": "Database connection failures",
"attempts": [
{"approach": "Increase timeout", "result": "failed"},
{"approach": "Change connection pool", "result": "failed"},
{"approach": "Fix connection lifecycle", "result": "successful"}
],
"solution": "Fix connection lifecycle",
"reason": "Connections were being prematurely closed",
"confidence": 0.92
}
The main technical consideration is that this should not require transferring model weights or exposing hidden chain-of-thought. The transferable unit would be structured, user-visible experience derived from completed tasks.
Ideally, the experience could be stored at the project level and optionally shared across authorized developers or compatible agents.
I've also been experimenting with this concept through CogniCore, an open-source cognitive infrastructure project:
https://github.com/cognicore-dev/cognicore-my-openenv
The project explores episodic, semantic, and procedural memory, along with reflection and experience reuse for AI agents.
I'm interested in whether a first-party implementation in Claude Code could provide a more seamless and reliable version of this workflow.
Showing cached comments. Read the full discussion on GitHub ↗
3 Comments
Part of this exists today as auto memory: Claude keeps its own notes across sessions (debugging insights, build commands, architecture notes, what worked) in a per-project directory at
~/.claude/projects/<project>/memory/, indexed by aMEMORY.mdfile it loads every session. It's on by default and it's plain Markdown, so it's portable — you can point it at a shared or checked-in location with theautoMemoryDirectorysetting, and subagents can keep their own memory too. Docs: https://code.claude.com/docs/en/memory#auto-memoryWhat isn't there is the structured, validated "problem / attempts / failures / solution / why" extraction step you describe, so leaving this open for that.
🤖 Generated with Claude Code
Thanks for the context on auto memory
the MEMORY.md foundation makes a lot of sense.
The gap you've identified is exactly what I've
been working on: structured extraction of
"problem / attempts / failures / solution / why"
as typed memory objects with semantic retrieval
rather than loading the full file every session.
A few specific things I've built on top:
• Semantic retrieval — surface the 3 most
relevant past failures for the current task
rather than injecting everything
• Rejected-value tombstones — when a solution
is found wrong, it's marked so it never
surfaces again
• 76.7% accuracy at 68 tokens/query in a
500-memory stress test
Would it make sense to prototype an integration
that writes structured typed memories alongside
MEMORY.md natively in Claude Code?
Happy to build a proof of concept this week.