memory-protocol

A protocol for storing and retrieving project memories from files, using a command-line memory tool. It records decisions, preferences, dates, tasks, and other useful history for later conversations.

In plain words
What is it for?
Use it to search previous work, review recent notes, save decisions or lessons, inspect the indexed files, and rebuild the workspace memory index.
Why use it?
It prevents important context from being forgotten between sessions. It also tells the assistant when to search past notes and how to report the files used as sources.

Cursor rule for Cursor

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 rules/nongjun/feishu-cursor-claw/memory-protocol
Clone the repo
git clone --depth 1 https://github.com/nongjun/feishu-cursor-claw

Made for: Cursor.

Per session 1,070 This file is loaded in full into every session.
When invoked 1,070 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.01070 $0.01070
Opus 5 $0.00535 $0.00535
Sonnet 5 $0.00214 $0.00214
Haiku 4.5 $0.00107 $0.00107

Measured 2d ago against content hash ed10d59e0bd2, method: parsed. Prices are Anthropic first-party input rates as of 2026-08-30, from the pricing page.

Security

Grade A, and why

memory-protocol 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 2d ago.

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.

templates/.cursor/rules/memory-protocol.mdc · 108 lines

What it actually says

记忆系统

你拥有一个向量记忆系统,覆盖工作区全部文本文件。通过 shell 调用 memory-tool.ts 使用。

记忆工具

# 语义搜索(向量+关键词混合,返回最相关的片段)
bun ~/Documents/Ai管理的文件夹/relay-bot/memory-tool.ts search "关键词或问题"

# 查看最近记忆摘要
bun ~/Documents/Ai管理的文件夹/relay-bot/memory-tool.ts recent --days 3

# 写入今日日记
bun ~/Documents/Ai管理的文件夹/relay-bot/memory-tool.ts write "要记录的内容"

# 查看索引统计(已索引哪些文件)
bun ~/Documents/Ai管理的文件夹/relay-bot/memory-tool.ts stats

# 重建全工作区索引
bun ~/Documents/Ai管理的文件夹/relay-bot/memory-tool.ts index

记忆召回协议(必须遵守)

在回答关于以下话题之前,先搜索记忆:

  • 过去的工作、决策、事件
  • 日期、时间线、截止日期
  • 人物、联系人、合作关系
  • 用户偏好、习惯、约定
  • 待办事项、开放性问题

搜索流程:

  1. search 命令搜索 .cursor/MEMORY.md + .cursor/memory/*.md
  2. 根据搜索结果回答问题
  3. 如果搜索后仍然没有信心,告诉用户"我查过记忆了但没找到"
  4. 引用来源时附上 来源: <文件名> 帮助用户验证

不需要搜索的情况: 简单指令("帮我写个脚本")、纯技术问题、与历史无关的新任务。

记忆文件布局

  • .cursor/MEMORY.md — 长期记忆(精华、偏好、重要决策)
  • .cursor/memory/YYYY-MM-DD.md — 每日日记(原始记录)
  • .cursor/sessions/ — 会话转录日志(只读参考)
  • 工作区其他所有文本文件也已被索引,search 可以搜到

记忆写入

除了用 write 命令写入日记,你也可以直接编辑文件:

  • 决策、偏好、持久事实 → 写入 .cursor/MEMORY.md
  • 日常笔记 → 写入 .cursor/memory/YYYY-MM-DD.md(今天的日期)
  • 用户说"记住这个" → 立即写入文件
  • 犯错后 → 记录教训,防止重蹈覆辙

每条记忆带时间戳:

### HH:MM 标题
- **标签**: #决策 #偏好 #项目
- 内容...

禁止心理笔记

  • "心理笔记"是幻觉 — 不要说"我记住了",你什么也记不住
  • 你是全新的实例,没有跨会话的记忆
  • 想记住任何东西 → 立刻写入文件,这是唯一有效的方式
  • 文件 > 大脑

长对话记忆防丢失(Memory Flush)

当对话变长时,上下文窗口会逐渐填满。系统可能在压缩上下文时丢失早期的关键信息。

主动保存规则:

  • 当对话超过 15 轮时,检查是否有重要信息还没写入文件
  • 当你感觉对话很长、做了很多事时,主动把关键决策和成果写入 .cursor/memory/YYYY-MM-DD.md
  • 写入时使用 APPEND 模式(追加),不要覆盖已有内容
  • 每次保存时记录当前时间戳

值得保存的内容:

  • 重要决策及其理由
  • 完成的任务和结果
  • 用户表达的偏好或约定
  • 需要后续跟进的事项
  • 关键的技术方案或配置变更

不值得保存的: 纯粹的闲聊、已写入其他文件的内容、临时性的调试过程。

记忆维护

定期(每隔几天):

  1. 回顾最近的 .cursor/memory/YYYY-MM-DD.md
  2. 提炼重要事件、教训、洞察到 .cursor/MEMORY.md
  3. .cursor/MEMORY.md 移除过时信息

安全

  • 不要在群聊或有其他人的会话中暴露记忆内容
  • 记忆包含个人上下文,仅在私聊中使用
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. 2d ago First seen · 108 lines · 1,070 tokens per session scan A ed10d59e0bd2

Subscribe to this mod's changes

memory-protocol is a cursor rule published in the GitHub repository nongjun/feishu-cursor-claw (14 stars, last pushed 1mo ago), licensed MIT. It adds 1,070 tokens to every session, about $0.0053 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-30.