opencontext

Compare original and translation side by side

🇺🇸

Original

English
🇨🇳

Translation

Chinese

OpenContext 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

默认路径

ItemPath
Contexts
~/.opencontext/contexts
Database
~/.opencontext/opencontext.db

项目路径
上下文存储
~/.opencontext/contexts
数据库
~/.opencontext/opencontext.db

2. Install and initialize

2. 安装与初始化

Install CLI

安装CLI

bash
npm install -g @aicontextlab/cli
bash
npm install -g @aicontextlab/cli

Or use npx

或使用npx

npx @aicontextlab/cli <command>
undefined
npx @aicontextlab/cli <command>
undefined

Initialize (run inside the repo)

初始化(在代码仓库内运行)

bash
cd your-project
oc init
What
oc init
does:
  • 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 init
oc init
执行的操作:
  • 首次运行时准备全局上下文存储
  • 为所选工具生成用户级命令/技能 + mcp.json
  • 更新仓库的AGENTS.md文件

3. Slash Commands

3. 斜杠命令

Beginner-friendly commands

新手友好命令

CommandPurpose
/opencontext-help
When you don't know where to start
/opencontext-context
(Recommended default) Load background before work
/opencontext-search
Search existing documents
/opencontext-create
Create a new document/idea
/opencontext-iterate
Store conclusions and citations
命令用途
/opencontext-help
不知道从何开始时使用
/opencontext-context
(推荐默认使用) 工作前加载背景信息
/opencontext-search
搜索已有文档
/opencontext-create
创建新文档/记录新想法
/opencontext-iterate
存储结论和引用内容

Install locations

安装位置

undefined
undefined

Slash 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
undefined
bash
undefined

List 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
undefined
oc doc ls project-a
undefined

Search & manifest

搜索与清单生成

bash
undefined
bash
undefined

Search (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
undefined
oc context manifest project-a --limit 10
undefined

Search modes

搜索模式

ModeDescriptionRequirements
--mode keyword
Keyword-based searchNo embeddings required
--mode vector
Vector searchEmbeddings + index required
--mode hybrid
Hybrid (default)Embeddings + index required
模式描述要求
--mode keyword
基于关键词的搜索不需要嵌入向量
--mode vector
向量搜索需要嵌入向量 + 索引
--mode hybrid
混合搜索(默认)需要嵌入向量 + 索引

Embedding configuration (for semantic search)

嵌入向量配置(用于语义搜索)

bash
undefined
bash
undefined

Set 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 link
bash
oc_list_folders    # 列出文件夹
oc_list_docs       # 列出文档
oc_manifest        # 生成清单
oc_search          # 搜索文档
oc_create_doc      # 创建文档
oc_get_link        # 生成稳定链接

Multi-Agent integration

多Agent集成

bash
undefined
bash
undefined

Gemini: 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] 汇总结果 + 存储到OpenContext

Practical example: API design + implementation + testing

实际示例:API设计 + 实现 + 测试

bash
undefined
bash
undefined

1. [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:
ActionHowResult
Cite text snippetSelect text → right-click → "Copy Citation"Agent reads the snippet + source
Cite documentClick the citation icon next to the document titleAgent reads the full document + obtains stable_id
Cite folderRight-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批量读取文件夹内所有文档

网页UI


---
bash
oc ui

Quick 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 link
bash
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  database

oc_list_folders  列出文件夹
oc_list_docs     列出文档
oc_search        搜索
oc_manifest      生成清单
oc_create_doc    创建文档
oc_get_link      生成链接

References

路径

~/.opencontext/contexts      上下文存储
~/.opencontext/opencontext.db  数据库

参考资料