Skip to content

Cursor集成

你的人工智能不再遗忘。赋予 Cursor 持久记忆。

每个 Cursor 会话都是从头开始的——你的 AI 不会记得它昨天处理过的内容。Claude-mem 改变了这一点。你的代理会随着时间积累关于你的代码库、决策和模式的知识。

  • Free to Start

Works with Gemini's free tier (1500 req/day) - no subscription required

  • Automatic Capture

MCP tools, shell commands, and file edits logged without effort

  • Smart Context

Relevant history injected into every chat session

  • Works Everywhere

With or without Claude Code subscription

无需订阅 Claude Code。 使用 Gemini(免费版)或 OpenRouter 作为您的 AI 提供者。

运作方式

Claude-mem 通过本地钩子与 Cursor 集成:

  1. 会话钩子 捕捉工具使用、文件编辑和 shell 命令
  2. 人工智能提取 将观察结果压缩为语义摘要
  3. 上下文注入 将相关历史加载到每个新会话中
  4. 记忆查看器http://localhost:37777 显示你的知识库

安装路径

选择适合您设置的安装方法:

路径 A:仅Cursor用户(无 Claude Code)

如果你在没有 Claude Code 订阅的情况下使用 Cursor:

bash
# Clone and build
git clone https://github.com/thedotmack/claude-mem.git
cd claude-mem && bun install && bun run build

# Run interactive setup wizard
bun run cursor:setup

安装向导将会:

  • 检测到你尚未配置 Claude Code
  • 帮助你选择和配置免费的 AI 提供商(推荐 Gemini)
  • 自动安装钩子
  • 启动 Worker 服务

详细指南:

路径 B:Claude Code用户

如果你安装了Claude Code:

bash
# Install the plugin (if not already)
/plugin marketplace add thedotmack/claude-mem
/plugin install claude-mem

# Install Cursor hooks
claude-mem cursor install

该插件默认使用 Claude 的 SDK,但你可以随时切换到 Gemini 或 OpenRouter。

先决条件

- [Bun](https://bun.sh): `curl -fsSL https://bun.sh/install | bash`
- Cursor IDE
- jq and curl: `brew install jq curl`


- [Bun](https://bun.sh): `curl -fsSL https://bun.sh/install | bash`
- Cursor IDE
- jq and curl: `apt install jq curl` or `dnf install jq curl`


- [Bun](https://bun.sh): `powershell -c "irm bun.sh/install.ps1 | iex"`
- Cursor IDE
- PowerShell 5.1+ (included in Windows 10/11)
- Git for Windows

快速命令参考

安装后,这些命令可以从 claude-mem 目录使用:

命令描述
bun run cursor:setup互动安装向导
bun run cursor:install安装 Cursor 钩子
bun run cursor:uninstall移除 Cursor 钩子
bun run cursor:status检查挂钩安装状态
bun run worker:start启动 Worker 服务
bun run worker:stop停止 Worker 服务
bun run worker:status检查 Worker 状态

验证安装

设置完成后,验证一切是否正常工作:

  1. 检查工作状态:

    bash
    bun run worker:status
  2. 检查挂钩安装:

    bash
    bun run cursor:status
  3. 打开内存查看器: 在浏览器中打开 http://localhost:37777

  4. 重启 Cursor 并开始编码会话 - 你应该能看到上下文被捕获

提供商比较

提供者费用速率限制最适合
Gemini免费套餐每天1500次请求个人使用,入门
OpenRouter按使用付费的免费模型根据模型不同模型多样,高流量
Claude SDK随 Claude Code 提供无限Claude Code 订阅者

建议: 从 Gemini 的免费套餐开始。它能很好地应对常规的个人使用需求。如果你需要更高的使用限额,可以切换到 OpenRouter 或 Claude SDK。

故障排除

工作未启动

bash
# Check if port is in use
lsof -i :37777

# Force restart
bun run worker:stop && bun run worker:start

# Check logs
bun run worker:logs

钩子未触发

  1. 安装后重启 Cursor IDE
  2. 检查挂钩是否已安装:bun run cursor:status
  3. 验证 hooks.json 是否存在于 .cursor/ 目录中

没有出现任何上下文

  1. 确保Worker 进程正在运行: bun run worker:status
  2. 检查您是否有观察:访问 http://localhost:37777
  3. 请验证您的 API 密钥配置是否正确

下一步