| name | search |
| description | Search cards and events by keyword or structured query |
| args | <query> |
| user_invocable | true |
/session-memory:search — Search Knowledge Base
Search through knowledge cards and session events.
Query Syntax
The query supports both simple keywords and structured filters:
- Simple:
/session-memory:search auth null — keyword search
- Structured filters (can combine):
tag:auth — match card tags
type:gotcha — match card type (decision, constraint, gotcha, runbook, onboarding)
file:src/auth.ts — match card files
importance:>=2 — filter by importance level
status:active — filter by status (active, draft, deprecated)
author:jay — filter by author
Examples:
/session-memory:search tag:auth type:gotcha
/session-memory:search database migration importance:>=2
/session-memory:search file:src/api
Search Algorithm
- Parse query: Separate structured filters (key:value) from free-text keywords
- Search cards first (
.claude/memory/cards/*.md):
- Apply structured filters on frontmatter fields
- Match free-text keywords against: title (weight 3x) > tags (2x) > TL;DR (1.5x) > body (1x)
- Score = keyword_match_score × recency_bonus × importance_bonus
- Search events (
.claude/memory/events/*.jsonl):
- Match keywords against summary field
- Only include if fewer than 10 card results
- Sort by score descending, return top 10
- Display format:
For cards:
[gotcha] Auth module null check (importance: 2, created: 2026-03-09)
TL;DR: req.user can be null before auth middleware runs
Files: src/auth.ts, src/middleware/auth.ts
Tags: auth, null-safety
For events:
[event] 2026-03-09T10:00:00Z | Edit | Fixed null check in auth.ts (importance: 1)
Implementation
- Read all cards from
.claude/memory/cards/*.md
- Parse YAML frontmatter using sed/grep
- For each card, check filter matches and compute keyword score
- Read events from
.claude/memory/events/*.jsonl if needed
- Merge, sort, and display top results
Edge Cases
- No cards or events: "No session memory found. Start working and cards will be auto-created."
- No matches: "No results for ''. Try broader keywords or check /session-memory:status."
- Deprecated cards: Include only if
status:deprecated explicitly requested