使用说明
复存储器
你的代码库永远不会忘记。
AI代理在每次会话中都会失去上下文。repomemory修复了这个问题——一个命令创建了一个持久的、可搜索的知识库,任何人工智能工具都可以读取、搜索和写入。
npx repomemory go
问题
每次使用Claude Code、Cursor、Copilot或任何AI编码代理打开项目时:
- 它从头开始重新发现您的架构
- 它提出了已经经过辩论和拒绝的修改
- 它重新引入了已经修复的错误
你的 CLAUDE.md / .cursorrules 有帮助,但它是静态的,会变得陈旧。
解决方案
.context/
├── index.md ← Quick orientation (loaded every session)
├── facts/ ← Architecture, database, deployment
├── decisions/ ← "We chose Drizzle over Prisma because..."
├── regressions/ ← "This broke before. Here's what happened."
├── preferences/ ← Your coding style — follows you across all repos
├── sessions/ ← Auto-captured AI session summaries
└── changelog/ ← Monthly git history syncs
事实 告诉特工事情是如何运作的。 决策 防止再次辩论。 回归 防止再次断裂。 偏好 教代理如何编码。
快速开始
使用API密钥(Claude Code,终端工作流)
npx repomemory go
一个命令:设置全局配置文件,创建 .context/,配置Claude Code+Cursor,运行AI分析,打印Claude.md指令。
使用Cursor(不需要API键)
npx repomemory setup cursor
这将安装Cursor所需的一切:
- MCP服务器 在
~/.cursor/mcp.json(在每个项目中自动启动repomemory) - 规则 在
.cursor/rules/repomemory.mdc(教Cursor的AI使用上下文) - 6个命令 在
.cursor/commands/(跑步/在光标聊天中)
然后在光标聊天中键入:
/repomemory-analyze
Cursor自己的AI扫描您的仓库并填充 .context/ 通过MCP工具。不需要外部API密钥-您的Cursor订阅会处理它。
可用光标命令:
| 命令 | 它的作用 |
|---|---|
/repomemory-analyze |
完整的回购分析——填充事实、决策、索引 |
/repomemory-orient |
会话开始时快速定位 |
/repomemory-search |
搜索知识库 |
/repomemory-record |
记录事实、决定或回归 |
/repomemory-session |
保存会话摘要 |
/repomemory-status |
显示上下文覆盖率 |
向导向导
npx repomemory wizard
完成供应商选择、工具集成和首次分析。如果未检测到API密钥,则提供 “无--我使用游标” 完全跳过外部分析的选项。
非交互式(CI安全)
npx repomemory go --yes --provider anthropic --embedding-provider gemini --max-files 80
在以下情况下没有提示 --yes / --defaults / --no-prompt 使用。
MCP服务器——具有真实内存的代理
真正的力量是MCP服务器。通过配置时 repomemory setup claude,它从Claude Code自动启动,并为代理提供7个工具:
| 工具 | 它做什么 |
|---|---|
context_search |
混合关键字+跨仓库语义搜索+全局上下文 |
context_auto_orient |
一个通话方向:索引、偏好、最近会话 |
context_write |
使用智能作用域路由(首选项)写入条目→ 全球) |
context_read |
阅读完整内容,先进行回购,然后进行全局回退 |
context_list |
浏览条目 [repo]/[global] 来源标签 |
context_risk |
评估修改风险——热点、隐藏耦合、总线因素 |
context_delete |
删除过时的知识 |
Agent: "Let me orient myself in this project..."
→ context_auto_orient()
→ Returns: project overview, preferences, recent sessions, recent changes
Agent: "Let me search for context about the auth flow..."
→ context_search("authentication flow")
→ Auto-routes to facts/ category, returns compact results
Agent: "I found a race condition. Let me record this."
→ context_write(category="regressions", filename="token-refresh-race", content="...")
→ Persisted. Detects if it supersedes an existing entry.
会话在关机时自动捕获。零配置-- repomemory setup claude 处理一切。
支持的工具
| 是否需要工具 | 集成 | API密钥? |
|---|---|---|
| 克劳德代码 | MCP服务器(自动启动)+提交后挂钩 | 是(用于分析) |
| 光标 | MCP服务器+规则+6个斜线命令 | 不 --使用Cursor的内置AI |
| GitHub Copilot | copilot-instructions.md |
是(用于分析) |
| 帆板运动 | .windsurfrules |
是(用于分析) |
| 克莱恩 | .clinerules |
是(用于分析) |
| 教唆者 | .aider.conf.yml |
是(用于分析) |
| 继续 | .continue/rules/ |
是(用于分析) |
光标用户: 您不需要任何API密钥。跑
npx repomemory setup cursor,然后使用/repomemory-analyze在Cursor聊天中。Cursor的AI使用MCP工具进行分析——无论Cursor使用什么模型(它甚至可以在任务中期切换模型)。
支持的提供商
| 提供者 | 模型 | 环境变量 |
|---|---|---|
anthropic |
claude-sonnet-4-6,claude-opus-4-6 | ANTHROPIC_API_KEY |
openai |
gpt-4o、o3 mini | OPENAI_API_KEY |
gemini |
双子座-2.0-flash,双子座-2.5-pro | GEMINI_API_KEY / GOOGLE_API_KEY |
grok |
grok-3,grok-3-mini | GROK_API_KEY / XAI_API_KEY |
嵌入 (可选,用于语义搜索):Gemini text-embedding-004 (免费,默认)或OpenAI text-embedding-3-small。从可用的API密钥中自动检测。
所有命令
repomemory go # One-command setup (add --yes for non-interactive)
repomemory wizard # Interactive guided setup
repomemory analyze # AI-powered repo analysis
repomemory analyze --merge # Update without overwriting edits
repomemory analyze --dry-run # Preview without API call
repomemory search <query> # Search knowledge base from terminal
repomemory status # Coverage and freshness report
repomemory doctor # Diagnostics and health check
repomemory dashboard # Local web UI (localhost:3333)
repomemory risk # Hotspots, coupling, ownership analysis
repomemory risk -f src/auth.ts # Targeted risk assessment for specific files
repomemory sync # Sync git history to changelog
repomemory setup <tool> # Configure Claude/Cursor/Copilot/etc
repomemory hook install # Auto-sync changelog on commits
repomemory global list # Manage global developer context
repomemory global export # Export global context as JSON
配置
.repomemory.json 在您的repo根目录中(所有字段都是可选的):
{
"provider": "anthropic",
"model": "claude-sonnet-4-6",
"embeddingProvider": "gemini",
"hybridAlpha": 0.5,
"maxFilesForAnalysis": 80,
"enableGlobalContext": true
}
自定义 ignorePatterns 和 keyFilePatterns 是 添加剂 --它们扩展了内置默认值,而不是替换它们。
为什么不只是CLAUDE.md?
| CLAUDE.md | 报告存储器 | |
|---|---|---|
| 维护 | 手动 | 人工智能生成+代理维护 |
| 搜索 | 加载所有内容 | 混合关键字+语义 |
| 十字工具 | 仅支持Claude Code | 7个工具 |
| 团队知识 | 一个人写 | 每个AI会话都有贡献 |
| 决策 | 与说明混合 | 结构化、可搜索 |
| 回归 | 未跟踪 | 防止重复出现错误 |
| 会话 | 未跟踪 | 关机时自动捕获 |
| 新鲜度 | 未知 | 停滞检测+自动清除 |
repomemory不会替换 CLAUDE.md --它是对它的补充。 CLAUDE.md 用于指示和规则。 .context/ 掌握着随着时间的推移而增长的知识。
贡献
看 贡献.md 用于开发设置、测试和贡献指南。
许可证
麻省理工学院
专为厌倦了AI代理在会话之间忘记一切的开发人员而设计。
