Open Source · Local-First · 819 Tests

Claude Code forgets everything.
This fixes that.

Hooks extract facts, decisions, and guardrails from every conversation. Six retrieval strategies inject relevant context back into every future prompt. Knowledge persists across sessions, across projects, across time.

Try the live demo View source Install
$ curl -fsSL .../install-remote.sh | bash click to copy

How It Works

Fully automatic. Zero config.

Install once, restart Claude Code. The system runs silently from that point forward.

01

Session starts

Long-term facts, guardrails, and decisions are injected as system context. Claude begins every session knowing what it learned before.

02

Every prompt

Six retrieval strategies run in parallel — semantic, BM25, graph, temporal, file-path, code — fused via Reciprocal Rank Fusion. Relevant context appears in <30ms.

03

Background extraction

At 40%, 70%, and 90% context usage, Claude Sonnet extracts structured knowledge: facts, entities, relationships, decisions, guardrails, error solutions.


See It Work

A conversation becomes
permanent knowledge

The extraction pipeline processes your conversations and stores structured knowledge. Here's a real debugging session.

Conversation
You
The deploy is failing on staging. Timing out on the health check after the ECS task starts.
Claude
The health check path is /api/health but the app is on port 8000. The ALB target group is configured for port 80.
You
Right, we changed the port when we added gRPC. The Terraform in ops/terraform/staging/ecs.tf still has the old port.
You
Also — never change the port without updating both the ECS task def AND the ALB target group. We've been burned by this twice.
Extracted → stored
Guardrail · importance 9
Never change container port without updating both ECS task definition AND ALB target group
Fact · long-term
Production backend runs on port 8000 (changed from 80 when gRPC was added)
Error Solution
ECS health check timeout → check ALB target group port matches container port
Relationship
ecs.tf —[configures]→ ALB target group

Next session: when someone edits ecs.tf, the guardrail surfaces automatically. If a similar timeout occurs, the error solution is recalled. The port fact is injected as context. Nobody has to explain any of this again.


Comparison

Not another CLAUDE.md file

Manual context files are static. This is automatic, structured, and retrieval-aware.

CLAUDE.md Cursor Windsurf ai-memory-db
Auto-extractionManualPartialYes3 passes/session
Knowledge typesFree textKey-valueRules8 structured types
Semantic searchNoBasicNo6-way + RRF
Temporal decayNoNoNo3-class exponential
Project isolationPer fileGlobalWorkspacePer-repo + promote
Entity graphNoNoNo2-hop BFS
Code graphNoNoNo5 languages
Guardrail enforcementManualNoRulesAuto + git stash
Data stays localFileCloudLocalDuckDB on disk
DashboardNoNoNoFull CRUD + graphs

Features

Built for engineering teams
who ship daily

Retrieval

6-way parallel search

Semantic, BM25, entity graph, temporal, file-path, and code symbol search — fused via Reciprocal Rank Fusion in <30ms.

Extraction

8 knowledge types

Facts, decisions, guardrails, procedures, error solutions, observations, entities, relationships — each with distinct recall priority.

Safety

Guardrail enforcement

PostToolUse hook detects edits to guardrailed files and auto-stashes via git. Correction detection supersedes bad facts.

Retrieval

Code graph

Multi-language AST parsing via tree-sitter. Python, TypeScript, JavaScript, Go, Rust — symbols, imports, and dependency chains.

Extraction

Temporal decay

Short-term facts fade at 0.18/day. Reinforced items promote through medium to long-term. Items in 3+ projects go global.

Dashboard

Web dashboard

Next.js + Cytoscape.js. Full CRUD, entity graph, code dependency view, live polling, per-scope filtering, PNG export.

Safety

Auto-snapshots

Database snapshot on every session end, rotating last 5. Export to JSON, import from JSON, restore from any snapshot.

Retrieval

Project scoping

Knowledge is isolated per git repo. Facts from project A never leak into project B. Cross-project items auto-promote to global.

Extraction

22 slash commands

/remember, /forget, /reflect, /knowledge, /audit-memory, /export-memory — full control over what's stored and recalled.


Architecture

The full pipeline

Two injection layers, three extraction triggers, six retrieval strategies — all converging on a single DuckDB knowledge base.

