Purpose
cortex-plugin (named memem within the code repository) is a persistent memory plugin for Claude Code, with the goal of letting Claude remember project-related experience across sessions and avoiding the need to re-explain project background in every session. It automatically mines long-term retainable "lessons" from conversations, including decisions, conventions, bug fixes, and preferences, and stores them as human-readable Markdown in a local Obsidian vault.
Main Capabilities
- Event-triggered mining: via the Stop hook (hooks/stop-mine.sh), after each Claude Code Stop event it launches a detached mine_delta subprocess, reads newly added conversation from the JSONL session file, and calls Haiku extract_from_text to extract memories. The hook itself costs about 50ms, and extraction is completed in the background.
- Memory storage: extracted content is written as Markdown to ~/obsidian-brain/memem/memories/, local-first, with no cloud service, no API Key, and no vendor lock-in.
- Retrieval and presentation: uses combined retrieval such as SQLite FTS5, BM25, cosine similarity, and RRF (Reciprocal Rank Fusion); active_memory_slice returns the "Active Memory Slice" working state, with the default runtime context being slice-first, while also retaining an explicit narrative assembly path.
- Path-scoped retrieval: v2.9.1 activates the path-scoped retrieval that was already built into v2.9.0 but not enabled, and recall automatically derives paths_context from the current session, making the paths: bonus take effect; it also supports callers manually providing paths_context.
- Transcript full-text search: transcript_search is backed by a persistent FTS5 index in ~/.memem/transcript_fts.db, with one row per question-answer pair, index_session() is called incrementally by mine_delta, the old per-session single-row index is automatically migrated, and the grep fallback is constrained by size/count/time limits.
- Write path: the miner performs batch Haik on extraction candidates and nearest-neighbor memoriesu comparison, choosing ADD, UPDATE, SUPERSEDE, or NOOP, with safety guardrails (protected targets, truncation protection, at most 5 destructive operations per delta, etc.).
- Feedback and evaluation: each retrieval is associated with a session id, and the miner scans memory ids referenced in assistant text and writes citation records to .recall_log.jsonl; it provides --analyze-recalls and benchmarking tools.
- Layered context model: starting from v2.8.0, it uses profiles (user-level and project-level always-injected documents), working rules (type:procedural memories, sorted by citation count), and an episode index (an index of at most 25 episodic titles) to replace the old L0-L3 layer system.
- Streamlined tool surface: v2.9.0 reduced MCP tools from 14 to 6, and the tool description schema size decreased by 57%.
Usage
- Install as a Claude Code plugin and configure the Stop hook (hooks/stop-mine.sh) and SessionStart hook.
- Memory files are stored in ~/obsidian-brain/memem/memories/ and can be viewed directly with Obsidian.
- At the start of a session, Claude can receive blocks such as ## Episode index or Working rules; for active retrieval, MCP tools such as memory_search, memory_get, and active_memory_slice or the CLI path can be used.
- Run python3 -m memem.server --analyze-recalls to view retrieval patterns; use --migrate-layers to bootstrap profiles from an existing vault; use --dream --safe-auto to automatically run the dreamer (reflection_with_citations, tense_rewrite, cluster_merge, etc.) after every 25 substantive mining deltas.
- Related CLI example: python3 -m memem.server --purge-contaminated [--apply].
Applicable Scenarios
- Claude Code users who need to maintain project context consistency across sessions.
- Developers who want to preserve important decisions, conventions, and bug fixes in readable Markdown form that can be browsed in Obsidian.
- Privacy-sensitive scenarios that prioritize local-first and do not require cloud services or API keys.
Limitations and Notes
- Official materials do not provide specific pricing or fee information; pricing and fee details are not yet available.
- Token cost: starting from v2.1.0, real-time mining makes the token cost per session approximately 5–20 times that of the previous v2.0.0 end-of-session batch mode.
- Depends on Claude Code hooks and Haiku calls; hook paths, MCP tools, and CLI parameters may undergo breaking changes across versions (e.g., v2.0.0 rewrote the schema, and active_memory_slice was streamlined from 8 parameters to 2).
- Some legacy environment variables and modules have been removed or become no-ops during upgrades (e.g., MEMEM_USE_LLM_JUDGE, MEMEM_USE_EMBEDDINGS, slice_daemon, etc.).
- Official materials do not provide clear explanations regarding supported platforms, data scale limits, concurrency capabilities, etc.; this information is not yet available.