remem
Stop re-explaining your project every new session.
Persistent memory for Claude Code. A single Rust binary that automatically captures, distills, and injects your project context across sessions — decisions, patterns, preferences, and learnings.
The Problem
- Session amnesia: Every new Claude Code session starts from zero — you re-explain architecture, conventions, and past decisions
- Lost context: Bug fixes, design rationale, and "why we did X" vanish when the session ends
- Preference fatigue: You correct the same behaviors ("use Chinese comments", "don't mock the database") session after session
- No continuity: Working on a feature across multiple sessions means constantly rebuilding context
How remem Solves This
| Without remem | With remem |
|---|---|
| "We use FTS5 with trigram tokenizer for CJK..." (every session) | Automatically injected from memory |
"Don't use expect() in non-test code" (again) |
Preference applied before you ask |
| "Last session we decided to..." (reconstructing from git log) | Full decision history with rationale |
| Bug fix context lost after session ends | Root cause + fix preserved as memory |
Install
# Option 1: Quick install (downloads pre-built binary)
|
# Option 2: Cargo
# Option 3: Build from source
# Then configure Claude Code hooks + MCP:
Restart Claude Code after installation. remem starts working automatically.
How It Works
remem runs silently through Claude Code's Hooks system:
Your normal Claude Code workflow
│
├─ SessionStart → Injects memories + preferences into context
├─ UserPromptSubmit → Registers session, flushes stale queues
├─ PostToolUse → Captures tool operations (queued, <1ms)
└─ Stop → Summarizes session in background (6ms return)
You don't need to do anything — capture, distillation, and retrieval are fully automatic.
Memories are scoped by project. Preferences (coding style, tool choices) are automatically shared across all projects — learn once, apply everywhere.
Search Architecture
remem uses a 4-channel Reciprocal Rank Fusion (RRF) search inspired by Hindsight:
Query: "数据库加密"
│
┌────┴────────────────────────────────┐
│ 4 parallel channels │
├─────────────────────────────────────┤
│ 1. FTS5 (BM25) trigram + OR │
│ 2. Entity Index 1600+ entities │
│ 3. Temporal "昨天"/"last week"│
│ 4. LIKE fallback short tokens │
└──────────┬──────────────────────────┘
│
RRF Fusion: score = Σ 1/(60 + rank_i)
│
Top-K results sorted by fused score
Additional search enhancements:
- CJK dictionary segmentation — "数据库加密" → "数据库" + "加密" → database + encrypt
- Chinese↔English synonym expansion (90+ term mappings)
- Title-weighted BM25 (
bm25(fts, 10.0, 1.0)— title matches 10x) - Hybrid routing — long tokens → FTS5, short tokens → LIKE, merged with dedup
- Core-token LIKE — LIKE channel uses CJK-segmented original tokens (no synonym noise)
LoCoMo Benchmark
Evaluated on the full LoCoMo benchmark — 10 conversations, 1540 QA pairs (skipping adversarial category, same as Mem0). All results and raw outputs are in eval/locomo/results/.
remem results (two configurations):
| Config | Overall | Single-hop | Multi-hop | Temporal | Open-domain | Ingest | Gen/Judge Model |
|---|---|---|---|---|---|---|---|
| v1 (fair) | 56.8% | 67.1% | 39.0% | 53.9% | 28.1% | per-turn | gpt-5.4 |
| v2 (optimized) | 62.7% | 72.3% | 61.3% | 40.5% | 56.2% | session_summary | gpt-5.4 |
Competitor comparison:
| System | Overall | Gen Model | Judge Model | Ingest Strategy | Source |
|---|---|---|---|---|---|
| Hindsight | 89.6% | Gemini-3 | GPT-4o-mini | LLM fact extraction | paper |
| Letta filesystem | 74.0% | GPT-4o-mini | GPT-4o-mini | per-session files | blog |
| Mem0 (self-reported) | 68.5% | GPT-4o | GPT-4o-mini | LLM memory extraction | paper |
| Mem0 (third-party) | ~58% | — | — | — | issue |
| remem v1 | 56.8% | gpt-5.4 | gpt-5.4 | per-turn raw | this repo |
| RAG baseline | ~55% | GPT-4o | GPT-4o-mini | chunk+embed | Mem0 paper |
| Full-context | ~39% | GPT-4o | GPT-4o-mini | all in context | LoCoMo paper |
Fairness notes:
- v1 (56.8%) is the fair comparison — per-turn ingest is closest to Mem0's method. remem uses gpt-5.4 (stronger than Mem0's gpt-4o), which may inflate scores by ~2-5pp.
- v2 (62.7%) uses LoCoMo's pre-built
session_summary(human-annotated), which other systems don't use. This shows search ceiling with ideal ingest quality, not real-world performance.- All systems use different LLM models for generation and judging, making exact comparison imprecise. Run the benchmark yourself for apples-to-apples:
python eval/locomo/run_locomo.py- remem uses no vector search — pure FTS5 + SQLite + RRF fusion.
Internal Search Quality (eval on 1001 real memories, 30 queries)
| Metric | Value |
|---|---|
| MRR | 0.858 |
| Precision@5 | 0.460 |
| Recall@5 | 0.628 |
| Hit Rate@5 | 1.000 |
Measured with remem eval against a calibrated golden dataset.
Commands
REST API
remem includes an Axum-based REST API for cross-platform integration:
| Endpoint | Method | Description |
|---|---|---|
/api/v1/search?query=&project=&limit= |
GET | Search memories |
/api/v1/memory?id= |
GET | Get single memory |
/api/v1/memories |
POST | Save a memory |
/api/v1/status |
GET | System status |
Security
- SQLCipher encryption:
remem encryptencrypts the database at rest - File permissions: Data directory
0700, log files0600 - Key storage:
~/.remem/.keywith0600permissions - Encryption key: Set
REMEM_CIPHER_KEYenv var or use auto-generated key file - API binding: REST API binds
127.0.0.1only (localhost)
Multi-Tool Support
remem's ToolAdapter trait enables support for multiple AI coding tools:
Currently supports Claude Code. Future: Codex, Cursor, Aider — implement the trait only.
remem vs Built-in Memory
| Feature | Claude Code Memory | remem |
|---|---|---|
| Capture method | Manual (save_memory) |
Automatic (hooks) |
| Cross-session context | ~5 recent memories | 50+ scored memories |
| Preferences | Mixed with other content | Dedicated section, always visible |
| Decision tracking | Not specialized | Type-aware (decision/bugfix/discovery) |
| Search | Basic | 4-channel RRF fusion with entity index |
| Branch awareness | No | Branch-scoped memories |
| Cross-project sharing | No | Preferences auto-shared globally |
| Session summaries | No | Auto-generated with request/completed/decisions |
| WorkStream tracking | No | Cross-session task tracking with status |
| Database encryption | No | SQLCipher at rest |
| CLI tools | No | doctor, search, show, eval |
| REST API | No | Axum HTTP server |
Real-world Usage
After 1 month of production use:
remem v0.3.0
Memories: 1001
Observations: 1834
Entities: 1599
Database: 138 MB
Tests: 128 passing
Search MRR: 0.858
Hit Rate@5: 1.000
Architecture
See docs/ARCHITECTURE.md for detailed documentation including:
- System architecture diagram
- Module overview (~10,200 lines across 30 modules)
- Data flow (observation capture → distillation → context injection)
- Memory lifecycle (pending → observations → memories)
- 4-channel RRF search (FTS5 + Entity + Temporal + LIKE)
- Rate limiting (3-gate system)
- AI call strategy (HTTP-first + CLI fallback)
- MCP Server (7 tools)
- REST API (Axum)
- Environment variables (full list)
- Database schema (v12)
- Design decisions
Uninstall
License
MIT