Memory Search
Purpose / When to Activate
Activate when an agent needs to find relevant memory but does not know the exact file path, domain, or DEC ID.
This skill locates memory — it does not load it. After results are returned, the agent invokes memory-retrieve to load the specific files.
Use cases:
- "Which decisions relate to database connection pooling?" → Mode A (frontmatter: domain=infrastructure, tags contains database)
- "Where did we discuss pool exhaustion?" → Mode B (full-text keyword: "pool exhaustion")
- "What decisions are related to DEC-42?" → Mode C (cross-reference: DEC-42 → related_to + mentions)
Process
Mode A — Frontmatter Search
Search YAML frontmatter fields across decisions/DEC-*.md files.
- Accept query as field-value pairs:
{domain: "infrastructure", level: "operational"} and/or {tags: ["connection-pooling"]} and/or {related_to: ["<DEC-id>"]} and/or {status: "active"}
- Grep frontmatter blocks (between
--- delimiters) of all decisions/DEC-*.md files
- Match files where ALL specified fields match (AND logic)
- Extract
id, title, and matched field values from each hit
- Rank by: exact tag match > domain match > level match
- Return top 10 results
Mode B — Content Search
Full-text keyword search across ALL memory files.
- Accept query as 1-3 keywords (e.g.,
"pool exhaustion", "scoring formula")
- Grep all files under
contexts/memory/ for keyword matches
- For each hit, extract:
file_path (relative to contexts/memory/)
id from frontmatter (if present)
title from first # heading
excerpt — the matching line ± 1 line of context (~50 tokens)
- Rank by: number of keyword matches > file recency (
updated_at)
- Return top 10 results
- Never return more than ~2,000 tokens total
Mode C — Cross-Reference Search
For a given DEC ID, find all files that reference it + traverse related_to (depth 1).
- Accept query as a single DEC ID (e.g.,
DEC-42)
- Direct mentions: grep all files under
contexts/memory/ for the literal string DEC-42
- Frontmatter
related_to: grep related_to: lines in decisions/DEC-*.md for the target ID
- Outbound relations: read the target file's own
related_to field → list those DEC IDs
- Deduplicate and merge results into a single list
- For each result, extract:
file_path, id, title, relevance (direct_mention | related_to_inbound | related_to_outbound)
- Rank: related_to_inbound > related_to_outbound > direct_mention
- Return all results (typically <15 files)
Quality Checks
- Never loads full file content — only returns paths, IDs, titles, and short excerpts
- Total output stays under ~2,000 tokens
- Mode A searches frontmatter only (fast, structured)
- Mode B searches content (slower, broader — use sparingly)
- Mode C is bounded to depth 1 (no recursive graph traversal)
- Results are always ranked by relevance
- Never modifies any file
Outputs
search_results — ranked list of memory file references:
- file_path: decisions/DEC-42.md
id: DEC-42
title: "Use connection pooling for database access"
relevance: related_to_inbound # or: frontmatter_match | content_match | direct_mention | related_to_outbound
excerpt: "prevents connection exhaustion under load" # ~50 tokens max, absent in Mode A
Agent receives this list and decides which files to load via memory-retrieve.
Non-Goals
This skill must NOT:
- Load full file contents (that is
memory-retrieve)
- Modify any memory files (that is
memory-ingest)
- Make decisions about which results to act on (that is the agent's job)
- Perform recursive graph traversal beyond depth 1
- Search outside
contexts/memory/
Memory-search finds. Memory-retrieve loads. The agent decides.
1---2name: memory-search3description: Search memory by frontmatter fields, full-text keywords, or cross-reference graph. Returns ranked file list — never loads full content. Use when the agent needs to find relevant memory without knowing exact paths.4license: ELv25compatibility: Works with any filesystem-based AI coding agent6metadata:7 author: gaai-framework8 version: "1.0"9 category: cross10 track: cross-cutting11 id: SKILL-CRS-02412 updated_at: 2026-03-0113 status: stable14 tags:15 - memory16 - search17 - retrieval18 - cross-reference19inputs:20 - search_mode: A | B | C21 - query: mode-specific (see Process)22 - contexts/memory/** (read-only scan)23outputs:24 - search_results: list of {file_path, id, title, relevance, excerpt} (~2,000 tokens max)25---2627# Memory Search2829## Purpose / When to Activate3031Activate when an agent needs to **find** relevant memory but does not know the exact file path, domain, or DEC ID.3233This skill **locates** memory — it does not **load** it. After results are returned, the agent invokes `memory-retrieve` to load the specific files.3435Use cases:36- "Which decisions relate to database connection pooling?" → Mode A (frontmatter: domain=infrastructure, tags contains database)37- "Where did we discuss pool exhaustion?" → Mode B (full-text keyword: "pool exhaustion")38- "What decisions are related to DEC-42?" → Mode C (cross-reference: DEC-42 → related_to + mentions)3940---4142## Process4344### Mode A — Frontmatter Search4546Search YAML frontmatter fields across `decisions/DEC-*.md` files.47481. Accept query as field-value pairs: `{domain: "infrastructure", level: "operational"}` and/or `{tags: ["connection-pooling"]}` and/or `{related_to: ["<DEC-id>"]}` and/or `{status: "active"}`492. Grep frontmatter blocks (between `---` delimiters) of all `decisions/DEC-*.md` files503. Match files where ALL specified fields match (AND logic)514. Extract `id`, `title`, and matched field values from each hit525. Rank by: exact tag match > domain match > level match536. Return top 10 results5455### Mode B — Content Search5657Full-text keyword search across ALL memory files.58591. Accept query as 1-3 keywords (e.g., `"pool exhaustion"`, `"scoring formula"`)602. Grep all files under `contexts/memory/` for keyword matches613. For each hit, extract:62 - `file_path` (relative to `contexts/memory/`)63 - `id` from frontmatter (if present)64 - `title` from first `#` heading65 - `excerpt` — the matching line ± 1 line of context (~50 tokens)664. Rank by: number of keyword matches > file recency (`updated_at`)675. Return top 10 results686. Never return more than ~2,000 tokens total6970### Mode C — Cross-Reference Search7172For a given DEC ID, find all files that reference it + traverse `related_to` (depth 1).73741. Accept query as a single DEC ID (e.g., `DEC-42`)752. **Direct mentions:** grep all files under `contexts/memory/` for the literal string `DEC-42`763. **Frontmatter `related_to`:** grep `related_to:` lines in `decisions/DEC-*.md` for the target ID774. **Outbound relations:** read the target file's own `related_to` field → list those DEC IDs785. Deduplicate and merge results into a single list796. For each result, extract: `file_path`, `id`, `title`, `relevance` (direct_mention | related_to_inbound | related_to_outbound)807. Rank: related_to_inbound > related_to_outbound > direct_mention818. Return all results (typically <15 files)8283---8485## Quality Checks8687- Never loads full file content — only returns paths, IDs, titles, and short excerpts88- Total output stays under ~2,000 tokens89- Mode A searches frontmatter only (fast, structured)90- Mode B searches content (slower, broader — use sparingly)91- Mode C is bounded to depth 1 (no recursive graph traversal)92- Results are always ranked by relevance93- Never modifies any file9495---9697## Outputs9899**`search_results`** — ranked list of memory file references:100101```yaml102- file_path: decisions/DEC-42.md103 id: DEC-42104 title: "Use connection pooling for database access"105 relevance: related_to_inbound # or: frontmatter_match | content_match | direct_mention | related_to_outbound106 excerpt: "prevents connection exhaustion under load" # ~50 tokens max, absent in Mode A107```108109Agent receives this list and decides which files to load via `memory-retrieve`.110111---112113## Non-Goals114115This skill must NOT:116- Load full file contents (that is `memory-retrieve`)117- Modify any memory files (that is `memory-ingest`)118- Make decisions about which results to act on (that is the agent's job)119- Perform recursive graph traversal beyond depth 1120- Search outside `contexts/memory/`121122**Memory-search finds. Memory-retrieve loads. The agent decides.**