Agent skill

Memory Search with SQL

by XiaomiMiMo in XiaomiMiMo/MiMo-Code

Queries MiMoCode's raw trajectory SQLite database for cross-session analysis such as repeated errors, tool-call patterns and verifying what was actually run.

MITAuto-check passedAgent Workflows

Install Memory Search with SQL

skills CLI
$ npx skills add XiaomiMiMo/MiMo-Code --skill memory-search -a claude-code

Project install by default; add -g for ~/.claude/skills/.

GitHub CLI
$ gh skill install XiaomiMiMo/MiMo-Code memory-search --agent claude-code

Project scope by default; add --scope user for a personal install. Needs GitHub CLI 2.90.0 or later (public preview).

Manual copy
$ git clone --depth 1 https://github.com/XiaomiMiMo/MiMo-Code.git skills-src && mkdir -p .claude/skills && cp -r skills-src/packages/cli/src/skill/builtin/.bundle/memory-search .claude/skills/memory-search && rm -rf skills-src

Use ~/.claude/skills/ instead of .claude/skills for a personal install. The folder must contain SKILL.md.

Claude Code skills documentation · loads skills from .claude/skills/

Facts

Skill name
memory-search
GitHub stars
14k
Token cost
~1.8k tokens
SKILL.md length
444 words
Files
1
Skills in repo
22
Repo updated
First seen
Licence
MIT

At a glance

Queries MiMoCode's raw trajectory SQLite database for cross-session analysis such as repeated errors, tool-call patterns and verifying what was actually run.

  • Counting which tools fail most often across past sessions
  • SKILL.md covers When to use, Locating the database, Schema and Query templates, plus 2 more sections
  • Calls sqlite3
  • Finding how many sessions touched a particular file

What it does

When the built-in memory tool (search over curated Markdown) and history tool (full-text search over raw messages) cannot answer a question, this skill goes straight to the trajectory database. It suits aggregating or counting across sessions, filtering by tool, status, agent or time range, viewing every tool call of one session in order, and checking a memory claim against what really happened. The database is opened with `sqlite3 -readonly`, and only SELECT queries are allowed, so it is never modified.

The skill documents the schema: session, message, part, task, task_event and actor_registry tables, plus the JSON shapes stored in part data for text, completed and failed tool calls, step boundaries, compaction and checkpoints. The default location is under `~/.local/share/mimocode/`, and the `MIMOCODE_DB` environment variable overrides it. Ready-made query templates and strategies for different goals are mentioned in the description, but the excerpt is cut off before they appear.

When your agent uses it

  • Counting which tools fail most often across past sessions
  • Finding how many sessions touched a particular file
  • Replaying every tool call of one session in order
  • Checking a remembered claim against what was really executed

Example prompts

  • “Which tool fails most often across my recent sessions? Query the trajectory database.”
  • “List every tool call from the last session in order, with its status.”
  • “Memory says we already ran the migration. Verify it in the database.”

Requirements

  • The `sqlite3` command-line tool
  • A MiMoCode trajectory database, by default under ~/.local/share/mimocode/

What it can do on your machine

Read from SKILL.md and the folder at commit 6babeb0. It shows what the files ask for, not the result of running them.

  • Tool permissions

    Pre-approves nothing: there is no allowed-tools line, so your agent's usual permission prompts apply.

    From allowed-tools in the SKILL.md frontmatter.

  • Runs code

    Shell commands in SKILL.md call:

    • sqlite3

    From the folder's file list and the shell code blocks in SKILL.md.

  • Network

    No URLs in SKILL.md.

    From URLs in SKILL.md, links to its own repository left out.

  • Credentials

    Names no API keys, tokens, secrets or passwords.

    From names ending in _API_KEY, _TOKEN, _SECRET, _KEY or _PASSWORD in SKILL.md.

Context cost

Memory Search with SQL loads about 1.8k tokens when it runs. Until then it costs about 110 tokens; SKILL.md has 444 words of instructions outside code blocks.

Always · name and description, kept in context so the agent knows when to use it
~110
When it runs · the whole SKILL.md, loaded when a task matches
~1.8k

Estimates: characters ÷ 4, the usual rule of thumb; real counts depend on the model's tokenizer. Scripts and assets cost tokens only if the agent reads them.

