Open Source · Local-First · MIT License

Persistent Memory
for Claude Code

Give Claude Code long-term memory that survives across sessions. Hybrid BM25 + vector search, auto-clustering, and confidence scoring — all stored locally.

$ git clone https://github.com/MIMI180306/claude-persistent-memory.git

AI memory that
actually works

A complete memory lifecycle — from structured storage to intelligent retrieval, clustering, and time decay.

01

Hybrid Search

BM25 full-text (FTS5) combined with vector semantic similarity (sqlite-vec). Fused ranking for precise memory retrieval.

02

4-Channel Retrieval

Pull via MCP tools on demand, plus auto-push through hooks on user prompt, pre-tool, and post-tool events.

03

LLM Structuring

Memories auto-structured into what / when / do / warn XML format by LLM for consistent retrieval quality.

04

Auto Clustering

Similar memories grouped automatically. Mature clusters promoted to reusable skill memories that never decay.

05

Confidence Scoring

Each memory has a confidence score adjusted through validation feedback and usage, with configurable time decay.

06

Local-First Storage

All data in local SQLite. Your memories never leave your machine. Zero cloud dependency for storage.

Pull + Push dual channels

On-demand MCP tools paired with automatic hook injection across the full Claude Code lifecycle.

Pull — MCP Server
memory_search
memory_save
memory_validate
memory_stats
Push — Hooks
UserPromptSubmit
PreToolUse
PostToolUse
PreCompact / SessionEnd
SQLite + FTS5 + sqlite-vec
memory.db — hybrid BM25 + cosine similarity
Embedding Server
TCP :23811
bge-m3 · 1024-dim
LLM Server
TCP :23812
Azure OpenAI GPT-4.1

Memory lifecycle

From save to structure, embed, search, validate, cluster, promote, and decay.

1
Save
MCP tool or auto-extract
2
Structure
LLM → XML format
3
Embed
bge-m3 1024-dim vector
4
Search
BM25 + vector fused
5
Validate
Confidence ± feedback
6
Cluster
Auto-group similar
7
Promote
Cluster → skill
8
Decay
Low confidence fades

Up and running
in 3 steps

Clone, configure, and start. Then add MCP + hooks config to your Claude Code project.

01
Install
git clone https://github.com/
  MIMI180306/claude-persistent-memory.git
cd claude-persistent-memory
npm install
02
Configure
cp config.default.js config.js

# Set Azure OpenAI credentials
export AZURE_OPENAI_ENDPOINT=...
export AZURE_OPENAI_KEY=...
export AZURE_OPENAI_DEPLOYMENT=...
03
Start Services
# Terminal 1: Embeddings (~2GB RAM)
npm run embedding-server

# Terminal 2: LLM proxy
npm run llm-server

7 types with
configurable decay

Each type has its own half-life. Skills promoted from mature clusters never expire.

fact
90 days
Stable facts about the codebase
decision
90 days
Architectural decisions and rationale
bug
60 days
Bug fixes and root causes
pattern
90 days
Recurring code patterns
context
30 days
Session-specific context
preference
60 days
User workflow preferences
skill
never
Promoted from mature clusters