skip to content

Codebase Search & Ignore Files

Agent finds code with Instant Grep, a local regex index, and an Explore subagent; .cursorignore hides files from Agent and Tab. Asked because what leaves your machine is a data question.

part ofAI coding toolsread it →
on this pageshow

explore

questions

4

A security lead asks what Cursor uploads to search a proprietary repository — how does Agent find code, and what still leaves the machine?

level: middleimportance: must knowfreq 12%

answer

  1. local index versus model request
  2. regex engine faster than ripgrep
  3. no paths, no code, no embeddings
  4. opened matches join the request
  5. Explore: own context, faster model

basics

~20 s

Cursor's Agent searches with Instant Grep, a regex index built and queried on your machine; Cursor uploads no paths or code to build it and stores no codebase embeddings. File content Agent opens can still go to the model.

solid answer

~40 s

Cursor's Agent finds code with **Instant Grep**, a custom regex search engine that builds and queries its index locally. Cursor's search page says it does not upload file paths or code to build a search index and does not store embeddings of your codebase for search, so a description of shipping the repository off for an embedding index does not match the current product. For broad searches Agent can spawn the **Explore subagent**, which runs many parallel searches in its own context window on a faster model and returns only the findings. What does leave the machine is what Agent reads: when it opens a match, that file's content can be included in the model request. `.cursorignore`, `.gitignore` and the default ignore list decide which files Agent may open at all.

go deeper

for a junior

Recall the two halves: Agent searches with Instant Grep, whose index lives on your machine, and files Agent opens can still be sent to the model.

for a middle

Explain Instant Grep's regex and word-boundary search, why the Explore subagent runs in its own context window, and how the ignore files limit what Agent opens.

for a senior

Answer a security review precisely: no uploaded index or stored embeddings, but opened files travel in model requests; then name ignore files and their terminal and MCP gap as the control.

for a principal

Separate the search design from the question of data governance; a local index settles one, while which code may reach a provider at all is a policy decision the editor cannot make for you.

