ML

Project

claude-engram

A persistent memory system for Claude Code, modeled on how human memory actually works — where forgetting is a feature, not a bug.

open sourceTypeScript · Bun · Claude Code hooks + MCP · Haiku / Sonnet / Voyage · Zod

What it is

Every LLM conversation starts from zero. claude-engram is a persistent memory system for Claude Code, modeled on human hippocampal memory formation: it hooks into the session lifecycle — session start, post-response, pre-compaction, session end — and exposes an MCP server with eight tools so Claude can search, store, reinforce, and forget memories mid-conversation. It works invisibly. No manual note-taking.

The thesis: forgetting is a feature, not a bug. Most memory systems hoard everything and drown in their own notes. Engram scores what’s worth keeping, lets the rest decay on a power-law curve, and consolidates what remains during “sleep cycles” — so the briefing Claude gets at session start stays short, current, and relevant to the project at hand.

There are two implementations: the fully automatic Claude Code version built on hooks and MCP, and a zero-infrastructure version that runs as a single React artifact inside Claude.ai. Model tiering keeps the running cost around five to fifteen cents a day.

How it’s built

  • LLM-as-hippocampus salience gating

    A separate Haiku instance scores every candidate memory on novelty, relevance, emotional weight, and prediction error — only salient content is stored. And the gate learns: reinforce, forget, and prune events emit training signals, so per-dimension extraction weights adapt to how you actually use your memories.

  • Power-law forgetting curves

    Memory strength is computed dynamically, never stored: salience + retrieval boost + consolidation bonus − decay × √age, following Ebbinghaus and Wixted. Detailed memories compress to gist after seven days (Fuzzy Trace Theory), and a new memory that updates an old one immediately dampens the old trace — proactive interference, on purpose.

  • Sleep consolidation

    A Sonnet cycle merges redundant memories, resolves contradictions (newest wins), extracts recurring patterns into generalized memories, and prunes dead ones. Above 100 memories it goes two-pass: Haiku flags merge-candidate clusters, Sonnet processes only the flagged groups.

  • Hybrid semantic recall

    Voyage embeddings with cosine similarity, layered over token fuzzy matching, ranked by relevance × strength. Recalling one memory surfaces others from the same session — temporal association — and deep_recall reaches archived, decayed memories, distinguishing retrieval failure from true forgetting.

  • Operational maturity

    File locking, pre-consolidation backups, auto-rotating logs, an SQLite log and event dashboard, cursor-tracked transcript parsing, a one-step installer, 130+ tests, and a companion benchmark repo (recall-bench). Zod-validated structured outputs end to end.

All projects