Open SourceGoogle GeminiTypeScriptCLI

My First Contribution to Google's Gemini CLI

How getting rejected by Google maintainers and learning the hard way turned a naive PR into a merged P1 feature in Gemini CLI.

PRAS Samin

PRAS Samin

November 18, 2026

1 views

8 min read

Earlier this year in April, Google’s Gemini CLI was one of the leading terminal AI harnesses in the developer space. Other CLI tools were either just getting off the ground or hadn't even appeared yet. I was a heavy user, working across multiple projects with Gemini as my primary coding partner.

One afternoon, I generated a new UI component, switched back to the CLI prompt, and typed @ to pass the file to Gemini to polish it.

Nothing showed up.

The file was right there on my disk. But as far as the autocomplete list was concerned, it didn't exist.


To get Gemini to see the new file, I had to quit the session and restart it from scratch. Doing that once is annoying. Doing it five times in an hour breaks your entire development flow.


I always had a quiet dream of contributing to a massive, industry-defining open-source project. So I went to the Gemini CLI repository, dug through the issues, and saw that people had already reported this exact problem multiple times.

It was a P1 priority issue-in Google's issue tracker, that means high-priority core friction right behind P0 fire drills.

I had no idea about standard open-source etiquette. I didn't know that outside contributors usually wait for maintainers to attach a help wanted label before jumping in. I was completely new.

So, blindly, I opened my editor and started writing code.


A couple of weeks later, PR #25256-labeled size/L was merged into main and featured in the v0.40.0 release notes.

Here’s the honest story of how that happened: the terrible first attempt, the rejection, the pivot, and the 9-day review marathon that followed.


TL;DR: Gemini CLI's @ file suggestion only crawled your workspace once on startup. My first naive attempt was rejected because it re-introduced expensive full-project crawls. After researching watcher techniques and pitching Google maintainer @scidomino, we implemented a debounced file watcher, swapped arrays to Set for O(1) operations, and shipped it safely behind a configuration flag.


The "Terrible" First Attempt

My initial idea was completely naive: every time a file changes, just recrawl the workspace and rebuild the whole index.

I opened a pull request. Maintainers ignored it.

I closed it, made a few minor tweaks to that same bad approach, and opened another. It was closed again.

Finally, a Google maintainer left a comment that gave me a cold shower of reality:

"We intentionally introduced the fzf index in #5136 because we didn't want users to have to wait to crawl their whole workspace before presenting autocompletions. But this PR reintroduces the full-workspace crawl. For most users this is probably fine, but we were getting lots of complaints from users with very large workspaces which is why we merged #5136... After discussing this with the team we've decided this is not the way to go. We'd want to use filewatchers if anything. Thanks for investigating this tho!"

My solution wasn't just suboptimal-it was undoing performance work the Google team had spent months optimizing.

It would have been very easy to close the tab, feel embarrassed, and give up. But the maintainer had dropped the exact architectural hint: "We'd want to use filewatchers if anything."


The Pivot: Asking Before Coding

I spent the next few hours researching background file-watching patterns. But this time, I didn't rush to open another PR. I decided to communicate first.

I reached out directly to Google maintainer @scidomino:

"Hey @scidomino, I have an idea for a fix. When the CLI first opens, the crawler runs and crawls the entire workspace to create results for the @ menu. Then, a file watcher will continuously watch the workspace for file/folder creation and deletion. When an event occurs, the watcher will update the crawled results in the background. This way, users won't need to wait when they press @. What do you think about this approach? Does it look okay to you? I'd love to work on this fix."

A short while later, he replied:

"@prassamin Yes. That's precisely what we were thinking of. One issue is that fzf can't be updated and just needs to be rebuilt every time but it's probably fine. Also, we will want this feature gated behind a settings flag just in case it has performance implications."

He added the help wanted label to the P1 issue and handed me the reins.


How It Worked Under the Hood

To understand why this fix wasn't trivial, look at how Gemini CLI handled file suggestions.

Inside the core package lives RecursiveFileSearch. On startup:

  1. It recursively walks your workspace directory.
  2. It filters out ignored folders like .git and node_modules.
  3. It stores matching paths in an in-memory list.
  4. When you type @, it passes that list to fzf for fuzzy autocomplete.

Active projects aren't static. You scaffold components, delete files, and switch git branches. But crawling 25,000 files in a monorepo every time something changes takes serious CPU time.