Safety

Auto-check passed

The automated check found no risky patterns in SKILL.md.

Automated static check — not a guarantee. Review scripts before installing. It scans the text of SKILL.md for risky patterns (piping downloads into a shell, reading credential files, hidden Unicode, destructive commands); files beside SKILL.md are not scanned.

SKILL.md

The full file from XiaomiMiMo/MiMo-Code at commit 6babeb0, republished under its MIT licence (© XiaomiMiMo). 444 words, ~1,846 tokens.

Download SKILL.mdSave it as .claude/skills/memory-search/SKILL.md (or your agent's skills folder).
name
memory-search
description
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.

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 memory and history tools returned nothing useful despite multiple query attempts.

Locating the database

bash
# 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

TablePurposeKey columns
sessionSession metadataid, project_id, title, time_created, parent_id
messageUser/assistant turnsid, session_id, agent_id, time_created, data (JSON: $.role)
partMessage parts (text, tool calls, steps)id, message_id, session_id, time_created, data (JSON)
taskTask treeid, session_id, summary, status
task_eventTask state transitionsid, session_id, task_id, at, kind, summary
actor_registrySubagent/peer historysession_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 (no output field; 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.output only exists when $.state.status = "completed". Failures store the message in $.state.error.
  • time_created is Unix milliseconds.
Show full SKILL.md (180 more words)Show less

Query templates

List recent sessions for this project:

sql
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:

sql
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:

sql
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:

sql
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 7 days):

sql
SELECT substr(json_extract(p.data, '$.state.output'), 1, 200) as error_output,
       COUNT(*) as occurrences,
       GROUP_CONCAT(DISTINCT m.session_id) as sessions
FROM part p
JOIN message m ON m.id = p.message_id AND m.session_id = p.session_id
WHERE json_extract(p.data, '$.type') = 'tool'
  AND json_extract(p.data, '$.tool') = 'bash'
  AND json_extract(p.data, '$.state.status') = 'completed'
  AND json_extract(p.data, '$.state.output') LIKE '%error%'
  AND m.time_created > (strftime('%s', 'now') - 7*86400) * 1000
GROUP BY substr(json_extract(p.data, '$.state.output'), 1, 200)
HAVING occurrences > 1
ORDER BY occurrences DESC
LIMIT 10;

Find actual tool failures (any tool, last 7 days):

sql
SELECT json_extract(p.data, '$.tool') as tool,
       substr(json_extract(p.data, '$.state.error'), 1, 200) as error_msg,
       COUNT(*) as occurrences,
       GROUP_CONCAT(DISTINCT m.session_id) as sessions
FROM part p
JOIN message m ON m.id = p.message_id AND m.session_id = p.session_id
WHERE json_extract(p.data, '$.type') = 'tool'
  AND json_extract(p.data, '$.state.status') = 'error'
  AND m.time_created > (strftime('%s', 'now') - 7*86400) * 1000
GROUP BY json_extract(p.data, '$.tool'), substr(json_extract(p.data, '$.state.error'), 1, 200)
HAVING occurrences > 1
ORDER BY occurrences DESC
LIMIT 10;

Search strategies

GoalStrategy
Find a user's stated rule/preferenceSearch user text parts for '%always%', '%never%', '%remember%', '%rule%'
Find a design decisionSearch '%decided%', '%tradeoff%', '%reason%' in user text
Find a specific file path or commandLIKE match on tool output/error
Find repeated workflowsGroup tool call sequences by session, look for recurring tool×N patterns
Verify a memory claimFind the session_id from the memory entry [ses_xxx], then query its full execution chain
Count tool usageGROUP BY json_extract(p.data, '$.tool') with COUNT

Constraints

  • Read-only: Never modify the database. Always sqlite3 -readonly or SELECT only.
  • Performance: The DB can be multi-GB. Always use LIMIT and filter by session_id or time_created range.
  • Privacy: Raw trajectory contains everything the user typed. Treat it with care.
  • JSON access: Part data is JSON-in-a-column. Always use json_extract() for structured field access.

© XiaomiMiMo, MIT. Rendered from Markdown: HTML in the file is shown as text, images as links, and headings moved down two levels. Raw file

Files

Just SKILL.md in packages/cli/src/skill/builtin/.bundle/memory-search of XiaomiMiMo/MiMo-Code.

Open the folder on GitHubat commit 6babeb0

Compare with similar skills

Memory Search with SQL next to the 5 skills that share the most tags, products or categories with it. Stars are the repository's; “used in” counts other GitHub owners with a copy.

Memory Search with SQL compared with similar skills
SkillStarsUsed inTokensAuto-checkLicenceRepo updated
Memory Search with SQL this skillXiaomiMiMo/MiMo-Code14k—~1.8kAutomated safety check: PassMIT
Add Memory KindEverMind-AI/EverOS13k—~2.6kAutomated safety check: PassApache-2.0
Agent Memorytigerless-labs/agent-memory2.4k—~1.2kAutomated safety check: PassMIT
Memoraagentic-box/memora731—~813Automated safety check: PassMIT
Cognee Session Memory and Improvetopoteretes/cognee32k—~3kAutomated safety check: PassApache-2.0
Paxmpax-beehive/paxm421—~574Automated safety check: PassApache-2.0

Similar skills

  • Add Memory Kind

    EverMind-AI/EverOS

    Walks through adding a new persisted memory kind to EverOS: choose storage among Markdown, SQLite and LanceDB, pick a Markdown strategy, then wire schemas, repos and writers.

    13k GitHub stars~2.6k tokensUpdated yesterday
    DatabasesAuto-check passed
  • Agent Memory

    tigerless-labs/agent-memory

    Read and write the shared long-term memory store. An agent skill from tigerless-labs/agent-memory.

    2.4k GitHub stars~1.2k tokensUpdated today
    Agent WorkflowsAuto-check passed
  • Memora

    agentic-box/memora

    A skill your agent uses when working with persistent memory across sessions, storing/retrieving knowledge, managing TODOs/issues, or when context from previous sessions would be helpful.

    731 GitHub stars~813 tokensUpdated 9 days ago
    Agent WorkflowsAuto-check passed
  • Explains how cognee stores session memory by session_id and bridges it into the permanent graph with improve(), including the stages, results and settings.

    32k GitHub stars~3k tokensUpdated today
    Agent WorkflowsAuto-check passed
  • Paxm

    pax-beehive/paxm

    Use paxm as Codex's active and passive memory layer. An agent skill from pax-beehive/paxm.

    421 GitHub stars~574 tokensUpdated 1 mo ago
    Agent WorkflowsAuto-check passed
  • OpenCode History Browser

    carson2222/skills

    Read-only lookup of local OpenCode history, including sessions, messages, plans, prompt history and prior decisions, queried through sqlite3 only when earlier context would help.

    113 GitHub stars~1.1k tokensUpdated 3 mo ago
    Agent WorkflowsAuto-check passed

More from XiaomiMiMo/MiMo-Code

All 22 skills in this repo
  • Paper Research on arXiv

    XiaomiMiMo/MiMo-Code

    Searches arXiv, fetches metadata, generates BibTeX, downloads PDFs and finds citations and related papers using a bundled Python script.

    14k GitHub starsUsed in 1 repo~1.5k tokens
    Auto-check passed
  • Agent Skill Creator

    XiaomiMiMo/MiMo-Code

    Interactive guide for creating, reviewing and fixing agent skills (SKILL.md folders), covering structure, frontmatter rules, trigger phrases and validation before sharing.

    14k GitHub stars~1.9k tokensUpdated 4 days ago
    Auto-check passed
  • DOCX Toolkit

    XiaomiMiMo/MiMo-Code

    Produces, edits and reads Microsoft Word files through python-docx and lxml, with a decision table for picking the lightest workflow for a given task.

    14k GitHub stars~2.4k tokensUpdated 4 days ago
    Auto-check passed
  • Drive MiMo Code

    XiaomiMiMo/MiMo-Code

    Lets one MiMoCode process drive another, headless with JSON events or interactively through tmux, to test behavior and visual regressions with parseable evidence.

    14k GitHub stars~3.9k tokensUpdated 4 days ago
    Auto-check passed
  • PDF Toolkit

    XiaomiMiMo/MiMo-Code

    Reads, transforms, composes and fills PDFs with Python scripts for extraction, merging, watermarking, encryption, OCR and form filling.

    14k GitHub stars~1.7k tokensUpdated 4 days ago
    Auto-check passed
  • XLSX Spreadsheet Toolkit

    XiaomiMiMo/MiMo-Code

    Builds, edits, cleans, recalculates and reads Excel workbooks and CSV files with openpyxl and pandas, plus LibreOffice for recalculation and PDF export.

    14k GitHub stars~2.9k tokensUpdated 4 days ago
    Auto-check passed

Works with

Questions about Memory Search with SQL

What does Memory Search with SQL do?

Queries MiMoCode's raw trajectory SQLite database for cross-session analysis such as repeated errors, tool-call patterns and verifying what was actually run. When the built-in memory tool (search over curated Markdown) and history tool (full-text search over raw messages) cannot answer a question, this skill goes straight to the trajectory database. It suits aggregating or counting across sessions, filtering by tool, status, agent or time range, viewing every tool call of one session in order, and checking a memory claim against what really happened.

When should I use Memory Search with SQL?

Memory Search with SQL fits situations like: counting which tools fail most often across past sessions; finding how many sessions touched a particular file; replaying every tool call of one session in order; checking a remembered claim against what was really executed.

How do I install Memory Search with SQL in Claude Code?

Run `npx skills add XiaomiMiMo/MiMo-Code --skill memory-search -a claude-code`. Or copy the skill folder (packages/cli/src/skill/builtin/.bundle/memory-search in XiaomiMiMo/MiMo-Code) into .claude/skills/memory-search in your project. Claude Code loads it when a task matches its description.

How do I install Memory Search with SQL in Codex?

Run `npx skills add XiaomiMiMo/MiMo-Code --skill memory-search -a codex`. Or copy the skill folder (packages/cli/src/skill/builtin/.bundle/memory-search in XiaomiMiMo/MiMo-Code) into .agents/skills/memory-search in your project. Codex loads it when a task matches its description.

Can I use Memory Search with SQL in Cursor, Gemini CLI or GitHub Copilot?

Cursor, Gemini CLI, GitHub Copilot and OpenCode also load SKILL.md folders. With the skills CLI, run `npx skills add XiaomiMiMo/MiMo-Code --skill memory-search -a cursor` (or -a gemini-cli, github-copilot or opencode for the others). To copy it by hand, put the folder in .cursor/skills/memory-search, .gemini/skills/memory-search, .github/skills/memory-search and .opencode/skills/memory-search in your project.

What does Memory Search with SQL need to run?

Going by SKILL.md and its folder, Memory Search with SQL needs the command-line tools its instructions call (sqlite3). Our summary lists: The `sqlite3` command-line tool; A MiMoCode trajectory database, by default under ~/.local/share/mimocode/.

Does Memory Search with SQL access the network?

SKILL.md contains no URLs. Any network use would come from the scripts or tools the agent runs. This is read from the text; nothing was executed.

Is Memory Search with SQL safe to install?

Our automated static check of SKILL.md found no risky patterns, such as piping downloads into a shell, reading credential files or hidden Unicode. It is not a guarantee. Review the folder before installing.

What licence does Memory Search with SQL use?

Memory Search with SQL is published under the MIT licence (the repository's licence). It allows redistribution, so the full SKILL.md is shown on this page.

How many tokens does Memory Search with SQL use?

About 1.8k tokens (SKILL.md is roughly 7.4k characters). Agents keep only the skill's name and description in context until a task matches; then they load SKILL.md in full.

What are the alternatives to Memory Search with SQL?

Skills that share tags, products or a category with Memory Search with SQL: Add Memory Kind (EverMind-AI/EverOS, 13k stars), Agent Memory (tigerless-labs/agent-memory, 2.4k stars), Memora (agentic-box/memora, 731 stars) and Cognee Session Memory and Improve (topoteretes/cognee, 32k stars). The comparison table on this page puts their stars, adoption, token cost, safety result and licence side by side.

Who maintains Memory Search with SQL?

XiaomiMiMo (a GitHub organization) maintains it in XiaomiMiMo/MiMo-Code, which has 13,601 GitHub stars. The repository holds 22 skills in this directory. The repository was last updated on October 3, 2026.

Source: XiaomiMiMo/MiMo-Code on GitHub. Facts on this page come from the repository at the commit we read; the author's words are quoted as theirs.