How does a coding agent find the right file in your repo: by searching the words (grep) or by searching the meaning (embeddings)? In this video I break down how each one works, which agents use which, and then I race both on real code: Excalidraw, and a brand new repo the model has never seen. If you use Claude Code, Codex, Cursor or any other coding agent, the result changes how you should ask for a file.
What I cover in this video
- 0:46 The problem: your agent can't read the whole repo, so it has to find the right file first, and there are two ways to do that.
- 1:32 How ripgrep works, why it is fast, and its one big weakness.
- 2:17 Why agents love grep, including what Claude Code's creator Boris Cherny said about dropping RAG.
- 3:47 How embeddings work: chunks, numbers, an index, and the catch with exact names.
- 5:19 The Cursor story: a published 12.5% accuracy gain from embeddings, then switching them off.
- 6:04 Round one of the race: 24 questions on Excalidraw.
- 8:21 Round two: a repo that did not exist when the model was trained.
- 9:51 When each method wins, and how to help your agent find the file.
How grep works, and why agents love it
Grep is about as old school as it gets. You give it a pattern, it reads every file line by line, and it prints every line that matches. Nothing is prepared ahead of time: no index, no database.
The version most agents use is ripgrep, a free tool Andrew Gallant put out in 2016. It is fast for a few reasons:
- It skips everything in your gitignore file, plus hidden and binary files.
- It pulls the plain letters out of your pattern and hunts for those first, with special processor instructions that check 16 bytes in a single step.
- It searches a bunch of files at the same time.
The weakness is simple. Grep only finds what you ask for. Search for login and you get every line that says login, and nothing that says sign in.
Agents get around that because they don't search once. They grep, look at what came back, and grep again with better words (I cover that loop in How the Claude Code Agent Loop Works). Boris Cherny told Latent Space that very early versions of Claude Code used RAG with an off-the-shelf embedding model, and it worked pretty well. Then they tried plain glob and grep, and it outperformed everything "by a lot". Asked on what benchmark, his answer was some internal benchmarks, but mostly vibes. He also gave real reasons: an index drifts out of sync with your code, and it has to live somewhere, which is one more thing that can get hacked. The trade, in his words, is latency and tokens.
Claude Code isn't alone. Codex tells every model in its system prompt to prefer rg, Gemini CLI runs ripgrep by default, and Cline wrote a whole post on why it doesn't index your codebase.
How embeddings work, and who uses what
Embeddings search meaning instead of words. Here is the setup I used for the race:
- Chunk the files. I cut every file into 60 lines at a time with a little overlap, which gave 5,845 chunks.
- Embed each chunk. I ran a free open-source model called Nomic Embed Text on my Mac. It turns each chunk into 768 numbers. Think of it as a spot on a giant map where code that does similar things lands close together.
- Store them. That is your index. It took about 6 minutes to build.
When the agent asks a question, the question gets turned into numbers too, and you grab the chunks that sit closest. At real scale you use a shortcut index called HNSW, which is basically layers of roads: highways first, then side streets.
The appeal is that you can search for what code does, not what it's called. The catch is exact names. Anthropic says it in their own post: search for a specific error code and an embedding model might find material about error codes in general and miss the exact match.
Here is how the agents split:
- Text search only: Claude Code, Codex, Gemini CLI and Cline.
- Both: GitHub Copilot and Windsurf.
- Embeddings when you switch them on: Roo Code and Kilo Code.
- Its own thing: Aider builds a map of your repo ranked by what calls what.
The biggest story is Cursor. In November 2025 it published a post saying its own embedding model gave 12.5% higher accuracy on average. In July 2026, Cursor staff said on their forum that the semantic path was no longer helping in a meaningful way, and they turned it off. They still keep an index, just an index of words: in big monorepos ripgrep was taking more than 15 seconds, so Instant Grep keeps a local index that makes text search fast. GitHub went the other way. In March 2026, Copilot's coding agent got semantic search, and GitHub measured 2% less time with no change in quality.
The race: Excalidraw, then a repo the model has never seen
Round one: Excalidraw
I wrote 24 questions before running anything, eight of each kind. Name questions use the exact function name. Behavior questions describe what the code does. Vibe questions describe it in everyday words, and I checked that the keywords aren't in the file.
The raw tools, with no agent, did what you'd expect. Grep alone had the right file somewhere in its results on all eight name questions and zero of eight vibe questions. Embeddings alone ranked the right file number one on three name questions, four behavior questions and zero vibe questions.
Then I gave each tool to the same agent, Claude Sonnet 5.5 inside Claude Code. Grep only: 23 out of 24. Embeddings only: 23 out of 24. Both in about 3 seconds.
So what happened to the vibe questions? One asked about the streak behind the presenting pen shrinking away after about a second. Grep on the word "streak" finds zero files. But the agent's first words were that this was likely the laser pointer trail in Excalidraw, and its one grep was for decay time, the real name in the code. The model translated the question before it searched. The embeddings agent did the same kind of thing: on the question where search came back with eight wrong files, it said search wasn't helpful and opened the right file from memory.
Round two: an unseen repo
The model knows Excalidraw, so for round two I used yogurt, an open-source meeting notes app whose first commit came after the model's training. It has 563 source files, and I wrote 18 new questions.
Now the agent had nothing to remember. Its searches used plain words like "typewriter" and "letter by letter", not the real names in the code. This is where the raw tools split. Grep alone went six for six on name questions and zero for six on vibe questions, and four of those searches found nothing at all. Embeddings alone ranked the right file number one on two of those vibe questions.
With the agent: grep 17 out of 18, embeddings 16 out of 18. The embeddings loss is the telling one. I asked where one exact warning message comes from. The embeddings agent made 12 tool calls, opened the wrong file first, and gave up after 21 seconds. The grep agent found it with one grep in under 3 seconds.
To be fair, these are small samples: one repo per round and one run on round two. On one question both agents picked a file my answer key didn't, which was honestly a fair answer.
When each one wins
Grep wins when you know a name: a function, an error message, a config key. It is exact, it needs no index, and it is never out of date because it reads the files as they are right now.
Embeddings help when nobody knows the name and the words in the question just aren't in the code. That is exactly where raw embeddings beat raw grep on the new repo. Cursor's own numbers were biggest on repos with over a thousand files.
On a codebase the model already knows, the tool barely matters. The best search engine in the whole video was the model rewriting my question into code words. I run coding agents all day in Beckon, so that is the part I care about most: give the agent the words, and you often save it a whole round of searching.
Key takeaways
- Agent with grep and agent with embeddings tied at 23/24 on Excalidraw. On the unseen repo it was 17/18 for grep and 16/18 for embeddings.
- Raw grep scored zero on vibe questions in both rounds. Raw embeddings found two of them on the unseen repo, which is where meaning search earns its keep.
- Embeddings get fuzzy on exact strings. One exact warning message cost the embeddings agent 12 tool calls and a wrong answer, while grep needed one search.
- Claude Code, Codex, Gemini CLI and Cline use text search only, and Cursor has turned its embeddings off in favor of an index of words.
- Name the function, paste the error, mention the folder. Your words are the best search engine your agent has.
Full video transcript
0:00I asked a coding agent where one function lives in a real codebase. It search came back with eight files and all eight were wrong. Cloud code's creator says they built a vector index first and plain GP beat it by a lot. Cursor published a 12.5% accuracy boost from embeddings and then this July it switched them off. So, we raced both methods on real code and the thing that mattered most wasn't GP or embeddings. In this video, we're breaking down how each one works, which agent uses which, our race, and when each one wins. I run coding agents all day, so this one's personal. Let's jump right into it. So, here's the problem. Your agent can't read your whole repo. The Excaladraw codebase we used has about 800 source
0:46files and over 200,000 lines of TypeScript. That doesn't fit in a context window. And even if it did, you'd pay for every line on every turn. So before your agent can change a single line, it has to find the right file. And if it picks the wrong one, it'll happily edit the wrong thing. And there are basically two ways to do that. One, search the words. That's GP. Two, search the meaning. That's embeddings. Everything else is a mix of those two. So GP first. GP is about as old school as it gets. You give it a pattern and it reads every file line by line and prints every line that matches. Nothing is prepared ahead of time. No index, no database. It just reads. And the version
1:32most agents use is called RIP Grep. It's a free tool Andrew Gallant put out in 2016, and it's fast for a few reasons. It skips everything in your Git ignore file, plus hidden and binary files. It pulls the plain letters out of your pattern and hunts for those first with special processor instructions that check 16 bytes in a single step. That's several gigabytes a second on his machine. And it searches a bunch of files at the same time. So on a normal repo, a search comes back before you can blink. But Grep only finds what you ask for. Search for login and you get every line that says login in every file and nothing that says sign in. That's the whole weakness. and we're coming back to it in the race. Still juggling cloud
2:17code, codecs, and cursor in five terminal windows. Beckin puts every coding agent on one canvas side by side. Press a key and just talk to them. Every idea gets its own workspace with memory that carries over. Becken. Hey, beckon.ai. So, why do agents love it? Because the agent doesn't search once. It searches like you do. It gs. It looks at what came back. And then it grips again with better words. Boris Churnney, who created Claude Code, said the very early versions actually used Rag. They indexed the codebase with an off-the-shelf embedding model and it worked pretty well. Then they tried plain Glob and Gp. And in his words, it outperformed everything by a lot. And when they asked him in what benchmark, some internal
3:02benchmarks, but mostly vibes, it just felt better. Come on now. But he also gave real reasons. An index drifts out of sync with your code and it has to live somewhere. So, it's one more thing that can get hacked. The trade, in his words, is latency and tokens. And Claude Code isn't alone. OpenAI's codeex literally tells every model in its system prompt to prefer RG. Gemini CLI runs RIPG by default, and Klein wrote a whole post on why it doesn't index your codebase. Their line is when you chunk code for embeddings, you're literally tearing apart its logic. So that's GP. Now let's look at the other side. So how do embeddings actually work? Step one,
3:47you cut every file into chunks. In our race, that was 60 lines at a time with a little overlap, which gave us 5,845 chunks. Step two, you run each chunk through an embedding model, and out comes a list of numbers. We used a free open-source model called Nomic embed text running right on my Mac and it gives you 768 numbers per chunk. Think of it as a spot on a giant map where code that does similar things lands close together. Step three, you store all of those. That's your index. And it took about 6 minutes to build on my Mac. Then when the agent asks a question, the question gets turned into numbers, too. And you grab the chunks that sit closest to it. At real scale, you use a shortcut index called HNSW, which is basically
4:34layers of roads. Highways first, then side streets. And here's why people love this. You can search for what code does, not what it's called. You don't need to know the function name. But there's a catch, and Anthropic says it in their own post. Search for error code TS99, and an embedding model might find stuff about error codes in general and miss the exact match. Names are where meaning search gets fuzzy. So who uses what? Text search only claude codeex Gemini CLI and Klein both GitHub copilot and windsurf embeddings when you switch it on rue code and kilo code and ader does its own thing a map of your repo ranked by what calls what. But the biggest
5:19story is cursor. In November 2025, Curser published a post saying its own embedding model gave 12.5% higher accuracy on average. Then in July 2026, Cursor staff said on their forum that the semantic path was rapidly no longer helping in a meaningful way, and they turned it off. Cursor doesn't compute embeddings of your code anymore. Now, this is the part I didn't expect. They still built an index. It's just an index of words. Cursor said in big monor repos rip grep was taking more than 15 seconds. So instant grep keeps a local index in your git folder that makes text search fast and github went the other way. In March copilot's coding agent got semantic search and github measured 2%
6:04less time with no change in quality which is a pretty small win. So everyone's arguing. We wanted to see it for ourselves. So here's the race. Excaladraw, the open-source whiteboard app, 1337 files. We wrote 24 questions before running anything, eight of each kind. Name questions use the exact function name. Behavior questions describe what the code does. And vibe questions describe it in everyday words, and we check that the keywords aren't in the file. Like, when I wave the presenting pen around, the streak behind it shrinks away after about a second. Where is that timing set? First, the raw tools, no agent. GP alone had the right file somewhere in its results on all eight name questions and zero out of eight
6:49vibe questions. Embeddings alone ranked the right file number one on three name questions, four behavior questions, and zero vibe questions. So far, so expected. Then we gave each tool to the same agent. Claude Sonnet 5.5 inside Claude code. One run with only GP, one with only our embedding search. Grep 23 out of 24. Embeddings 23 out of 24. Both in about 3 seconds. So, what happened to the vibe questions? Look at that pen question. The agent's first words were likely the laser pointer trail in Excaladraw. Its one GP was decay time, the real name in the code. GP on the word streak finds zero files. The model translated the question before it searched. And when we took every tool
7:35away, it couldn't name a single file. But look at what it tried to search for. On a question about two friends dragging the same box, it wrote reconcile elements, the real function name, and that word is nowhere in the question. And with embeddings, it was the same story. On the one where search came back with eight wrong files, the agent said search wasn't helpful and open the right file from memory. That's my cold open. So the model knows Excaladraw. Then what happens on code it's never seen? So, for round two, we found a repo that didn't exist when the model was trained. It's called Yogurt, an open- source meeting notes app, and its first commit was on November 10th. 563 source files and 18 brand new questions. Now, the agent had nothing to remember. Its searches used
8:21plain words like typewriter and letter by letter, not the real names in the code. And this is where the raw tools split. GP alone had the right file in its results on six of six name questions and zero for six on vibe questions. Four of those searches found nothing at all. Embeddings alone ranked the right file number one on two of those vibe questions like this one. The words don't pop in all at once. They trickle onto the screen letter by letter. GP on trickle zero files. Embeddings went straight to the file that smooths the text. So that's where meaning search earns its keep. Then the agents grep 17 out of 18. Embeddings 16 out of 18. And look at where embeddings lost. We asked
9:06where one exact warning message comes from. The embeddings agent made 12 tool calls, opened the wrong file first, and then said, "I couldn't find that exact warning text." 21 seconds, wrong answer. The GP agent, one GP, under 3 seconds, right file. To be fair, this is one repo, one run, and small samples. And on one question, both agents picked a file my answer key didn't, which honestly was a fair answer, but the pattern held. So, when does each one win? GP wins when you know a name, a function, an error message, a config key. It's exact. It needs no index, and it's never out ofd because it reads the files as they are right now. Embeddings help when nobody knows the name, and the words in the
9:51question just aren't in the code. That's exactly where raw embeddings beat raw GP on the new repo. Cursor's own numbers were biggest on repos with over a thousand files. And on a codebase the model already knows, honestly, the tool barely matters. Okay, real talk. The part you'll actually care about. The best search engine in this whole video was the model rewriting your question into code words. So, if you want your agent to find the right file, help it with the words. Name the function, paste the error, mention the folder. A lot of the time that saves it a whole round of searching. So, what does your agent used to search? And has it ever opened the wrong file on you? Let me know in the comments. And if this cleared up GP versus embeddings for you, a like really
10:37helps the video spread. Have a blessed day.