opencontext
Compare original and translation side by side
🇺🇸
Original
English🇨🇳
Translation
ChineseOpenContext Context Management (Persistent Memory)
OpenContext 上下文管理(持久化内存)
Give your AI assistant persistent memory. Stop repeating explanations, and build smarter.
为你的AI助手提供持久化内存。 无需反复解释背景信息,更高效地开展工作。
When to use this skill
何时使用该技能
- When you need to keep context across sessions
- When you need to record project background/decisions
- When you need to search prior conclusions/lessons
- When you need knowledge sharing in a Multi-Agent workflow
- When you want to reduce repetitive background explanations
- 需要跨会话保留上下文时
- 需要记录项目背景/决策时
- 需要搜索过往结论/经验教训时
- 需要在多Agent工作流中实现知识共享时
- 想要减少重复性背景解释时
1. Core concepts
1. 核心概念
Problem
问题背景
When working with an AI assistant, context gets lost (across sessions, repos, and dates). You end up repeating background, re-explaining decisions, and sometimes the assistant continues with incorrect assumptions.
使用AI助手工作时,上下文会(跨会话、跨仓库、跨时间)丢失。你需要反复说明背景、重新解释决策,有时助手还会基于错误的假设继续工作。
Solution
解决方案
OpenContext is a lightweight personal context/knowledge store for AI assistants.
[Load context] → [Do work] → [Store conclusions]OpenContext 是一款为AI助手打造的轻量级个人上下文/知识存储工具。
[加载上下文] → [开展工作] → [存储结论]Default paths
默认路径
| Item | Path |
|---|---|
| Contexts | |
| Database | |
| 项目 | 路径 |
|---|---|
| 上下文存储 | |
| 数据库 | |
2. Install and initialize
2. 安装与初始化
Install CLI
安装CLI
bash
npm install -g @aicontextlab/clibash
npm install -g @aicontextlab/cliOr use npx
或使用npx
npx @aicontextlab/cli <command>
undefinednpx @aicontextlab/cli <command>
undefinedInitialize (run inside the repo)
初始化(在代码仓库内运行)
bash
cd your-project
oc initWhat does:
oc init- Prepare the global context store (on first run)
- Generate user-level commands/skills + mcp.json for the selected tool
- Update the repo's AGENTS.md
bash
cd your-project
oc initoc init- 首次运行时准备全局上下文存储
- 为所选工具生成用户级命令/技能 + mcp.json
- 更新仓库的AGENTS.md文件
3. Slash Commands
3. 斜杠命令
Beginner-friendly commands
新手友好命令
| Command | Purpose |
|---|---|
| When you don't know where to start |
| (Recommended default) Load background before work |
| Search existing documents |
| Create a new document/idea |
| Store conclusions and citations |
| 命令 | 用途 |
|---|---|
| 不知道从何开始时使用 |
| (推荐默认使用) 工作前加载背景信息 |
| 搜索已有文档 |
| 创建新文档/记录新想法 |
| 存储结论和引用内容 |
Install locations
安装位置
undefinedundefinedSlash Commands
斜杠命令
Cursor: ~/.cursor/commands
Claude Code: ~/.claude/commands
Cursor: ~/.cursor/commands
Claude Code: ~/.claude/commands
Skills
技能
Cursor: ~/.cursor/skills/opencontext-/SKILL.md
Claude Code: ~/.claude/skills/opencontext-/SKILL.md
Codex: ~/.codex/skills/opencontext-*/SKILL.md
Cursor: ~/.cursor/skills/opencontext-/SKILL.md
Claude Code: ~/.claude/skills/opencontext-/SKILL.md
Codex: ~/.codex/skills/opencontext-*/SKILL.md
MCP Config
MCP配置
Cursor: ~/.cursor/mcp.json
Claude Code: ~/.claude/mcp.json
---Cursor: ~/.cursor/mcp.json
Claude Code: ~/.claude/mcp.json
---4. Core CLI commands
4. 核心CLI命令
Folder/document management
文件夹/文档管理
bash
undefinedbash
undefinedList folders
列出文件夹
oc folder ls --all
oc folder ls --all
Create folder
创建文件夹
oc folder create project-a -d "My project"
oc folder create project-a -d "My project"
Create document
创建文档
oc doc create project-a design.md -d "Design doc"
oc doc create project-a design.md -d "Design doc"
List documents
列出文档
oc doc ls project-a
undefinedoc doc ls project-a
undefinedSearch & manifest
搜索与清单生成
bash
undefinedbash
undefinedSearch (keyword/hybrid/vector)
搜索(关键词/混合/向量)
oc search "your query" --mode keyword --format json
oc search "your query" --mode keyword --format json
Generate a manifest (list of files the AI should read)
生成清单(AI需要读取的文件列表)
oc context manifest project-a --limit 10
undefinedoc context manifest project-a --limit 10
undefinedSearch modes
搜索模式
| Mode | Description | Requirements |
|---|---|---|
| Keyword-based search | No embeddings required |
| Vector search | Embeddings + index required |
| Hybrid (default) | Embeddings + index required |
| 模式 | 描述 | 要求 |
|---|---|---|
| 基于关键词的搜索 | 不需要嵌入向量 |
| 向量搜索 | 需要嵌入向量 + 索引 |
| 混合搜索(默认) | 需要嵌入向量 + 索引 |
Embedding configuration (for semantic search)
嵌入向量配置(用于语义搜索)
bash
undefinedbash
undefinedSet API key
设置API密钥
oc config set EMBEDDING_API_KEY "<<your_key>>"
oc config set EMBEDDING_API_KEY "<<your_key>>"
(Optional) Set base URL
(可选)设置基础URL
oc config set EMBEDDING_API_BASE "https://api.openai.com/v1"
oc config set EMBEDDING_API_BASE "https://api.openai.com/v1"
(Optional) Set model
(可选)设置模型
oc config set EMBEDDING_MODEL "text-embedding-3-small"
oc config set EMBEDDING_MODEL "text-embedding-3-small"
Build index
构建索引
oc index build
---oc index build
---5. MCP Tools
5. MCP工具
OpenContext MCP Tools
OpenContext MCP工具
bash
oc_list_folders # List folders
oc_list_docs # List documents
oc_manifest # Generate manifest
oc_search # Search documents
oc_create_doc # Create document
oc_get_link # Generate stable linkbash
oc_list_folders # 列出文件夹
oc_list_docs # 列出文档
oc_manifest # 生成清单
oc_search # 搜索文档
oc_create_doc # 创建文档
oc_get_link # 生成稳定链接Multi-Agent integration
多Agent集成
bash
undefinedbash
undefinedGemini: large-scale analysis
Gemini: 大规模分析
ask-gemini "Analyze the structure of the entire codebase"
ask-gemini "Analyze the structure of the entire codebase"
Codex: run commands
Codex: 运行命令
shell "docker-compose up -d"
shell "docker-compose up -d"
OpenContext: store results
OpenContext: 存储结果
oc doc create project-a conclusions.md -d "Analysis conclusions"
---oc doc create project-a conclusions.md -d "Analysis conclusions"
---6. Multi-Agent workflow integration
6. 多Agent工作流集成
Orchestration Pattern
编排模式
[Claude] Plan
↓
[Gemini] Analysis/research + OpenContext search
↓
[Claude] Write code
↓
[Codex] Run/test
↓
[Claude] Synthesize results + store in OpenContext[Claude] 制定计划
↓
[Gemini] 分析/调研 + OpenContext搜索
↓
[Claude] 编写代码
↓
[Codex] 运行/测试
↓
[Claude] 汇总结果 + 存储到OpenContextPractical example: API design + implementation + testing
实际示例:API设计 + 实现 + 测试
bash
undefinedbash
undefined1. [Claude] Design API spec using the skill
1. [Claude] 使用该技能设计API规范
/opencontext-context # Load project background
/opencontext-context # 加载项目背景
2. [Gemini] Analyze a large codebase
2. [Gemini] 分析大型代码库
ask-gemini "@src/ Analyze existing API patterns"
ask-gemini "@src/ Analyze existing API patterns"
3. [Claude] Implement code based on the analysis
3. [Claude] 基于分析结果实现代码
(Use context loaded from OpenContext)
—
4. [Codex] Test and build
—
shell "npm test && npm run build"
#(使用从OpenContext加载的上下文)
5. [Claude] Create final report + store conclusions
4. [Codex] 测试与构建
/opencontext-iterate # Store decisions and lessons learned
---shell "npm test && npm run build"
7. Recommended daily workflow
5. [Claude] 创建最终报告 + 存储结论
Before work (1 min)
—
bash
/opencontext-context- Load project background + known pitfalls
/opencontext-iterate # 存储决策和经验教训
---During work
7. 推荐日常工作流
—
工作前(1分钟)
bash
/opencontext-search- Search existing conclusions when unsure
bash
/opencontext-context- 加载项目背景 + 已知陷阱
After work (2 min)
工作中
bash
/opencontext-iterate- Record decisions, pitfalls, and next steps
bash
/opencontext-search- 不确定时搜索已有结论
High-ROI document types
工作后(2分钟)
- Acceptance Criteria - acceptance criteria
- Common Pitfalls - common pitfalls
- API Contracts - API contracts
- Dependency Versions - dependency versions
bash
/opencontext-iterate- 记录决策、陷阱和下一步计划
8. Stable links (Stable Links)
高投入回报比的文档类型
Keep links stable across renames/moves by referencing document IDs:
markdown
[label](oc://doc/<stable_id>)- 验收标准 - 验收条件
- 常见陷阱 - 常见问题
- API合约 - API约定
- 依赖版本 - 依赖包版本
Generate a link via CLI
8. 稳定链接(Stable Links)
bash
oc doc link <doc_path>通过引用文档ID,确保链接在重命名/移动后仍然有效:
markdown
[label](oc://doc/<stable_id>)Generate a link via MCP
通过CLI生成链接
bash
oc_get_link doc_path="Product/api-spec"bash
oc doc link <doc_path>9. Desktop App & Web UI
通过MCP生成链接
Desktop App (recommended)
—
- Manage/search/edit context with a native UI
- Use without the CLI
- Automatic index builds (in the background)
Citation features:
| Action | How | Result |
|---|---|---|
| Cite text snippet | Select text → right-click → "Copy Citation" | Agent reads the snippet + source |
| Cite document | Click the citation icon next to the document title | Agent reads the full document + obtains stable_id |
| Cite folder | Right-click folder → "Copy Folder Citation" | Agent bulk-reads all docs in the folder |
bash
oc_get_link doc_path="Product/api-spec"Web UI
9. 桌面端应用与网页UI
—
桌面端应用(推荐)
bash
oc ui- 通过原生UI管理/搜索/编辑上下文
- 无需使用CLI即可使用
- 后台自动构建索引
引用功能:
| 操作 | 方式 | 结果 |
|---|---|---|
| 引用文本片段 | 选中文本 → 右键 → "复制引用" | Agent读取片段 + 来源 |
| 引用文档 | 点击文档标题旁的引用图标 | Agent读取完整文档 + 获取stable_id |
| 引用文件夹 | 右键文件夹 → "复制文件夹引用" | Agent批量读取文件夹内所有文档 |
Default URL: http://127.0.0.1:4321
网页UI
---bash
oc uiQuick Reference
默认地址: http://127.0.0.1:4321
Essential workflow
—
Before: /opencontext-context (load background)
During: /opencontext-search (search)
After: /opencontext-iterate (store)
---Core CLI commands
快速参考
—
核心工作流
bash
oc init # Initialize project
oc folder ls --all # List folders
oc doc ls <folder> # List documents
oc search "query" # Search
oc doc create ... # Create document工作前: /opencontext-context (加载背景)
工作中: /opencontext-search (搜索)
工作后: /opencontext-iterate (存储)MCP Tools
核心CLI命令
oc_list_folders list folders
oc_list_docs list documents
oc_search search
oc_manifest manifest
oc_create_doc create document
oc_get_link generate linkbash
oc init # 初始化项目
oc folder ls --all # 列出文件夹
oc doc ls <folder> # 列出文档
oc search "query" # 搜索
oc doc create ... # 创建文档Paths
MCP工具
~/.opencontext/contexts context store
~/.opencontext/opencontext.db databaseoc_list_folders 列出文件夹
oc_list_docs 列出文档
oc_search 搜索
oc_manifest 生成清单
oc_create_doc 创建文档
oc_get_link 生成链接References
路径
~/.opencontext/contexts 上下文存储
~/.opencontext/opencontext.db 数据库—