claude-memory
A persistent semantic memory system for Claude Code, using vector search and a judgment ledger to surface prior decisions and calibrate predictions.
README
Sapience
Human-like memory and a judgment ledger for AI — an MCP server for Claude Code.
An LLM has intelligence — it processes and analyzes brilliantly — but it's amnesiac between sessions and never accumulates your experience. Humans win on something else: memory that persists and judgment that gets sharper because we keep track of how our past calls turned out. That faculty — the one that makes Homo sapiens more than raw brainpower — is what Sapience adds to your AI.
Two halves:
- A human-like memory — episodic and semantic memories, ranked by importance, consolidated over time into durable patterns. Not RAG over a scratch file.
- A judgment ledger — log a prediction with a probability, resolve it against what actually happened, and get a real calibration read (Brier score, reliability by confidence band, a bias map) so you can see where your judgment is systematically off.
Sapience gives one user's AI a compounding memory + judgment loop. It is not a claim to reproduce human cognition — it's the missing feedback loop that lets an intelligence learn from experience.
The judgment ledger
This is the part you won't find in other memory tools. Every "AI memory" remembers what you said; Sapience keeps score of whether you were right.
- Log a forward-looking call with a probability (0–1) and — crucially — the reasoning and conditions as they were at the time. Most retrospectives rewrite history; this preserves the contemporaneous evidence.
- Resolve it when the outcome is known (right / partial / wrong).
- Calibrate. Sapience computes a Brier score against a base-rate baseline, breaks accuracy down by confidence band, and flags over/under-confidence. A Claude-written narrative sits on top of the numbers — never instead of them.
Honesty by design: below a sample threshold (20 resolved by default), Sapience refuses to call anything a "bias" and explicitly labels its output "reflection, not statistics." A bias is not a bias at n=3.
How the memory works
- Storage — a local ChromaDB vector store; the ledger is local SQLite. No third-party SaaS account.
- Embeddings — OpenAI (
text-embedding-3family) for semantic similarity. - Synthesis — Anthropic Claude for context briefs, consolidation, calibration, and bias maps.
- Retrieval — candidates are over-fetched by similarity, then reranked by
similarity × salience, so an important-but-slightly-less-similar memory can still surface.
Memory types: episodic (events/decisions), semantic (patterns, written by consolidation), user (facts about you), feedback (how to work with you), project (initiatives), reference (external pointers).
Privacy — read this precisely
Your data is stored locally (vector DB + SQLite on your machine; no hosted account). But Sapience is not fully local compute: memory content is sent to OpenAI to create embeddings, and selected memories are sent to Anthropic for briefs, consolidation, and calibration. If that tradeoff doesn't work for your data, don't point Sapience at it.
Tools
Memory — search_memory, save_memory, get_context_brief, get_related, consolidate, list_memories, memory_stats
Judgment ledger — log_assessment (prefer a numeric probability), list_pending_assessments, resolve_assessment, generate_calibration (Brier + reliability, gated for sufficiency), get_bias_map
Setup
Requires Python 3.12+.
git clone https://github.com/allenc84/sapience.git
cd sapience
python3.12 -m venv venv
./venv/bin/pip install -e .
cp .env.example .env # then edit
Configure .env (see .env.example):
MEMORY_USER_CONTEXT="Jane Doe, founder of Acme" # who the memory serves
OPENAI_API_KEY=sk-proj-...
ANTHROPIC_API_KEY=sk-ant-...
# Optional:
LEDGER_DOMAINS="predictions,decisions,commitments" # your judgment domains
SAPIENCE_DATA_DIR=/absolute/path/to/data # defaults to a per-user OS dir
macOS Keychain (optional): the
run_*.shscripts read keys from the Keychain if present, falling back to.env. Store keys as the-wargument, never via the interactive prompt — the prompt truncates at 128 chars and silently corrupts longer keys:security add-generic-password -U -s "OPENAI_API_KEY" -a "claude-memory" -w 'sk-proj-...'
Wire into Claude Code
Add to your MCP config (~/.claude.json or project .mcp.json):
{
"mcpServers": {
"sapience": {
"command": "/absolute/path/to/sapience/run_server.sh"
}
}
}
Or, with the package installed, point directly at the console script / module:
{ "mcpServers": { "sapience": {
"command": "/absolute/path/to/sapience/venv/bin/python",
"args": ["-m", "sapience.server"],
"env": { "SAPIENCE_DATA_DIR": "/absolute/path/to/data" }
} } }
Restart Claude Code. The server reads keys and config at launch — restart after changing either.
The /log command
.claude/commands/log.md provides a /log slash command for the ledger — logging, reviewing, resolving, and generating calibrations/bias maps in natural language. Copy it into your project's .claude/commands/.
Automation (optional)
run_consolidate.sh— nightly: extract semantic patterns from recent episodes (cron/launchd).run_weekly_review.sh— weekly ledger review; designed for a Claude Code Stop hook.
Migrating existing markdown memories
MEMORY_MIGRATE_DIR="$HOME/path/to/memory" ./venv/bin/python -m sapience.migrate
License
MIT — see LICENSE.
推荐服务器
Baidu Map
百度地图核心API现已全面兼容MCP协议,是国内首家兼容MCP协议的地图服务商。
Playwright MCP Server
一个模型上下文协议服务器,它使大型语言模型能够通过结构化的可访问性快照与网页进行交互,而无需视觉模型或屏幕截图。
Magic Component Platform (MCP)
一个由人工智能驱动的工具,可以从自然语言描述生成现代化的用户界面组件,并与流行的集成开发环境(IDE)集成,从而简化用户界面开发流程。
Audiense Insights MCP Server
通过模型上下文协议启用与 Audiense Insights 账户的交互,从而促进营销洞察和受众数据的提取和分析,包括人口统计信息、行为和影响者互动。
VeyraX
一个单一的 MCP 工具,连接你所有喜爱的工具:Gmail、日历以及其他 40 多个工具。
graphlit-mcp-server
模型上下文协议 (MCP) 服务器实现了 MCP 客户端与 Graphlit 服务之间的集成。 除了网络爬取之外,还可以将任何内容(从 Slack 到 Gmail 再到播客订阅源)导入到 Graphlit 项目中,然后从 MCP 客户端检索相关内容。
Kagi MCP Server
一个 MCP 服务器,集成了 Kagi 搜索功能和 Claude AI,使 Claude 能够在回答需要最新信息的问题时执行实时网络搜索。
e2b-mcp-server
使用 MCP 通过 e2b 运行代码。
Neon MCP Server
用于与 Neon 管理 API 和数据库交互的 MCP 服务器
Exa MCP Server
模型上下文协议(MCP)服务器允许像 Claude 这样的 AI 助手使用 Exa AI 搜索 API 进行网络搜索。这种设置允许 AI 模型以安全和受控的方式获取实时的网络信息。