Give Claude Code persistent memory from an Obsidian vault with five hooks

Guido Di Lauro wired five Claude Code hooks to an Obsidian vault so each prompt pulls in up to three relevant notes and a cheap headless agent files each session's decisions back into the vault.

Done withClaude CodeinOllama· Nov 13, 2026

What they did

Di Lauro was tired of a coding assistant starting every session with no idea of past decisions, so the Obsidian vault of Markdown notes became its long-term memory, following the shape of Karpathy's LLM wiki idea. Five Claude Code hooks do the moving. At session start one injects the vault's operating manual and folder map. On every prompt another embeds the message with a local nomic-embed-text model through Ollama, compares it with a SQLite index of note chunks and adds up to three matching snippets. A write hook checks each note against the vault's note format and exits with code 2 so the model sees and fixes problems. After a compaction an opt-in headless agent copies decisions and tasks into the vault. When a turn stops, a headless Claude run on a cheap model saves anything worth keeping, and changed notes are re-embedded.

How it went

The author says recall questions now go in plain words and the assistant answers from the project history with nothing pasted in. On a 155-note test vault the prompt hook averaged about 124 ms and a full injection cost about 283 tokens; the session-start manual costs about 2.3k tokens once. In a five-prompt smoke test, vector search found the right note where keyword grep missed or ranked it lower in most cases. The author estimates 5,000 to 15,000 tokens saved per session but calls it a guess, not a measured bill.

Worth knowing

Similarity scores for unrelated prose all sat in a narrow band, so the setup uses two cutoffs: a loose one when the prompt sounds like a recall question and a strict one otherwise, or every prompt fills up with noise. The save agent runs on every Stop event and is the main running cost. The author warns that the upstream plugin's compaction hook has used the skip-permissions flag; their own scripts use an allowlist instead.

Try it

With Claude Code· 4 parts to fill in

Set up persistent memory for yourself using my notes vault at [path to my Markdown or Obsidian vault]. Add hooks to [my Claude Code settings file]: at session start, load the vault's rules file and folder map; on each prompt, embed the prompt with [my local embedding model], search an index of note chunks and add at most three relevant snippets, using a looser cutoff only when the prompt asks about past work; when a turn ends, run a headless save on [a cheap model] that files decisions and fixes into the right notes, then re-index only changed files. Use an explicit tool allowlist, never skip permissions. Show me every hook script and the settings change before you install anything.

Square brackets are the parts to fill in. The prompt is ours; the story is theirs.

Where they said it

Related