/ 目录 / 演练场 / claude-mem
● 社区 thedotmack ⚡ 即开即用

claude-mem

作者 thedotmack · thedotmack/claude-mem

claude-mem captures every Claude Code session, compresses it with AI into a searchable memory, and injects only the relevant bits into future sessions.

claude-mem is a plugin/skill hybrid for Claude Code (also Gemini CLI and OpenCode). Five lifecycle hooks observe everything your agent does; an AI compression pass distills sessions into structured observations; a SQLite + Chroma vector store powers semantic recall. You search memory with the mem-search skill, and a local web viewer at localhost:37777 shows the memory stream in real time. Privacy controls via <private> tags keep secrets out. The biggest win: no more 'remind me what we decided last Tuesday' at the start of every session.

为什么要用

核心特性

实时演示

实际使用效果

claude-mem-skill.replay ▶ 就绪
0/0

安装

选择你的客户端

~/Library/Application Support/Claude/claude_desktop_config.json  · Windows: %APPDATA%\Claude\claude_desktop_config.json
{
  "mcpServers": {
    "claude-mem-skill": {
      "command": "npx",
      "args": [
        "claude-mem",
        "install"
      ]
    }
  }
}

打开 Claude Desktop → Settings → Developer → Edit Config。保存后重启应用。

~/.cursor/mcp.json · .cursor/mcp.json
{
  "mcpServers": {
    "claude-mem-skill": {
      "command": "npx",
      "args": [
        "claude-mem",
        "install"
      ]
    }
  }
}

Cursor 使用与 Claude Desktop 相同的 mcpServers 格式。项目级配置优先于全局。

VS Code → Cline → MCP Servers → Edit
{
  "mcpServers": {
    "claude-mem-skill": {
      "command": "npx",
      "args": [
        "claude-mem",
        "install"
      ]
    }
  }
}

点击 Cline 侧栏中的 MCP Servers 图标,然后选 "Edit Configuration"。

~/.codeium/windsurf/mcp_config.json
{
  "mcpServers": {
    "claude-mem-skill": {
      "command": "npx",
      "args": [
        "claude-mem",
        "install"
      ]
    }
  }
}

格式与 Claude Desktop 相同。重启 Windsurf 生效。

~/.continue/config.json
{
  "mcpServers": [
    {
      "name": "claude-mem-skill",
      "command": "npx",
      "args": [
        "claude-mem",
        "install"
      ]
    }
  ]
}

Continue 使用服务器对象数组,而非映射。

~/.config/zed/settings.json
{
  "context_servers": {
    "claude-mem-skill": {
      "command": {
        "path": "npx",
        "args": [
          "claude-mem",
          "install"
        ]
      }
    }
  }
}

加入 context_servers。Zed 保存后热重载。

claude mcp add claude-mem-skill -- npx claude-mem install

一行命令搞定。用 claude mcp list 验证,claude mcp remove 卸载。

使用场景

实战用法: claude-mem

Resume a multi-week project without re-briefing Claude every morning

👤 Engineers on long-running features or research ⏱ ~5 min beginner

何时使用: You spend the first 10 minutes of every session re-explaining context that Claude had yesterday.

前置条件
  • Claude Code installed — npm install -g @anthropic-ai/claude-code
  • claude-mem installed — npx claude-mem install (registers hooks in ~/.claude)
步骤
  1. Work normally
    Just use Claude Code. claude-mem is passive — hooks capture events automatically.✓ 已复制
    → localhost:37777 shows the memory stream updating as you work
  2. Start tomorrow's session
    Where did we leave off on the migration branch?✓ 已复制
    → Claude recalls concrete facts + cites observation IDs
  3. Correct misremembering
    That's wrong about the DB schema — we decided to keep the v1 field. Mark that observation as corrected.✓ 已复制
    → mem-search writes a correction; future recall prioritizes it

结果: Sessions feel continuous. The re-briefing ritual disappears.

注意事项
  • Memory recalls stale facts after you change course — Explicitly mark corrections; mem-search respects recency and overrides
  • Sensitive code snippets get captured — Wrap them in <private>...</private> tags; hooks skip private blocks
搭配使用: filesystem

Turn individual sessions into team knowledge without writing docs

👤 Team leads; ICs who avoid writing postmortems ⏱ ~10 min intermediate

何时使用: You solve a gnarly bug, explain the fix to Claude, and want that explanation findable next month without writing a README.

