Document the on-demand memory workflow and snippet (boilerplate/template) reuse workflow for agents working in this repo: query shared-memory only when detail is needed (don't bulk-load), and browse snippet_list before recreating known boilerplate, fetching by exact name with snippet_get. Mirrors the user-scope `consult-memory-before-work` shared-memory snippet. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
2.4 KiB
CLAUDE.md — shared-memory
Project key (for the shared-memory MCP): shared-memory (set by the .shared-memory-project marker at the repo root).
Consulting memory before substantive work
There are TWO memory stores. The file-based memory (MEMORY.md + topic files) is auto-loaded into context every session. The shared-memory MCP (mcp__shared-memory__*) is NOT auto-loaded — you must query it. Query on demand when you need detail; do not bulk-load everything (that wastes context).
When a request draws on accumulated project knowledge — an architecture/development overview, debugging, planning, reviewing, or implementing a feature, or any question about how the system works — do this BEFORE answering or acting:
- Use what's already in the auto-loaded
MEMORY.mdindex. - ALSO check the shared-memory MCP: call
project_identifyonce per session (resolves the key from.shared-memory-project), thenmemory_searchwith the task topic in natural language (a couple of queries if the task spans areas). Fetch full bodies withmemory_getwhen a hit looks relevant. - Fold both sources into your answer; note when something came from saved memory.
Reusing saved snippets (boilerplate / templates) before recreating work
Snippets (mcp__shared-memory__snippet_*) hold reusable artifacts — boilerplate, standard formats, checklists, established workflows. They are pull-only and, unlike memory, NOT searchable: snippet_get fetches by EXACT name, and the description shown by snippet_list is the ONLY discovery surface (tags are just for human browsing).
Before hand-writing standard/boilerplate code or re-deriving a known workflow, check whether a template already exists:
- Call
snippet_listonce — it's cheap: it returns names + descriptions + tags, no bodies. Scan the descriptions for a match. - If one fits,
snippet_get <name>to pull just that body and apply it, instead of recreating it from scratch. - When you produce a reusable artifact worth keeping, save it with
snippet_putunder a stable, predictable name (e.g.boilerplate/<area>/<thing>) and a concrete "when to use"descriptionso a future agent can find it by scanningsnippet_list.
Skip both checks only for trivial, self-contained requests (a quick edit, a one-off shell command, casual conversation) where prior project context can't matter. If the MCP server isn't connected in this session, proceed with file memory and say so.