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.

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.

Speed Sub-second discovery at scale Indexed trigram search returns results in under a second across thousands of repositories, holding near-constant speed even across billions of lines.
Precision Symbol-aware, no follow-up reads Indexes built from the Lossless Semantic Tree carry type and symbol data, so the first search is the answer instead of a grep followed by expensive confirmation reads.
Scope Scoped to your organization Searches run inside a business unit, team, or application portfolio as defined in the Moderne Platform, not across every repository indiscriminately.

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.

ApproachWhat it gives youWhere it falls short at scale
grep, ripgrep, ag Simple, local, immediate raw-text scanningRe-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 filesApproximate 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 LSTMore 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 automationBy 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.

Step 01 Builds a compact trigram index Built at repository-build time in a Zoekt-compatible format, so queries intersect a persistent index instead of scanning raw files.
  • ~10–20% of source size, built once, not per query
  • Near-constant speed across very large portfolios
Step 02 Infuses it with Lossless Semantic Tree data Because the index carries the symbol and type data raw text lacks, results are precise enough to act on directly and the grep-then-read loop disappears.
  • Filter by symbol, type, visibility, and inheritance
  • The first search is the answer — no confirmation reads
Step 03 Scopes search to your org structure Indexes align with the org structure already defined in Moderne, so a search can start within a business unit, team, or portfolio instead of spanning every repository.
  • Scope to organizations, teams, business units, or portfolios
  • Focused results instead of noise across the whole estate
Step 04 Feeds discovery straight into automation Results feed recipe runs as a prefilter: match 47 of 10,000 repositories and the run processes 47, not 10,000.
  • 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.

trigrep_search Text, regex, and symbol queries Beyond literal text and regex, symbol-aware queries match on code meaning. A query like extends:Person returns the classes that actually extend Person, not every file that mentions the word.
trigrep_structural Comby-style structural patterns Match multi-token code shapes with placeholder holes. A pattern like :[obj].equals(:[arg]) catches every .equals(...) call, whatever the operands, across naming and formatting variations.
Familiar syntax No new language to learn Sourcegraph and Zoekt query syntax plus Comby patterns, so models already trained on those tools use Trigrep without learning anything new.

Use cases

What you can do with Moderne Trigrep

Scope a migration before you run it Search for a framework, version string, or deprecated construct to size the work before any recipe runs.
Surface security and compliance signals Find vulnerable version strings, weak crypto calls, disabled protections, or credential-like patterns that warrant a closer look.
Trace dependencies and usage Locate imports, annotations, configuration keys, and API names to see where a technology or pattern actually appears.
Investigate incidents faster Search error messages, log fragments, and stack-trace text to land on the relevant code in seconds.
Prefilter large-scale automation Narrow thousands of repositories to the ones that match, then run recipes only where they apply.
Validate change after the fact Use search results as a checklist to confirm a transformation reached every occurrence.

The payoff

Make discovery the fast part of change

Orient Orient in sub-second time Engineers and agents locate what matters across the whole org without scanning repository by repository.
Save tokens Stop wasting tokens on reads Symbol-aware results remove the grep-then-read loop that burns context window space and tokens before any work begins.
Act Turn discovery into action Fast search becomes the first step of a governed change, feeding the matched set directly into recipes.

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.

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.