Semantic code search
Semantic code search is finding code by meaning and structure — symbols, types, and dependency relationships — rather than by literal text matching, so a query like "who calls fetchUser?" returns the actual references instead of every line where the characters happen to appear.
Most code search is lexical: tools like grep and ripgrep match characters, so a search for getUser misses fetchUser, loadAccount, or the same function reached through an import alias. Semantic code search tries to answer the question behind the query — "where is the user loaded?" — rather than the literal string. Two broad families exist. Embedding-based search chunks the codebase, encodes each chunk into a vector with a model, and ranks results by vector similarity to the query; this is the technique behind many "chat with your repo" products and is good at fuzzy, natural-language recall. Structure-based search uses the compiler's own understanding — parsing to an AST, resolving symbols and types via an LSP server, and following definition, reference, and import edges — so a hit is a precise language fact, not a probabilistic match.
The two families trade off differently. Embeddings tolerate vague queries and cross synonyms well, but results are approximate, can drift as code changes unless re-indexed, and can't tell you *exactly* which call sites would break under a rename. Structural search is exact and stays correct after edits, but it answers "where is this symbol used" better than "where is the rate-limiting logic," which has no single symbol. In practice strong systems combine layers: symbol/graph resolution for precision, plain text/regex as a fast fallback, and sometimes embeddings on top for natural-language recall.
For an AI coding agent, semantic search is what replaces the blind grep | read-file | guess loop. The agent needs to find the right definition, enumerate every caller, and understand what a change touches — questions that lexical matching answers incompletely and that an agent otherwise pays for in extra round-trips and wasted context. The quality of an agent's edits is bounded by how well it can locate the relevant code first.
Semantic search is also distinct from a one-time index dump: the value is in keeping the model current as the repo mutates, and in ranking results so the highest-impact code surfaces before noise.