The Agent Panel and Ask Mode
The Agent Panel and Ask Mode
One of the most useful features in Cursor is the Agent side panel. It gives you an AI assistant that is not sitting in a separate browser tab but is built into your editor, reading the file you have open and the code you have selected. This lesson covers how to open the panel, how its three modes differ, and how to get the most out of read-only Ask mode.
What You'll Learn
- How to open and close the Agent side panel with Cmd+L or Cmd+I
- The three modes (Agent, Ask, and Plan) and how to switch between them with Shift+Tab
- Why Ask mode is read-only and when that matters
- How the panel uses your current file and selection as context
- Using Ask mode to explain unfamiliar code
- Generating code snippets from the panel
- Managing chat history and starting fresh conversations
- Tips and patterns for writing prompts that produce useful answers
Opening the Agent Panel
In the Cursor editor, the AI lives in the Agent side panel. Press Cmd+L or Cmd+I on macOS (Ctrl+L or Ctrl+I on Windows and Linux) to toggle it. Both shortcuts open the same panel, so use whichever feels natural. The panel slides in on the side of your editor, giving you a conversation interface without leaving your workspace.
You can also click the panel icon in the editor's title bar, but the keyboard shortcut is worth learning right away. Press it again to hide the panel and get your screen space back.
A few related shortcuts are worth knowing from day one:
- Cmd+Shift+L adds the code you have selected to the current chat
- Cmd+N or Cmd+R starts a new chat
- Cmd+T opens a new chat tab, so you can keep several conversations open side by side
Your conversations are saved. If you close the panel and reopen it, your previous chat is still there. This is useful for referring back to something the AI explained earlier, or for building on a previous response.
Cursor also has a separate Agents Window for running many agents in parallel. This lesson focuses on the side panel inside the classic editor, which is where most people start. Shortcuts and layouts can change between versions, so check Cursor's keyboard shortcuts settings if something does not match.
The Three Modes: Agent, Ask, and Plan
The first thing to understand is the mode picker in the chat input. Cursor gives you three main modes. Press Shift+Tab in the chat input to cycle between them, or click the mode picker (Cmd+. opens the mode menu).
Agent Mode
Agent is the default. It can read and edit files, search your codebase on its own, and run terminal commands to finish a task. Agent mode has its own lesson later in this module. For now, remember the short version: Agent acts.
Ask Mode
Ask mode is read-only. You ask a question, and the AI explores your code and answers with text and code suggestions. It does not edit your files or run commands that change your project. If it writes a code snippet, the snippet appears in the chat for you to review.
Ask mode is best for:
- Understanding what existing code does
- Getting a second opinion on an approach
- Exploring options before committing to one
- Asking questions about APIs, libraries, or language features
- Getting a code snippet you will review before using
Think of Ask mode as a knowledgeable colleague who explains and suggests, then waits for you to decide what to do. Ask talks.
Plan Mode
Plan mode sits between the two. The agent researches your codebase, asks you clarifying questions, and writes an editable plan before any code changes. You review and adjust the plan, then build from it. Plan mode is most useful for complex, multi-file work or tasks where the requirements are still fuzzy. You will use it in the Agent mode lesson.
Choosing a Mode
| Mode | What it does | Use it when |
|---|---|---|
| Agent | Reads, edits, and runs commands | You want the work done |
| Ask | Read-only answers and exploration | You want to understand or decide |
| Plan | Researches, asks questions, writes a plan | The task is big or unclear |
Cursor also has a Debug mode for tracking down bugs with runtime evidence. You do not need it yet.
When you want to stay fully in control of what changes in your code, switch to Ask mode.
How the Panel Reads Your Code
A big advantage of Cursor over a standalone chatbot is that it already knows what you are working on. It pulls context from your current file and any selected code.
Your Current File
When you open the panel while a file is open in your editor, Cursor can attach that file as context. You will see it shown in the chat input as a file reference. You do not need to paste your whole file into the chat to ask about it.
For example, if you have a 200-line React component open and you ask "what does this component do?", the AI can read the file and give you a specific answer, not a generic explanation of React components.
Selected Code
If you highlight a section of code and press Cmd+Shift+L, that selection is added to the chat. This is useful when you want to ask about one function or block rather than the whole file.
// Select this function, then press Cmd+Shift+L
function calculateDiscount(price, userTier) {
if (userTier === 'premium') return price * 0.8;
if (userTier === 'standard') return price * 0.9;
return price;
}
With this selection added, you could ask: "Can this function handle edge cases like null prices or invalid user tiers?" and the AI will analyze exactly that function.
Adding More Context
Sometimes the open file is not enough. You have two options:
- Just ask. The agent can search your codebase on its own to find related files, types, and config. If you are not sure where something lives, describe it and let it look.
- Use
@mentions when you already know the relevant files. Type@in the chat input and pick a file or folder (for example@auth.tsor@src/components/). This is covered in detail in the context module.
Using Ask Mode for Code Explanations
Ask mode is great at explaining code you did not write or have not touched in a while. Instead of reading unfamiliar logic line by line, ask Cursor to walk you through it.
Useful explanation prompts:
- "Explain what this function does step by step"
- "What is the purpose of this middleware?"
- "Why would this code use a closure here instead of a regular function?"
- "What are the potential side effects of calling this?"
- "Walk me through this SQL query"
- "Where is the user session created, and what reads it later?"
Be specific about what you want explained. "Explain this code" works, but "explain why this code uses debounce instead of throttle" gets a more targeted answer.
Following Up
The chat keeps conversation history, so you can ask follow-up questions naturally. If the first explanation is too high-level, say "can you go deeper on the caching logic?" If a term is unfamiliar, ask "what does memoization mean in this context?" The AI remembers what was just discussed and builds on it.
Generating Code Snippets
Ask mode is not only for reading code. It is also a quick way to sketch new code before you decide where to put it.
Example: Generating a Utility Function
Suppose you need a function that formats a date for display. Instead of looking up the Date API, ask:
Write a TypeScript function that takes a Date object and returns a
human-readable string like "March 16, 2026". Handle null gracefully.
Cursor writes the function in the chat. You review it, and if it looks right, you can copy it or apply it to your file.
Generating Boilerplate
The panel is good at boilerplate you already know the shape of but do not want to type out:
- "Generate a zod schema for a user profile with name, email, and optional avatar"
- "Write a basic Express route handler for POST /api/login"
- "Give me a Jest test skeleton for a function that processes payment data"
You know what you want, and the typing is tedious. Let the AI handle it so you can focus on the meaningful parts.
Getting the Code Into Your File
When Ask mode produces a code block, you have a few options:
- Copy: copy the block and paste it where you want it
- Apply: use the apply option on the code block to have Cursor insert it into your file, then review the diff
- Switch to Agent: if you like the suggestion and want Cursor to make the change for you, switch to Agent mode (Shift+Tab) and say "go ahead and make that change"
Always read generated code before applying it. The AI is good at producing plausible-looking code, but it does not always know your project's conventions unless you tell it.
Chat History and New Conversations
As you work, your conversation history builds up. This helps with continuity: you can scroll back to see what was discussed and what code was generated.
Starting a New Conversation
When you switch to a new task or a different part of your codebase, start a fresh chat. The AI uses the whole conversation as context, and an old discussion about an unrelated feature can confuse or dilute its answers about your new task.
Press Cmd+N (or Cmd+R) to start a new chat, or click the new chat button at the top of the panel. If you want to keep the old conversation visible, open a new chat tab with Cmd+T instead.
A good habit: new task, new chat. It keeps conversations focused and answers relevant.
Referencing Previous Conversations
Cursor saves your chat history so you can revisit older conversations from the history list. You can also pull a past conversation into a new one with the @Chats mention. For active work, a fresh, focused chat usually works better than a long old one.
Tips for Writing Good Prompts
The quality of your prompts directly affects the quality of the answers. A few habits that consistently help:
Be Specific About What You Want
Instead of: "fix this"
Try: "this function throws a TypeError when user is undefined. Add a null check and return an empty array in that case"
Specific prompts leave less room for unhelpful answers.
Include the Relevant Constraints
The AI does not automatically know your project's conventions unless you have set up rules (covered later in the course). Mention what matters:
- "Add error handling using our standard pattern: try/catch that logs to our logger and throws a custom AppError"
- "Write this in the functional style we use elsewhere, no classes"
Ask for One Thing at a Time
Multi-part requests work, but they raise the chance of one part being handled poorly. If you need several things, break them into follow-up messages. It is a conversation, so you do not need to pack everything into one prompt.
Request Explanations Alongside Code
If you want to understand what was generated, ask for it:
- "Show me the function and explain why you structured it that way"
- "Add inline comments explaining the non-obvious parts"
This turns the panel into a learning tool as well as a coding tool.
Use Ask Mode to Sanity-Check Your Own Code
Before committing, ask the AI to review what you wrote:
- "Does this look correct? Are there any edge cases I am missing?"
- "Is there a more idiomatic way to write this in TypeScript?"
- "Would this function handle concurrent calls correctly?"
Summary
The Agent side panel (Cmd+L or Cmd+I) is your always-available AI collaborator inside Cursor. It has three main modes that you cycle with Shift+Tab: Agent acts, Ask answers in read-only mode, and Plan researches and writes a plan before building. Ask mode is the safe way to explore code, ask questions, generate snippets, and build understanding without any changes to your files. The panel uses your current file and selection as context, and the agent can search the rest of your codebase on its own.
The habits to build: start with a specific question, give the AI the context it needs, read generated code before applying it, and start a new chat when you switch tasks.
Key Takeaways
- Press Cmd+L or Cmd+I (Ctrl on Windows/Linux) to toggle the Agent side panel without leaving your editor
- The panel has three main modes: Agent (default, edits files and runs commands), Ask (read-only), and Plan (researches and writes a plan first). Press Shift+Tab to switch
- Ask mode explains and suggests but does not change your files unless you click Apply, so it is the safe choice when you want to stay in control
- The panel uses your current file and any selected code (Cmd+Shift+L) as context, and the agent can search your codebase for more
- Use Ask mode to explain unfamiliar code, generate boilerplate, sketch functions, and sanity-check your own code
- Start a new chat (Cmd+N or Cmd+R) when switching tasks to keep the AI's context clean
- Better prompts mean better answers: be specific, include constraints, ask for one thing at a time, and request explanations with generated code

