- Learn
- AI Code Editors
- Cursor
- Using the Chat Panel
Have conversations with AI about your code, ask questions, debug issues, and get explanations using Cursor's Chat panel.
Using the Chat Panel
The Chat panel is your conversational AI assistant. Unlike Tab completion or inline editing, Chat lets you have ongoing discussions about your code—asking questions, debugging issues, and getting detailed explanations.
Opening the Chat Panel
Open Chat with:
- Keyboard:
Cmd+L(Mac) orCtrl+L(Windows/Linux) - Menu: View → Chat
- Sidebar: Click the chat icon
The panel opens on the right side of your editor.
Chat Interface
┌─────────────────────────────────────┐
│ Model: claude-3.5-sonnet [▾] │
├─────────────────────────────────────┤
│ │
│ Previous messages appear here │
│ │
├─────────────────────────────────────┤
│ @ Add context... │
│ ┌─────────────────────────────────┐ │
│ │ Type your message... │ │
│ └─────────────────────────────────┘ │
└─────────────────────────────────────┘
Components
- Model selector: Choose which AI model to use
- Conversation history: Previous messages in the thread
- Context bar: Files and code snippets attached
- Input field: Where you type your questions
Basic Chat Usage
Asking Questions
Ask about programming concepts:
You: What's the difference between useMemo and useCallback in React?
AI: Great question! Both are React hooks for optimization, but they serve
different purposes:
- useMemo: Memoizes a computed value
- useCallback: Memoizes a function reference
[detailed explanation with examples...]
Getting Code Explanations
Select code, then open Chat:
You: [code automatically attached]
What does this code do?
AI: This function implements a debounce utility. Here's how it works:
1. It takes a function and delay as parameters
2. It uses a timeout to delay execution
3. If called again before the delay, it cancels the previous timeout
...
Debugging Help
Describe your problem:
You: I'm getting "undefined is not a function" when I call this method.
[code attached]
The error happens on line 15.
AI: I see the issue. On line 15, you're trying to call `user.getProfile()`,
but `user` might be undefined when this runs. Here's how to fix it:
[solution with explanation...]
Adding Context with @
The @ symbol lets you reference specific context:
@Files
Reference entire files:
You: @api/users.ts @models/user.ts
How should I add pagination to the user list endpoint?
@Symbols
Reference specific functions, classes, or variables:
You: @UserService @fetchUsers
Can you explain how these work together?
@Web
Search the web for current information:
You: @web What are the latest Next.js 15 features?
@Docs
Reference documentation:
You: @Docs React Query
How do I invalidate queries after a mutation?
@Codebase
Search your entire codebase:
You: @Codebase Where is user authentication handled?
@Git
Reference git history:
You: @Git What changed in the last commit?
@Definitions
Include type definitions and interfaces:
You: @Definitions User
I need to add a new field to this type
Conversation Management
New Conversations
Click "New Chat" or press Cmd+N to start fresh. Each conversation maintains its own context.
Conversation History
Your previous chats are saved. Access them from the chat history dropdown.
Clearing Context
Sometimes you want to start without accumulated context:
- Click "Clear" to reset the current conversation
- Start a new chat for completely fresh context
Working with Code in Chat
Code Blocks in Responses
When Chat generates code, you'll see options:
┌──────────────────────────────────────────┐
│ ```typescript │
│ function validateEmail(email: string) { │
│ const regex = /^[^\s@]+@[^\s@]+$/ │
│ return regex.test(email) │
│ } │
│ ``` │
│ [Copy] [Apply] [Insert at Cursor] │
└──────────────────────────────────────────┘
- Copy: Copy code to clipboard
- Apply: Replace selected code or apply as edit
- Insert at Cursor: Add code at your current cursor position
Applying Code
Click "Apply" on a code block to:
- See a diff view of the changes
- Review what will change
- Accept or reject the modification
Effective Chat Strategies
Strategy 1: Provide Context
The more context you give, the better the response:
You: I'm building a Next.js e-commerce site with Supabase for the backend.
@api/products.ts
How should I implement product search with filtering?
Strategy 2: Be Specific About Output
Tell Chat exactly what you want:
You: Write a TypeScript function that validates credit card numbers.
- Use the Luhn algorithm
- Accept Visa, Mastercard, and Amex
- Return an object with isValid and cardType
- Include JSDoc comments
Strategy 3: Iterate
Use follow-up questions to refine:
You: Can you also add expiration date validation?
You: Now show me how to use this in a React form
You: Add error messages for each validation failure
Strategy 4: Ask for Alternatives
You: Are there other ways to implement this?
What are the tradeoffs?
Strategy 5: Request Explanations
You: Explain this line by line for a junior developer
You: What could go wrong with this approach?
You: Are there any edge cases I'm missing?
Chat for Different Tasks
Code Review
You: @src/components/UserProfile.tsx
Review this component for:
- Performance issues
- Accessibility problems
- Best practices
Architecture Decisions
You: I need to add real-time notifications to my app.
Should I use WebSockets, Server-Sent Events, or polling?
Consider that I'm using Vercel for hosting.
Learning
You: I'm trying to understand React Suspense.
Can you explain it step by step with simple examples?
Then show me a practical use case.
Troubleshooting Build Errors
You: I'm getting this error when I run npm build:
[paste error]
Here's my package.json: @package.json
What's wrong?
Model Selection
Cursor supports multiple AI models. Choose based on your needs:
| Model | Best For | Speed |
|---|---|---|
| claude-3.5-sonnet | Complex reasoning, long code | Fast |
| gpt-4o | General coding tasks | Fast |
| gpt-4-turbo | Legacy support | Medium |
| claude-3-opus | Deep analysis | Slower |
Switch models using the dropdown at the top of the chat panel.
Chat vs Other Features
| Task | Best Tool |
|---|---|
| Quick code completion | Tab |
| Modify specific code | Cmd+K (Inline) |
| Ask questions | Chat |
| Multi-file changes | Composer |
| Discuss architecture | Chat |
| Generate boilerplate | Cmd+K or Chat |
Tips for Better Responses
Format Your Questions Well
Use markdown in your questions:
You: I need help with this function:
```typescript
function process(data) { ... }
- Add TypeScript types
- Handle the null case
- Add error logging
### Include Error Messages
Always paste the actual error:
You: Getting this error: TypeError: Cannot read property 'map' of undefined at UserList (UserList.tsx:15)
### Specify Your Stack
You: Using React 18, TypeScript 5, and Tailwind CSS. How do I create an animated dropdown menu?
## Summary
- **Cmd+L** opens the Chat panel
- **@ mentions** add specific context (files, symbols, web, docs)
- **Apply** code blocks directly to your editor
- **Iterate** on responses with follow-up questions
- **Choose the right model** for your task
- **Provide context** for better answers
## Next Steps
Chat is great for one-off questions and explanations. For making changes across multiple files simultaneously, Composer is Cursor's most powerful feature.