The CLI didn't need to recrawl. It needed an event-driven watcher that updated state in the background.


The 3 Technical Traps

Once I started implementing the watcher, three performance hurdles appeared:

1. Arrays Are Too Slow for Rapid Changes

In the original code, file paths lived in a standard string[] array.

That works fine for a static list. But file watchers are update-heavy. If you run git checkout main, the filesystem fires a burst of hundreds of add and unlink events in milliseconds.

With an array:

  • Checking if an added file exists requires an includes() scan: O(N).
  • Removing a deleted file requires filtering or splicing: O(N).

Doing hundreds of linear scans across tens of thousands of items on the main thread will quickly spike CPU.

The solution was swapping the array for a native Set<string>:

// packages/core/src/utils/filesearch/fileSearch.ts
export class RecursiveFileSearch {
  // Using a Set instead of an Array for O(1) lookups and deletes
  private files: Set<string> = new Set();
  private fileWatcher: FileWatcher | null = null;
  private debounceTimer: NodeJS.Timeout | null = null;

  public handleFileEvent(event: "add" | "unlink", filePath: string) {
    if (event === "add") {
      // Don't let massive repos cause runaway memory growth
      if (this.files.size >= this.maxFiles) return;
      this.files.add(filePath);
    } else if (event === "unlink") {
      this.files.delete(filePath);
    }

    this.scheduleIndexRebuild();
  }
}

With a Set, checking, adding, and deleting paths became O(1) constant time.


2. fzf Can't Do Incremental Updates

Updating our Set in memory was fast. But as @scidomino pointed out, fzf doesn't let you append a single file to an existing index. The index has to be rebuilt from scratch.

If we rebuilt the index on every single watcher event, running bun install or a build step would freeze the terminal.

We solved this with a debounced queue:

  1. When a file event fires, update the in-memory Set immediately.
  2. Schedule the index rebuild for 500ms later.
  3. If new events arrive before the timer fires, reset the clock.
  4. Once filesystem activity settles, run a single, clean rebuild.

Rapid bursts get batched into one invisible rebuild, while single file additions feel instantaneous.


3. Guarding Against Giant Repos

If someone opens Gemini CLI in their root directory or a repository with an un-ignored 200,000-file cache, a greedy watcher could swallow all available RAM and crash Node.js.

We added an explicit safeguard: once this.files.size hits the configured maxFiles ceiling, new additions are dropped cleanly instead of taking down the user's terminal session.


The 9-Day Review Marathon

Because this PR touched 14 files and core search behavior, it was tagged as size/L in the repository.

From April 13 to April 22-nine straight days-@scidomino and I worked through review cycles. He wasn't just reviewing; he was actively mentoring me through edge cases:

  1. Clean Shutdown on Disposal: If a user hit Ctrl + C while an asynchronous file scan was still resolving, floating promises could trigger unhandled rejections during exit. We added an explicit lifecycle flag to cancel pending tasks cleanly when the searcher is disposed.
  2. Sandbox Error Propagation: In early revisions, I silenced watcher errors. Maintainers noted that in corporate sandboxes where filesystem access might be restricted, silent errors make troubleshooting impossible. We wired up an onError channel so issues bubble up to the CLI’s logger.
  3. Cross-Platform Tests: Writing comprehensive unit tests for file/folder creation, deletion, and path-ignoring behavior across Windows and Linux.

On April 21, the final checkmarks turned green:

image_1795076572019

Seeing It in v0.40.0

A few days later, Google posted the official Gemini CLI v0.40.0 release announcement.

Under the 🧠 Smarter Memory & Context section, it was surreal to see:

The @ file recommendation system now uses real-time watchers to detect new files. (#25256, @prassamin)


Wrapping Up

Looking back, the biggest lesson wasn't about Set vs Array or file debouncing.

It was about how to handle failure:

  • When your first PR gets rejected, don't take it personally. Maintainers are protecting millions of users.
  • Stop coding and start communicating. Ask the maintainers if your architecture makes sense before writing 500 lines of code.
  • If you listen to feedback and keep showing up, even the busiest engineers at Big Tech will gladly help you cross the finish line.

Thanks for reading! Feel free to check out the full review history on GitHub: PR #25256.


Tommaso Sciortino
Tommaso Sciortino
Senior Software Developer at Google