How do I chat with my codebase in Cursor?
Starting a chat
Press Ctrl+L (Windows/Linux) or Cmd+L (Mac) to open the chat panel on the right side of the window. Alternatively, click the chat icon in the sidebar. Type your question, such as 'How does the authentication flow work?' or 'Where is the database connection configured?' The AI will respond based on your code.
You can also select code in the editor and then open chat to ask about that specific snippet. The selected code becomes part of the context.
Referencing files and context
To give the AI more context, you can type '@' in the chat input to mention specific files or symbols. For example, '@src/utils.js' will include that file in the conversation. This is useful when your question involves multiple parts of the codebase.
For the AI to understand your entire project, enable codebase indexing in Settings > AI. This allows the chat to search and reference any file, not just the ones you mention. Indexing may take a few minutes for large projects.
- Open chat with Ctrl+L or Cmd+L.
- Use @ to reference files.
- Enable indexing for full-project context.
- Select code to ask about it directly.
Common mistakes
- Asking vague questions without referencing relevant files, leading to generic answers.
- Not enabling indexing, so the AI only sees the current file.
- Expecting the AI to know about external documentation or APIs not in your code.
