CursorIntermediate

How to Set Up Codebase Indexing in Cursor

Build and manage the codebase index so Cursor can find relevant code across your whole repo, and exclude what it should ignore.

7 minIntermediate

Codebase indexing is what lets Cursor answer questions about code you have not opened. It builds an embedding index of your repo so a request can surface the relevant files automatically. This guide shows how to build the index, check its progress, and keep secrets and junk out of it.

What you need

  • A project folder open in Cursor
  • Cursor signed in (indexing uses the cloud)
  • A .gitignore, or willingness to add a .cursorignore

Step 1: Open indexing settings

Go to Settings and find the Indexing section (sometimes under Features). When you open a new project, Cursor usually starts indexing automatically; this screen lets you trigger it manually and watch progress.

Cursor Settings — Indexing
Codebase Indexing
Status: Indexed (1,284 / 1,284 files)
[ Resync Index ] [ Delete Index ]
[x] Index new files automatically
Index status and the resync control.

Step 2: Build or resync the index

Click the build or resync control. A progress bar shows how many files have been processed. Large repos take a few minutes the first time; after that, only changed files are reindexed, which is fast.

Step 3: Exclude files with .cursorignore

Create a .cursorignore file at the repo root to keep paths out of the index and out of AI context. The syntax is the same as .gitignore. This is the place to exclude build output, large data files, and anything with secrets.

.cursorignore
# build + deps
node_modules/
dist/
.next/

# data + secrets
*.csv
*.sqlite
.env
.env.*

Step 4: Confirm the index is working

Ask a question about a part of the code you have not opened in this session, like where is rate limiting handled. With a healthy index, Cursor finds and cites the right file without you attaching it.

Cursor chat
$Where is request rate limiting implemented?
Found in src/middleware/rateLimit.ts (token bucket, 100 req/min).
$
Keep secrets out of the index
Anything indexed can be pulled into a request. Add .env files, key files and credential dumps to .cursorignore before you build the index, not after, so they never get embedded in the first place.

Result: Cursor answers whole-repo questions and edits the right files even when you have not opened them, while build artifacts and secrets stay out of its reach.

Watch related tutorials

Tags
#indexing#codebase#search#config