Context
Codebase Indexing
Indexing Your Codebase
To get better and more accurate codebase answers using @codebase
or Ctrl/⌘ Enter
, you can index your codebase. In the background, Cursor computes embedding vectors for each file in your codebase and uses these vectors to improve the accuracy of codebase answers.
Your codebase index automatically stays in sync with the latest codebase changes.
You can check the status of your codebase indexing under Cursor Settings
> Features
> Codebase Indexing
.
Advanced Settings
By default, Cursor indexes all files in your codebase.
You can also access more advanced options by expanding the Show Settings
section. Here, you can decide whether to enable automatic indexing for new repositories and configure which files Cursor should ignore during repository indexing, in addition to .gitignore settings.
If you have large content files in your project that AI absolutely doesn't need to read, ignoring these files can improve answer accuracy.
AI Rules
You can add custom instructions for Cursor by modifying the Rules for AI
section under Cursor Settings
> General
> Rules for AI
.
These custom instructions will be used for features like Cursor Chat and Ctrl/⌘ K.
.cursorrules
For project-specific instructions, you can include them in a .cursorrules
file in your project's root directory.
Like the "Rules for AI" section, instructions in the .cursorrules
file will be used for features like Cursor Chat and Ctrl/⌘ K.
@ Symbols
Basic Usage
In Cursor's AI input boxes, such as Cmd K, Chat, or Terminal Cmd K, you can use @ symbols by typing @
. A popup menu with suggestions will appear, which automatically filters based on your input to show only the most relevant suggestions.
Keyboard Shortcuts
You can navigate through the suggestions list using the up/down arrow keys. You can select a suggestion by pressing Enter
. If the suggestion is a category, like Files
, the suggestions will be filtered to show only the most relevant items in that category.
Cmd K Keyboard Shortcuts
You can navigate through the selected Cmd K @ symbols list using up/down arrow keys, and use Enter
to expand/collapse selected context items. For file references, you can use Ctrl/⌘ M
to toggle the file reading strategy. Read more about file reading strategies here.
@Files
@Files
In AI input boxes like Cursor Chat and Cmd K, you can use @Files
to reference entire files. Additionally, if you continue typing after @
, you'll see your file search results after the @Code
strategy.
To ensure you're referencing the correct file, Cursor shows a preview of the file path. This is especially useful when you have multiple files with the same name in different folders.
Long File References in Chat
In Cursor's chat, if the file content is too long, Cursor will break the file into smaller chunks and reorder them based on relevance to the query.
Cmd K Chunking Strategy
For Cmd K, Cursor also uses file references differently based on content length.
- auto
- Automatically selects one of three reading strategies based on file size
- full file
- The entire file is used as context.
- outline
- Cursor parses the file's outline and uses the information as context.
- chunks
- Cursor breaks the file into smaller chunks and selects the most relevant one.
Drag and Drop
You can also drag and drop files from the main sidebar into Chat or Cmd K to add them as context.
@Folders
Currently, @Folders
is only supported in Cursor Chat.
@Folders
You can also reference entire folders as context in Cursor. @Folders
is particularly useful for long context chat where you want to provide the AI with a large amount of context.
@Code
@Code
To reference specific sections of code, you can use the @Code
symbol.
Code Preview
Similar to the @Files
symbol, Cursor shows a preview of the code content so you can verify you're referencing the correct code.
From Editor
Another way to add code snippets as context is to select the code you want to reference and click "Add to Chat" (Ctrl/⌘ Shift L
) or "Add to Edit" (Ctrl/⌘ Shift K
).
These actions will add the selected code snippet to the chat input box or the currently active Cmd K prompt bar.
To add the selected code to a new chat, you can press Ctrl/⌘ L
.
@Docs
@Docs
Cursor comes with a set of third-party documentation that has been crawled, indexed, and is ready to use as context. You can access them using the @Docs
symbol.
Adding Custom Documentation
If you want to crawl and index custom documentation that isn't already provided, you can do so through @Docs
> Add new doc
. After you paste the URL of the documentation you want, the following modal will appear:
Cursor will then index and learn the documentation, and you can use it as context just like other documentation. If you want to index all subpages and subdirectories, make sure to add a slash at the end of the URL.
Managing Custom Documentation
Under Cursor Settings
> Features
> Docs
, you'll see the documentation you've added. You can edit, delete, or add new documentation here.
@Git
Currently, @Git
is only supported in Cursor Chat.
@Git
In Cursor's chat, you can use @Git
to add git commits, diffs, or pull requests to your prompt.
Common Use Cases
A common use case for @Git
is to have Cursor's AI scan diffs and look for potential errors or issues that might be caused by the diff.
You can also use @Diff of Working State
to generate commit messages from the current diff.
@Codebase
@Codebase
With @Codebase
, Cursor Chat goes through these steps until it finds the most important code snippets to use.
- Collect: Scans your codebase to find important files/code blocks
- Reorder: Reorders context items based on relevance to the query
- Reason: Thinks about the plan for using the context
- Generate: Proposes a response
Another way to submit advanced codebase queries is to click the dropdown next to the Ctrl/⌘ + Enter
button and select reranker
for the search behavior. This is only available when @Codebase
is not used, otherwise @Codebase
takes precedence.
@Web
@Web
With @Web
, Cursor constructs search queries based on your provided query and context, and searches the web to find relevant information as additional context.
This is useful for having Cursor find the latest information online, or having Cursor scrape multiple websites in seconds to find the best answer without users having to manually search anywhere.
@Chat
This feature is currently only available for Cmd K.
@Chat
You can use @Chat
in Cmd K to add current chat messages as context. This is useful when you have an AI conversation that you want to apply to editing or generating code.
@Definitions
This feature is currently only available for Cmd K.
@Definitions
The @Definitions
symbol adds all nearby definitions to Cmd K as context.
Pasting Links
@https://your-link.com
To have Cursor visit a link before responding, type @
and then paste the link.
Removing Links
By default, we automatically parse links and convert them to @Links
in Cursor Chat. If you prefer to have links as plain text, click the link and then click Unlink
.
Ignoring Files
The .cursorignore
file allows you to exclude files and directories from Cursor's codebase indexing
About .cursorignore
To ignore files from codebase indexing, you can use a .cursorignore
file in your project's root directory. It works the same way as git's .gitignore
.
.cursorignore
follows .gitignore
. If you already have a .gitignore
, files are ignored by default. If you want to ignore additional files, you can add them to the .cursorignore
file.
You can read more about how this works on our security page.
Chat and Composer Context
Currently, Cursor Chat and Composer can access all files in their context without being affected by .cursorignore
settings.
More information about how we handle AI requests can be found on our security page.
.cursorignore File Example
Ignoring Specific Files
# Ignore all files in the `dist` directory
dist/
# Ignore all `.log` files
*.log
# Ignore specific file `config.json`
config.json