← All guides

PRO TIPS Multi-Tool Second Brain

Ask your notes anything with a local RAG

One script, SQLite, and a free local embedding model. Ask your whole notes vault questions from the terminal, with ranked citations. No API keys.

The problem

A second brain is only useful if you can get answers out of it. Plain search fails the moment you forget the exact word you wrote. And the popular fix, uploading everything to a “chat with your notes” SaaS, means your journal, your goals, and your business notes sit on someone else’s server behind someone else’s subscription.

Personal notes are exactly the data that should never leave your machine.

What I built

One script, zero npm dependencies. It indexes my whole Obsidian vault into a single SQLite file and answers questions from the terminal:

bun brain-rag.ts query "what did I decide about pricing" --k 5

It prints the top matching chunks with a file path, the heading they sit under, and a score. I open the cited note for full context. My agents run the exact same command to look things up before they act.

The numbers on my Mac mini: 543 files indexed into 4,918 chunks, about 2 minutes for a full build, 0.1 seconds to re-index after edits, and around 140 ms per query. Zero API keys. If the embedding model is unreachable, it degrades to plain keyword search instead of failing.

The recipe

You do not need my script, you need the shape. Five parts, any language:

  1. Chunk: split each markdown file at headings, cap chunks around 1,600 characters with a little overlap.
  2. Embed: run Ollama locally with nomic-embed-text. Free, and it runs fine on a normal Mac.
  3. Store: one SQLite database. Vectors go in as blobs, and an FTS5 table gives you keyword search for free.
  4. Search: run both arms on every query, vector similarity plus BM25 keyword, then merge the two ranked lists with reciprocal rank fusion.
  5. Cite: print file paths and headings, not just text. The chunk is the pointer, the note is the answer.

Paste this into Claude Code from inside your notes folder:

Build me a single-file local RAG script over this folder of
markdown notes. Chunk by headings (about 1600 chars with
overlap), embed with Ollama nomic-embed-text, store vectors
plus an FTS5 keyword index in one SQLite file, search hybrid
(cosine plus BM25, merged with reciprocal rank fusion), and
print ranked results as file path + heading + snippet.
Re-index incrementally by file hash, delete chunks for
deleted files, no API keys, no external services.

That prompt is the compressed version of how mine was built.

Why local wins here

Privacy: notes and queries never touch the network, and it works offline. Cost: nothing per query, no subscription, the embedding model is free. Ownership: the whole system is one file you can read top to bottom, and the index is one database you can delete and rebuild in two minutes. No SaaS gives you all three.

Do this now

  1. Install Ollama and run ollama pull nomic-embed-text.
  2. Paste the prompt above into Claude Code inside your notes folder.
  3. Ask a question you already know the answer to and check the citation.

Want to build this yourself?

Join Claude Code Academy, my free community. Courses, build alongs, and builders turning AI into real systems. And I post a new build on Instagram nearly every day.