Agent Tools · Search
Sub-second code search for agents and large codebases
Moderne Trigrep is symbol-aware, trigram-indexed code search for coding agents and engineers, scoped to how you organize code, so discovery stays instant and accurate instead of slowing down repo by repo.
Search first, automate second
The recipe runs only on the 47 — and the same search doubles as a validation checklist after the change lands.
Why Trigrep
Fast discovery. Precise results. Search scoped to how you organize code.
Moderne Trigrep gives engineers and coding agents an indexed view of the whole codebase, so discovery stays instant and accurate instead of slowing down repo by repo.
The idea
What is Moderne Trigrep?
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.
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.
How it compares
grep was built to scan a few files on your filesystem. Trigrep was built for the whole estate.
Different search approaches serve different jobs. The question is which one keeps up when an agent runs dozens of searches across thousands of repositories in a single workflow.
| Approach | What it gives you | Where it falls short at scale |
|---|---|---|
| grep, ripgrep, ag | Simple, local, immediate raw-text scanning | Re-scans files on every query and needs follow-up reads to confirm matches, so it slows down sharply across large, multi-repo codebases |
| Vector / embedding search | Fuzzy, similarity-based retrieval across files | Approximate by design: returns broad candidate sets that still need reading and reasoning, adding tokens and latency |
| Semantic search & transformation (Moderne recipes) | Full type resolution and precise transformation on the LST | More than discovery needs as a first step — better run after Trigrep narrows scope, to transform or fully resolve the matches |
| Moderne Trigrep | Trigram indexing with LST data and organizational scoping: fast, contextual discovery ready to feed automation | By design, stops at discovery. Hands the matched set to recipes when full semantic resolution or transformation is needed |
How it works
How Moderne Trigrep works
Trigrep turns code search into an indexed lookup that is fast, structurally aware, scoped to your org, and wired directly into automation.
- ~10–20% of source size, built once, not per query
- Near-constant speed across very large portfolios
- Filter by symbol, type, visibility, and inheritance
- The first search is the answer — no confirmation reads
- Scope to organizations, teams, business units, or portfolios
- Focused results instead of noise across the whole estate
- Pass a search straight to a recipe run as a prefilter
- Results double as a before-and-after checklist
Search modes
Structure, symbol, and meaning
Trigram indexing handles fast text and structural matching; the LST adds symbol and type meaning on top. A mature agent reaches for the cheapest mode that answers the question, then hands the precise result to deeper analysis.
extends:Person returns the classes that actually extend Person, not every file that mentions the word.
:[obj].equals(:[arg]) catches every .equals(...) call, whatever the operands, across naming and formatting variations.
Use cases
What you can do with Moderne Trigrep
The payoff
Make discovery the fast part of change
Part of the agent toolset
Trigrep is the Find stage of Moderne’s agent toolset, exposed over MCP alongside Prethink for context and recipes for transformation. For the full technical story, see From grep to Moderne Trigrep, and how the Lossless Semantic Tree makes symbol-aware search possible.
The agent toolset
- DiscoverTrigrepFind
- UnderstandPrethinkFrame
- ActRecipesFix
- OperateChangelogGovern
FAQ
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.
Bring fast, precise discovery to your software estate.