## Why this gets asked When a team adopts Cursor on a proprietary repository, the first question from security is rarely about features. It is about data flow: does the editor ship the codebase somewhere to make search work? Many engineers still describe AI editors as uploading code to compute **embeddings** (numeric vectors used for similarity search) on a server. Cursor's current search page says something different, and a candidate who knows it can separate two things the security lead tends to merge: the **search index**, which is local, and the **model request**, which is not. ## Instant Grep: the local search engine **Instant Grep** is the search engine Agent uses for exact matches: a function name, a variable, an error string or a regex pattern. - It is a custom engine that Cursor describes as outperforming `ripgrep` on large codebases. - It supports full regex and word-boundary matching, so Agent can construct patterns such as `import.*PaymentService` or `PaymentFailedError` to trace references across files. - It runs automatically; there is nothing to configure or switch on. - It **builds and queries its index on your machine**. In the page's words, Cursor "does not upload file paths or code to build a search index, and it does not store embeddings of your codebase for search." Agent reaches for grep on its own when you reference specific symbols, and its search tools can also find files by name and read directory structures. ## The Explore subagent Broad questions, such as "where do we validate user input?", need many searches. Running all of them in the main conversation would fill its context window with raw matches. Cursor handles this with a built-in subagent called **Explore**: 1. Agent spawns it automatically when it decides a task benefits from broad search, or you ask for one in plain words ("use a subagent to find all the places we validate user input"). 2. It runs in **its own context window** with a **faster model** by default, executing many searches in parallel; Cursor's subagents page puts it at ten parallel searches in the time a single main-agent search would take. 3. It returns **only the relevant findings**, summarized, so the main conversation stays focused instead of holding every file it opened. Explore changes where search output piles up, not the privacy picture: it is still an agent, so the content it reads lands in its own context window, which a model processes like any other agent context. ## What leaves the machine, and what does not | Item | Leaves the machine? | |---|---| | The Instant Grep index, built from your paths and code | No: built and queried locally | | Embeddings of the codebase for search | None are stored | | Content of a file Agent opens from a match | Yes: it can be included in the model request | | The Explore subagent's summary | Becomes part of the main Agent conversation | | Files hidden by `.cursorignore`, `.gitignore` or the default ignore list | Not read by Agent's file tools | The third row is the one people miss. "The index is local" does not mean "the code is local": once Agent opens a match to reason about it, that content can be part of the request sent to a model provider. How a provider then treats the request (Privacy Mode, retention, training) is a separate question of data governance, answered by Cursor's data-use and privacy documentation rather than by the search design. ## Controlling what Agent can open The lever on *which* files Agent may read is the ignore system: - A `.cursorignore` file in the project root, written in `.gitignore` syntax, blocks the files it lists from Agent, Tab, Inline Edit and @-mention references. - Files in `.gitignore` and on Cursor's default ignore list (`.env*`, `.git/`, lock files, binaries and media among them) are excluded without any extra entry. - Terminal commands and MCP tools run outside Cursor's file access controls, so an ignored file is not out of reach of a shell command that Agent runs. So the honest answer to the security lead has three parts: search builds no remote index and stores no embeddings, files Agent opens do reach the model, and ignore files narrow what Agent opens without sealing it off. ## Common mistakes - Claiming Cursor uploads the repository to build an embedding index for search; the current search page says the opposite. - Concluding that a local index means no source code ever leaves the machine. - Assuming the Explore subagent pastes every file it read into the main conversation. - Treating Instant Grep as a feature to configure before Agent can search.

  • Does Instant Grep need any setup before Cursor's Agent can search a repository?
    No. Cursor's search page says it runs automatically with no configuration. If Agent still cannot find a file, the troubleshooting page has you check `.cursorignore` and `.gitignore` first, then run the command-palette "Reindex" step, and finally attach the file directly with an @-mention.
  • When does Cursor's Agent use the Explore subagent instead of searching in the main conversation?
    Automatically, when Agent decides a task benefits from broad search, or when you ask for it ("use a subagent to find all the places we validate user input"). Explore keeps the many intermediate matches in its own context window and hands back a summary, so the main conversation is not flooded with raw file contents.
  • If no search index is uploaded, how can proprietary code still reach a model provider?
    Through the request itself. When Agent opens a file it found, that content can be included in the model request, and so can anything Agent reads through other tools. To keep a file out of Agent's own reads, list it in `.cursorignore`, knowing that terminal commands and MCP tools are not covered by it.

  • Cursor uploads the repository to build an embeddings index for codebase search.
  • Because the search index is local, no source code ever leaves the machine.
  • Instant Grep must be enabled and configured before Agent can search.
  • The Explore subagent dumps every file it opened into the main conversation.
  • Ignored files are only hidden from search results, not from Agent's file reads.
open as a page

Before anyone writes a .cursorignore, which files does Cursor already keep away from Agent and Tab, and where do cross-project ignore patterns go?

level: juniorimportance: should knowfreq 7%

basics

~20 s

Cursor already ignores everything in .gitignore plus a built-in default list: .env* files, .git/, lock files, binaries, media, archives and folders like node_modules/. Global ignore patterns in user settings cover every project, but that list starts empty.

open as a page

Cursor's Agent printed a key from secrets/prod.env even though .cursorignore lists secrets/ — how did it read the file, and what actually stops that?

level: seniorimportance: should knowfreq 6%

basics

~20 s

.cursorignore governs only Cursor's own file access: Agent's reads, search, Tab, Inline Edit and @-mentions. Terminal commands and MCP tools run outside it, so a cat reads the file. File system permissions or encryption, plus command hooks, are what stop it.

open as a page

A gitignored generated client is invisible to Cursor's Agent — how does .cursorignore re-include it, and when does a ! negation fail?

level: middleimportance: nice to knowfreq 3%

basics

~20 s

Add a ! pattern for the directory to .cursorignore, such as !src/generated/, which overrides .gitignore and the default list. Negating a single file fails when a parent directory is excluded, because excluded directories are not traversed.

open as a page