步骤
  1. Narrate your fix
    Walk me through why the deadlock happened and the fix you just landed. Be complete — future me might read this.✓ 已复制
    → Claude writes a narrative; compression captures it
  2. Tag the memory
    Tag this observation with 'db-deadlock-2026-04' and 'billing-cluster'.✓ 已复制
    → Tags stored on the observation
  3. Recall later
    A month later: 'We've got another deadlock in billing — pull any prior notes.'✓ 已复制
    → The April note surfaces first

结果: Lightweight knowledge base that grows by itself.

注意事项
  • Memory gets noisy as months pass — Use mem-search --prune on low-signal old sessions; Endless Mode (beta) handles this automatically
搭配使用: memory

Keep customer data and secrets out of memory captures

👤 Anyone working with sensitive data ⏱ ~15 min intermediate

何时使用: You work on code that touches PII or secrets and can't let them land in a local vector store.

步骤
  1. Wrap sensitive blocks
    Write me the sample data with real test records wrapped in <private> tags so claude-mem doesn't capture the values.✓ 已复制
    → Private blocks are in the transcript but not in the memory store
  2. Verify
    Open localhost:37777 and check today's stream. Confirm no records from the <private> block appear.✓ 已复制
    → Private content absent
  3. Add repo-wide policy
    Update CLAUDE.md: 'Always wrap real customer data in <private>'.✓ 已复制
    → CLAUDE.md updated; future sessions inherit

结果: Memory is useful without being a data-leak surface.

注意事项
  • Forgetting to tag sensitive content — Make it a pre-commit / hook convention; claude-mem can enforce prompts that remind on detection

组合

与其他 MCP 搭配,撬动十倍杠杆

claude-mem-skill + filesystem

Memory recalls the file you edited, filesystem re-reads it

Pull from mem-search the last file we edited in the billing refactor; then read it and continue where we left off.✓ 已复制
claude-mem-skill + serena

Memory supplies the intent; Serena supplies the current code state

Memory says we're renaming ChargeService → BillingService; use Serena to finish the rename.✓ 已复制
claude-mem-skill + github

Cross-reference memory with real PR state

Memory says we opened a PR yesterday; use GitHub MCP to get its current status and review comments.✓ 已复制

工具

此 MCP 暴露的能力

工具输入参数何时调用成本
mem-search (skill) query: str, limit?: int, since?: date Any time you'd ask Claude to 'remember' — full-text and semantic search over your history free (local SQLite + embedding model)
mem-compress (hook) session transcript Automatic — runs at session end; rarely invoked manually small Claude call per session
web viewer URL http://localhost:37777 Debug what's being captured; check privacy filters free

成本与限制

运行它的成本

API 配额
Local SQLite + Chroma vectors; embedding model bundled
每次调用 Token 数
Small — observations are already compressed
费用
Free (MIT)
提示
Compression calls use your Claude API key; set a monthly budget in the claude-mem config if you chat a lot

安全

权限、密钥、影响范围

凭据存储: None for the tool itself; compression uses your existing Claude API key
数据出站: Compression calls go to Anthropic (your account); nothing else leaves your machine
切勿授予: Uploading the SQLite/Chroma store off-device without review — it contains transcripts

故障排查

常见错误与修复

Web viewer at localhost:37777 won't load

Check the hook is running: ps aux | grep claude-mem. Reinstall with npx claude-mem install if it's absent.

验证: curl -I http://localhost:37777
Recall returns nothing useful

First few sessions are cold; memory gets better after ~10 sessions as patterns emerge. Also check that hooks are actually firing (see viewer).

验证: Open viewer during a session; events should stream in real time
Compression calls are expensive

Lower compression depth in config or use Endless Mode (beta) which is cheaper per session

验证: Check Anthropic usage dashboard for attribution
<private> content still shows up

Tag must be on its own lines; inline <private>…</private> in the middle of a sentence isn't parsed. Use block form.

验证: Reproduce and inspect the stored observation in the viewer

替代方案

claude-mem 对比其他方案

替代方案何时用它替代权衡
Memory MCPYou want explicit, user-controlled memory writes — not passive captureYou do the memory-saving yourself; less ambient, less magic
Serena memoryYour use case is code-focused and you'd rather have per-project notes than transcript compressionNo session-stream capture; more project-level
Just take notesYou prefer explicit, human-curated notesNo automation; discipline-dependent

更多

资源

📖 阅读 GitHub 上的官方 README

🐙 查看未解决的 issue

🔍 浏览全部 400+ MCP 服务器和 Skills