ANTIGRAVITY LABJP
Articles/Editor View
Editor View/2026-06-28Advanced

Turning Faster Substring Search into Solid Grounding for Agents in Large Repos

Antigravity's substring search got faster. Rather than stopping at perceived speed, here is how to wire it into a search design that hands agents exactly the right context in a huge codebase, with concrete steps and pitfalls.

Antigravity283editor29searchcodebasedesign11

Premium Article

In a repo with tens of thousands of files, have you ever asked an agent to "fix the callers of this function" and watched it edit the wrong place entirely? Most of the time the cause is that the agent could not narrow down where to look and pulled unrelated code into context.

A recent Antigravity point release made substring search faster. It would be a waste to file that under "less waiting, nicer experience." Fast search also means you can narrow the context you assemble for the agent, cheaply, as many times as you like. Speed converts directly into grounding accuracy.

As an indie developer, I carry a monorepo that grew large under Dolice, and I have hit the wall many times where letting the agent read the whole thing increases off-target suggestions. Once I started using search as a context-design tool, the precision of fixes changed noticeably. Here is the thinking.

Why agents miss in large repositories

When accuracy drops in a huge codebase, the cause is less about capability and more about how context is supplied. Looking back at my own failures, nearly 80% of the off-target edits were triggered by giving too much context.

Hand over loosely related files and the agent treats them as clues, editing places that look similar but are not. Conversely, leave out a needed file and it fills the gap by imagination, writing code that papers over the hole. Too much or too little, accuracy falls either way. The target is a single bundle that is neither.

This is where fast search earns its keep. If you can narrow cheaply and repeatedly, you do not need to land the perfect query on the first try. You can afford the round trip of casting wide, looking at results, then narrowing.

Narrow in two passes

I never finish search in one shot; I always split it into two passes.

Pass 1: cast wide by symbol

First, hit the whole repo with the function or class name itself to understand the distribution. See which directories it concentrates in and whether it has spread to unexpected places.

# Pass 1: grasp the overall distribution by symbol name
rg --no-heading -n "processPayment" \
  | awk -F: '{print $1}' | sort | uniq -c | sort -rn

Tallying hit counts per file makes "where the core lives" obvious at a glance. Files with one or two hits are periphery; files with a dozen are the center.

Pass 2: narrow by context terms

Next, restrict the scope to the apparent core and re-search with terms tied directly to the fix. If the goal is "change the arguments at the call site," hit the call pattern itself.

# Pass 2: extract only the call pattern inside the core directory
rg --no-heading -n "processPayment\(" src/billing/ \
  --type ts -C 2

With two passes, the candidates you hand the agent shrink from "everything" to "the relevant calls inside the core directory." It is not unusual to cut context volume by an order of magnitude.

Thank you for reading this far.

Continue Reading

What follows includes implementation code, benchmarks, and practical content we hope you'll find useful. This site runs without ads — server and development costs are supported entirely by members like you. If it's been helpful, we'd be truly grateful for your support.

WHAT YOU'LL LEARN
A two-pass procedure: cast wide, then narrow, instead of one vague query
An observation that about 80% of lost accuracy in big repos is too much context, and how to trim it
An ignore design that cuts search noise, plus a lightweight script that bundles only the relevant files
Secure payment via Stripe · Cancel anytime

Unlock This Article

Get full access to the rest of this article. Buy once, read anytime. This site is ad-free — your support goes directly toward keeping it running.

or
Unlock all articles with Membership →
Share

Thank You for Reading

Antigravity Lab is ad-free, supported entirely by members like you. We publish practical guides daily with implementation code, benchmarks, and production-ready patterns. If you've found it useful, we'd love to have you on board.

  • Copy-paste ready implementation code
  • New advanced guides published daily
  • $5/mo or $10 for lifetime access
View Membership →

Related Articles

Editor View2026-03-10
VS Code × Antigravity Migration Guide — Seamlessly Transition Your Dev Environment to an AI IDE
A complete guide to migrating from VS Code to Google Antigravity. Learn how to transfer settings, extensions, keybindings, and effectively use both editors together.
Editor View2026-06-26
Splitting a Giant Antigravity Diff Into Meaningful Commits
Are you committing the agent's 400-line diffs as a single blob? Here is a practical workflow, with scripts, for re-splitting an unreviewable bulk commit into one concern per commit.
Editor View2026-06-22
Precedence for Nested AGENTS.md: A Merge Design for Many Projects in One Workspace
Put several projects in one workspace, each with its own AGENTS.md, and which instruction the agent follows turns ambiguous. Root and per-project rules quietly collide; one wins, or both blend. Taking 'closer is stronger' as the base rule, this designs a merge that distinguishes overriding from appending, with working Python and field notes.
📚RECOMMENDED BOOKS
Build a Large Language Model (From Scratch)
Sebastian Raschka
LLM Dev
Prompt Engineering for LLMs
Berryman & Ziegler
Prompting
AI Engineering
Chip Huyen
AI Eng
* Contains affiliate links
See all →