Claude Code Session User Prompts Claude Responses Status Bar MCP Tools HOOKS (automatic) MCP (on-demand) Session Start session_recall Inject long/medium facts Code graph parse systemMessage ~3k tok Every Prompt 6-way parallel retrieval RRF fusion <30ms Guardrail defense additionalContext ~4k Status Line Monitor ctx window % Trigger at 40 / 70 / 90% Prefetch next prompt background spawn MCP Server memory_search memory_store memory_guardrail memory_check_file _extract_worker Claude Sonnet tool_use Embed & upsert Consolidate observations Decay pass & purge incremental delta ~/.claude/memory/knowledge.duckdb facts · decisions · guardrails · entities · relationships · procedures · errors · code_symbols recall recall

Extraction & Recall Passes

Pass 1 — Session Start Recall
Long-term and medium-term facts, decisions, guardrails, entities, procedures, and community summaries injected as systemMessage (~3000 tokens). Triggers incremental code graph parse.
SessionStart hook
Pass 2 — Per-Prompt Recall
6-way parallel retrieval (semantic, BM25, graph, temporal, path, code) fused via RRF. Injected as additionalContext (~4000 tokens). Includes defensive guardrail/procedure/error_solution lookup.
UserPromptSubmit hook · <30ms
Passes 3–5 — Incremental Extraction (40%, 70%, 90%)
Background worker parses conversation delta, calls Claude Sonnet with tool_use for structured extraction, deduplicates against prior passes and recalled items. Each pass receives the prior narrative summary as context.
StatusLine trigger · background
Pass 6 — Session End Maintenance
Final extraction, narrative finalization, consolidation (synthesize observations), temporal decay pass, purge soft-deleted items (>30 days), rebuild FTS indexes, auto-snapshot database.
SessionEnd + PreCompact hooks
Continuous — PostToolUse Guard
Fires after every Write/Edit. Re-parses modified files in the code graph. Checks guardrails linked to edited files — auto-stashes via git if violated.
PostToolUse hook · per-file

MCP Integration

Four tools for any MCP client

The memory system exposes an MCP server (stdio JSON-RPC 2.0) that any compatible client can use — not just Claude Code hooks.

ToolDescriptionInput
memory_search Semantic search across facts, guardrails, procedures, error solutions, decisions query, types[], limit
memory_store Store a fact, decision, guardrail, procedure, or error solution text, type, importance, file_paths[]
memory_guardrail Create a guardrail with warning, rationale, and consequence warning, rationale, consequence, file_paths[]
memory_check_file Get all memory (guardrails, procedures, facts) linked to a file path file_path
Register the MCP server
claude mcp add --scope user \ -e PYTHONPATH=~/.claude \ memory python3 ~/.claude/hooks/memory_mcp_server.py

REST API

50+ endpoints for the dashboard

The FastAPI backend serves the web dashboard and exposes full CRUD on all knowledge types. Run locally on port 9111.

Knowledge CRUD
GETPOSTPUTDEL /api/v1/facts
GETPOSTPUTDEL /api/v1/decisions
GETPOSTPUTDEL /api/v1/guardrails
GETPOSTPUTDEL /api/v1/procedures
GETPOSTPUTDEL /api/v1/error_solutions
GETPOSTPUTDEL /api/v1/entities
GETPOSTPUTDEL /api/v1/relationships
GETPOSTPUTDEL /api/v1/ideas
GETPUTDEL /api/v1/questions
GETDEL /api/v1/observations
Search, Graph & System
POST /api/v1/search
GET /api/v1/relationships/graph
GET /api/v1/code-graph/graph
GET /api/v1/code-graph/files
GET /api/v1/code-graph/symbols/search
GET /api/v1/stats
GET /api/v1/scopes
GET /api/v1/sessions
GET /api/health
Start the API server
python3 -m uvicorn dashboard.backend.server:app --port 9111 # Interactive docs at http://localhost:9111/docs

Get Started

Install in 60 seconds

One command installs the memory package, hook scripts, and 22 slash commands into ~/.claude/. Restart Claude Code. That's it.

Everything runs locally. DuckDB stores your knowledge. Ollama (or ONNX Runtime) generates embeddings. Your data never leaves your machine.

Read the docs Try the demo
terminal
# Prerequisites curl -LsSf https://astral.sh/uv/install.sh | sh ollama pull nomic-embed-text export ANTHROPIC_API_KEY="sk-ant-..." # Install curl -fsSL https://raw.githubusercontent.com/ gilmanb1/ai-memory-db/master/ install-remote.sh | bash # Restart Claude Code — done