Back to Articles

Claude-Mem: Building Long-Term Memory for AI Coding Assistants with Progressive Disclosure

[ View on GitHub ]
36
AI-Assisted Full Provenance Report →
Claude CodeCopilot
AI Provenance badge [![AI Provenance](https://starlog.is/badge/provenance/thedotmack/claude-mem.svg)](https://starlog.is/provenance/thedotmack/claude-mem)

Claude-Mem: Building Long-Term Memory for AI Coding Assistants with Progressive Disclosure

Hook

Your AI coding assistant forgets everything between sessions, forcing you to re-explain your architecture every single time. Claude-Mem fixes this by giving Claude a memory that actually remembers your last three months of work—and tells you exactly what it costs.

Context

AI coding assistants like Claude Code and GitHub Copilot have a fundamental limitation: they're amnesiac. Each conversation starts from scratch. You explain your microservices architecture on Monday, your database schema on Wednesday, and that weird bug workaround on Friday—and by the following Monday, you're explaining everything again. The context window helps within a session, but cross-session continuity doesn't exist.

This isn't just annoying; it's architecturally expensive. Every new chat requires re-establishing context, burning tokens and time. RAG (Retrieval-Augmented Generation) systems exist for chatbots and document search, but applying them to coding sessions introduces unique challenges: observations are noisy (every file read, git command, and test run generates data), privacy matters (your API keys and credentials are in those logs), and developers need transparency about what context is being injected and what it costs. Claude-Mem tackles these problems by building a persistent memory layer specifically designed for AI coding workflows, complete with compression, embeddings, and what they call 'progressive disclosure'—showing you exactly what memory is being retrieved and how many tokens it's consuming.

Technical Insight

Claude-Mem's architecture centers on three components: an observation capture system, an AI-powered compression pipeline, and a RAG retrieval layer with progressive disclosure. The capture system hooks into IDE tool usage events—when Claude reads a file, runs a command, or executes a test, that observation gets logged. But here's where it gets interesting: instead of storing raw observations (which would be massive and semantically noisy), Claude-Mem uses Claude's API itself to compress these into semantic summaries.

The compression happens asynchronously through a worker service. Raw observations flow into a queue, get batched, and are sent to Claude with a specialized prompt that extracts semantic meaning while discarding noise. For example, instead of storing "Read package.json, read tsconfig.json, ran npm install, 247 packages installed," it might compress to "Developer configured TypeScript project with standard Node.js tooling." This compression happens using the agent-sdk, creating a self-referential system where Claude helps Claude remember.

Here's how you'd configure the memory injection in your Claude Code session:

// .claude/config.json
{
  "memory": {
    "enabled": true,
    "maxTokens": 2000,
    "progressiveDisclosure": true,
    "relevanceThreshold": 0.7,
    "privacy": {
      "excludePatterns": [
        "**/secrets/**",
        "**/.env"
      ]
    }
  }
}

Storage uses SQLite with embeddings for vector similarity search. When you start a new session and ask about your project, Claude-Mem intercepts the query, generates an embedding, performs similarity search against historical summaries, and injects the top-k results into the context. The 'progressive disclosure' feature is brilliant: instead of silently injecting context (which would be opaque and potentially wasteful), it shows you a UI element displaying what memories are being retrieved and their token cost.

// Example of retrieved context injection
[Memory Retrieved: 3 observations, 847 tokens]
1. [2024-01-15] Database migration system (relevance: 0.89)
   - Implemented Knex.js migrations for PostgreSQL
   - Created rollback strategy for production deploys
   [Citation: obs_1234]

2. [2024-01-18] API authentication refactor (relevance: 0.82)
   - Switched from JWT to session-based auth
   - Added Redis for session storage
   [Citation: obs_1267]

The citation system is particularly clever. Each injected memory includes a reference ID that Claude can use in its responses ("As we discussed in obs_1234..."), creating verifiable continuity. You can click citations in the web viewer (localhost:37777) to see the original observations that formed that memory.

Privacy controls use a simple tagging system. Wrap sensitive content in <private> tags and it's excluded from compression and storage:

# This gets stored
$ git commit -m "Add user authentication"

# This doesn't
$ export API_KEY=<private>sk_live_abc123xyz</private>

The cross-IDE support is implemented through MCP (Model Context Protocol) servers, making it work with Claude Code, Gemini CLI, and even OpenCode. There's also an experimental OpenClaw gateway integration that streams observations to Slack/Discord in real-time, which sounds gimmicky but is actually useful for team visibility into what the AI is doing.

Gotcha

The compression dependency on Claude's API is a double-edged sword. Every observation compression requires an API call, which means latency and cost beyond your normal IDE usage. If you're in a heavy coding session generating hundreds of observations, the background compression can lag significantly, and you're paying for those API calls even when you're not actively chatting with Claude. The project documentation doesn't clearly specify compression costs, but based on the agent-sdk usage, you're looking at additional API spend that could be substantial for active developers.

The AGPL 3.0 license is another consideration. If you're building commercial tools or plugins that integrate with Claude-Mem, you'll need to open-source your derivative work or negotiate a different license. For personal use this is fine, but enterprises evaluating this for team deployment need to factor in compliance review. Additionally, the project includes beta features like 'Endless Mode' (continuous context injection without limits) that suggest the stability story isn't complete. The 73K+ star count seems suspiciously high for a TypeScript project of this scope—this could be a metadata error or artificial engagement, so don't let popularity metrics alone drive your evaluation.

Verdict

Use if: You're working on long-term projects (multi-month) where re-explaining context between sessions is a significant pain point, you're comfortable with AGPL licensing for your use case, you want transparency into what context is being injected and its token cost, and you're already paying for Claude API access so additional compression costs are acceptable overhead. The progressive disclosure and privacy controls make this practical for real codebases with actual secrets. Skip if: You're doing short-term or one-off projects where session continuity doesn't matter, you need to avoid external API dependencies or can't tolerate the latency of compression calls, you're in an enterprise environment where AGPL licensing is a non-starter, or you want a fully production-ready solution rather than a beta tool with experimental features. Cursor IDE's built-in context management or Continue.dev might be better fits for those scenarios.

// ADD TO YOUR README
[![Featured on Starlog](https://starlog.is/api/badge/ai-dev-tools/thedotmack-claude-mem.svg)](https://starlog.is/api/badge-click/ai-dev-tools/thedotmack-claude-mem)