memory-search
What it does
This skill lets the agent run read-only database queries on saved coding session history. It is for people who want to find patterns in past work that normal text search cannot show.
When to use it
- βWhen you want to count how often a tool or command failed across sessions.
- βWhen you need to find a specific past command or decision.
- βWhen you want the full sequence of actions in one session.
Skill link
https://github.com/XiaomiMiMo/MiMo-Code/blob/main/packages/cli/src/skill/builtin/.bundle/memory-search/SKILL.mdCopy it and paste it into your AI (Claude, ChatGPT or Cursor), asking it to follow the instructions.
How to use
The easiest way: copy the message and paste it into your AI. It reads the skill and follows the instructions.
Ready-to-paste message
For Claude Code, Codex or Cursor: run it in your project folder and the skill gets installed.
Download the SKILL.md and drop it into your agentβs skills folder.
Example of what to ask your AI
βI want to find which tool failed most often across my past coding sessions.β
5 new skills a week. 1 minute to read.
How it works
The agent opens the session database in read-only mode and runs SQL queries on its tables. It uses the results to answer your question and never changes the data.
Technical content (original SKILL.md)
Original text by the author, straight from 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
FAQ
Can it change my session data?
No. The skill says to use read-only access or SELECT queries only.
When is it better than normal memory search?
It is for counting, filtering by tool or status, and comparing sessions, which text search does not do well.
Where is the database?
The skill gives a typical location, and notes that an environment variable can point to another path.
Details
Original description by the author
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
Popularity
- GitHub stars
- 14k
- Ranking position
- #11332
- License
- MIT
- Updated
- 11/2/2026
Comments
- β¦
More skills from this repository
effect
14kHelps your agent answer questions about the Effect TypeScript framework by checking its source code and docs instead of relying on memory.
arxiv
14kHelps your agent search, read, cite, and track academic papers on arXiv, including abstracts, BibTeX citations, PDF downloads, and citation links.
claude-code
14kHelps your agent hand a coding task to the Claude Code command line tool, as a one-shot run, an interactive session, or a background job.
codex
14kHelps your agent run the OpenAI Codex command line tool without a chat window, for coding tasks, scripts, and automated pipelines.
Similar skills
add-model-provider
394kLets your agent connect a new AI model provider to OpenClaw using safe setup commands, keep API keys out of plain text, and run a live test.
acp-router
394kHelps your agent send a task to a coding assistant such as Claude Code or Cursor through OpenClaw, so the work runs in that tool.
browser-automation
394kTeaches your agent to control web pages step by step, including logins, tabs, and recovery when a page stops responding.