AI/TLDR

Claude-Mem

Persistent context across sessions for coding agents

Agent MemoryOpen source
Language
JavaScript
License
Apache-2.0
Coverage
1 story
$npx claude-mem install

Overview

Claude-Mem is an open-source persistent memory system for coding agents. During a session it captures what the agent does — tool calls and their observations — compresses those observations with an AI model into semantic summaries, and stores them locally. When a new session starts, the relevant summaries are injected back in, so the agent begins with knowledge of what happened on the project before rather than from a blank slate.

It is built around lifecycle hooks rather than a library you import. Installing it registers hook scripts (SessionStart, UserPromptSubmit, PostToolUse, Stop, SessionEnd) plus a local worker service that exposes an HTTP API and a web viewer. Observations, sessions and summaries live in a SQLite database, and a Chroma vector database backs hybrid semantic-plus-keyword search over them. The project describes itself as built for Claude Code, and the repository also documents installs for OpenCode, Antigravity CLI and OpenClaw gateways.

Retrieval is deliberately layered to keep token cost down — the project calls this progressive disclosure. Four MCP search tools implement a three-step workflow: `search` returns a compact index of matching observations at roughly 50–100 tokens per result, `timeline` shows what was happening chronologically around a result, and `get_observations` fetches the full detail (roughly 500–1,000 tokens each) only for the IDs you actually chose. The README puts the saving from filtering before fetching at about 10x.

What it does

  • Automatic capture of tool-use observations during a session, summarized and stored without manual intervention
  • Context from previous sessions injected into new ones, with fine-grained configuration over what gets injected
  • MCP search tools (`search`, `timeline`, `get_observations`) implementing a token-efficient three-layer retrieval workflow
  • SQLite storage with FTS5 plus a Chroma vector database for hybrid semantic and keyword search
  • A local worker service with an HTTP API and a real-time web viewer for the memory stream
  • Privacy control via `<private>` tags, which exclude the wrapped content from storage

Getting started

Claude-Mem installs as a plugin with hooks and a worker service, not as a plain npm dependency. The README is explicit that `npm install -g claude-mem` gives you the SDK/library only and does not register hooks — use the installer or the plugin marketplace. Node.js 20+ is required; Bun, uv and SQLite are installed automatically if missing.

Install with the one-line installer

This registers the lifecycle hooks and sets up the worker service.

bashbash
npx claude-mem install

Or install from the plugin marketplace

Run these inside Claude Code, then restart it. Context from previous sessions appears automatically in new ones.

bashbash
/plugin marketplace add thedotmack/claude-mem

/plugin install claude-mem

Search your project history

Use the MCP tools in the intended order: get a cheap index first, then fetch full detail only for the IDs worth reading.

tsts
// Step 1 — search for an index
search(query="authentication bug", type="bugfix", limit=10)

// Step 2 — review the index, pick relevant IDs (e.g. #123, #456)

// Step 3 — fetch full details, batching the IDs
get_observations(ids=[123, 456])

Configure the model, worker and injection settings

Settings live in `~/.claude-mem/settings.json`, created with defaults on first run. It controls the AI model, worker port, data directory, log level and context injection, plus a `CLAUDE_MEM_MODE` workflow/language mode. Restart the agent after changing the mode.

jsonjson
{
  "CLAUDE_MEM_MODE": "code--zh"
}

Commands and code are distilled from the project's own documentation — always check the official repo for the latest.

When to use it

  • Keep a long-running project's history available to a coding agent so it stops re-deriving the same context every session
  • Search back through past sessions in natural language to find when and why a bug was fixed or a decision was made
  • Cut the token cost of memory retrieval by pulling a cheap index first and full observations only on demand
  • Give several agent CLIs a shared, locally-stored record of what has already been tried on a codebase

How Claude-Mem compares

Claude-Mem alongside other open-source agent memory tools AI/TLDR tracks, ranked by GitHub stars.

ToolStarsWhat it does
Claude-Mem★ 93.6kPersistent context across sessions for coding agents
Mem0★ 65.1kA memory layer that you add to existing LLM agents to extract, store, and recall user facts and preferences across sessions using vector, graph, and key-value backends.
MemPalace★ 59kLocal-first agent memory that stores conversations verbatim instead of summarising them, with a structured palace index, pluggable vector backends and an MCP server.
OpenViking★ 36.5kA context database that stores an agent's memories, resources, and skills as one browsable viking:// filesystem with three-tier (abstract/overview/details) on-demand loading.
Graphiti★ 30.8kA library that builds a temporal knowledge graph from an agent's conversations and data so facts can be tracked and queried as they change over time.
Cognee★ 30.6kA graph-native memory engine that turns raw documents and conversations into a queryable knowledge graph for agents that need to build lasting knowledge.
Supermemory★ 29.6kA memory and context engine that ingests information across tools and sessions and can run fully locally, acting as a second brain for AI applications.
agentmemory★ 28.3kLocal memory server for coding agents that captures tool use through lifecycle hooks, consolidates it into four memory tiers, and serves it back over MCP with hybrid BM25, vector, and knowledge-graph search.