● ● ● ● ● ○ ○ ○ ○   Lesson 5 of 9

Build a docs Skill · A brown-bag

Pick the engine

The smartest search tech is right there. Why would we pick the simplest math instead?

Why · the problem

Lesson 4 proved it with a number: we need full-text search. Now the real question — how do we build it, and how do we ship it?

Two tempting options jump out, both "better" on paper:

But before we fall for either, remember what a skill actually is:

The constraint that decides everything A skill is a file other agents download. It has to run on someone else's machine with no server you control, no secret keys, no big model loaded. So the right question is not "which search is smartest?" It's "which search can ship as a plain file and still work?"

That one constraint quietly kills both fancy options. Let's watch it happen.

What · the solution approach

Option 1 — the site's search (Inkeep). Rejected: brittle. The live docs use a hosted AI search called Inkeep. To call it, you'd have to get past a security gate (a "proof-of-work" puzzle) whose exact rules are buried in minified JavaScript that can change any day. Hardcode it and your skill breaks the next time they ship.

"the Inkeep JS can change whenever they want — hardcoding the algo is a brittle maintenance trap." — CORPUS.md, Act C

Option 2 — embeddings / vector search. Rejected: you can't ship it. Here's the catch most people miss. To search with embeddings, you turn each page into a list of numbers (a "vector") using a model. Fine — do that once at build time. But to search, you must turn the user's question into a vector too — and that needs the same model, running on the client, every single query. You cannot pack a model into a static file.

"the client also needs to run the same embedding model … unless you serve this as an MCP server?" — CORPUS.md, Act C

So embeddings only work if you host a server. Park that thought — it's the road we weigh in Lesson 9.

The winner — TF-IDF. Just arithmetic. It scores pages by counting words. No model. No server. No gate. You do the math once, save the numbers in a JSON file, and ship that file inside the skill.

"TF-IDF is just arithmetic … No model, no training, no GPU." … "No auth, no PoW, no browser, no model." — CORPUS.md, Act C
⏱️ Worth it? Be honest about why TF-IDF won: not because it retrieves best — because it ships. We traded some search smarts for zero runtime cost and zero maintenance. For a file other agents download, that trade is almost always right. (When it isn't, you host a server — Lesson 9.)
How · the mechanics

The whole decision in one picture:

"How do we build & ship full-text search?" │ ├─ Inkeep (site's own) ─▶ hosted + security gate + minified JS ─▶ ✗ brittle trap ├─ Embeddings (vectors)─▶ query needs the model too, every time ─▶ ✗ needs a server └─ TF-IDF (arithmetic) ─▶ bake the numbers into a JSON file ─▶ ✓ ships as a file
Same goal, three engines. Only one survives "must ship as a plain file."

TF-IDF is two simple ideas multiplied together:

Multiply them — weight = TF × IDF — add up the weights of the query's words for each page, and the highest total wins. That's it.

The shipping trick is when you do the math:

BUILD TIME (once, offline) QUERY TIME (in the skill, every search) download 765 .md twins read the query's words count words, compute TF×IDF look up their saved weights save ─▶ search-index.json (~4 MB) add them up, sort, return top pages ship the file in the repo no model · no GPU · no network
All the cost is paid once, at build time. The shipped skill just adds numbers.

This is the build-time vs query-time split: heavy work happens once when you build the index; the downloaded skill does only cheap lookups. It's also the next short round of Agile iteration — we've gone from "search the title" to "search the body by word weight," each round tested before the next.

One honesty note to carry forward: the body-only evals from Lesson 4 are now our contract. Whatever engine we pick must pass them. TF-IDF does.

But here's the trap waiting in that simple weight = TF × IDF. A huge page — say a 3,000-line changelog — contains every word many times. What happens to our ranking when sheer page size starts winning?

That's Lesson 6: raw counts lie.

Quick self-check (recall before you peek):

1. What single constraint decided the engine?

A skill is a file other agents download — so the search must ship as a plain file and work with no server, keys, or model. "Which ships?", not "which is smartest?"

2. Why can't embeddings ship inside a static skill?

To search, the client must turn each query into a vector using the same model — and you can't pack a model into a file. Embeddings need a hosted server.

3. What does IDF do, in plain words?

It weights rare words higher and common words lower — a word in almost every page tells you nothing; a rare one is a strong signal.

4. What is the build-time vs query-time split?

Do the heavy math once at build time and save the numbers; the shipped skill only does cheap lookups and addition at query time — no model, no GPU.