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.
npx skills add zhanpu89/ai-memory-mcp --skill ai-memorygit clone --depth 1 https://github.com/zhanpu89/ai-memory-mcpWrote this? Show the measurements
A badge with what this costs and how it scanned, read live from this page, so it follows the numbers instead of freezing them. Markdown for a README, HTML for a documentation site or a project page.
[](https://agentmods.dev/skills/zhanpu89/ai-memory-mcp/ai-memory)<a href="https://agentmods.dev/skills/zhanpu89/ai-memory-mcp/ai-memory"><img src="https://agentmods.dev/badge/skills/zhanpu89/ai-memory-mcp/ai-memory.svg" alt="Measured on agentmods" height="20"></a>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.
| Model | Per session | Once invoked |
|---|---|---|
| Fable 5.1 | $0.00124 | $0.02059 |
| Opus 5 | $0.00062 | $0.01030 |
| Sonnet 5 | $0.00025 | $0.00412 |
| Haiku 4.5 | $0.00012 | $0.00206 |
Grade A, and why
ai-memory 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 7d 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.
How it starts
The opening of the file, as written. The whole thing — 141 lines — stays where its author put it; the contents beside it link to each section on GitHub.
AI 记忆管理
管理 AI 助手的持久化记忆,覆盖四个阶段。每个阶段有独立的参考文件,仅在对应场景触发时加载。
阶段路由
根据当前场景,判断进入哪个阶段,然后读取对应的参考文件执行:
| 阶段 | 触发场景 | 参考文件 | 核心工具 |
|---|---|---|---|
| 记忆加载 | 会话启动、项目切换、用户说"加载记忆/恢复上下文/继续上次" | references/memory-load.md |
init_session, get_summary_by_id, list_recent_sessions |
| 记忆丰富 | 任务执行中发现关键决策、Bug 修复、状态变更 | references/memory-enrich.md |
add_decision, update_summary |
| 记忆保存 | 任务结束、用户说"生成摘要/保存记忆"、里程碑达成 | references/memory-save.md |
save_summary, add_decision |
| 记忆检索 | 遇到 Bug、技术选型、架构设计、用户提到历史任务 | references/memory-search.md |
search_summaries, search_summaries_fts, get_summary_by_id |
读取规则:只加载当前阶段对应的参考文件,不要一次性读取全部。
公共前置:项目上下文识别
所有阶段在首次调用 MCP 工具前,都必须执行以下步骤:
步骤 1:定位项目根目录
从当前工作目录开始,向上查找 .project_name 文件,最多查找 2 层:
- 第 1 层:当前目录
- 第 2 层:父目录
找到后,该目录即为"项目根目录"。如果 2 层内均未找到,报错并提示用户在项目根目录(通常在 src/ 同级或上级)创建 .project_name 文件。
步骤 2:读取 project_name
- 读取项目根目录下的
.project_name文件 - 去除首尾空白字符,忽略空行和注释行(
#开头) - 取第一行有效内容作为
project_name - 如果文件不存在或内容为空:
- 向用户提示:"检测到当前项目缺少
.project_name文件,请在项目根目录创建该文件,内容为一行项目名称(例如:my-awesome-project)" - 暂停执行,等待用户确认已创建
- 用户确认后重新读取
- 向用户提示:"检测到当前项目缺少
步骤 3:读取 branch_name
- 检查项目根目录是否存在
.git目录 - 存在:读取
.git/HEAD提取分支名(如ref: refs/heads/main→main) - 不存在:标记
branch_name = "no-vcs"
缓存机制
首次读取后,在会话上下文中记录当前 project_name 和 branch_name,后续工具调用直接引用这两个值,不重复读取文件。用户明确说"切换项目"时,重新执行上述步骤。
Session ID 管理
- 生成时机:任务开始时生成,格式为
session-{YYYYMMDD}-{task_slug} - 复用规则:同一任务的所有操作(保存、丰富、更新)使用同一 session_id
- 里程碑保存:不生成新 ID,复用现有 ID,仅更新 status
状态值约束(严格遵守)
所有涉及 status 字段的操作,必须且只能使用以下五种状态值:
| 状态值 | 含义 | 使用场景 |
|---|---|---|
completed |
已完成 | 任务所有目标已达成 |
in_progress |
进行中 | 任务正在执行,或里程碑保存 |
pending |
待处理 | 任务已计划但尚未开始 |
blocked |
被阻塞 | 任务需要外部依赖或决策才能继续 |
abandoned |
已放弃 | 任务确定不再继续 |
禁止使用任何其他状态值(如 pending_review、waiting、paused 等)。如需表达更复杂的状态,请在 summary_content 中用文字描述。
上下文窗口预算
记忆加载时控制 Token 占用,默认 L0,按需升级:
| 层级 | 触发条件 | 加载内容 | 预估 Token |
|---|---|---|---|
| L0 | 会话启动(默认) | init_session 返回的标题+下一步 |
~100-200 |
| L1 | 用户选择继续某任务 | get_summary_by_id 完整摘要 |
~500-1000 |
| L2 | 遇到复杂问题需历史参考 | search_summaries(use_vector=True) 3条 |
~1500-3000 |
| L3 | 用户明确要求完整回顾 | list_recent_sessions + 逐条详情 |
~3000+ |
What ships with it
4 files beside SKILL.md in the same directory: the scripts, references and assets a skill reads on demand. Not counted in the per-session cost; read them before you install if any of them is executable.
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.
- 7d ago First seen · 141 lines · 124 tokens per session scan A 017950865ec8
ai-memory is a skill published in the GitHub repository zhanpu89/ai-memory-mcp (0 stars, last pushed 3mo ago), licensed MIT. It adds 124 tokens to every session and 2,059 once invoked, about $0.0006 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.
Other skills, from other repositories
media-ingest
Ingest video, audio, PDF, book, screenshot, and GitHub repo content into the brain. Multi-format handling with entity extraction and backlink propagation. Covers video-ingest, youtube-ingest, and book-ingest subtypes.
mem0-oss-to-platform
Plan and then execute a migration of a project from the mem0 open-source / self-hosted SDK (the local Memory class) to the mem0 Platform / hosted / managed SDK (the MemoryClient class). Use this whenever a developer wants to move, switch, or migrate their mem0 usage off OSS/self-hosted to the hosted API — e.g.…
Cortex
Operate Cortex, the LifeOS memory system — the typed Knowledge Archive (People, Companies, Ideas, Research with typed related: links) plus recall of prior work sessions, ISAs, and conversations. Search, add, harvest, develop, ingest, distill, graph-navigate, recall. USE WHEN cortex, knowledge, knowledge base, search…
memory
Use when the user asks to remember, recall, forget, update, search, or inspect durable OpenSquilla memory, including profile facts in USER.md and long-term notes in MEMORY.md or memory//.md.
ha-data-stores
Map of Hope Agent's local data stores and safe read-only query workflow. Use when the user asks where Hope Agent stores data, wants to inspect sessions/messages/memory/logs/background jobs/knowledge indexes/settings, asks the model to query local app data, or debugging requires checking persisted state. Trigger…
establishing-project-context
Use when the user asks to establish shared project language, or project work exposes a conflicting, renamed, or deprecated domain term that needs active semantic modeling. Routine small tasks stay on the fast path.