Retrieving

Pull context back out — before acting, not after. The agent consults engrams at three moments: session start (prime), before editing files (relevant), and before designing or fixing (query, decision search). All output is JSON, ranked and token-lean.

Session start — engrams prime

One call replaces half a dozen. prime fans out queries across product context, active-context tracks, decisions, progress, and patterns, joins PRs and anchors, and returns a single consolidated briefing. It is the first command of every session.

engrams prime
engrams prime --budget 1000 --paths src/ops,src/db.rs --tags database
FlagPurpose
--budgetApproximate token budget; lower-priority sections are shed to fit.
--pathsFilter the briefing to items anchored to these paths.
--tagsFilter by tags.

Token estimation is payload length ÷ 4. When the estimate exceeds the budget, less critical sections are discarded in a fixed order — but active-context is never shed, because it carries the session's immediate goals, open questions, and next steps.

Before editing — engrams relevant

The anchor graph in reverse: give it paths, get back every decision and pattern anchored to them. This is how context stays anchored to the files being edited instead of the whole database. Run it before touching any file.

engrams relevant src/db.rs src/ops
engrams relevant --staged
FlagPurpose
[PATHS]...Files or directories to match against stored anchors; directory anchors match recursively.
--stagedUse git diff --cached --name-only as the path list — context for exactly what you're about to commit.
--allInclude superseded decisions (default: active only) to see how an area evolved.

Before designing — engrams query

Cross-type full-text search over decisions, patterns, and custom data, backed by SQLite FTS5 and ranked by BM25. Results come back as highlighted snippets — matching terms wrapped in >>/<< markers — so the agent scans hits without pulling full rows.

engrams query "authentication"
engrams query "redis" --types decision,pattern --tags database,cache --limit 5
engrams query "JWT" --since "2026-07-01T00:00:00Z" --all
FlagPurpose
--typesRestrict to decision, pattern, custom (comma-separated; default all three).
--tagsOnly items carrying these tags.
--sinceRFC3339 lower bound on timestamp.
--limitMax results (default 10).
--allInclude superseded decisions.

Decisions only — engrams decision search

FTS over decisions alone, for when the question is specifically "have we already decided this?" Settled choices stay settled instead of being re-litigated every session.

engrams decision search "database" --snippets --limit 10
engrams decision search "sqlite" --all
FlagPurpose
--snippetsReturn highlighted FTS snippets instead of full rows — the token-lean default for agents.
--limitMax results (default 10).
--allInclude superseded decisions.
Why retrieval gets better over time These four commands are the same on day 1 and day 90 — what changes is what they find. Every stored item and asserted link makes the next retrieval sharper. That compounding is the subject of The Advisor Loop.
Next Retrieval assumes the graph is current. Continue to Maintaining for superseding, auditing, and export.