Trigrep is the richest code search on earth.

Moderne Trigrep is symbol-aware, trigram-indexed code search for coding agents and engineers. It executes in near constant time on a billion lines of code. And it’s built for customization, adding business specific context to everything a compiler knows about every symbol in your code.

Trigrep combines trigram indexing with the grep
workflow agents already use, and builds it on the
Lossless Semantic Tree.

The name combines two ideas. The “tri” is trigram indexing, a decades-old technique that replaces repeated file scanning with indexed lookup. The grep is the search workflow engineers and coding agents reach for to orient themselves before they act. Together they describe a search tool built for the way modern codebases are actually explored.

Trigrep saves AI inference by replacing an agent’s grep-and-read loop with one symbol-aware search.

Instead of scanning every file on every query, Trigrep uses a persistent index, so searching a billion lines of code takes roughly the time it takes to search thousands. Moderne builds those indexes from the Lossless Semantic Tree, the compiler-accurate model that also powers Moderne recipes, so a search can combine plain-text discovery with structural filters and symbol-aware searches that would be fragile or impractical with text-only tools.

Moderne’s AI agent tools: deterministic, accurate, and faster reasoning at scale.

Agents need code search that understands symbols,
not just strings.

Coding agents spend most of their time searching. Before an agent writes anything, it greps and globs for names and files, and it keeps looping until it finds them. Every one of those searches costs tokens. Then it reads the files and the binary dependencies and infers what the code actually means.

Trigrep builds its index from the Lossless Semantic Tree, so the agent can query structure, types, symbols, and dependencies instead of guessing at them from text. The index is built once and updated incrementally, so Trigrep answers at close to constant speed whatever the size of the codebase. Grep scales linearly, reading every line every time.

The Code Genome Project is building Trigrep indexes across every open source package.

Moderne is building LSTs and their corresponding Trigrep indexes for millions of packages in public Maven, NPM, PyPI, and NuGet indexes. Think of it as sequencing the genome of the world’s great volume of code: it’s open source code. Together they form a context registry where you can search, compare, and comprehend your dependencies.

The Code Genome Project homepage with search for compiler-accurate open source packages
Search open source packages

Frequently asked questions

Trigrep is a high-speed, symbol-aware code search engine built for coding agents and engineers working across large, multi-repository codebases. It builds trigram indexes from your code and returns results in sub-second time, scoped to a business unit, team, or application portfolio as defined in Moderne.

grep and ripgrep scan raw files on every query, which slows down across large codebases and often forces follow-up reads to confirm a match has the right type. Trigrep queries a prebuilt trigram index instead of scanning, and because that index is built from the Lossless Semantic Tree, results carry symbol and type data. A search returns semantically precise results in under a second, with no follow-up reads needed.

Trigrep supports Sourcegraph query syntax (the default) and the original Zoekt syntax, plus Comby-style structural patterns. Because these are the same query languages widely documented online, AI models already trained on those tools can use Trigrep without learning a new language. Searches support literal text, regular expressions, boolean operators, and structural matching.

Both. Trigrep matches text quickly, and because its index is built from the Lossless Semantic Tree it adds structural awareness on top, so you can filter by symbol, return type, visibility, and inheritance. For questions that require full type resolution across a hierarchy, Trigrep hands off to recipes, which resolve types at every call site.

Agents call Trigrep the same way they reach for grep today, through the Moderne CLI and MCP. A plain output mode returns one match per line (file, line number, and a short snippet) optimized for agents like Claude Code and Cursor. Because the first search is precise, agents orient faster and spend fewer tokens before the first line of automation runs.

Yes. A search can act as a prefilter for a recipe run, so a transformation processes only the repositories that contain a relevant pattern. If a search matches 47 of 10,000 repositories, the recipe run handles 47 instead of all 10,000. The same results also serve as a checklist to confirm the change reached every occurrence.

Trigrep performs text, regex, and structural search across the languages Moderne indexes. For the current language coverage of semantic filters, see the Moderne documentation.

Trigrep is available through the Moderne CLI and through Moderne’s MCP server, and it operates within the context of a Moderne organization. Indexes are built during the LST build process and stored alongside, so search is ready whenever an engineer or agent needs it.