SKILL.md
Hybrid Memory Retrieval
Search memories using the optimal strategy based on query analysis.
State Machine
START → PARSE_QUERY → CLASSIFY
├→ NO_QUERY ────→ GET_RECENT ────────────────────┐
├→ RECENT ──────→ GET_RECENT_N ──────────────────┤
├→ KEYWORD ─────→ KEYWORD_SEARCH ────────────────┤
└→ SEMANTIC ────→ VECTOR_SEARCH ──┬→ RESULTS ────┤
└→ FALLBACK ───┤
▼
INCLUDE_SUMMARIES? → FORMAT → END
Query Classification
| Pattern |
Type |
Example |
Strategy |
| Empty |
none |
"" |
Recent memories |
| Temporal |
recent |
"last 5", "recent" |
Recent N memories |
| Short specific |
keyword |
"JWT token" |
Keyword match |
| Question/conceptual |
semantic |
"How does auth work?" |
Vector + fallback |
Execution
Path A: Subagent (preferred)
Task(
subagent_type: "summarizer",
prompt: "Search memories in project PROJECT_ID for: QUERY"
)
Path B: Direct script
bun .opencode/skills/memory-retrieve/scripts/retrieve-memories.ts PROJECT_ID [QUERY] [OPTIONS]
Commands
Main Retrieval
# Recent memories (no query)
bun .opencode/skills/memory-retrieve/scripts/retrieve-memories.ts PROJECT_ID
# Semantic search
bun .opencode/skills/memory-retrieve/scripts/retrieve-memories.ts PROJECT_ID "authentication flow"
# With summaries
bun .opencode/skills/memory-retrieve/scripts/retrieve-memories.ts PROJECT_ID "JWT" --include-summaries
# JSON output
bun .opencode/skills/memory-retrieve/scripts/retrieve-memories.ts PROJECT_ID "auth" --format json --limit 10
Individual Scripts
# Classify query type
bun .opencode/skills/memory-retrieve/scripts/classify-query.ts "QUERY"
# Recent only
bun .opencode/skills/memory-retrieve/scripts/get-recent-memories.ts PROJECT_ID --limit 10
# Vector search
bun .opencode/skills/memory-retrieve/scripts/search-vector.ts PROJECT_ID "QUERY" --limit 20
# Keyword fallback
bun .opencode/skills/memory-retrieve/scripts/search-keyword.ts PROJECT_ID "QUERY" --limit 20
Options
| Option |
Default |
Description |
--limit N |
20 |
Max results |
--include-summaries |
false |
Include project summaries |
| `--format json\ |
text` |
text |
Output format |
--quiet |
false |
JSON only, no progress |
Exit Codes
| Code |
Meaning |
| 0 |
Success |
| 1 |
Error |
| 2 |
No results (search scripts only - triggers fallback) |
Output
Text Format
## Summaries
### coding_session (1/8/2026)
OBJECTIVE: Implement authentication...
## Memories
- **fact** [0.92]: Implemented JWT verification...
- **fact** [0.89]: Added refresh token logic...
JSON Format
{
"success": true,
"memories": [...],
"summaries": [...],
"searchMethod": "vector",
"totalTokens": 2340,
"count": 8
}
Environment Variables
| Variable |
Default |
Description |
BRAINYAPIURL |
http://localhost:3000 |
API endpoint |
BRAINYPROJECTID |
3afb861a-... |
Default project if not specified |
RETRIEVERECENTLIMIT |
10 |
Default limit for recent queries |
RETRIEVESEARCHLIMIT |
20 |
Default limit for search queries |
RETRIEVEMINSIMILARITY |
0.5 |
Min similarity for vector results |