$git clone https://github.com/sdsrss/claude-mem-litePersistent long-term memory for Claude Code via MCP — captures coding decisions, bugfixes, and context across sessions. Hybrid FTS5 + TF-IDF search with episode batching. Single SQLite DB, no external services. Alternative to claude-mem with 600x lower cost.
| 1 | [English](README.md) | [中文](README.zh-CN.md) |
| 2 | |
| 3 | # claude-mem-lite |
| 4 | |
| 5 | `claude-mem-lite` is a **persistent memory** (also called *long-term memory* or *cross-session context*) system for **[Claude Code](https://docs.anthropic.com/en/docs/claude-code)** — Anthropic's CLI coding agent. It runs as an **[MCP](https://modelcontextprotocol.io/) server** plus a set of Claude Code hooks, automatically capturing coding observations, decisions, and bug fixes during sessions, then providing hybrid full-text + semantic search to recall them later. |
| 6 | |
| 7 | Compared to general-purpose LLM memory frameworks like [`mem0`](https://github.com/mem0ai/mem0) or the MCP reference [`memory`](https://github.com/modelcontextprotocol/servers/tree/main/src/memory) server, claude-mem-lite is purpose-built for Claude Code's hook lifecycle: episode batching cuts LLM calls 7–10× vs the original [claude-mem](https://github.com/thedotmack/claude-mem) (an estimated ~600× lower total cost — see the cost model below; this is an architecture estimate, not a measured benchmark), while the hybrid FTS5 + TF-IDF retriever benchmarks at 0.88 Recall@10 / 0.96 Precision@10. |
| 8 | |
| 9 | > 中文简介:claude-mem-lite 是 Claude Code 的轻量级**持久化记忆 / 长期记忆 / 跨会话上下文**插件,基于 MCP 协议 + 钩子机制,自动捕获编码会话中的决策、修复和上下文,并通过 FTS5 + TF-IDF 混合检索召回。详见 [中文 README](README.zh-CN.md)。 |
| 10 | |
| 11 | Zero external services. Single SQLite database. Minimal overhead. |
| 12 | |
| 13 | ## Why claude-mem-lite? |
| 14 | |
| 15 | A ground-up redesign of [claude-mem](https://github.com/thedotmack/claude-mem), replacing its heavyweight architecture with a smarter, leaner approach. |
| 16 | |
| 17 | ### Architecture comparison |
| 18 | |
| 19 | | | claude-mem (original) | claude-mem-lite | |
| 20 | |---|---|---| |
| 21 | | **LLM calls** | Every tool use triggers a Sonnet call | Only on episode flush (5-10 ops batched) | |
| 22 | | **LLM input** | Raw `tool_input` + `tool_output` JSON | Pre-processed action summaries | |
| 23 | | **Conversation** | Multi-turn, accumulates full history | Stateless single-turn extraction | |
| 24 | | **Noise filtering** | LLM decides via "WHEN TO SKIP" prompt | Deterministic code-level Tier 1 filter | |
| 25 | | **Runtime** | Long-running worker process (1.8MB .cjs) | On-demand spawn, exits immediately | |
| 26 | | **Dependencies** | Bun + Python/uv + Chroma vector DB | Node.js only (3 npm packages) | |
| 27 | | **Source size** | ~2.3MB compiled bundles | ~50KB readable source | |
| 28 | | **Data directory** | `~/.claude-mem/` | `~/.claude-mem-lite/` (hidden, auto-migrates) | |
| 29 | |
| 30 | ### Token & cost efficiency |
| 31 | |
| 32 | For a typical 50-tool-call session (illustrative cost model — the ratios below are |
| 33 | architecture estimates derived from batch size, token counts, and model pricing, **not** |
| 34 | a measured end-to-end benchmark): |
| 35 | |
| 36 | | | claude-mem | claude-mem-lite | Ratio (estimated) | |
| 37 | |---|---|---|---| |
| 38 | | LLM calls | ~50 (every tool use) | ~5-8 (per episode) | **~7-10x fewer** | |
| 39 | | Tokens per call | 1,000-5,000 (raw JSON + history) | 200-500 (summaries only) | **~5-10x smaller** | |
| 40 | | Total tokens | ~100K-250K | ~1K-4K | **~50-100x less** | |
| 41 | | Model cost | Sonnet ($3/$15 per M) | Haiku ($0.25/$1.25 per M) | **~12x cheaper** | |
| 42 | | Combined savings | | | **~600x lower cost (estimated)** | |
| 43 | |
| 44 | ### Quality comparison |
| 45 | |
| 46 | | Dimension | Winner | Why | |
| 47 | |---|---|---| |
| 48 | | **Classification accuracy** | Tie | Both produce correct type/title/narrative | |
| 49 | | **Noise filtering** | **lite** | Code-level filtering is deterministic; LLM "WHEN TO SKIP" is unreliable | |
| 50 | | **Observation coherence** | **lite** | Episode batching groups related edits into one coherent observation | |
| 51 | | **Code-level detail** | original | Sees full diffs, but rarely useful for memory search | |
| 52 | | **Search recall** | Tie | Users search semantic concepts ("auth bug"), not code lines | |
| 53 | | **Hook latency** | **lite** | Async background workers; original blocks 2-5s per hook | |
| 54 | |
| 55 | ### Design philosophy |
| 56 | |
| 57 | The original sends **everything to the LLM and hopes it filters well**. claude-mem-lite **filters first with code, then sends only what matters** to a smaller model. This is not a downgrade; it's a smarter architecture that produces equivalent search quality at a fraction of the cost. |
| 58 | |
| 59 | ### Comparison: memory systems for AI coding agents |
| 60 | |
| 61 | How claude-mem-lite differs from the major neighbors in the LLM-memory space (verified May 2026): |
| 62 | |
| 63 | | | **claude-mem-lite** | [`mem0`](https://github.com/mem0ai/mem0) | MCP reference [`memory`](https://github.com/modelcontextprotocol/servers/tree/main/src/memory) | [claude-mem](https://github.com/thedotmack/claude-mem) (original) | |
| 64 | |---|---|---|---|---| |
| 65 | | **Target client** | Claude Code only | Any LLM app via SDK | Any MCP client | Claude Code only | |
| 66 | | **Capture model** | Auto via hooks | Manual `memory.add()` | Manual tool calls (`create_entities`, `add_observations`) | Auto via hooks | |
| 67 | | **Code-aware retrieval** | FTS5 + 100+ synonym pairs (incl. CJK↔EN) | General-purpose | Generic graph nodes | Code-aware | |
| 68 | | **Search** | Hybrid: FTS5 BM25 + TF-IDF cosine via RRF | Hybrid: semantic + BM25 + entity linking | Knowledge-graph traversal | FTS5 + Chroma vector | |
| 69 | | **Storage** | Single local SQLite | Pluggable; Qdra |