claude-mem-lite
claude-mem-lite is a persistent memory (also called long-term memory or cross-session context) system for Claude Code — Anthropic's CLI coding agent. It runs as an MCP server plus a set of Claude Code hooks, automatically capturing coding observations, decisions, and bug fixes during sessions, then providing full-text search with query expansion to recall them later.
Compared to general-purpose LLM memory frameworks like mem0 or the MCP reference 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 (an estimated ~600× lower total cost — see the cost model below; this is an architecture estimate, not a measured benchmark), while the FTS5 retriever benchmarks at 0.90 Recall@10 / 0.85 Precision@10
(see Search Quality for the reproduction command).
中文简介:claude-mem-lite 是 Claude Code 的轻量级持久化记忆 / 长期记忆 / 跨会话上下文插件,基于 MCP 协议 + 钩子机制,自动捕获编码会话中的决策、修复和上下文,并通过 FTS5 全文检索召回。详见 中文 README。
Zero external services. Single SQLite database. Minimal overhead.
Why claude-mem-lite?
A ground-up redesign of claude-mem, replacing its heavyweight architecture with a smarter, leaner approach.
Architecture comparison
| claude-mem (original) | claude-mem-lite | |
|---|---|---|
| LLM calls | Every tool use triggers a Sonnet call | Only on episode flush (5-10 ops batched) |
| LLM input | Raw tool_input + tool_output JSON | Pre-processed action summaries |
| Conversation | Multi-turn, accumulates full history | Stateless single-turn extraction |
| Noise filtering | LLM decides via "WHEN TO SKIP" prompt | Deterministic code-level Tier 1 filter |
| Runtime | Long-running worker process (1.8MB .cjs) | On-demand spawn, exits immediately |
| Dependencies | Bun + Python/uv + Chroma vector DB | Node.js only (3 npm packages) |
| Source size | ~2.3MB compiled bundles | ~50KB readable source |
| Data directory | ~/.claude-mem/ | ~/.claude-mem-lite/ (hidden, auto-migrates) |
Token & cost efficiency
For a typical 50-tool-call session (illustrative cost model — the ratios below are architecture estimates derived from batch size, token counts, and model pricing, not a measured end-to-end benchmark):
| claude-mem | claude-mem-lite | Ratio (estimated) | |
|---|---|---|---|
| LLM calls | ~50 (every tool use) | ~5-8 (per episode) | ~7-10x fewer |
| Tokens per call | 1,000-5,000 (raw JSON + history) | 200-500 (summaries only) | ~5-10x smaller |
| Total tokens | ~100K-250K | ~1K-4K | ~50-100x less |
| Model cost | Sonnet ($3/$15 per M) | Haiku ($0.25/$1.25 per M) | ~12x cheaper |
| Combined savings | ~600x lower cost (estimated) |
Quality comparison
| Dimension | Winner | Why |
|---|---|---|
| Classification accuracy | Tie | Both produce correct type/title/narrative |
| Noise filtering | lite | Code-level filtering is deterministic; LLM "WHEN TO SKIP" is unreliable |
| Observation coherence | lite | Episode batching groups related edits into one coherent observation |
| Code-level detail | original | Sees full diffs, but rarely useful for memory search |
| Search recall | Tie | Users search semantic concepts ("auth bug"), not code lines |
| Hook latency | lite | Async background workers; original blocks 2-5s per hook |
Design philosophy
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.
Comparison: memory systems for AI coding agents
How claude-mem-lite differs from the major neighbors in the LLM-memory space (verified May 2026):
| claude-mem-lite | mem0 | MCP reference memory | claude-mem (original) | |
|---|---|---|---|---|
| Target client | Claude Code only | Any LLM app via SDK | Any MCP client | Claude Code only |
| Capture model | Auto via hooks | Manual memory.add() | Manual tool calls (create_entities, add_observations) | Auto via hooks |
| Code-aware retrieval | FTS5 + 100+ synonym pairs (incl. CJK↔EN) | General-purpose | Generic graph nodes | Code-aware |
| Search | FTS5 BM25 + query expansion (PRF, concept co-occurrence) | Hybrid: semantic + BM25 + entity linking | Knowledge-graph traversal | FTS5 + Chroma vector |
| Storage | Single local SQLite | Pluggable; Qdrant or configurable vector store | Single JSONL file (knowledge graph) | SQLite + Chroma |
| LLM dependency | Haiku per episode (5–10 ops batched) | LLM per add/search op | None (graph CRUD only) | Sonnet per tool call |
| Setup | One command (/plugin install or npx) | SDK integration + vector store config | MCP install (per-client) | Bun + Python + Chroma |
When to pick which: pick mem0 if you need a memory layer for a non-Claude-Code app (your own agent, multiple LLM providers). Pick the MCP reference memory server if you specifically want a knowledge-graph data model and don't mind invoking memory tools by hand. Pick claude-mem-lite if you want zero-touch automatic capture purpose-built for Claude Code's hook lifecycle, with code-domain retrieval and no external services.
Features
- Automatic capture -- Hooks into the Claude Code lifecycle (SessionStart, PreCompact, PreToolUse, PostToolUse, PostToolUseFailure, Stop, UserPromptSubmit — the seven events in
hooks/hooks.json) to record observations without manual effort - Lexical search with query expansion -- FTS5 BM25 scoring, an AND->OR rescue pass, pseudo-relevance feedback and concept co-occurrence. A TF-IDF vector arm shipped alongside it until it was measured net-negative and removed;
--deepstill fuses multiple LLM-rewritten queries with Reciprocal Rank Fusion - Timeline browsing -- Navigate observations chronologically with anchor-based context windows
- Episode batching -- Groups related file operations into coherent episodes before LLM encoding
- Error-triggered recall -- Automatically searches memory when Bash errors occur, surfacing relevant past fixes
- Proactive file history -- When editing a file, automatically shows relevant past observations for that file
- Session summaries -- written at every Stop (the assistant's final report when it has Done / Not done sections, else — when the final reply has no report section at all — its first 120 characters, else the first prompt and recent observation titles), then upgraded by a background model summary when the session has observations
- Project-scoped context -- Injects recent memory into
CLAUDE.mdand session startup for immediate context - Observation types -- Categorized as
decision,bugfix,feature,refactor,discovery, orchange - Importance grading -- LLM assigns 1-3 importance levels (routine / notable / critical) to each observation
- Observation relations -- Bidirectional links between related observations based on file overlap
- User prompt capture -- Records user prompts via UserPromptSubmit hook for intent tracking
- Read file tracking -- Tracks files read during sessions for richer episode context
- Degraded fallback when the LLM fails -- An episode that fixed an error is saved with inferred metadata (as an activity event) instead of being discarded, when a command that exited 0 printed the error (
npm test 2>&1 | tail): a command Claude Code reports as failed does not enter the episode, so a fix that follows one counts as edit-only. An edit-only episode, config and schema changes included, is summarised from raw tool output, which the noise rules drop in most cases (Modified a.js, b.jswith no lesson; only a short single-file summary survives) — as they do when the model answers without a lesson — so a failing provider loses those episodes unlessCLAUDE_MEM_KEEP_LOW_SIGNAL=1is set;claude-mem-lite doctorwarns when theclaudeCLI it would call does not resolve - Two-tier dedup -- Jaccard similarity (5-minute window) + MinHash signatures (7-day cross-session window) prevent duplicates
- Synonym expansion -- Abbreviations like
K8s,DB,authautomatically expand to full forms in FTS5 search (100+ pairs including CJK↔EN cross-language mappings) - CJK synonym extraction -- Unsegmented Chinese text is scanned for known vocabulary words (数据库→database, 搜索→search, etc.) enabling cross-language memory recall
- Stop-word filtering -- English stop words filtered from FTS queries, preventing false negatives from noise terms like "how", "the", "does"
- Pseudo-relevance feedback (PRF) -- Top results seed expansion queries for broader recall
- Concept co-occurrence -- Shared concepts across observations expand search to related topics
- Context-aware re-ranking -- Active file overlap boosts relevance (exact match + directory-level half-weight)
- Superseded detection -- Marks older observations as outdated when newer ones cover the same files with higher importance
- Adaptive time windows -- Session startup recall uses velocity-based time windows (high/medium/low activity tiers)
- Token-budgeted context -- Greedy knapsack algorithm selects session-start context within a 2,000-token budget, prioritizing by recency and importance
- Observation compression -- Old low-value observations can be compressed into weekly summaries to reduce noise
- Secret scrubbing -- Automatic redaction of API keys, tokens, PEM blocks, connection strings, and 15+ credential patterns
- Atomic writes -- All file writes (episodes, CLAUDE.md) use write-to-tmp + rename to prevent corruption on crash
- Robust locking -- PID-aware lock files with automatic stale/orphan cleanup (>30s timeout or dead PID)
- Stale session cleanup -- Sessions active for >24h are automatically marked as abandoned on next start
- Domain synonym expansion -- Search queries expand to domain synonyms (e.g., "fix" → debug, bugfix, troubleshoot, diagnose, repair)
- Multi-provider LLM mode -- Provider priority
ANTHROPIC_API_KEY(direct Anthropic API) →OPENROUTER_API_KEY(OpenRouter, OpenAI-compatible — point it at any model viaOPENROUTER_MODEL) →claude -pCLI fallback when no key is set - Lesson-learned indexing --
lesson_learnedfield indexed in FTS5 with weight 8, making past debugging insights directly searchable - Cross-source normalization --
mem_searchnormalizes scores across observations, sessions, and prompts before merging, preventing any source from dominating results - Exponential recency decay -- Type-differentiated half-lives (decisions: 90d, discoveries: 60d, bugfixes: 14d, changes: 7d) consistently applied in all ranking paths
- Prompt-time memory injection -- UserPromptSubmit hook automatically searches and injects relevant past observations with recency and importance weighting
- Dual injection dedup --
user-prompt-search.jsandhandleUserPromptcoordinate via temp file to prevent duplicate memory injection - Plugin cache hook self-heal -- Claude Code runtime reads plugin hooks from
~/.claude/plugins/cache/<mp>/<plugin>/<ver>/hooks/hooks.json, not from the marketplace source. Wheninstall.mjs-managedsettings.jsonhooks coexist with a stale cachehooks.json(e.g. from a previous marketplace install or a plugin auto-update), the runtime registers hooks twice → every session start / user prompt fires twice.install.mjsandhook-update.mjsnow clear cachehooks.jsonin every version dir, andhook.mjs session-startself-heals on every session (gated byhasInstallManagedHooksso plugin-only users are not affected).install.mjs statusreports cache pollution state (since v2.31.1/2.31.2). - Result-dedup cooldown -- User-prompt memory injection uses result-overlap detection (>80% ID overlap → skip) instead of time-based cooldown, allowing topic switches within seconds while preventing redundant injections
- OR query fallback -- When AND-joined FTS5 queries return zero results, automatically relaxes to OR-joined queries for broader recall (applied in both user-prompt-search and hook-memory paths)
- Configurable LLM model -- Switch between Haiku (fast/cheap) and Sonnet (deeper analysis) via
CLAUDE_MEM_MODELenv var - DB auto-recovery -- Detects and cleans corrupted WAL/SHM files on startup; periodic WAL checkpoints prevent unbounded growth
- Schema auto-migration -- Idempotent
ALTER TABLEmigrations run on every startup, safely adding new columns and indexes without data loss - LLM concurrency control -- File-based semaphore limits background workers to 2 concurrent LLM calls, preventing resource contention
- stdin overflow protection -- Hook input truncated at 256KB with regex-based action salvage for oversized tool outputs
- Cross-session handoff -- Captures session state on
/exitand/clear, then injects context when the next session detects continuation intent Changed in v6.10.0: the injected block went from two sections to six. Its observation queries were keyed on the hook-minted session id while everymem_savewrites amanual-<project>id, socompletedandkey_decisionscould not reach a saved lesson at all — 17 of 17 stored rows held 0 bytes in both. The block now also carries## Tree state(branch, short sha, uncommitted count) and## Next steps, read from the project's newesttasks/<slug>-paused.mdwhen it is under a week old. Four additive nullable columns land onsession_handoffs; the schema version deliberately does not move, so an older build still opens the database (measured: the v6.9.1 tree read and wrote a database this release had migrated). Revert by pinningclaude-mem-lite@6.9.1— no data-directory work. Original behaviour and the measurements behind it via explicit keywords or FTS5 term overlap. The/clearand/compactarm fires since v5.4.0 (R10-P1-1); before that it had never once written a row —session_handoffson the maintainer's install held 4exitrows and 0clearrows. Two host facts settled it, both measured rather than assumed. (1)Stopruns at the end of every assistant turn, not once per session, and it deleted the session file that SessionStart reads to learn which session just ended — so the branch was unreachable, and mem sessions were minted per turn (58 prompts over 16 host sessions produced 56 mem sessions and 56 summary rows, 2026-09-07). (2) Claude Code rotates its session id across/clear: of 21 real transcripts, 12 carry a/clearcommand record, and in 12/12 that record's timestamp precedes its own file's first record by ~0.1s — the command is issued in the old session and replayed into a new file under a new id. SoStopno longer deletes the file, SessionStart asks the host'ssource(startup/clear/compact/resume) instead of guessing from the file, and the handoff's prompt lookup falls back to the unscoped set when the new session's id matches none. Revert path:CLAUDE_MEM_LEGACY_STOP_UNLINK=1 - Git-SHA continuation anchor (v2.31.0) -- Handoff rows include
git_sha_at_handoff; any handoff matching the currentHEADcounts as continuation regardless of TTL. Code state is a stronger continuation signal than wall-clock time - Startup dashboard (v2.31.0) -- SessionStart hook aggregates
git status+~/.claude/tasks/*.json+~/.claude/plans/*.md+ most-recent exit handoff + recent event count into a single structured block injected viahookSpecificOutput.additionalContext - Activity namespace (v2.31.0) -- Dedicated
eventstable + FTS5 for non-memdir types (bugfix,lesson,bug,discovery,refactor,feature,observation,decision) that don't compete withWHAT_NOT_TO_SAVEsemantics on the observations table. CLI:claude-mem-lite activity save|search|recent|show.hook-llmroutes non-memdir summary types throughpersistHaikuSummaryso upgrades from observations→events are atomic. (v3.39: the/lessonand/claude-mem-lite:bugslash commands were redirected from this events table to searchable observations —mem_searchnever read the events table, so explicit saves were unfindable; the events table remains the auto-capture activity log.) - In-place observation updates --
mem_updatetool modifies existing observations atomically (field update + FTS text rebuild in one transaction), preserving original IDs and references - Bulk export --
mem_exporttool exports observations as JSON or JSONL, with project/type/date filtering and 1000-row pagination cap with batch guidance - FTS integrity management --
mem_fts_checktool verifies FTS5 index health or rebuilds indexes on demand, useful after database recovery or when search results seem wrong - Atomic multi-table writes --
saveObservationwraps the observations + observation_files INSERTs in a singledb.transaction(), preventing orphaned rows on crash - Modular NLP pipeline -- Synonym maps, stop words, scoring constants, and query building extracted into focused modules (
synonyms.mjs,stop-words.mjs,scoring-sql.mjs,nlp.mjs) for independent testing and maintenance - Surface-form PRF expansion --
observations_ftsis built on FTS5's defaultunicode61tokenizer, so the index is not stemmed: a query term matches the word forms actually stored, andcrashdoes not match a row that only containscrashes. Pseudo-relevance feedback therefore uses the Porter stemmer only to bucket morphological variants when judging which candidate terms are discriminative, and emits the most frequent surface form of each — emitting a bare stem (cach) would match nothing and kill expansion recall
Platform Support
| Platform | Status | Notes |
|---|---|---|
| Linux | Supported | Primary development and testing platform; the whole CI matrix runs here |
| macOS | Supported | Fully compatible (Intel and Apple Silicon) |
| Windows | Installs, not CI-covered | The MCP server, the CLI and the node hooks work (better-sqlite3 ships win32-x64 and win32-arm64 prebuilds, so nothing is compiled). Four hook commands run under bash — setup.sh, post-tool-use.sh, pre-agent-inject.sh, pre-tool-recall-bash.sh — and need Git for Windows or WSL on PATH; claude-mem-lite doctor reports it when bash cannot be found. No GitHub Actions runner exercises Windows, so this rests on user reports (#28), not on a green pipeline |
| WSL2 | Untested | Linux under the hood, so it should behave as the Linux row; nobody has reported either way |
From v5.1.0 through v6.1.0, package.json declared os: ["darwin", "linux"]. That is an npm install
gate, not a runtime check: on Windows it made npm install exit EBADPLATFORM, which the
plugin launcher runs on the first MCP start after every plugin update — so the server never
came up and /mcp reported CONNECTION_CLOSED. win32 is now in the list. A platform that
is still outside it gets a message naming both sides of the mismatch instead of a guess.
Requirements
- Node.js >= 22
- Claude Code CLI installed and configured (
claudecommand available) - SQLite3 support (provided by
better-sqlite313, which ships prebuilt binaries for 8 platforms — no compiler needed on any of them; a platform it has no prebuild for falls back to building from source) - Platform: Linux or macOS; Windows installs and runs but is not CI-covered and needs Git Bash or WSL for four hooks (see Platform Support)
Installation
Method 1: Plugin Marketplace (recommended)
bash/plugin marketplace add sdsrss/claude-mem-lite /plugin install claude-mem-lite
Plugin mode manages its own hooks/runtime. On session start it only checks and reports new claude-mem-lite versions; it does not self-overwrite plugin files in place. Update plugin-mode installs through Claude's plugin workflow.
The plugin install is complete on its own — hooks, MCP tools, and the bundled slash commands (
/mem,/lesson,/claude-mem-lite:bug,/adopt) all run from the plugin with no second step. The slash commands invoke the bundled CLI by an absolute path resolved from the plugin directory (node "${CLAUDE_PLUGIN_ROOT}/cli.mjs" <cmd>), so they work without anything on yourPATH. A globalclaude-mem-liteshell command (for running queries yourself in a terminal) is optional —npm i -g claude-mem-lite— and is a separate npm install: the plugin's auto-update does not refresh it, so re-runnpm i -g claude-mem-lite@latestif you want that shell command kept in sync. You do not need it for the plugin to be fully functional.
Auto-adopt no longer adds its block to your project's
CLAUDE.md(next release after 6.19.4). On every SessionStart the plugin delivers its steering text — the trigger table that boosts Claude's proactive use ofmem_recall/mem_save. In a git repository that does not already carry the block it keeps a managed block inCLAUDE.local.mdat the repository root (Claude Code loads that file likeCLAUDE.md, also in subagents that load project instructions; the built-in Explore and Plan agents load none) and adds the file to the repository's.git/info/excludeunless your ignore rules already cover it, so git does not list or commit it; you get a one-time notice the first time it is written. Claude Code reads instruction files before the plugin's startup hook runs, so the session that creates the file gets the text added to its context instead, once (its subagents do not see it). Where Claude Code reads anAGENTS.mdas the project's instructions, it stops reading it once aCLAUDE.mdorCLAUDE.local.mdexists in the session's directory or above, so there nothing is written and the text is injected (subagents do not see it), with a one-time notice that names thatAGENTS.md. WithCLAUDE_MEM_RULES_STEERING=1the block goes to.claude/rules/claude-mem-lite.mdat the repository root instead — excluded from git the same way, loaded by Claude Code as project instructions, also in subagents that load project instructions, and it leavesAGENTS.mdloading — with its own one-time notice; it is not the default because in a pre-registered A/B it did not beat injection by the bar set in advance (docs/audits/20261006-d212-ab.md). Outside git, in a repository rooted at$HOME, whereCLAUDE.local.mdis tracked or a symbolic link, or where the repository root is an npm package thatnpm publishwould ship it with (no"private": true, nofileslist leaving it out, and without one no.npmignorenaming it), nothing is written and the text is injected into each session's context, with a one-time notice suggesting/adopt(not at$HOME). With the variable set, the same holds where the rules file cannot be written (a symbolic link on its path, a tracked or foreign file of that name, an npm package that would ship it). The notice beside anAGENTS.mdnames it, why there is no file, and the ways to a file that keep it loading, each only where it works: Project instructions =claude-md-and-agents-mdin/config, after whichCLAUDE.local.mdis written (not whereCLAUDE.local.mdis refused too: a package root, or a file you removed), and/adopt, whoseCLAUDE.mdimports theAGENTS.mdbeside it (not offered when anAGENTS.mdabove that directory or in a subdirectory would stop loading). The detail file the block points at lives in the plugin's data directory, named with a~/path..git/info/excludeis read by git only: docker build contexts, archives and other packagers can pickCLAUDE.local.mdor the rules file up (a publishable npm package root does not keepCLAUDE.local.md: a block written before is taken out at the next session start; in a project whoseAGENTS.mdit would switch off, the block comes out and is injected, or, withCLAUDE_MEM_RULES_STEERING=1, moves to the rules file where that can be written). Earlier versions added the block to your project's own<cwd>/CLAUDE.md(a file that is normally committed) plus a<cwd>/.claude/plugin_claude_mem_lite.mddetail file, unasked, in every project you opened; those projects keep the block, and the first session of this version refreshes it because the text changed — to move one to the local file, runclaude-mem-lite unadoptthere and commit the removal. Why not inject everywhere: in our sandbox evaluation (one project, Claude Opus 5.5) the agent made 1.5 proactive memory saves per 8-session run with injected steering against 5.25 with the block inCLAUDE.local.mdorCLAUDE.md, and subagents never saw injected text. It applies regardless of install path (npm, npx,/plugin, manual); silence these notices withMEM_NO_ADOPT_HINT=1.Want the block in
CLAUDE.mdinstead (for example to share it with your team)? Runclaude-mem-lite adopt: it writes the slug-scoped managed block into<cwd>/CLAUDE.mdplus the detail file, preserving everything outside the block, and removes the auto-written local copy (CLAUDE.local.mdor the rules file). Claude Code stops readingAGENTS.mdonce aCLAUDE.mdexists, so aCLAUDE.mdthat adopt creates next to anAGENTS.md(or.claude/AGENTS.md) starts by importing it (@AGENTS.md, behind a marker comment Claude Code does not load), and that file keeps loading; anAGENTS.mdabove the directory or tracked below it cannot be imported that way and is named in adopt's output, with the setting that keeps it (Project instructions =claude-md-and-agents-md). Nothing is imported where aCLAUDE.mdof yours already exists, sinceAGENTS.mdwas not being read there.unadoptdeletes aCLAUDE.mdthat holds nothing but those lines and the block. A project that carries the block is kept in sync on every SessionStart — refreshed when the shipped template changes — and gets no local or injected copy on top of it, also in sessions started from a subdirectory. ACLAUDE.mdholding nothing but the block (what an earlier version's auto-adopt wrote) gets the sameAGENTS.mdimport at the next session started in its directory, with a one-time notice. Seen from a session started in a subdirectory, the import points outside the working directory, so Claude Code asks once to approve it. A local block (CLAUDE.local.mdor the rules file) the plugin created and you deleted (orclaude-mem-lite unadoptremoved) is not written back — the text is injected instead — untilclaude-mem-lite adopt --enable(beside anAGENTS.mdthatCLAUDE.local.mdwould switch off, a file comes back only withCLAUDE_MEM_RULES_STEERING=1too). Turn steering off per project withclaude-mem-lite adopt --disable(it also removes the local block; aCLAUDE.mdblock stays untilunadopt;--enablere-arms) or globally withexport MEM_NO_AUTO_ADOPT=1(blocks already written stay and keep loading untilunadopt); freeze the blocks against template refreshes withCLAUDE_MEM_NO_TEMPLATE_REFRESH=1.claude-mem-lite unadoptremoves theCLAUDE.mdblock, the detail file, and the local block (CLAUDE.local.mdor.claude/rules/claude-mem-lite.md) with its exclude entry.
Method 2: npx (one-liner)
bashnpx github:sdsrss/claude-mem-lite
Source files are automatically copied to ~/.claude-mem-lite/ for persistence.
Note:
npx github:…installs from the repo's default branch (HEAD), which can be ahead of the latest published release. For the stable released version use the npm package (npx claude-mem-lite), or pin a release tag:npx github:sdsrss/claude-mem-lite#vX.Y.Z.
Method 3: git clone
bashgit clone https://github.com/sdsrss/claude-mem-lite.git cd claude-mem-lite node install.mjs install
install copies the source files to ~/.claude-mem-lite/, as the npx method does. Update with node install.mjs update, which installs the latest signed release. git pull && node install.mjs install installs the checked-out branch instead: it can be ahead of the latest release, and no signature is checked.
What happens during installation
- Install dependencies --
npm install --omit=dev(compiles nativebetter-sqlite3) - Register MCP server --
mem-liteserver with 19 tool definitions (10 core + 9 hidden-but-callable;mem_search_feedbackis registered only when search telemetry is enabled). The pre-v2.78 generic server namememis renamed tomem-litefor namespace hygiene; the tool names themselves (mem_search,mem_recall, ...) are unchanged. - Configure hooks -- all seven lifecycle events:
SessionStart,PreCompact,PreToolUse,PostToolUse,PostToolUseFailure,Stop,UserPromptSubmit - Create data directory --
~/.claude-mem-lite/(hidden) for database, runtime, and managed resource files - Auto-migrate -- If
~/.claude-mem/(original claude-mem) or~/claude-mem-lite/(pre-v0.5 unhidden) exists, migrates database and runtime files to~/.claude-mem-lite/, preserving the original untouched - Initialize database -- SQLite with WAL mode, FTS5 indexes created on first server start
Restart Claude Code after installation to activate.
Migration
All installation methods auto-detect and migrate from previous versions:
From claude-mem (original ~/.claude-mem/):
- Copy
claude-mem.db→~/.claude-mem-lite/claude-mem-lite.db(renamed) - Copy the
runtime/directory - Original
~/.claude-mem/is preserved (no deletion, no overwrite)
From pre-v0.5 unhidden directory (~/claude-mem-lite/):
- Entire directory is moved to
~/.claude-mem-lite/(hidden)
In-place rename:
- Existing
claude-mem.dbin~/.claude-mem-lite/is automatically renamed toclaude-mem-lite.db
Remove old directories manually after confirming:
bashrm -rf ~/.claude-mem/ # original claude-mem rm -rf ~/claude-mem-lite/ # pre-v0.5 unhidden (if not auto-moved)
Directory Structure
~/.claude-mem-lite/ claude-mem-lite.db # SQLite database — memory (WAL mode) runtime/ session-<project> # Active session state ep-<project>.json # Episode buffer ep-flush-*.json # Flushed episodes awaiting processing reads-<project>.txt # Read file paths (collected on flush) managed/ repos/ # Shallow-cloned source repos
Upgrading to 6.29.0
Chinese text in lessons, facts, concepts and aliases becomes searchable, and the database opens after the update fill that in without holding up a hook. No schema-version change: 6.28.1 still opens, searches and writes the database after this release has. Go back only after the fill finishes: rows it has not reached stay without the Latin identifiers glued to Chinese under 6.28.1.
- What it costs. Each database open spends about 250 ms filling the index terms of existing observations, newest first, each batch committed, until all are done. On a copy of the maintainer's store (516 observations, most already filled by an earlier build of this pass) the pass walked every row in one open of 48–49 ms. On a synthetic v6.27.0 store of 250,000 observations and 200,000 events (mostly CJK) the first open takes about 1 s (6.28.1: about 9 s, and a 5 s hook opening it first was killed), and the fill then takes 105 opens of about 0.5 s; an open after it takes 3 ms.
- A lesson a model writes onto one of your explicit saves starts with
🤖, andgetsays "🤖 lesson auto-written". A lesson you write is never marked. - Exit codes. A flag that takes no value (
--force,--json,--confirm,--or,--dry-run, …) no longer swallows the next word:delete --confirm 12now deletes #12, andrecent --json 5prints JSON.maintain,compress,optimize,delete,activity promote/delete,import-jsonl,defer dropandfts-check rebuild, which never read--dry-run, refuse it with exit 1 on a run that would write, instead of running;activity save,import-jsonlandrestorerefuse a mistyped--project;uninstallexits 3 when the MCP registration is left. CHANGELOG.md lists the rest; a script that relied on the old behaviour needs a look. - Also in this release: the database waits of a hook that opens through
ensureDball end by its deadline, the first open's migration, the prompt search and the Agent injection included; the unattended re-enrich raises importance to 2 at most; three more background prompts send stored rows to the model as data, and smart-compress and cluster merge act only on an explicit yes. Details in CHANGELOG.md.
Upgrading to 6.28.1
After the update, events are re-indexed so Chinese text in them is searchable (the Han ranges U+4E00–9FFF and U+3400–4DBF; kana, Hangul and the rarer Han extensions are not segmented). No schema-version change: 6.27.0 still opens, searches and writes the database after this release has, and an event it writes is filled the next time this release opens the database.
- What it costs. The first open adds a column, rebuilds the events index and adds the Latin identifiers glued to Chinese text to existing observations' index text. Existing events are then filled newest first, about 250 ms per database open (checked after each row), each batch committed, so a killed open keeps its progress; with nothing left an open takes 3–4 ms. On the maintainer's store (6963 events) the first three opens took 295–327, 80–102 and 4 ms, and the file grew from 14 to 15 MB; on a CJK-heavy synthetic store of 200,000 events the first open takes 964 ms, the fill 79 opens, and the file grows from 93 to 273 MB. Until an event is filled, a Chinese query misses it as before.
- The MCP server waits out another writer's lock at startup (up to 15 s of retries) instead of exiting with "database is locked".
- Exit codes. Some commands that exited 0 now exit 1, among them
save,update,defer addandactivity savegiven a flag they do not take,saveanddefer addgiven a mistyped project,deletegiven an id list with a malformed part (1,abc),self-updatewhen it checked nothing, andimport-jsonlon lines none of which is a transcript event (an empty file still exits 0); CHANGELOG.md lists the rest.installexits 3 when only the MCP registration failed. A script that relied on exit 0 there needs a look. - Also in this release:
installno longer empties the marketplace clone'shooks/hooks.json(it puts back, withgit checkout, one an earlier install emptied); four MCP tool texts say what the tools do; a hook under a long write lock exits instead of being killed (UserPromptSubmit and SessionStart with their context), and a lock that ends between 3.5 s and the 5 s kill, which 6.27.0 waited out, now drops the write the hook was waiting to make (UserPromptSubmit's prompt row, for one). Details in CHANGELOG.md.
Upgrading to 6.25.0
Every session gets the same first line on a file-recall block again. No schema-version change: 6.24.0 still opens the database after this release has.
- What changes. Since 6.16.0 half of sessions got a plain statement of where the notes come
from instead of "system-injected context, continue your planned action", so the two could be
compared by how often the agent cited a lesson. On the maintainer's own sessions the comparison
found no difference it could detect, and a scan of the agent's replies found neither line
surfaced to the user, so the split is closed: unset now means the older line in every session.
CLAUDE_MEM_RECALL_FRAMING=factualkeeps the plain statement;=abrestores the split. - Also in this release: when the data directory cannot be read,
doctorsays "not checked" for what it could not look at andstatusnames the directory, instead of reporting a missing or empty store.maintain execute --ops dedupnames the merge pairs it skips. Details in CHANGELOG.md.
Upgrading to 6.24.0
If you set CLAUDE_CONFIG_DIR, the installer, updates and hooks now use that directory, as
Claude Code does. No schema-version change: 6.23.3 still opens the database after this
release has. Without CLAUDE_CONFIG_DIR nothing in this item changes.
- Who is affected. Claude Code keeps
settings.json,plugins/and.claude.jsoninCLAUDE_CONFIG_DIRwhen it is set. The plugin kept using~/.claudeand~/.claude.json:installwrote its hooks where Claude Code never reads them, and with two profiles the session-start setup andself-updatepruned the other profile's plugin cache and edited its.claude.json. - What to do. Installed with npm or npx: run
claude-mem-lite installonce more with the variable set, so the hooks land in your config directory. Plugin installs need nothing. Hook entries an older version wrote into~/.claude/settings.jsonstay there; if no other profile uses~/.claude,env -u CLAUDE_CONFIG_DIR claude-mem-lite cleanup-hooksremoves them. - Also in this release:
npm install -g claude-mem-liteandnpxno longer install the development toolchain. As a dependency install it went from 298 packages / 541 MB to 96 / 57 MB; after the release,-gandnpxmeasured the same 96 packages. A confirmedmaintain execute --ops purge_stalenow deletes every row its preview counted in one run, behind one snapshot.doctorwarns about a failing update check and about anANTHROPIC_BASE_URLthat ends in/v1. Details in CHANGELOG.md.
Upgrading to 6.23.1
If you set ANTHROPIC_BASE_URL and ANTHROPIC_API_KEY, background LLM calls now go to that
gateway. No schema-version change: 6.22.1 still opens the database after this release has.
To keep the old behaviour, stay on 6.22.1; a plugin install that already updated can follow the
rollback recipe under "Trust model per install path".
- Who is affected. The direct API leg used to post to
api.anthropic.comwith the built-in model IDs whateverANTHROPIC_BASE_URLsaid; only theclaude -pfallback followed it. Now the direct leg uses it too, together withANTHROPIC_DEFAULT_HAIKU_MODEL/ANTHROPIC_DEFAULT_SONNET_MODEL. WithoutANTHROPIC_BASE_URLnothing changes, even when the two model variables are set. - A value the plugin cannot use (not a parseable URL, not http or https, plain http to a
host that is not loopback, credentials in the URL, a query or a fragment) skips the direct
leg: every background call falls back to
claude -p, which readsANTHROPIC_BASE_URLitself, andclaude-mem-lite doctorsays why.doctornow probes the gateway's host and port instead ofapi.anthropic.com. - Also in this release: large stores no longer time out on every prompt. The database now
gets SQLite's planner statistics, which adds SQLite's own
sqlite_stat1/sqlite_stat4tables. AndCLAUDE_MEM_SEARCH_TELEMETRY=1is a new, off-by-default switch that records MCP searches for relevance feedback. Details in CHANGELOG.md.
Upgrading to 6.21.0
Projects whose names are not plain ASCII get a new id, and what they stored moves once. No
schema-version change: 6.20.0 still opens the database after this release has. Pin
claude-mem-lite@6.20.0 before upgrading to avoid the move; after it, 6.20.0 names these
directories by their old ids again, so their moved rows are listed only with
--project=<new id>.
- Which projects. Every character outside ASCII letters, digits and
_.-used to become-, so~/projects/博客and~/projects/商城were bothprojects----and shared one memory. Letters, marks and digits of every script are now kept (projects--博客). An id whose parent and directory names are both plain ASCII keeps its id byte for byte; a name with letters, marks or digits of another script, or with a character outside the Basic Multilingual Plane such as🚀, changes id. - At a project's first session start its data moves. When no stored file path shows another
directory using the old id, the project takes everything under it, deferred items and session
history included. Otherwise only the memories whose file paths lie inside the directory move;
the rest stay under the old id. A one-time notice says what moved and how to list what stayed
(
claude-mem-lite recent 50 --project=<old id>). - Not in this release: directories with the same parent and name in different repositories
(
~/a/packages/apiand~/b/packages/api) still share one id. - Also changed: two sessions open in one project keep separate memory sessions (handoffs,
summaries and unsaved tool activity no longer mix); a session's follow-up prompts no longer
resume another session; maintenance hides idle memories for 7 days before queuing them for
deletion, in every project; an importance you set is no longer changed by reads, the access
boost or re-enrich;
recall/mem_recallrank the current project and the exact path first (--project/projectkeep one project);<private>fails closed on an unclosed, nested or attributed tag. Full list: CHANGELOG.md.
Upgrading to 6.19.0
Search output changes; no switch. No schema change and no migration, so reverting is
pinning claude-mem-lite@6.18.0.
search/mem_searchmark machine-written observations with🤖, andget/mem_getname them in the header. Hook-captured, imported and compressed rows carry it; explicit saves and events do not. The result line explains the mark whenever a shown row has it, andsearch --jsonaddsautoto observation rows.mem_searchshows a snippet line only when it adds to the title.- Fixes: a lone search match in a new per-project store no longer sorts last; a Bash step's stored description keeps the end of its output; the secret scrubber catches values behind markdown labels and stays linear-time on crafted input.
Upgrading to 6.18.0
One default changes, with a switch. No schema change and no migration. Pinning
claude-mem-lite@6.17.1 stops new lines; a line already written stays until that session's
next observation titles replace it, and 6.17.1 keeps its unrecognised tag as text in the
row's notes.
- Last Session shows how the previous session ended even without a report. When the
final reply has no Done / Not done / Failed / Uncertain section,
Completed:is its first 120 characters (code blocks and line-leading markers removed) where it used to be observation titles, which are usually empty; the /clear handoff labels it<session-summary source="last-reply">. A report or a model summary still takes precedence. A later reply under 400 characters ("You're welcome!") does not replace an earlier one, and a reply in which the secret scrubber finds anything writes no line at all.CLAUDE_MEM_SUMMARY_TAIL=0restores the titles from the session's next turn on.
Upgrading to 6.17.0
Two defaults change; one has a switch. No schema change and no migration, so reverting
everything is pinning claude-mem-lite@6.16.0.
- The pre-edit lesson line asks for a lesson's
#NNonly where it changed the edit. It no longer asks for an applied / not-applicable verdict on every lesson in your next reply, which put lesson-id lists into replies. Old directive:CLAUDE_MEM_SALIENCE=verdict(since 6.17.1 it also says it overrides the managed row and detail doc, which keep the new wording). Adopted projects get the matching CLAUDE.md managed row and detail doc on the next SessionStart;CLAUDE_MEM_NO_TEMPLATE_REFRESH=1keeps the old text. - SessionStart's "Deferred Work" list ends with "+N more open" when more than its 5 rows are open. No switch; pin 6.16.0 to revert.
Upgrading to 6.16.0
Three defaults change; one has an off switch. No schema change and no migration, so
reverting everything is pinning claude-mem-lite@6.15.0.
- Each session gets one of two first lines on a file-recall block. Half of sessions keep
"system-injected context, continue your planned action"; the other half get a plain
statement of where the notes come from, as Claude Code's hooks guide recommends. The two
are compared by cite-rate before one becomes the default. Off (old line everywhere):
CLAUDE_MEM_RECALL_FRAMING=legacy. - Memory text longer than the host's 10,000-character hook limit is trimmed by whole lines, with a closing line naming the ids left out, instead of the host replacing it with a 2,000-character preview. No switch; pin 6.15.0 to revert.
- Lessons shown after a failed Bash command now count in citation decay, like every other surface: ones never cited are ranked down over time. No switch; pin 6.15.0 to revert.
Upgrading to 6.15.0
Two defaults change; one has an off switch. No schema change and no migration, so
reverting everything is pinning claude-mem-lite@6.14.0.
- An auto-captured lesson that repeats text a tool printed is kept out of automatic
injection. Whoever controls a command's output (a repository's test, a fetched page, an
MCP server) could otherwise get a sentence of their choosing stored as a lesson that later
sessions are shown. Such an event stays searchable at importance 1; a
changeobservation loses the lesson. Four shared words are enough, filler included, so an occasional lesson of your own is demoted too. Off:CLAUDE_MEM_LESSON_OUTPUT_CAP=off. - Last Session reads your own Done / Not done report when it uses markdown headings
(
## Done,**Not done**) instead of falling back to the model's summary. No switch; pin 6.14.0 to revert.
Upgrading to 6.14.0
Five defaults change; three have an off switch. No schema change and no migration: an
older build still opens the database, so reverting everything is pinning
claude-mem-lite@6.13.6.
- File recall now also fires before Bash commands that view or write a file (
cat,sed -n,head;sed -i,cat > f, a python patch) — on recent models most reads and edits go through Bash, and the recall face with the highest measured cite rate had almost stopped firing. A fourth hook command runs underbash,pre-tool-recall-bash.sh; on Windows it needs Git Bash or WSL like the other three. Off:CLAUDE_MEM_BASH_RECALL=off. - Error recall stays quiet on a failure you meant to cause (running a test file you just
wrote or edited) and on commands that only print data and exit 0. No switch; pin 6.13.6 to
revert.
error_recallcounts incitation-statsdrop from here on — do not compare them across this version. - Auto-captured lessons must quote what happened. The episode summarizer ignores
mutation-test probes, the agent's own failing inline scripts and subagent calls that do not
edit the project, and a lesson that quotes nothing from its window is dropped (the event is
kept, at importance 1). Off:
CLAUDE_MEM_EPISODE_INPUT_FILTER=off/CLAUDE_MEM_LESSON_GROUNDING=off. - The
[mem] episode flushed: N entriesline is no longer injected. The hints that followed it are unchanged.
Upgrading to 6.13.0
One default changes: SessionStart no longer injects ### Key Events. That section listed
the five newest importance ≥ 2 rows of the events table — activity the background summarizer
records — at the top of every session, chosen by recency rather than by what you were doing. A
check of 30 of them against git history and transcripts found 2 accurate and 16 wrong. Events are still stored, searchable with mem_search, and
injected when your prompt or the file being edited matches them. To restore the section, set
CLAUDE_MEM_SESSION_EVENTS=1. No schema change and no migration: an older build still opens
the database, so reverting is pinning claude-mem-lite@6.12.2.
Citation readings drop at this version, and that is a measurement change. A lesson the
agent answers with #NN n/a is no longer counted as cited, so citation-stats per-face rates
read lower from here on (--sidechain excepted: it counts an n/a as an answer). Do not compare
a reading taken before 6.13.0 with one taken after.
Upgrading to 6.11.0
One default changes: re-enrich stops leaving part of its budget idle. It reserves half of
each run's budget for two backfill passes and gives its main scope the rest. When the main
scope had fewer rows to enrich than its share, the remainder went unspent; it now goes to the
backfills. The daily unattended pass runs once per machine per day, over all projects
together, so with an empty main pool it now makes up to 6 of these LLM calls a day where it
made 3. The ceiling of 6 is unchanged — it was always the declared budget — and a separately
budgeted scope-classification pass, also unchanged, can add up to 6 more short calls. A manual
claude-mem-lite optimize --run or mem_optimize behaves the same way. No schema change and
no migration: an older build still opens the database, so reverting is pinning
claude-mem-lite@6.10.3.
One security fix does not reach data you already have. In some combinations of two
labelled credentials on one line — token: <v> secret: <v> is one, when the first value e




