claude-code icon indicating copy to clipboard operation
claude-code copied to clipboard

Feature Request: Advanced Memory Tool for Claude Code

Open pheuter opened this issue 1 year ago • 9 comments

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

  1. Remember build/test/lint commands used in the project
  2. Store project architecture knowledge for better code navigation suggestions
  3. Remember user's preferred patterns for implementing specific features
  4. Track domain model and design patterns across the codebase

pheuter avatar Feb 25 '25 17:02 pheuter

Let me noodle on this!

bcherny avatar Feb 25 '25 20:02 bcherny

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.

travelingflwr avatar Apr 12 '25 17:04 travelingflwr

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

gianpaj avatar Jun 08 '25 06:06 gianpaj

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?

anuramat avatar Jun 08 '25 18:06 anuramat

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.

PaulRBerg avatar Sep 02 '25 21:09 PaulRBerg

Closed via PR #292

RobEasthope avatar Nov 27 '25 15:11 RobEasthope