MCPInstall
davidlee avatar

retrieve-memory

Use before making non-trivial assumptions — before touching a subsystem you have not this session, before running or changing a command pipeline, when code and docs conflict, when asked "what is the right way here?", when debugging a recurring failure, or when about to answer with "probably/usually/likely".

Installs
144
Last 24h
—
Trending rank
—
Security
Not audited

Install

Works with every agent the skills CLI supports.

npx skills add https://github.com/davidlee/doctrine --skill retrieve-memory
  1. 01

    Install

    Run the command in your project. The CLI asks which agents to install for.

  2. 02

    Describe the task

    Ask your agent for something this skill covers. It loads retrieve-memory automatically when relevant.

  3. 03

    Review the result

    The agent follows the SKILL.md steps, scripts and references bundled with the skill.

SKILL.md

The instructions your agent reads when the skill is triggered.

Retrieve Memory

Default rule: if you cannot cite a source-of-truth file/doc/ADR from the repo, consult memories first, then proceed. The memory model is documented in [[mem.concept.doctrine.memory-model]].

Tool preference

If your harness supports MCP tools and doctrine's MCP server is connected (you see memory_search, memory_retrieve, memory_show, memory_list in your tool list), prefer these MCP tools over the CLI. They return machine-parseable JSON text in the MCP content block without spawning a shell, and memory_show enriches results with resolved backlinks.

Progressive disclosure (MCP pattern)

  1. memory_search — scope-constrained discovery first. Always supply at least one selector (path, glob, tag, type, or free-text query). Metadata only, no bodies. Rows include a held_back_on_retrieve flag — do not treat high-risk memories as consumable knowledge.
    • Find vs browse. Free text is floored: only memories with lexical or exact-key evidence for the query come back; selectors alone browse every scope match, severity first. Either way you get one page (20 by default); page on with offset = next_offset (CLI: --page).
    • Empty is an answer. An empty free-text result means "no match", not "empty corpus" — reword with the memory's likely terms, or drop the query and browse by scope.
  2. memory_retrieve — safe context recall for candidates identified in step 1. Trust holdback enforced; low-trust high-severity memories are suppressed automatically.
  3. memory_show — full inspection only when you need the complete picture. Use view: summary for token efficiency. Held-back memories carry a warning; do not consume them as knowledge.
  4. memory_list — browse/index only. Prefer scoped memory_search.

When MCP tools are not available (e.g. in a plain shell environment), fall back to the doctrine memory CLI commands described below.

Two surfaces

  • doctrine memory retrieve — see doctrine memory retrieve --help for the data-not-instruction framing and the non-bypassable trust holdback.
  • doctrine memory search — ranked rows that keep risk visible (holdback-exempt). Use it to discover and triage, including the risky memories retrieve hides.
  • doctrine memory show <UID|KEY> — read one memory's full body.

Graph traversal

  • doctrine memory backlinks <REF> — discover reverse edges: which memories point to this one. Use when you land on a memory and need to know what depends on it.
  • doctrine memory retrieve --expand N — expand the result graph by N hops along [[relation]] edges. Each hop pulls in directly-connected memories. Use for context when a single memory is too narrow.
  • --lifespan filter (on retrieve and search) — restrict to memories with a lifespan at or above the given threshold. identity returns everything; semantic filters out episodic/working; procedural excludes working. Use to suppress transient noise in a deep dive.

When the question is not memory-shaped

doctrine memory search reaches only the memory corpus. For a "where does this live / what is the right way here?" question whose answer may be an ADR, spec, slice, RFC, or backlog item, use doctrine search <query> instead — one ranked query over the entity corpus. It is entities-only, and its default kind set omits policies and standards; lib:reference/using-doctrine.md gives the scope and how to widen it.

Procedure (fast → thorough)

  1. Scoped query first. Run doctrine memory retrieve scoped to the concrete files you expect to read or edit, plus the command context you are about to run (ask --help for flags; lib:reference/using-doctrine.md for the verb model). Glob-scoped memories still match path scopes — no separate flag needed. Scope probes are OR'd; type/status are AND hard filters, so do not over-filter unless certain.

  2. Tune the surface. See doctrine memory retrieve --help for --limit and --min-trust (raises, never lowers, the default trust floor).

  3. Inspect risk. If search shows risky or held-back memories relevant to the task, show them and judge — do not act blind to what retrieve withheld.

  4. Make connections. After retrieving, check the relations on key memories and follow edges to related knowledge: memory show <REF> renders relation rows; memory backlinks <REF> surfaces reverse edges; memory retrieve --expand 1 pulls the immediate graph neighbourhood. A memory in isolation is less useful than one with its edges visible.

  5. Validate before acting. Before relying on an old or high-severity memory, run doctrine memory validate <REF> to check for dangling relations, stale verification, and draft expiry. A memory that looked definitive six months ago may have drifted. Validate, then act.

