Feature Request: Advanced Memory Tool for Claude Code
Description
Claude Code already supports a basic form of memory through CLAUDE.md files, but this feature could be significantly enhanced to provide a more sophisticated memory system for code assistants. This would allow Claude to save and retrieve important information about codebases across sessions.
Current Implementation
Currently, Claude Code can read from a CLAUDE.md file if it exists, which serves as a rudimentary memory. However, this requires:
- Manual creation and maintenance of the file by users
- Explicit assistance from Claude to suggest additions
Proposed Enhancements
1. Persistent Memory Tool
Add a dedicated memory tool that allows Claude to:
- Store and retrieve information about the codebase without modifying files
- Maintain a structured database of codebase knowledge
- Access this knowledge across different sessions with the same repository
2. Automatic Learning
Enable Claude to automatically:
- Identify important patterns, conventions, and structures in the codebase
- Remember frequently used commands and workflows
- Learn user preferences for code style, naming conventions, etc.
- Store location of important files and their purposes
3. Memory Management Interface
Provide users with:
- Commands to view what Claude has remembered about their codebase
- Options to correct or update Claude's understanding
- Ability to explicitly teach Claude about codebase specifics
- Export/import memory for sharing with team members
4. Context-Aware Retrieval
Implement smart retrieval that:
- Prioritizes relevant information based on current task
- Surfaces similar patterns from elsewhere in the codebase
- Suggests best practices based on observed patterns
Benefits
- Reduced onboarding time for Claude to understand a codebase
- More consistent code generation matching project conventions
- Better assistance with complex codebases where context is spread across many files
- Improved project-specific recommendations without constant retraining
Technical Considerations
- The memory could be stored locally within the repository (e.g., in
.claude/directory) - Provide user controls for privacy (what is/isn't remembered)
- Optional git-ignore patterns for teams who don't want to share memories
Use Cases
- Remember build/test/lint commands used in the project
- Store project architecture knowledge for better code navigation suggestions
- Remember user's preferred patterns for implementing specific features
- Track domain model and design patterns across the codebase
Let me noodle on this!
It would be really nice if this persistent memory could be shared with Claude desktop somehow.
I currently use a memory MCP server for this but built in would be nice.
It would be great to have a memory, for example, for a computer-wide AI assistant.
It will know where my projects are, what my preferred programming language is, and where to push code to. What libraries do I prefer for Node.js, Python, etc?
Thinking in these terms after reading this blog post https://steipete.me/posts/2025/claude-code-is-my-computer
what about updating CLAUDE.md more often for starters? e.g.:
- add a new slash command, that essentially runs
/init, prepending to the context the output of git diff so that only the changes have to be in the context:git diff $(git log -1 --format=%H CLAUDE.md) - wrap that in a tool, instruct the the model to use it after finishing a task
- hardcode a periodic diff (
--numstat/--shortstat) check?
This feature would be incredibly helpful and I urge the Anthropic team to consider implementing this soon - it will be a massive QoL improvement and it will boost productivity for CC users.
My problem: having to selectively import some files in CLAUDE.md based on some environment variables. At the moment, I have some custom scripts that override my root CLAUDE.md, but this is bad UX.
It would great if I could add <!-- claude-ignore --> comments in CLAUDE.md and have Claude ignore the sections embedded within tags like that.
Closed via PR #292