by redleaves
🧠 LLM-Driven Intelligent Memory & Context Management System (AI记忆管理与智能上下文感知平台) AI记忆管理平台 | 智能上下文感知 | RAG检索增强生成 | 向量检索引擎
# Add to your Claude Code skills
git clone https://github.com/redleaves/context-keeperGuides for using ai agents skills like context-keeper.
Last scanned: 5/30/2026
{
"issues": [
{
"type": "npm-audit",
"message": "axios: Axios is vulnerable to DoS attack through lack of data size check",
"severity": "high"
},
{
"type": "npm-audit",
"message": "follow-redirects: follow-redirects leaks Custom Authentication Headers to Cross-Domain Redirect Targets",
"severity": "medium"
},
{
"type": "npm-audit",
"message": "ws: ws: Uninitialized memory disclosure",
"severity": "medium"
}
],
"status": "WARNING",
"scannedAt": "2026-05-30T16:09:33.983Z",
"npmAuditRan": true,
"pipAuditRan": true
}context-keeper is an open-source ai agents skill for AI coding assistants such as Claude Code, Codex CLI, and ChatGPT, built by redleaves. 🧠 LLM-Driven Intelligent Memory & Context Management System (AI记忆管理与智能上下文感知平台) AI记忆管理平台 | 智能上下文感知 | RAG检索增强生成 | 向量检索引擎. It has 153 GitHub stars.
context-keeper returned warnings in SkillsLLM's automated security scan. It has no critical vulnerabilities, but review the flagged issues in the Security Report section before adding it to your workflow.
Clone the repository with "git clone https://github.com/redleaves/context-keeper" and add it to your Claude Code skills directory (see the Installation section above).
context-keeper is primarily written in Go. It is open-source under redleaves on GitHub, so you can review or fork the full source.
Yes. SkillsLLM lists many other AI Agents skills you can browse and compare side by side. Open the AI Agents category from the badge at the top of this page, or use the Related Skills and comparison links further down to weigh context-keeper against similar tools.
No comments yet. Be the first to share your thoughts!
Requires a passing catalog security scan. Resolve the flagged issues and resubmit to enable featuring.
基于LLM驱动的智能记忆与上下文管理系统
重新定义AI助手的记忆边界,让每一次对话都有意义
"还记得昨天讨论的微服务架构方案吗?" → "抱歉,我不记得..." → 😤
| 👤 个人开发者 | 👥 团队Leader | 🏗️ 项目经理 | 🏢 企业高管 | |
|---|---|---|---|---|
| 💔 核心痛点 | 🔄 每天重复解释项目背景给AI🧠 上下文丢失:AI无法理解开发意图🌀 重复劳动:相似问题反复解决 | 📚 知识断层:老员工经验无法传承💬 沟通成本高:反复解释相同问题🚫 决策延迟:缺乏历史上下文参考 | 🔧 技术债务:历史决策原因不明⏱️ 项目延期:新人上手周期长📋 文档滞后:代码与文档不同步 | 💸 人才流失:核心知识随人员离职📈 ROI下降:跨项目最佳实践难复用🎯 竞争劣势:创新速度被拖慢 |
| ⚡ 直接影响 | 🔥30%开发时间浪费 | 📉团队效率下降40% | 💰项目成本超预算2x | ⏰人才培养成本6-12个月 |
核心问题:AI工具缺乏持续记忆能力,无法形成智能的知识积累和传承体系。面对这些困境,我们需要的不是另一个记忆工具,而是一个真正理解开发者意图的智能大脑。🚀 Context-Keeper:突破传统边界的智能解决方案
%%{init: {'theme':'base', 'themeVariables': {'fontSize':'16px', 'fontFamily':'Arial, sans-serif'}}}%%
graph LR
subgraph Stage1["🔍 多维宽召回<br/>(高覆盖率)"]
A1("语义检索<br/>TOP-50")
A2("时间线检索<br/>TOP-30")
A3("知识图谱<br/>TOP-20")
A1 --> A4("候选集<br/>~100条")
A2 --> A4
A3 --> A4
end
subgraph Stage2["🧠 LLM精排序<br/>(高准确率)"]
A4 --> B1("LLM智能分析")
B1 --> B2("质量评估")
B2 --> B3("相关性排序")
B3 --> B4("TOP-N<br/>精准结果")
end
subgraph Stage3["🎯 多维融合<br/>(个性化输出)"]
B4 --> C1("语义维度")
B4 --> C2("时间维度")
B4 --> C3("知识维度")
C1 --> C4("智能融合引擎")
C2 --> C4
C3 --> C4
C4 --> C5("个性化方案")
end
style Stage1 fill:#e3f2fd,stroke:#e2e8f0,stroke-width:1px,rx:8,ry:8
style Stage2 fill:#fff3e0,stroke:#e2e8f0,stroke-width:1px,rx:8,ry:8
style Stage3 fill:#e8f5e9,stroke:#e2e8f0,stroke-width:1px,rx:8,ry:8
| 突破点 | 传统方案痛点 | Context-Keeper解决方案 | 核心优势 |
|---|---|---|---|
| 🧠 智能推理 | 机械匹配,无法理解意图 | LLM深度推理:理解开发场景和项目上下文 | 准确率75%+ |
| ⚡ 宽召回+精排序 | 召回率与准确率矛盾 | 两阶段架构:宽召回(100条) → 精排序(TOP-N) | 覆盖率80%+ |
| 🎯 多维融合 | 单一语义检索,信息孤立 | 三维记忆空间:语义+时间+知识图谱深度融合 | 关联发现率3倍提升 |
| 应用场景 | 开发者问题 | Context-Keeper智能响应 | 价值体现 |
|---|---|---|---|
| 架构决策回顾 | "为什么选择微服务而非单体?" | 基于3月15日技术评审记录的详细分析 | 🧠 历史智慧复用 |
| Bug修复复用 | "类似性能问题怎么解决?" | 发现2个相关案例并提供解决方案 | ⚡ 经验快速复用 |
| 技术选型参考 | "Redis集群配置最佳实践?" | 项目历史配置+业界最佳实践对比 | 🎯 决策支持优化 |
Context-Keeper目前经历了两个版本的迭代:
📚 长短期记忆分层设计
👤 用户隔离与个性化
🔄 记忆与批次管理机制
Context-Keeper基于LLM驱动的智能上下文记忆管理系统,在一期基础上实现了两个关键突破:
🧠 LLM驱动的宽召回+精排序架构 - 构建"意图理解 → 宽召回 → 精排序 → 智能合成"的LLM驱动架构
⭐️ 智能上下文管理 - 四维统一上下文模型+LLM驱动的全生命周期智能管理
sequenceDiagram
participant User as 👤 用户
participant LLM1 as 🧠 LLM阶段一
participant MDRE as 🔍 多维检索引擎
participant LLM2 as 🧠 LLM阶段二
participant Context as 🌟 上下文管理
User->>LLM1: "回忆项目架构设计"
LLM1->>LLM1: 🎯 意图分析<br/>核心意图+领域上下文+应用场景
LLM1->>MDRE: 检索策略+查询改写
par 宽召回阶段
MDRE->>MDRE: 向量检索:架构语义
MDRE->>MDRE: 时间线检索:设计讨论
MDRE->>MDRE: 知识图谱:架构关联
end
MDRE->>LLM2: 候选集 (~100条)
LLM2->>LLM2: 🧠 精排序<br/>质量评估+相关性排序
LLM2->>Context: 结构化合成
Context->>User: ✅ 个性化架构方案
| 层级 | 核心能力 | 技术实现 | 性能优势 |
|---|---|---|---|
| 🧠 智能层 | 两阶段LLM协同推理 | 意图分析+智能合成分工 | 准确率75% |
| 🔍 检索层 | 多维宽召回+精排序 | 语义+时间+图谱混合检索 | 召回率80%+ |
| ⭐️ 管理层 | 智能上下文管理 | 四维协同+实时同步 | 响应<500ms |
Context-Keeper构建了四维统一上下文模型作为上下文信息的载体,通过LLM驱动的智能管理机制,实现上下文从初始构建→填充完善→智能分析&更新上下文(循环往复)的全生命周期管理
核心设计:
sequenceDiagram
participant User as 👤 用户
participant SessionMgmt as 🚀 会话管理工具
participant RetrieveCtx as 🔍 上下文检索工具
participant StoreConv as 💾 对话存储工具
participant AssocFile as 📝 文件关联工具
participant Context as ⭐️ 上下文管理
participant LLM1 as 🧠 LLM阶段一
participant MDRE as 🔍 多维检索
participant LLM2 as 🧠 LLM阶段二
participant Storage as 💾 存储层
Note over User,Storage: 🆕 初始构建(首次会话)
User->>SessionMgmt: session_management(get_or_create)
SessionMgmt->>SessionMgmt: 工程感知分析<br/>技术栈·架构·依赖识别
SessionMgmt->>Context: 触发初始构建管理
Context->>Context: 创建ProjectContext<br/>构建统一上下文模型基础
Context->>Storage: 持久化ProjectContext
Note over User,Storage: 🔍 填充完善(首次检索)
User->>RetrieveCtx: retrieve_context(query, sessionId)
RetrieveCtx->>Context: 获取当前上下文
Context-->>RetrieveCtx: 返回ProjectContext
RetrieveCtx->>LLM1: 用户查询+上下文
LLM1->>LLM1: 意图理解+查询改写
LLM1->>MDRE: 宽召回指令
par 宽召回并行检索
MDRE->>MDRE: 向量检索
MDRE->>MDRE: 时间线检索
MDRE->>MDRE: 知识图谱检索
end
MDRE->>LLM2: 候选集数据
LLM2->>Context: 获取当前上下文进行比对
Context-->>LLM2: ProjectContext(其他维度待填充)
LLM2->>LLM2: 🧠 语义比对+精排序合成
LLM2->>Context: 触发填充完善管理
Context->>Context: 完整构建TopicCtx+ConvCtx<br/>(CodeCtx由代码变更触发)
Context->>Storage: 持久化完整上下文模型
RetrieveCtx->>User: 返回智能合成结果
Note over User,Storage: 🔄 变更管理(后续所有交互)
loop 标准SOP循环:每次MCP工具调用
alt 检索触发
User->>RetrieveCtx: retrieve_context(query, sessionId)
RetrieveCtx->>Context: 获取当前上下文
Context-->>RetrieveCtx: 完整四维上下文
RetrieveCtx->>LLM1: 查询+上下文
LLM1->>MDRE: 宽召回
MDRE->>LLM2: 候选集
LLM2->>Context: 语义比对+变更检测
else 存储触发
User->>StoreConv: store_conversation(messages, sessionId)
StoreConv->>Context: 获取当前上下文
Context->>Context: 基于当前上下文进行变更检测
else 代码变更触发
User->>AssocFile: associate_file(filePath, sessionId)
AssocFile->>Context: 获取当前上下文
Context->>Context: 结合主题上下文更新CodeContext
end
Context->>Context: 🎯 变更检测管理<br/>当前上下文 vs 新数据
alt 检测到语义变更
Context->>Context: ⚡️ 智能更新管理<br/>增量变更+冲突解决
Context->>Storage: 持久化变更
else 无变更
Context->>Context: 保持当前状态
end
alt 检索触发
RetrieveCtx->>User: 返回检索结果
else 存储触发
StoreConv->>User: 返回存储确认
else 代码变更触发
AssocFile->>User: 返回关联确认
end
end
🔥 管理机制核心优势:
在部署Context-Keeper之前,需要准备以下基础设施:
1. 向量数据库(必需)
我们设计了统一的向量存储接口,可按照开发者/企业需要自行扩展,支持多种向量数据库:
# 配置示例(二选一)
# 选项1:使用阿里云DashVector
VECTOR_STORE_TYPE=aliyun
VECTOR_DB_URL=https://your-instance.dashvector.cn-hangzhou.aliyuncs.com
VECTOR_DB_API_KEY=your-dashvector-api-key
# 选项2:使用京东云Vearch
VECTOR_STORE_TYPE=vearch
VEARCH_URL=http://your-vearch-instance.jd.local
VEARCH_USERNAME=your-username
VEARCH_PASSWORD=your-password
2. 时序数据库(必须)
自行安装:TimescaleDB/PostgreSQL(用于时间线存储)
3. 图数据库(必须)
自行安装:Neo4j(用于知识图谱和关联分析)
4. LLM模型配置(必须)
我们支持本地和云端大模型配置,灵活满足不同场景需求:
🏠 本地模型(推荐)
curl -fsSL https://ollama.ai/install.sh | shollama pull deepseek-coder-v2:16b☁️ 云端模型(备用)
# 1. 获取Context-Keeper
git clone https://github.com/redleaves/context-keeper.git
cd context-keeper
# 2. 环境配置(重要!)
cp confi