What to trust

  • Ranking already encodes severity, weight, scope specificity, and recency — prefer the top rows.
  • A memory carries a verification state. Surface it qualitatively when you rely on one: never attested → say so; many commits since attestation → "treat with caution, its scope has churned"; recently attested → "scope is quiet".
  • If memories disagree, do not average — escalate (/consult, or update/supersede the stale one) before a consequential change.

Output discipline

When you act on a memory, cite its uid/key and the sources it points to. Run the scoped query before deep reading or editing, so glob-scoped gotchas surface while the change is still cheap.

FAQ

What does the retrieve-memory skill do?

Use before making non-trivial assumptions — before touching a subsystem you have not this session, before running or changing a command pipeline, when code and docs conflict, when asked "what is the right way here?", when debugging a recurring failure, or when about to answer with "probably/usually/likely".

How do I install retrieve-memory?

Run npx skills add https://github.com/davidlee/doctrine --skill retrieve-memory in your project. The skills CLI detects the agents you use and copies the skill into the right folder. For Claude Code you can also place the skill folder at ~/.claude/skills/retrieve-memory/ (personal) or .claude/skills/retrieve-memory/ (project).

Which AI agents can use retrieve-memory?

Any agent that supports the open Agent Skills format (a folder with a SKILL.md file), including Claude Code, Codex, Cursor, GitHub Copilot, Gemini CLI, Windsurf, Cline, OpenCode and more.

Is retrieve-memory safe to install?

No partner security audit is available yet. Skills can run commands and scripts, so read the SKILL.md and any bundled files before installing.

Who maintains retrieve-memory?

It is published by davidlee in davidlee/doctrine. It has 144 recorded installs.

More from davidlee/doctrine

View all →
davidlee avatar

code-review

davidlee/doctrine

Use whenever reviewing code for quality and correctness — a diff, PR, module, or subsystem — producing verified, severity-ranked findings on the RV ledger. Not for comprehension tours (walkthrough) or doctrine-conformance hunts (inquisition, user-invoked only).

davidlee avatar

pair

davidlee/doctrine

Agentic pair programming — drive a change together with a human partner in the loop, narrating intent and pausing at decision points. Use when the user wants to work side-by-side rather than hand off a whole task. Calibrated by three dials (role, detail, autonomy) and an always-on challenge mandate.

AI & Agents148 installs
davidlee avatar

consult

davidlee/doctrine

Use the moment you hit an unanticipated obstacle, a decision with competing tradeoffs, or emergent complexity mid-task — before adapting planned scope, adding a dependency, taking a shortcut, or making any impactful concession on your own.

davidlee avatar

handover

davidlee/doctrine

Use when handing work to a fresh context — first bring the durable harvest current, then emit a continuation at one of two weights — a printed continuation prompt (light) or a handover.md context packet (full). Use whenever a fresh agent would more efficiently continue.

AI & Agents146 installs
davidlee avatar

canon

davidlee/doctrine

Use before making architectural or workflow choices, when correctness depends on project governance, or when entering an unfamiliar subsystem — to load the project's authoritative rules before you act on assumptions.

davidlee avatar

plan

davidlee/doctrine

Use when a slice's design is locked and it needs an executable phase plan — refine each phase's objective and entry/exit/verification criteria, author plan.toml + plan.md, and materialise the runtime phase sheets. Routed to from /design.

Popular code quality & workflow skills

View category →
mattpocock avatar

grill-me

mattpocock/skills

A relentless interview to sharpen a plan or design.

Scan a codebase for deepening opportunities, present them as a visual HTML report, then grill through whichever one you pick.

mattpocock avatar

handoff

mattpocock/skills

Compact the current conversation into a handoff document for another agent to pick up.

mattpocock avatar

domain-modeling

mattpocock/skills

Build and sharpen a project's domain model. Use when discussing codebase terminology, writing or editing a GLOSSARY.md, or recording or editing an ADR.

mattpocock avatar

codebase-design

mattpocock/skills

Shared vocabulary for designing deep modules. Use when the user wants to design or improve a module's interface, find deepening opportunities, decide where a seam goes, make code more testable or AI-navigable, or when another skill needs the deep-module vocabulary.

mattpocock avatar

diagnosing-bugs

mattpocock/skills

Diagnosis loop for hard bugs and performance regressions. Use when the user says "diagnose"/"debug this", or reports something broken/throwing/failing/slow.