Week 7 · Build the Clone

RAG + Vector Databases

Give the agent a map

⏱ ~6 hours, hands-on🐍 Python / 🔷 TypeScript🛠 You ship: Semantic search over any codebase
What this week is

Week 5 gave your agent grep and glob — fast, exact, free. They are the right first tool for most searches. But they share one blind spot: they match text, not meaning.

Ask "where do we decide if a user can retry a payment?" and grep needs you to already know the code says retry and not reattempt, backoff, or idempotency_key. When you do not know the words, you need search by concept.

This week you build the whole pipeline yourself — chunker, embedder, vector store, and an incremental indexer — because a "vector database" sounds like infrastructure you rent and is actually a JSON file and a loop.

The most important judgment this week is knowing when not to use RAG. Known symbol or string → grep. Vague "where/how do we…" question → semantic search.

The walkthrough

Each part adds one capability to the same growing codebase, and each is a runnable checkpoint.

  1. 01ChunkingSplit code into nameable units, not fixed windows.
  2. 02EmbeddingsText into vectors — batched, cheap, and about meaning.
  3. 03The vector storeCosine similarity over a JSON file. No infrastructure required.
  4. 04Incremental indexingRe-index only what changed, so the map stays current.
  5. 05The search toolExpose it to the agent alongside grep, and teach it which to pick.
  6. 06Ask the codebaseA full RAG command that answers questions about a repo it was never told about.

After this week you can

  • Build a vector search pipeline end to end, no library
  • Choose correctly between lexical and semantic search
  • Keep an index fresh as a codebase changes