memory-search
它能做什么
这项技能让智能体对已保存的编程会话历史运行只读数据库查询。适合希望找出普通文字搜索无法显示的过往工作规律的人。
适用场景
- ✓当你想统计某个工具或命令在多次会话中失败的次数的时候。
- ✓当你需要找到某条过去的命令或决定的时候。
- ✓当你想查看某个会话中完整的操作顺序的时候。
技能链接
https://github.com/XiaomiMiMo/MiMo-Code/blob/main/packages/cli/src/skill/builtin/.bundle/memory-search/SKILL.md复制后粘贴给你的 AI(Claude、ChatGPT 或 Cursor),让它按照说明操作。
使用方法
最简单的方法:复制下面的消息,粘贴给你的 AI。它会读取这个技能并按说明操作。
可直接粘贴的消息
适用于 Claude Code、Codex 或 Cursor:在项目文件夹中运行,即可安装该技能。
下载 SKILL.md,放进智能体的技能文件夹。
可以这样问 AI
“我想找出在我过去的编程会话中,哪个工具失败得最频繁。”
每周 5 个新技能,1 分钟读完。
工作原理
智能体会以只读模式打开会话数据库,并对其表运行 SQL 查询。它利用结果回答你的问题,且从不修改数据。
技术内容(原始 SKILL.md)
作者在 GitHub 上的英文原文。
Memory Search: SQLite Trajectory Database
Direct SQL access to mimocode's trajectory database for structured analysis that the memory (BM25 over curated markdown) and history (FTS over raw messages) tools cannot perform — aggregation, filtering by tool/status/time, cross-session pattern detection, and execution chain inspection.
When to use
- You need to aggregate or count across sessions (e.g. "which tool fails most often?", "how many sessions touched file X?").
- You need to filter by structure — tool name, status, agent_id, time range — not just text content.
- You need to view a complete execution chain for a session (every tool call in order).
- You need to verify a memory claim against what actually happened (the DB is the source of truth).
- The
memoryandhistorytools returned nothing useful despite multiple query attempts.
Locating the database
# Typically at this path. MIMOCODE_DB env var overrides if set.
sqlite3 -readonly ~/.local/share/mimocode/mimocode.db ".tables"
Always use -readonly or only SELECT queries — never modify the database.
Schema
| Table | Purpose | Key columns |
|---|---|---|
session |
Session metadata | id, project_id, title, time_created, parent_id |
message |
User/assistant turns | id, session_id, agent_id, time_created, data (JSON: $.role) |
part |
Message parts (text, tool calls, steps) | id, message_id, session_id, time_created, data (JSON) |
task |
Task tree | id, session_id, summary, status |
task_event |
Task state transitions | id, session_id, task_id, at, kind, summary |
actor_registry |
Subagent/peer history | session_id, actor_id, agent, mode, status, description |
Part types in part.data
{"type":"text","text":"..."}— agent text output{"type":"tool","tool":"<name>","callID":"...","state":{"status":"completed","input":{...},"output":"..."}}— completed tool call{"type":"tool","tool":"<name>","callID":"...","state":{"status":"error","input":{...},"error":"..."}}— failed tool call (nooutputfield; error message in$.state.error){"type":"step-start"}/{"type":"step-finish","tokens":...}— step boundaries{"type":"compaction","auto":true/false}— compaction boundary{"type":"checkpoint",...}— checkpoint/rebuild boundary
Key conventions
agent_id = 'main'= main agent; other values = subagent (e.g."explore-1","general-1").$.state.outputonly exists when$.state.status = "completed". Failures store the message in$.state.error.time_createdis Unix milliseconds.
Query templates
List recent sessions for this project:
SELECT id, title, time_created,
datetime(time_created/1000, 'unixepoch', 'localtime') as created
FROM session
WHERE project_id = '<PROJECT_ID>'
AND parent_id IS NULL
ORDER BY time_created DESC
LIMIT 20;
Find user messages containing a keyword:
SELECT m.session_id, m.id,
substr(json_extract(p.data, '$.text'), 1, 200) as preview
FROM message m
JOIN part p ON p.message_id = m.id AND p.session_id = m.session_id
WHERE json_extract(m.data, '$.role') = 'user'
AND json_extract(p.data, '$.type') = 'text'
AND json_extract(p.data, '$.text') LIKE '%keyword%'
ORDER BY m.time_created DESC
LIMIT 10;
Find tool calls by tool name:
SELECT m.session_id, m.id, m.agent_id,
json_extract(p.data, '$.tool') as tool,
json_extract(p.data, '$.state.status') as status,
substr(COALESCE(json_extract(p.data, '$.state.output'), json_extract(p.data, '$.state.error')), 1, 300) as result_preview
FROM message m
JOIN part p ON p.message_id = m.id AND p.session_id = m.session_id
WHERE json_extract(m.data, '$.role') = 'assistant'
AND json_extract(p.data, '$.type') = 'tool'
AND json_extract(p.data, '$.tool') = '<TOOL_NAME>'
AND m.session_id = '<SESSION_ID>'
ORDER BY m.time_created DESC
LIMIT 20;
View a session's full execution chain:
SELECT m.id, m.agent_id,
json_extract(p.data, '$.type') as part_type,
json_extract(p.data, '$.tool') as tool,
substr(p.data, 1, 800) as preview
FROM message m
JOIN part p ON p.message_id = m.id AND p.session_id = m.session_id
WHERE m.session_id = '<SESSION_ID>'
AND json_extract(m.data, '$.role') = 'assistant'
ORDER BY m.time_created, p.time_created;
**Find repeated stdout errors (completed bash calls, last
常见问题
它会修改我的会话数据吗?
不会。这项技能要求使用只读访问或仅使用 SELECT 查询。
它何时比普通的记忆搜索更好?
它适用于计数、按工具或状态筛选,以及比较会话,而这些是文字搜索不擅长的。
数据库在哪里?
这项技能给出了一个常见位置,并说明可以通过环境变量指向其他路径。
详情
作者的原始描述
Query the raw trajectory SQLite database directly when the built-in memory and history tools are insufficient. Use when you need structured analysis across sessions: finding repeated errors, grouping tool calls by pattern, verifying what was actually executed, or locating specific past commands/decisions that text search cannot surface. Provides the database schema, ready-to-use SQL query templates, and per-goal strategies.
repo: XiaomiMiMo/MiMo-Code
热度
- GitHub 星标
- 14k
- 排名
- #11332
- 许可证
- MIT
- 更新时间
- 2026/11/2
评论
- …
同一仓库的更多技能
effect
14k帮你的智能体通过查看源代码和文档来回答关于 Effect TypeScript 框架的问题,而不是依赖记忆。
arxiv
14k帮你的智能体在 arXiv 上搜索、阅读、引用和跟踪学术论文,包括摘要、BibTeX 引用、PDF 下载和引用关系。
claude-code
14k帮你的智能体把编程任务交给 Claude Code 命令行工具,可以是一次性运行、交互式会话或后台任务。
codex
14k帮你的智能体在没有聊天窗口的情况下运行 OpenAI Codex 命令行工具,用于编程任务、脚本和自动化流程。