Code search is one of those capabilities that looks like a small convenience until you lose it, and then you discover it was load-bearing for how the whole organisation reasons about its own systems.
The questions engineers ask a code search tool are not really search questions. They are questions about consequence. Who calls this function, so I know what I break by changing it. Where else do we do this thing, so I can copy the pattern that already works. Is this configuration key used anywhere, so I can delete it. Which of our forty repositories still use the deprecated client. Those are dependency questions dressed as text queries, and a tool that answers them across the whole estate changes how people work more than one that answers them within a file.
The hard parts are not the ones vendors compete on. Ranking is nice. What decides whether people use the tool is whether the index reflects what was merged an hour ago, whether it can hold a repository large enough that your editor gives up, and whether a cross-repository reference query returns in the time a person is willing to wait, which is short.
There is also a persistent confusion between two different retrieval models that solve different problems. Regex search finds exactly what you typed. Semantic search finds things related to what you meant. Both are useful, and they are not substitutes for each other in either direction.
Key takeaways
- Index freshness is the adoption gate. An index that trails the default branch by a day sends people back to grepping a local checkout, and they do not come back.
- Regex and semantic search answer different questions. Regex is for exactness and refactoring safety; semantic is for orientation in code you do not know. Using either for the other job produces frustration.
- Cross-repository reference finding is the capability that justifies a hosted tool. Within one repository your editor already does this through the language server.
- The language server protocol gives precise references for a single project. Code search gives approximate references across every project. Do not expect either to do the other’s job.
LSP: a standard, not a product
Most of what engineers think of as “find all references” comes from the Language Server Protocol, which standardises how an editor asks a language-aware server for definitions, references, symbols and diagnostics. It is worth separating clearly from code search, because the two get compared as if they were competing tools when they operate at different scopes with different guarantees.
What it gives you
- Precise, compiler-grade answers within a project. A language server has parsed the code and resolved the types, so “go to definition” lands on the actual definition rather than on a string that happens to match.
- One protocol across editors and languages, so a language implementation written once is available in every editor that speaks the protocol, and your team is not locked to one tool to get intelligence.
- Live accuracy against unsaved buffers. The server is analysing what is in your editor right now, which no external index can do.
- Symbol-level operations that text search cannot express at all, such as rename-with-references, type hierarchy and call hierarchy.
What it does not do
- It does not cross repository boundaries. A language server is scoped to a project or workspace, so it cannot tell you which of your other forty services calls this API.
- It does not handle cross-language calls. A HTTP route defined in one language and called from another is invisible to both servers, and that is most of a modern estate.
- It does not scale to arbitrarily large repositories without pain. Indexing time and memory grow with the project, and very large monorepos are where language servers become slow or simply stop working.
- It is not available to anyone outside an editor. Nothing about the protocol produces a URL a colleague can open in a code review comment or an incident channel.
The practical arrangement is both: language servers for precision inside the project you have checked out, and a code search index for everything that crosses a boundary. Teams that try to make one cover both cases end up unhappy with whichever one they picked.
Index freshness decides adoption
An index is a claim about the state of the code. When the claim is stale, every answer is suspect, and an engineer who gets one wrong answer in an incident stops trusting the tool permanently.
The relevant mechanics:
Trigger, not schedule. Indexing driven by push webhooks from the version control host reflects a merge within minutes. Indexing on a nightly cron reflects it tomorrow. The difference determines whether the tool can be used during a code review, which is when people most want it.
Incremental, not full. Reindexing an entire monorepo on every push does not finish before the next push. Practical implementations index changed paths and merge shards, and the difference is the gap between minutes and hours on a large repository.
Branch coverage. Most tools index the default branch only, which is usually correct: searching every branch multiplies index size and returns results from abandoned experiments. But it means a search cannot find code that exists only in an open pull request, which surprises people during review.
Visible staleness. The single most underrated feature in this category is showing the indexed commit. A tool that tells you it is three commits behind is trustworthy. A tool that silently returns yesterday’s answer is not, and there is no way for the user to tell the difference from the result page.
The local escape hatch. For anything that must be exactly current, a local grep over a fresh checkout is the ground truth, and it is why ripgrep remains in every engineer’s workflow regardless of what else is deployed. A hosted index is for breadth. The checkout is for certainty.
Needs first-hand data: Instrument the lag between a commit landing on the default branch and that commit being searchable, sampled hourly for two weeks across your largest and smallest repositories. Record the distribution, not the average, because the tail is what destroys trust. If the ninety-fifth percentile exceeds the time it takes to review a pull request, the tool will not be used during review.
Regex versus semantic, and when each wins
These are different retrieval models and the distinction is not marketing. Knowing which question you are asking tells you which tool to reach for.
Regex and literal search matches the text you specified, exactly, with no interpretation. Its defining property is that the result set is complete and verifiable: if the pattern is right, every occurrence is returned, and none of the returned results is a guess.
This is what you want for anything where missing a case is the failure. Deleting a configuration key. Finding every caller before changing a signature. Auditing for a vulnerable pattern. Confirming a secret is not committed anywhere. In all of these, a tool that returns “the most relevant results” is actively dangerous, because relevance ranking hides the one occurrence you needed to find.
Its weakness is that you must already know what the code looks like. Regex cannot find the authentication middleware if you do not know whether it is called authMiddleware, requireAuth, checkSession or something in another language entirely.
Semantic and embedding-based search retrieves code whose meaning is close to your description. Ask “where do we handle refund idempotency” and it returns candidate regions without you knowing a single identifier.
This is the orientation tool, and it is genuinely good at that job. It is how you find your way into an unfamiliar service, and it is what makes AI coding assistants useful on a codebase they were not trained on. The mechanism is the same retrieval that sits behind those tools, which is why this category and the assistant category keep converging.
Its weakness is the mirror image: the result set is neither complete nor verifiable. It can miss occurrences and it can return confidently irrelevant ones, and nothing in the interface distinguishes the two. Using it to answer “have I found every caller” is how you ship a breaking change.
Structural search is the third model and the least known. Instead of matching characters or meaning, it matches syntax: a call to this function with three arguments where the second is a literal, regardless of whitespace, line breaks or variable names. For large mechanical refactors this is dramatically more precise than regex, because regex across multiple lines of real code is where careful engineers introduce careless bugs.
The rule of thumb that holds up: if being wrong is expensive, use regex or structural. If being lost is the problem, use semantic. Most good workflows use semantic to locate the area and regex to enumerate the cases.
Monorepo scale and cross-repo references
Two different scaling problems get conflated, and a tool can be excellent at one and useless at the other.
Depth: one enormous repository. Here the constraints are index size, shard management and query latency over a very large token set. Trigram indexing, the approach behind most serious regex-capable search engines, is what makes substring and regex queries fast at this scale: the index stores three-character sequences, candidate documents are narrowed by trigram intersection, and the expensive regex match only runs on survivors. It is the reason a well-built index can regex-search a repository that would take a local grep minutes.
The failure mode at depth is the long tail of pathological queries: a regex with no extractable literal cannot be narrowed by the index at all and degrades to a full scan. Good tools reject or throttle those. Bad ones take the cluster down.
Breadth: hundreds of repositories. Here the problem is not raw size but the fan-out of a single query across many indexes, permission filtering per repository, and result merging. Permission filtering is the part that gets underestimated: results must be filtered by what the searching user can see, and doing that correctly without destroying latency is real engineering. A tool that filters after ranking returns half-empty pages; a tool that filters before ranking needs the permission data in the index.
Cross-repository references is the query that only works at breadth, and it is the one that changes behaviour. Knowing that a function in your shared library has call sites in services you had forgotten existed, before you change it, is information nothing else in your toolchain gives you. Language servers cannot, because the callers are not in the workspace. Your version control host can, partially, if search is good enough. This is the single strongest argument for deploying a dedicated code search platform rather than relying on what the hosting provider includes.
Be clear-eyed about precision, though. Cross-repository reference finding in a text index is name-based, not type-resolved. A common method name returns matches from unrelated types. Some platforms improve this by ingesting precise index data generated by a compiler plugin, which gives true type-resolved cross-repository references, at the cost of running an extra step in every repository’s CI. That tradeoff, extra build-time work in exchange for precision, is the real decision in a large estate.
Needs first-hand data: Pick ten representative queries your engineers actually run, half regex and half natural language, and measure two things per candidate tool: median time to result, and precision judged by hand against a known ground truth built with a local exhaustive grep. Publish the false negative count. Recall is the number that matters for refactoring safety and it is the number no vendor reports.
Sourcegraph

