Ignore Files
Control which files Cursor’s AI features and indexing can access using .cursorignore and .cursorindexingignore
Overview
Cursor reads and indexes your project’s codebase to power its features. You can control which directories and files Cursor can access by adding a .cursorignore
file to your root directory.
Cursor makes its best effort to block access to files listed in .cursorignore
from:
- Codebase indexing
- Code accessible by Tab, Chat, and ⌘K
- Code accessible via @ symbol references
Tool calls initiated by Cursor’s Chat feature to services like Terminal and MCP servers are not currently able to block access to code governed by .cursorignore
Global Ignore Files
You can now define ignore patterns that apply across all projects via your user-level settings. This keeps noisy or sensitive files like build outputs or secrets out of prompts, without needing per-project configuration.
Why Ignore Files?
There are two common reasons to configure Cursor to ignore portions of your codebase:
Security
While your codebase is not permanently stored on Cursor’s servers or the LLMs that power its features, you may still want to restrict access to certain files for security reasons, such as files containing API keys, database credentials, and other secrets.
Cursor makes its best effort to block access to ignored files, but due to unpredictable LLM behavior, we cannot guarantee these files will never be exposed.
Performance
If you work in a monorepo or very large codebase where significant portions are irrelevant to the code you’re developing, you might consider configuring Cursor to ignore these parts of the application.
By excluding irrelevant parts of the codebase, Cursor will index large codebases faster and find files with more speed and accuracy when searching for context.
Cursor is designed to support large codebases and is skilled at assessing file relevancy, but the ignore feature is helpful when using a codebase that is especially large or includes files immaterial to your development.
Configuring .cursorignore
To implement Cursor’s ignore feature, add a .cursorignore
file to the root of your codebase’s directory and list the directories and files to be ignored.
The .cursorignore
file uses pattern matching syntax identical to that used in .gitignore
files.
Basic Pattern Examples
Advanced Pattern Examples
Considerations
-
Blank lines are ignored
-
Lines starting with
#
are considered comments and ignored -
Patterns are matched relative to the location of the
.cursorignore
file -
Patterns will override conflicting patterns listed earlier in the file
Limit Indexing with .cursorindexingignore
To implement Cursor’s ignore feature for indexing only, add a .cursorindexingignore
file to the root of your codebase’s directory, and list the directories and files to be excluded from the index.
Files listed in .cursorindexingignore
will not be included in Cursor’s index but can still be accessed by Cursor’s AI-assisted features, including when Cursor searches the codebase and exposes it to LLMs.
Files Ignored by Default
Cursor will also ignore all files listed in the .gitignore
file in your root directory and in the Default Ignore List provided below.
To not ignore a file listed in these files, add it to your .cursorignore
file with an !
prefix.
Troubleshooting
To troubleshoot issues with your ignore files, try testing patterns using the git check-ignore -v [file]
command.
Was this page helpful?