kimi-code-memory-mcp-server AGENTS.md

Project instructions for a memory-enabled MCP server, which gives an AI system long-term notes about a codebase. They define how to load workspace context and classify information as decisions, rules, knowledge, references, or temporary notes.

In plain words
What is it for?
Use them to bootstrap a session, decide what project information to remember, store it in the right category, and check existing memories before changing the project.
Why use it?
They make sure the assistant starts with the right project context and records durable decisions without saving every temporary detail.

Instructions file for CodexOpenCode

Install

Getting it into your agent

One page per mod, every tool's command on it. A separate URL per tool would split the same page into five that compete with each other.

agentmods
npx agentmods add instructions/zehee/kimi-code-memory-mcp-server/agents-md
Clone the repo
git clone --depth 1 https://github.com/Zehee/kimi-code-memory-mcp-server

Made for: Codex, OpenCode.

Per session 1,641 This file is loaded in full into every session.
When invoked 1,641 The same file — it is already loaded in full.
Security scan A 0 findings. Scan, not verified.
Origin original No closer match found in the catalogue.
Token cost

What it costs to keep this loaded

Counted locally with the o200k_base tokenizer, which is exact for GPT models; Claude uses its own tokenizer and its counts differ. Treat this as one consistent yardstick across the catalogue rather than a bill. Prices are per million input tokens.

ModelPer sessionOnce invoked
Fable 5 $0.01641 $0.01641
Opus 5 $0.00821 $0.00821
Sonnet 5 $0.00328 $0.00328
Haiku 4.5 $0.00164 $0.00164

Measured yesterday against content hash 52359bcc4cf6, method: parsed. Prices are Anthropic first-party input rates as of 2026-08-30, from the pricing page.

Security

Grade A, and why

kimi-code-memory-mcp-server AGENTS.md scanned grade A with 0 findings against 26 rules in 11 categories — prompt injection, anti-refusal, data exfiltration, privilege escalation, supply chain, agent snooping, system-prompt leakage, SSRF and excessive agency — measured yesterday.

A static scan of the body, not an audit. Every finding is printed with the line that produced it so you can judge whether it matters here. A mod is markdown that instructs an agent; that is exactly why what it instructs is worth reading.

Nothing flagged

None of the 26 patterns this scan looks for appear in this file: no shell pipes, no recursive deletes, no credential paths, no hidden text, no instruction-override or anti-refusal phrasing, no agent-config snooping. That is not a guarantee, it is the absence of the things that are checkable.

AGENTS.md · 145 lines

How it starts

The opening of the file, as written. The whole thing — 145 lines — stays where its author put it; the contents beside it link to each section on GitHub.

强制启动协议-(subagent忽略)

每次新会话开始后、回答用户第一个问题或执行任何可能改变项目状态的操作之前,必须调用 mcp__kimi-memory__bootstrap_workspace()

必须读取并内化:

  1. essence.md —— 当前工作区什么最重要
  2. memoryIndexTree —— 记忆目录结构,关注标记 [new] 的最近变化
  3. recentContext —— 当前 session 的最近对话
  4. notesRefs —— 是否有待处理的速记

记忆分类约定

类型 folder tags 用途
决策 memory/decisions/ decision 架构、接口、流程决策
规则 memory/rules/ rule 编码规范、协作红线
知识 memory/knowledge/ knowledge 技术栈、业务背景
参考 memory/reference/ reference 外部链接、文档引用
速记 notes/ scratch 临时便签,不进入长期精要

什么时候必须 remember

出现以下信号时立即写入 memory/

  • 用户说"我们决定…"、"拍板了" → memory/decisions/,tag decision
  • 用户说"这里必须…"、"红线是…" → memory/rules/,tag rule
  • 技术选型、接口约定首次出现 → memory/knowledge/,tag knowledge
  • 定位到 bug 根因和修复方案 → memory/decisions/memory/knowledge/,tag fix
  • 编码风格、目录结构、命名规范 → memory/rules/,tag convention

什么时候不要 remember

  • ❌ 临时调试命令或探索性代码
  • ❌ 用户未确认的推测
  • ❌ 一次性报错(没有形成通用结论)
  • ❌ 当前会话的临时上下文(由 wire.jsonl 自动捕获)
  • ❌ 已经在 memory/ 中存在的知识

判断口诀:如果这条信息三天后回头看仍然有价值,才写入 memory/


决策守卫

准备执行任何可能改变项目状态的操作之前(写文件、改结构、做选择、引入依赖):

  1. 提取关键词(技术实体 + 动作)
  2. 并行查询:
    • search(query, folder="memory") —— 查决策/规则/知识
    • search_context(query) —— 查历史对话
  3. 命中且一致 → 引用来源后继续
  4. 命中但矛盾 → 向用户报告冲突,请求澄清
  5. 未命中但重要 → 询问用户"这是一个新决策,是否记录?"

引用来源的纪律

所有从 memory/ 召回的关键结论,回复中必须标注来源:

  • ✅ "根据 memory/decisions/xxx,我们决定…"
  • ❌ "我们之前决定…"(无来源)

主题追溯

当用户要求追溯某个主题时:

  1. 确认主题范围
  2. search_context 打捞相关 turns(调用时会自动按 90 秒时间簇扩展并提炼命中的 turns)
  3. list_search_views 查看最近的搜索视图,作为 theme 挂载的候选集
  4. 对搜索命中的 turns 做语义分析,用 tag_theme 把 genuinely belongs to the theme 的 turns 逐个挂载到 themes/<theme>.json
  5. 如果候选不足,用新的 query 再次 search_context 打捞,生成新的 search view
  6. trace_theme 输出主题时间线

search_context 已内置提炼能力,不需要单独调用 refine_session_turns


记忆卫生检查清单

每次调用 remember 前:

  • 这条信息三天后还有价值吗?
  • 是否已有重复记忆?(先 search
  • folder 选对了吗?项目相关不进 notes/
  • tags 是否包含最贴切的分类标签?
  • 正文是否包含决策原因/影响范围/相关文件?

Read the full file on GitHub · 145 lines

Changes

What this file has done since we first saw it

Hashed on every crawl. A supply-chain change to an agent config is a question of when, not whether, so the history is kept rather than the latest state alone.

  1. yesterday First seen · 145 lines · 1,641 tokens per session scan A 52359bcc4cf6

Subscribe to this mod's changes

kimi-code-memory-mcp-server AGENTS.md is an instructions file published in the GitHub repository Zehee/kimi-code-memory-mcp-server (2 stars, last pushed 14d ago), licensed MIT. It adds 1,641 tokens to every session, about $0.0082 per session on Opus 5. A static security scan graded it A with 0 findings. No closer match exists in the catalogue, so it is treated as the original; first seen 2026-08-31.