memforge-auto-recall

Rules that make an AI assistant automatically retrieve and save team memories during conversations.

In plain words
What is it for?
Use them when an assistant needs to recall team context across sessions and store new project knowledge.
Why use it?
They help the assistant reuse knowledge from earlier work instead of relying only on the current conversation.

Cursor rule

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/zql0805/memforge/memforge-auto-recall
Clone the repo
git clone --depth 1 https://github.com/zql0805/memforge
Per session 7,463 This file is loaded in full into every session.
When invoked 7,463 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.07463 $0.07463
Opus 5 $0.03732 $0.03732
Sonnet 5 $0.01493 $0.01493
Haiku 4.5 $0.00746 $0.00746

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

Security

Grade A, and why

memforge-auto-recall 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.

packages/memory-service/src/rules-templates/memforge-auto-recall.mdc · 567 lines

How it starts

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

════════════════════════════════════════════════════

GATE 1 — recall_memory 强制入口(与 GATE 0 同级最高优先级)

读到此处即锁定:本会话首次回复必须先调用 recall_memory

════════════════════════════════════════════════════

铁律:会话首次回复的第一个工具调用必须是 recall_memory

无论用户问什么、任务是否紧急、对话摘要是否已提供上下文,每个会话的第一轮回复中,第一个 MCP/工具调用必须是 recall_memory

执行要求

  • 从用户消息中提取核心关键词作为 query
  • 必须传 product_line(从工作区路径推断)
  • 对话摘要不能替代 recall_memory — 摘要只包含上次对话快照,记忆库包含跨会话的经验、规范和关联知识
  • 检索完成后,结合记忆结果和对话摘要决定下一步行动
  • 跨会话恢复未完成工作时,遵循「跨会话恢复安全协议」(见下方独立章节)

后续交互的检索规则

  • 同一会话内,当任务/话题发生变化时必须再次 recall_memory
  • 同一任务的连续交互无需重复检索
  • 涉及代码修改时,额外检索相关文件路径和业务域

违规识别

  • 会话首轮回复中未调用 recall_memory 就执行其他工具(Read/Shell/Grep 等)→ 违规
  • 以「对话摘要已提供上下文」为由跳过 recall_memory → 违规
  • MCP 服务可用时因「任务简单」而跳过 recall_memory → 违规

唯一例外

  • Memforge MCP 服务不可用(连接失败/超时)→ 静默跳过,不阻塞
  • 用户明确写「不用检索记忆」「跳过 recall」→ 可省略

════════════════════════════════════════════════════

跨会话恢复安全协议

════════════════════════════════════════════════════

核心原则:用户当前问题优先于历史待办

当新会话带有上次对话摘要且存在未完成工作时,必须先回答用户当前的问题,而非直接跳到历史待办。

恢复流程

  1. 先回答用户当前问题 — 无论待办工作是否存在,用户当前消息的优先级最高
  2. 判断关联性 — 用户当前问题是否与待办工作直接相关:
    • 相关(如用户说"上次那个功能做完了吗")→ 回答后自然衔接待办工作
    • 不相关(如用户问了一个新问题)→ 回答完后,在末尾单独提醒:"上次还有 X 功能未完成,是否继续?"
  3. 恢复前必须验证实际状态 — 不能盲信 TODO 列表的标记:
    • 检查 git log 确认代码变更是否已提交/部署
    • 检查数据库/文件系统确认数据变更是否已执行
    • 向用户展示验证结果 + 待办列表,获得明确确认后再继续

安全红线

场景 规则
TODO 标记为 completed 的任务 绝不重做,即使用户问了相关问题也只汇报结果
破坏性/不可逆操作(删除数据、DROP TABLE、force push 等) 必须单独确认,即使 TODO 标记为 pending
有副作用的操作(数据库写入、发消息、部署等) 验证是否已执行过,防止重复执行
TODO 状态与实际环境矛盾 以实际环境为准,向用户说明差异

违规识别

  • 未回答用户当前问题就直接继续历史待办 → 违规
  • 未验证实际状态就执行待办中的破坏性操作 → 违规
  • 重复执行已完成的有副作用操作 → 违规

════════════════════════════════════════════════════

Memforge 记忆自动检索与存储

核心指令

你有权访问 Memforge MCP 工具(29 + 17 个)。在回答用户问题或执行任务之前,必须先检索相关记忆(参见 GATE 1)。

编码规范强制加载(修改代码前必须执行)

在修改、创建、审查代码之前,必须调用 get_system_rules 加载团队规范:

get_system_rules({
  product_line: "<从工作区路径推断>",
  language: "<当前项目主语言,如 java/php/typescript>",
  format: "prompt"
})

Read the full file on GitHub · 567 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. 2d ago First seen · 567 lines · 7,463 tokens per session scan A 1016fb09d8ce

Subscribe to this mod's changes

memforge-auto-recall is a cursor rule published in the GitHub repository zql0805/memforge (2 stars, last pushed 2mo ago), licensed MIT. It adds 7,463 tokens to every session, about $0.0373 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.