Sourcegraph is the most complete product in the category: it indexes many repositories, supports literal, regex and structural patterns, layers code navigation on top through precise index data or name-based heuristics, and adds large-scale change tooling that turns a search result set into pull requests across every matching repository. That last capability, batch changes across an estate, is what separates it from everything else here.
Pros
- Cross-repository search and reference finding at genuine scale, with precise navigation when repositories publish compiler-generated index data
- Batch changes turn a search result into coordinated pull requests across every affected repository, which is the only practical way to run an estate-wide migration
- Supports literal, regex and structural patterns in one query language, so the exactness-versus-orientation choice is made per query rather than per tool
- Self-hosted deployment keeps the index and the source inside your own boundary, which matters for most security reviews
Cons
- Operating a self-hosted deployment at scale is real infrastructure work, with index storage and search performance to tune
- Precise navigation requires running index generation in each repository’s CI, so the good version of the feature has an ongoing per-repository cost
- Commercial licensing has moved repeatedly, so the licence terms you evaluate on may not be the terms you renew on
- Substantially heavier than teams with a handful of repositories need
Best for: Organisations with many repositories where cross-repository reference finding and coordinated estate-wide refactors are recurring needs.
Pricing: Commercial per-developer subscription, with self-hosted and managed deployment options and enterprise tiers, quoted rather than published.
GitHub code search
GitHub rebuilt its code search on a purpose-built index and the result is a substantial capability available where the code already lives. It supports substring and regex matching across repositories you can see, with symbol-aware filters, and it requires no deployment, no index maintenance and no separate permission model. For a very large number of teams this is now sufficient and the honest recommendation is to try it before buying anything.
Pros
- Nothing to deploy or operate, and permissions match repository access exactly because it is the same system
- Search across all repositories in your organisation, including ones you would never have thought to add to a separate index
- Symbol and path filters plus regex support cover the majority of everyday queries without a query language to learn
- Results link directly into the code review and pull request context engineers are already working in
Cons
- Only covers code hosted on the platform, so any repository elsewhere, or an archive, or a vendored dependency outside it, is invisible
- No batch-change capability, so a search result is a list rather than the first step of a migration
- Reference finding is name-based rather than type-resolved, with the false positives that implies on common method names
- You have no control over index freshness, query limits or behaviour, and no way to tune any of it
Best for: Teams whose code is entirely on GitHub and whose searches are everyday questions rather than estate-wide refactoring campaigns.
Pricing: Included with the platform subscription, so there is no separate meter for search, and cost tracks your existing per-seat plan.
Zoekt
Zoekt is the trigram-based code search engine that underpins several larger systems, including Sourcegraph’s own indexed search path. It is a focused piece of infrastructure rather than a product: an indexer, a web server and a query language, fast regex over large corpora, and nothing else. If what you want is the search engine without the platform around it, this is the search engine.
Pros
- Trigram indexing gives genuinely fast regex and substring queries over large repository sets, which is the hard part solved well
- Small, comprehensible codebase with a clear operational model, so a team can run it without a dedicated platform group
- No vendor relationship, no licence negotiation and no per-seat meter, which makes it attractive at large headcount
- Composable as a component, which is why it appears underneath other tools rather than competing with them directly
Cons
- It is search, not code intelligence: no reference finding, no navigation, no cross-language understanding
- The user interface is minimal and will not win adoption on its own against a polished product
- You own indexing orchestration, permission filtering and availability, and permission filtering in particular is not trivial to add
- Sparse documentation compared with commercial alternatives, so operating it means reading source
Best for: Platform teams that want fast self-hosted regex search over many repositories and are willing to build the surrounding experience themselves.
Pricing: No vendor and no bill. Open source under a permissive licence; cost is the infrastructure it runs on and the engineering time to operate it.
ripgrep
ripgrep is a local command-line search tool, and it is on this list because it is the one every engineer actually uses every day. It walks a directory tree, respects ignore files, and matches regex at speed that makes searching a large checkout feel instant. It is the ground truth against which any hosted index should be validated, because it reads the files on disk right now.
Pros
- Searches exactly what is on disk at this moment, so there is no index staleness and no trust question at all
- Fast enough on real repositories that exhaustive search becomes a reflex rather than a decision
- Respects ignore files and binary detection by default, which removes most of the noise that makes naive grep unusable
- Composes with the shell, so a result set can be piped into a scripted transformation immediately
Cons
- Local only, so it cannot answer anything about repositories you have not checked out, which is the question that matters most in a large estate
- Purely textual, with no symbol awareness, so it cannot distinguish a definition from a comment mentioning the same word
- Produces no shareable link, so findings cannot be passed to a colleague in a review or an incident channel
- Large monorepos still take real time to scan cold, and repeated scans are repeated work an index would have amortised
Best for: Every engineer, for every question that has to be exactly correct within a repository they already have checked out.
Pricing: No vendor and no bill. Open source, installed from any package manager, with no service to run.
Comby
Comby is structural search and replace: patterns match syntax rather than characters, so a template describing a function call with specific arguments matches regardless of formatting, line breaks or variable naming, across many languages without a per-language parser configuration. For mechanical refactors it is the right tool and it is much less known than it should be.
Pros
- Matches code structure rather than text, which removes the entire class of multi-line regex bugs that make large refactors dangerous
- Works across many languages from one pattern syntax, so a polyglot estate does not need a different tool per language
- Rewrite mode makes it a refactoring engine rather than only a search tool, which is where the payback is
- Small enough to run locally in a script or a pipeline, with no service to deploy
Cons
- Another pattern syntax to learn, and the learning curve is real even for people fluent in regex
- Approximate parsing rather than full language semantics, so it can mismatch on unusual constructs and must be reviewed
- Local and file-based, so it does not answer cross-repository questions without orchestration you write
- Smaller community than the mainstream tools, so unusual cases have fewer published answers
Best for: Engineers running mechanical refactors across a codebase where a multi-line regex would be too fragile to trust.
Pricing: No vendor and no bill. Open source, run as a local binary, with cost limited to the time spent learning the pattern syntax.
Grep.app
Grep.app is a hosted search over a large set of public repositories, with regex support and filters by language and repository. It answers a different question from the rest of this list: not “where is this in our code” but “how does everyone else actually use this library”. For evaluating an unfamiliar API or checking whether a pattern you invented is the pattern the ecosystem uses, it is faster than reading documentation.
Pros
- Searches real usage across a large corpus of public code, which answers API questions that documentation frequently does not
- Regex support with language and repository filters makes it precise enough to trust for the questions it is aimed at
- Instant to use with nothing to configure, index or authenticate against
- Excellent for evaluating a dependency before adopting it, by seeing how it is used rather than how it is described
Cons
- Public code only, so it has nothing to say about your own repositories and is not a replacement for anything else here
- Corpus coverage and freshness are outside your control and not fully specified
- No code navigation or reference finding, only text matching
- Depends entirely on a third-party service remaining available, so it cannot be part of a critical workflow
Best for: Engineers evaluating an unfamiliar library or API who want to see how it is genuinely used in production code.
Pricing: A free public web service. There is no published paid tier and no self-hosted distribution, so it should be treated as a convenience rather than infrastructure.
OpenGrok
OpenGrok is the long-established self-hosted source browser and search engine, built on a full-text index with language-aware tokenising and cross-reference generation. It predates the current generation by a long way and it is still deployed in places that need a self-contained, self-hosted browsable source archive with no external dependency of any kind.
Pros
- Fully self-contained and self-hosted, with no vendor, no telemetry and no external service in the path
- Generates browsable cross-referenced source pages, which makes it a code browser as well as a search index
- Handles multiple version control systems including older ones that modern tools have dropped support for
- Long operational track record in conservative environments, with well-understood behaviour
Cons
- The user interface and general experience are dated, and engineers used to modern tools will resist it
- Indexing large repository sets is slow and the operational tuning story is thin
- Cross-references are language-tokeniser based, so precision is well below a compiler-backed approach
- Smaller and shrinking community, which raises long-term maintenance risk
Best for: Air-gapped or highly regulated environments that need self-hosted browsable code search with no external dependency and can accept a dated interface.
Pricing: No vendor and no bill. Open source, self-hosted, with cost being the server it runs on and the time to operate the indexer.
How to choose
Start from where your code lives and how many repositories there are, because that eliminates most of the list.
All on GitHub, fewer than a few dozen repositories. Use GitHub code search and ripgrep locally. That is the whole answer. Deploying a platform here creates maintenance for a capability you already have.
Many repositories, frequent estate-wide changes. Sourcegraph, because the batch-change capability is the actual product and nothing else does it. Budget for running index generation in CI if you want precise navigation rather than name matching.
Many repositories, no budget, a platform team that can operate things. Zoekt for the index, with your own thin interface over it. You will not get code navigation and you should not pretend otherwise.
Air-gapped or otherwise unable to use a hosted service. Self-hosted Sourcegraph if there is budget, OpenGrok if there is not.
Whatever else you choose: ripgrep on every machine, and Comby in the toolkit of whoever runs migrations. Those two are free and they cover the queries where being wrong is expensive.
One more rule worth adopting. For any question whose answer must be complete, verify with an exhaustive local search before acting, even if a semantic tool already answered it. Ranking hides omissions, and the occurrence you did not see is the one that pages you.
| Tool | Model | Scope | Navigation | Picks itself when |
|---|---|---|---|---|
| LSP (standard, not a product) | Compiler-resolved | One project | Precise, in-editor | You are working inside one checkout |
| Sourcegraph | Literal, regex, structural | Many repositories | Precise or name-based | Estate-wide search and refactoring |
| GitHub code search | Literal and regex | Your GitHub organisation | Name-based symbol filters | All code is already on the platform |
| Zoekt | Regex over trigrams | Many repositories | None | You want the engine, not a product |
| ripgrep | Regex over files | Local checkout | None | The answer has to be exactly current |
| Comby | Structural | Local files | None | Running a mechanical refactor |
| Grep.app | Regex | Public code | None | Learning how a library is really used |
| OpenGrok | Full text, tokenised | Self-hosted repositories | Generated cross-references | Air-gapped with no budget |
Frequently asked questions
Is semantic code search better than regex search?
Neither is better; they answer different questions. Semantic search is better when you do not know what the code is called, which is most of the time in an unfamiliar system, and it is what makes AI assistants useful against a codebase they have not seen. Regex is better when the result set must be complete, because it is the only one of the two whose completeness you can reason about. For any change where missing an occurrence causes a production problem, use regex or structural search and verify with an exhaustive local scan.
Do I need a code search tool if I use an AI coding assistant?
Yes, for different reasons than you would expect. Assistants retrieve context semantically, which is exactly the retrieval model that can silently miss occurrences, and their answers about “all the callers” of something should not be trusted for a breaking change. A good code search tool is also what makes an assistant better, because giving it precise results from an exhaustive search beats letting it guess. The broader tradeoffs are in AI coding assistants.
How fresh does a code search index need to be?
Fresh enough to be usable during code review, which in practice means minutes rather than hours. The specific threshold that matters is whether a commit is searchable before a reviewer looks at the pull request that depends on it. Beyond that, the more important property is that the tool displays which commit it indexed, because a visible lag is manageable and an invisible one destroys trust after a single bad answer in an incident.
Can code search replace documentation?
For “where is this” and “how is this used”, yes, and it is usually more accurate because it cannot go stale. For “why is this like this”, no, because the reason is not in the code. The healthiest arrangement is to use search for the factual questions and reserve written documentation for rationale and constraints, which is also the argument in documentation generation tools.
How do I find every caller of a function across all our repositories?
Name-based search across repositories gets you a candidate set quickly, and for an uncommon name that is usually sufficient. For a common name, you need type resolution, which means either a platform that ingests compiler-generated index data from each repository’s CI, or a language-specific tool run per repository and the results merged. Whichever you use, verify the final list with an exhaustive text search before making the change, and expect to find at least one call site in a repository nobody remembered existed.
Related reading
- Best AI coding assistants — the retrieval layer underneath them is the same semantic search discussed here.
- Best monorepo build tools — the other half of surviving a very large repository.
- Best AI tools for legacy code migration — where estate-wide search turns into an estate-wide change.
- Best documentation generation tools — what search cannot answer, and who has to write it.
- Best developer onboarding tools — orientation in an unfamiliar codebase, which search does a lot of.
- Best code quality and technical debt tools — finding the patterns you want to stop repeating.