Search Session Memory
Search the persistent memory database for past coding observations, decisions, and context.
$ARGUMENTS
How It Works
This skill queries the SQLite FTS5 full-text search index at ~/.softspark/ai-toolkit/memory.db to find relevant observations from past sessions.
Instructions
Parse the search query from $ARGUMENTS. If empty, prompt the user for a query.
Initialize the database if it does not exist:
python3 "$HOME/.softspark/ai-toolkit/hooks/../plugins/memory-pack/scripts/init_db.py" 2>/dev/null || true
Run the FTS5 search against the observations table:
sqlite3 ~/.softspark/ai-toolkit/memory.db "
SELECT o.id, o.session_id, o.tool_name, o.content, o.created_at,
s.project_dir, s.summary
FROM observations_fts fts
JOIN observations o ON o.id = fts.rowid
LEFT JOIN sessions s ON s.session_id = o.session_id
WHERE observations_fts MATCH '<query>'
ORDER BY rank
LIMIT 10;
"
Replace <query> with the user's search terms. Escape single quotes by doubling them.
Progressive disclosure -- present results in two stages:
Stage 1: Summary view (show first)
## Memory Search: "<query>"
Found N results across M sessions.
| # | Session | Project | Tool | Time | Preview |
|---|---------|---------|------|------|---------|
| 1 | abc123 | /path | Edit | 2025-01-15 | First 80 chars... |
Stage 2: Detail view (on request)
Show the full observation content, session summary, and related observations from the same session.
If no results found, suggest:
- Trying broader search terms
- Checking if memory-pack hooks are installed
- Running
init-db.sh if the database is missing
Query Tips
- Use simple keywords:
mem-search database migration
- FTS5 supports prefix matching:
migrat* matches "migration", "migrate"
- Boolean operators:
database AND NOT test
- Column filters:
tool_name:Edit to search only Edit tool observations
Example
/mem-search "postgres migration rollback"
Typical output:
## Memory Search: "postgres migration rollback"
Found 3 results across 2 sessions.
| # | Session | Project | Tool | Time | Preview |
|---|---------|------------------|------|------------|--------------------------------------|
| 1 | abc123 | magento2-os | Edit | 2026-03-12 | Rolled back 0042_add_tax_col... |
| 2 | def456 | magento2-b2b | Bash | 2026-02-28 | pg_dump before schema migration... |
| 3 | abc123 | magento2-os | Read | 2026-03-12 | Reviewed migration safety checklist |
Rules
- MUST escape single quotes in queries by doubling (
it''s) — SQL injection into the FTS5 call will break the query
- NEVER return the raw database path — treat
~/.softspark/ai-toolkit/memory.db as internal
- CRITICAL: if the database does not exist, initialize it silently and return zero results — do not fail the skill
- MANDATORY: present Stage 1 (summary table) first; only expand to Stage 2 on follow-up
Gotchas
- FTS5
MATCH is picky: hyphens, slashes, and dots are parsed as operator separators and will reject queries like mem-search api/v1 with a cryptic malformed MATCH expression. Wrap multi-token phrases with double-quotes: "api/v1" or "mem-search".
- Results are ordered by
rank (FTS5 relevance), not by created_at. A stale but high-ranked match outranks a fresh but weak one — include the created_at column and consider ORDER BY rank, created_at DESC for time-sensitive queries.
- The database path is static at
~/.softspark/ai-toolkit/memory.db. If the user runs from a container, ~ resolves to the container's home, not the host's — the observation list will look empty. Check the env var SOFTSPARK_HOME before assuming the DB is missing.
observations_fts is a separate virtual table; when observations are deleted directly (not via the SDK) the FTS index can drift. If counts between observations and observations_fts differ, rebuild with INSERT INTO observations_fts(observations_fts) VALUES('rebuild');.
When NOT to Use
- To search the KB or documentation — use
/research-mastery or smart_query()
- To find a specific commit — use
git log --grep or /git-mastery
- To list agent tasks — use
TaskList or /plan
- When memory-pack hooks are not installed — direct the user to install them first
1---2name: mem-search3description: "Searches past coding sessions for observations, decisions, context. Triggers: mem-search, recall session, past work, prior decisions, session history."4effort: medium5argument-hint: "[search query]"6allowed-tools: Bash, Read7user-invocable: true8---910# Search Session Memory1112Search the persistent memory database for past coding observations, decisions, and context.1314$ARGUMENTS1516## How It Works1718This skill queries the SQLite FTS5 full-text search index at `~/.softspark/ai-toolkit/memory.db` to find relevant observations from past sessions.1920## Instructions21221. **Parse the search query** from `$ARGUMENTS`. If empty, prompt the user for a query.23242. **Initialize the database** if it does not exist:25 ```bash26 python3 "$HOME/.softspark/ai-toolkit/hooks/../plugins/memory-pack/scripts/init_db.py" 2>/dev/null || true27 ```28293. **Run the FTS5 search** against the observations table:30 ```bash31 sqlite3 ~/.softspark/ai-toolkit/memory.db "32 SELECT o.id, o.session_id, o.tool_name, o.content, o.created_at,33 s.project_dir, s.summary34 FROM observations_fts fts35 JOIN observations o ON o.id = fts.rowid36 LEFT JOIN sessions s ON s.session_id = o.session_id37 WHERE observations_fts MATCH '<query>'38 ORDER BY rank39 LIMIT 10;40 "41 ```42 Replace `<query>` with the user's search terms. Escape single quotes by doubling them.43444. **Progressive disclosure** -- present results in two stages:4546 **Stage 1: Summary view** (show first)47 ```markdown48 ## Memory Search: "<query>"4950 Found N results across M sessions.5152 | # | Session | Project | Tool | Time | Preview |53 |---|---------|---------|------|------|---------|54 | 1 | abc123 | /path | Edit | 2025-01-15 | First 80 chars... |55 ```5657 **Stage 2: Detail view** (on request)58 Show the full observation content, session summary, and related observations from the same session.59605. **If no results found**, suggest:61 - Trying broader search terms62 - Checking if memory-pack hooks are installed63 - Running `init-db.sh` if the database is missing6465## Query Tips6667- Use simple keywords: `mem-search database migration`68- FTS5 supports prefix matching: `migrat*` matches "migration", "migrate"69- Boolean operators: `database AND NOT test`70- Column filters: `tool_name:Edit` to search only Edit tool observations7172## Example7374```bash75/mem-search "postgres migration rollback"76```7778Typical output:7980```81## Memory Search: "postgres migration rollback"82Found 3 results across 2 sessions.8384| # | Session | Project | Tool | Time | Preview |85|---|---------|------------------|------|------------|--------------------------------------|86| 1 | abc123 | magento2-os | Edit | 2026-03-12 | Rolled back 0042_add_tax_col... |87| 2 | def456 | magento2-b2b | Bash | 2026-02-28 | pg_dump before schema migration... |88| 3 | abc123 | magento2-os | Read | 2026-03-12 | Reviewed migration safety checklist |89```9091## Rules9293- **MUST** escape single quotes in queries by doubling (`it''s`) — SQL injection into the FTS5 call will break the query94- **NEVER** return the raw database path — treat `~/.softspark/ai-toolkit/memory.db` as internal95- **CRITICAL**: if the database does not exist, initialize it silently and return zero results — do not fail the skill96- **MANDATORY**: present Stage 1 (summary table) first; only expand to Stage 2 on follow-up9798## Gotchas99100- FTS5 `MATCH` is picky: hyphens, slashes, and dots are parsed as operator separators and will reject queries like `mem-search api/v1` with a cryptic `malformed MATCH expression`. Wrap multi-token phrases with double-quotes: `"api/v1"` or `"mem-search"`.101- Results are ordered by `rank` (FTS5 relevance), **not** by `created_at`. A stale but high-ranked match outranks a fresh but weak one — include the `created_at` column and consider `ORDER BY rank, created_at DESC` for time-sensitive queries.102- The database path is static at `~/.softspark/ai-toolkit/memory.db`. If the user runs from a container, `~` resolves to the container's home, not the host's — the observation list will look empty. Check the env var `SOFTSPARK_HOME` before assuming the DB is missing.103- `observations_fts` is a separate virtual table; when observations are deleted directly (not via the SDK) the FTS index can drift. If counts between `observations` and `observations_fts` differ, rebuild with `INSERT INTO observations_fts(observations_fts) VALUES('rebuild');`.104105## When NOT to Use106107- To search the KB or documentation — use `/research-mastery` or `smart_query()`108- To find a specific commit — use `git log --grep` or `/git-mastery`109- To list agent tasks — use `TaskList` or `/plan`110- When memory-pack hooks are not installed — direct the user to install them first