Beginner18 min1 prerequisite

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) or Ctrl+L (Windows/Linux)
  • Menu: View → Chat
  • Sidebar: Click the chat icon

The panel opens on the right side of your editor.

Chat Interface

Terminal
┌─────────────────────────────────────┐
 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:

Terminal
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:

Terminal
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:

Terminal
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:

Terminal
You: @api/users.ts @models/user.ts
     How should I add pagination to the user list endpoint?

@Symbols

Reference specific functions, classes, or variables:

Terminal
You: @UserService @fetchUsers
     Can you explain how these work together?

@Web

Search the web for current information:

Terminal
You: @web What are the latest Next.js 15 features?

@Docs

Reference documentation:

Terminal
You: @Docs React Query
     How do I invalidate queries after a mutation?

@Codebase

Search your entire codebase:

Terminal
You: @Codebase Where is user authentication handled?

@Git

Reference git history:

Terminal
You: @Git What changed in the last commit?

@Definitions

Include type definitions and interfaces:

Terminal
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:

Terminal
┌──────────────────────────────────────────┐
 ```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:

  1. See a diff view of the changes
  2. Review what will change
  3. Accept or reject the modification

Effective Chat Strategies

Strategy 1: Provide Context

The more context you give, the better the response:

Terminal
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:

Terminal
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:

Terminal
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

Terminal
You: Are there other ways to implement this?
     What are the tradeoffs?

Strategy 5: Request Explanations

Terminal
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

Terminal
You: @src/components/UserProfile.tsx
     Review this component for:
     - Performance issues
     - Accessibility problems
     - Best practices

Architecture Decisions

Terminal
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

Terminal
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

Terminal
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:

ModelBest ForSpeed
claude-3.5-sonnetComplex reasoning, long codeFast
gpt-4oGeneral coding tasksFast
gpt-4-turboLegacy supportMedium
claude-3-opusDeep analysisSlower

Switch models using the dropdown at the top of the chat panel.

Chat vs Other Features

TaskBest Tool
Quick code completionTab
Modify specific codeCmd+K (Inline)
Ask questionsChat
Multi-file changesComposer
Discuss architectureChat
Generate boilerplateCmd+K or Chat

Tips for Better Responses

Format Your Questions Well

Use markdown in your questions:

Terminal
You: I need help with this function:

     ```typescript
     function process(data) { ... }
  1. Add TypeScript types
  2. Handle the null case
  3. Add error logging
Terminal

### Include Error Messages

Always paste the actual error:

You: Getting this error: TypeError: Cannot read property 'map' of undefined at UserList (UserList.tsx:15)

Terminal

### Specify Your Stack

You: Using React 18, TypeScript 5, and Tailwind CSS. How do I create an animated dropdown menu?

Terminal

## 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.
Mark this lesson as complete to track your progress