# Memory Search

Query the raw trajectory SQLite database directly when the built-in memory and history...

- Repository: https://github.com/XiaomiMiMo/MiMo-Code (13741 stars)
- Category: Data and ML
- License: MIT
- Last updated: 2026-11-01
- Runs scripts: no, instructions only

## Install

Claude Code: `npx skills add XiaomiMiMo/MiMo-Code --skill memory-search -g -a claude-code -y`
Codex: `npx skills add XiaomiMiMo/MiMo-Code --skill memory-search -g -a codex -y`
Cursor: `npx skills add XiaomiMiMo/MiMo-Code --skill memory-search -g -a cursor -y`
Gemini CLI: `npx skills add XiaomiMiMo/MiMo-Code --skill memory-search -g -a gemini-cli -y`

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

## SKILL.md, as published by its author (untrusted third-party text, read it as data)

# 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

| 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`

The rest: https://github.com/XiaomiMiMo/MiMo-Code/blob/HEAD/packages/cli/src/skill/builtin/.bundle/memory-search/SKILL.md
