Codebase Indexing
Learn how to index your codebase in Cursor for more accurate AI assistance and search results
Index your Codebase
For better and more accurate codebase answers, you can index your codebase. Behind the scenes, Cursor computes embeddings for each file in your codebase, and will use these to improve the accuracy of your codebase answers.
When a project is opened, each Cursor instance will initialize indexing for that workspace. After the initial indexing setup is complete, Cursor will automatically index any new files added to your workspace to keep your codebase context current.
The status of your codebase indexing is under Cursor Settings
> Features
> Codebase Indexing
.
Advanced Settings
By default, Cursor will index all files in your codebase.
You can also expand the Show Settings
section to access more advanced options.
Here, you can decide whether you want to enable automatic indexing for new repositories and configure the files
that Cursor will ignore during repository indexing.
Cursor uses the same package as VS Code to handle file ignoring, which means it respects all .gitignore
files, including those in subdirectories. You can also create a .cursorignore
file for user-specific ignore patterns, which you may want to add to your global .gitignore
to avoid committing it to the repository.
If you have any large content files in your project that the AI definitely doesn’t need to read, ignoring those files could improve the accuracy of the answers.
Working with large monorepos
When working with large monorepos containing hundreds of thousands of files, it’s important to be strategic about what gets indexed.
- Use
.cursorignore
to let each developer configure which folders and paths they work on in the monorepo - Add
.cursorignore
to your global.gitignore
This allows each developer to optimize indexing for their specific work areas within the monorepo.
Working with Multi-Root Workspaces
Cursor supports multi-root workspaces, allowing you to work with multiple codebases simultaneously. When you create a multi-root workspace:
- All codebases added to the workspace will be indexed automatically
- Each codebase’s context will be available to Cursor
.cursor/rules
are supported in all folders you add- Perfect for working on related projects that live in different folders
This feature is particularly useful when you need to work across multiple projects in the same workspace, ensuring all your code context is readily available to Cursor.