From rg to zg: Local Search for the AI Agent Era
For searching source code, ripgrep (rg) is the standard tool. But rg excels specifically when you already know what you’re looking for — a function name, an error message, and so on. When you want to search by meaning or intent — something like “the code that restores the theme setting on startup” — you have to guess at the right keywords.
That’s where “zg” (zvec-grep), an open-source tool introduced by Alibaba Cloud, comes in: a local search tool aimed at solving exactly this problem. It combines vector search, BM25, and rg-style exact-match search, so you can search loosely in natural language first and then pin down the exact location afterward — which looks quite convenient.
Another nice point is that indexing and embedding are handled locally by design, which makes it easier to work with internal documents or unreleased code. It supports not just a CLI but also MCP, so it can be used directly from AI Coding Agents like Codex and Claude Code.
Going forward, code search seems to be moving away from plain string matching and toward search that understands “what the developer — or the AI — is actually looking for.” zg is a tool worth watching as a kind of new grep for the AI agent era.
References:
This is an English translation of the original Japanese post: 「rg」から「zg」へ――AIエージェント時代のローカル検索