Find the note by what it means
I write things down. A notes repo, a folder of architecture decision records (ADRs) in each project, a runbook here and there. All of it is markdown in git, on the same laptop as the code.
My coding agents still miss it. An agent searches with the words it happens to have, and the note that answers it uses other words. Here’s one from today. I searched the ADRs of one of my projects for a file holding “agents”, “edit” and “checkout”, and got no matches. The decision that answers the question exists. It talks about sessions that share one working tree, and two of my three words aren’t in it.
I had started to build a hosted knowledge service for this, with its own server and database. That was a lot of machinery for a few hundred markdown files that already sit on the machine, in repos my code search already indexes. What was missing was one more way to search them.
What the docs search is
csl is my local code search, a zoekt index over every git checkout on the machine, served to coding agents as an MCP server. I wrote about why it runs locally and about handing file reads to a small model.
The docs search adds two ways to search one list of markdown sources that you pick.
The first goes by meaning. A small embedding model in a local Ollama turns each section of each listed file into a vector. Your question becomes a vector too, and the closest sections come back. The words don’t have to match.
The second goes by word. It’s a normal csl search, kept to the same files, and it needs no model.
Both work from the terminal and from an agent, and both run on the laptop. At search time the model sees only the question.
How it works
- A source is a repo plus a list of paths inside it.
"."means the whole repo. Paths are required, so nothing gets indexed by accident. csl takes only markdown that git tracks, never follows a symlink, and reads a repo’s main checkout, never a linked worktree. - Each file is cut at its headings into sections of at most 6,000 characters.
- Each section goes to
qwen3-embedding:0.6bthrough Ollama with an 8,192-token window, and comes back as 1,024 numbers. The question gets an instruction in front of it (“Given a web search query, retrieve relevant passages that answer the query”). The documents get none. - The vectors go into a local store, one per source. A build re-embeds only the files whose content changed. Each store records the model, the vector width, the chunker version and the model pin, so changing any of them rebuilds it. csl refuses a vector of all zeros, or one holding a value that isn’t a number, since it would score the same against every question.
- A search embeds the question once and compares it with every stored section, in the calling process. Hits collapse per file, and each file shows its best three sections with their line ranges.
The code side of csl uses a different model, a code-trained jina model that the csl docs list as about four times faster to index. That speed matters across a whole fleet of repos. For a few hundred notes it doesn’t, and in my test the qwen3 model ranked prose a little better. The numbers are further down.
The config
It all lives under semantic.docs in ~/.config/csl/config.yaml.
semantic:
enabled: false # the code semantic index stays off: lexical search plus docs only
docs:
enabled: true
embed_model: qwen3-embedding:0.6b
dim: 1024
model_sha256: 06507c7b42688469c4e7298b0a1e16deff06caf291cf0a5b278c308249c3e439
sources:
- repo: acme/notes
paths: ["."]
- repo: acme/platform
paths: [docs/adr/]
semantic.enabledis the code semantic index, a separate switch. I keep it off and use plain word search for code.docs.enabledturns on the meaning search. Off, csl never calls the model and registers no MCP tool for it.sourcesis the list, here a whole notes repo and the ADR folder of one project. Paths match letter case exactly.embed_modelanddimare the defaults, written out.model_sha256pins the model file. The last section covers it. The file a plainollama pullfetches today has this hash, so it passes.
Then build and ask:
ollama pull qwen3-embedding:0.6b
csl index --docs # build, or bring up to date
csl index --docs --status # per source: files, chunks, pin and model
csl semantic docs 'why did we pick postgres' --path docs/adr/
csl search 'retention' --docs -o content
csl doctor
csl semantic docs takes --limit (default 10), --repo, --path and --json. csl sync runs the docs pass too, and only calls Ollama when a file needs embedding.
The word search needs the source list and nothing else. It works with docs.enabled: false, so a machine that can’t run the model still searches the same files, by word.
Wiring it for an agent
Register csl’s MCP server once:
claude mcp add --scope user csl -- csl mcp
Two tools carry the docs search:
csl_docs_searchtakes a question in plain words, plus optionallimit,repoandpath. It’s registered only when the docs index is enabled and has at least one source.csl_searchwithdocs: trueis the word search over the same sources.
csl docs --claude-md prints csl’s rules block for an agent’s instruction file, and since v0.42.0 that block names both tools. On top of it I added a few lines about notes in general:
## Notes and decisions
- A question about what was decided, chosen or looked into before is a
question for the notes. Its first search is `csl_docs_search`.
- Exact words, or a machine without the model: `csl_search` with
`docs: true`, same sources.
- A note is a lead. Check it against the code before you act on it.
- Cite the file and the line.
- When nothing fits, say "not found". Never answer from a note on another
subject.
The last line matters more than it looks. The meaning search always returns its closest sections, even when nothing in the sources answers the question.
Proof
All of this ran on my laptop, an Apple Silicon Mac with Ollama 0.40.19.
The build
| what | measured |
|---|---|
| sources | 3 |
| markdown files | 448 |
| sections | 4,383 |
| first build | 3 min 46 s |
| rebuild, nothing changed | 0.15 s |
| one search from the shell, model warm | about 0.12 s |
Does it find the right file?
I wrote 12 questions, each with one file I knew held the answer, over 420 markdown files. Then I ran them against a few setups.
| setup | right file first | right file in top five |
|---|---|---|
| jina v2 base code (csl’s code model), sections | 8 of 12 | 10 of 12 |
qwen3-embedding:0.6b, sections |
9 of 12 | 11 of 12 |
| the shipped docs search, same questions | 8 of 12 | 11 of 12 |
Twelve questions is thin. One question moves the first-place score by about 8 points, so the gap between the two models is one question in each column. The shipped search lost one first place against the test run, and with this few questions I can’t tell that from noise. The top five holds up better. The right file was in it for 11 of 12 questions.
I also tried embedding whole files with a 32k window instead of sections. Ollama 0.31.1 returned all-zero vectors at that window. So sections stayed, and so did the 8,192 window.
What a hit looks like
These come from the public thismoon repo, one of my sources. I trimmed the opening text under each section.
$ csl semantic docs 'why did we move away from seatbelt' --repo thismoon --limit 2
mad01/thismoon/docs/adr/0028-sandbox-runtime-replaces-seatbelt.md score=0.44
1-11 0.44 ADR-0028: sandbox-runtime replaces hand-written seatbelt profiles
13-36 0.37 ADR-0028: sandbox-runtime replaces hand-written seatbelt profiles > Context
36-93 0.32 ADR-0028: sandbox-runtime replaces hand-written seatbelt profiles > Decision
mad01/thismoon/docs/adr/0025-present-terminal-sessions-in-serve.md score=0.35
90-101 0.35 ADR-0025: present terminal sessions live in serve behind an opt-in switch > Amendment (2026-10-25)
...
That one is easy, since “seatbelt” is in the title. The harder one is the question from the top of this post:
$ csl search 'agents edit checkout' --docs --repo thismoon
no matches
$ csl semantic docs 'what happens when two agents edit the same checkout' --repo thismoon --limit 1
mad01/thismoon/docs/adr/0014-loom-skill-only-worktree-coordination.md score=0.54
37-47 0.54 ADR-0014: worktree coordination is skill-only; git is the state store > Consequences
9-18 0.44 ADR-0014: worktree coordination is skill-only; git is the state store > Context
18-37 0.39 ADR-0014: worktree coordination is skill-only; git is the state store > Decision
The word search stays in scope
The word “mise” matches 584 files across every repo csl indexes on this machine. With --docs it matches 59, all markdown, all inside the listed sources. A word search over notes, without the code drowning it.
Will an agent use it?
In the csl_ask post, a rule in the instruction file did nothing. The agent only changed course when the tools themselves pushed. Here a rule worked, on the second try.
My first wording named the tool: find a note with csl_docs_search when the tool is there. I started two fresh agents with no hint and asked each about an old decision. Both could quote the line and both had the tool. Both opened with a plain code search anyway. Asked why, they said a question like “which one did I settle on” didn’t read to them as “find a note”.
The second wording names the situation, as in the lines above. A question about what I decided, chose or looked into before is a question for the notes, and its first search is the docs search. I asked the same two questions of two new agents. Both loaded the tool, searched by meaning first, and cited file and line.
That’s four runs, so it’s a reading and not a result. What I take from it is that a rule has to name the moment it applies. The agent matches on the question in front of it, not on a tool’s name.
What to expect
It always answers. The meaning search returns its closest sections even when the answer isn’t there. I asked the thismoon ADR folder for a parental leave policy, and an unrelated ADR came first at 0.29. The right files above scored 0.44 and 0.54. Three questions don’t make a threshold, which is why the agent lines say to check the note and say “not found”.
The top section is sometimes the title block. In the seatbelt hit, lines 1 to 11 are the title and its status lines, and the decision itself came third. Read the file, not just the first line.
It reads main checkouts only. A note on a branch in a worktree won’t show up until it lands and the main checkout is pulled.
The two searches share a scope but not an index. Each reads its own, and a few files differ. The word search finds markdown that git doesn’t track, and the docs index skips it. For files under most hidden folders it’s the other way round. There’s a full table in the csl docs.
It’s markdown only. A wiki or a PDF has to become markdown in git first.
The first query after idle is slower. Ollama keeps the model loaded for 20 minutes after a request, and the next query after that pays a model load, a second or two by the csl docs.
And the proof is thin. Twelve questions, two agent runs, one laptop. I use it to find leads, and I wouldn’t quote a hit rate from it.
Pinning the model
A model name in Ollama is a label, and the file behind it can change. A tag moves upstream, another quantisation gets pulled under the same name, or a typo in the config loads some other model. Ollama never checks a file again once it’s on disk. On most machines that’s fine. On a machine where a model file must be reviewed before it runs, the name isn’t enough.
Set model_sha256, and csl checks the bytes itself. Before it embeds, it asks Ollama which file the name loads and hashes that file. It also reads Ollama’s manifests for the name and requires exactly one weight file, since Ollama can load more model layers than the one it reports. It sends nothing to the model unless the hash matches the pin, and when it can’t decide, it refuses. csl doctor shows the result on its docs-model-pin line. Hashing takes about a second, and csl caches the hash by path, size and modification time between full checks.
csl publishes the file it was tested with as a release of the thismoon repo:
| what | value |
|---|---|
| tag | models/qwen3-embedding-0.6b-q8_0/v1 |
| file | Qwen3-Embedding-0.6B-Q8_0.gguf |
| size | 639,150,592 bytes |
| next to it | SHA256SUMS, LICENSE (Apache-2.0), SOURCE.md |
I checked the hash against Qwen’s own file in Qwen/Qwen3-Embedding-0.6B-GGUF on Hugging Face, and against the model layer Ollama’s registry serves for qwen3-embedding:0.6b. Same size and same hash in all three. That’s why a plain ollama pull passes the pin today. The release keeps the tested file in one place in case the tag moves.
To load the release file instead, following the csl docs:
gh release download models/qwen3-embedding-0.6b-q8_0/v1 --repo mad01/thismoon --dir qwen3-q8
cd qwen3-q8
shasum -a 256 -c SHA256SUMS
echo "FROM $PWD/Qwen3-Embedding-0.6B-Q8_0.gguf" > Modelfile
ollama create qwen3-embedding:0.6b -f Modelfile
csl doctor # the docs-model-pin line names the hash it computed
csl index --docs # re-embeds every store once, under the pin
The pin doesn’t prove the weights are safe. It proves the file is the published one, and a few things are out of its reach. A replaced or hostile Ollama can name any file. Another process running as the same user can swap the file between the check and the embed. A local port that forwards to another machine runs the embeds where csl can’t read the file. The pin needs Ollama on the same machine; with ollama_url on another host, a pin refuses every embed.
Why this model? I also looked at Microsoft’s harrier-oss-v1-0.6b, a model of the same size. Microsoft publishes it as safetensors only, with no GGUF file (the format Ollama loads), so a pin would have to match a file someone else converted. A bigger model costs build time and index size, and a few hundred notes don’t need one.
The docs index shipped in csl v0.41.0, the word search in v0.42.0 and the pin in v0.43.0.
Try it
List one notes repo or one ADR folder as a source and run csl index --docs. Then ask it something you know the answer to, in words the note doesn’t use. The semantic search doc has every key and flag, and the code is in thismoon.