Add context to chat
Providing relevant context helps the AI give more accurate responses. Add files, folders, editor selections, images, GitHub items, web URLs, and browser content directly to your prompt when you want the AI to consider specific details.
Unless otherwise noted, the features on this page work in Copilot harness sessions across both the Chat view and the Agents window. For context pickers that apply only to the deprecated Local harness, see Local harness context options (Deprecated).
For background on what context is and how VS Code assembles it, see Context concepts.
Attach context with #-mentions and Add Context
You can explicitly add context to your prompt by typing # followed by the file, folder, or #selection you want to mention, or by selecting Add Context (+ icon) in the chat input to open the context picker. You can also paste stack traces, terminal output, or code snippets directly into the chat input, where VS Code attaches large pasted blocks cleanly as text context.

For a full reference of context items and legacy Local tool names, see the Tools and context reference.
Add files and folders as context
Agents can use workspace search and file-reading tools to gather relevant context automatically. A workspace index helps locate code, but doesn't attach every file to the conversation. Add specific files, folders, or editor selections when you know which sources the agent should consider:
-
Type
#followed by a file or folder name to mention it in your prompt, or type#selectionto attach the code currently selected in the active editor. -
Drag and drop files or folders from the Explorer view, Search view, or editor tabs onto the Chat view to add them as context.
-
Select Add Context (
+icon) and then Files & Folders to pick workspace items, or Files to choose files from anywhere on disk.
To request a broad search across the repository, describe what you want the agent to find in your prompt. See workspace search and indexing for how agents search your project.
Attach files from disk
Use the file chooser to attach files outside your workspace, such as a log file, screenshot, or UI mockup from your desktop. You don't need to add their folder to the workspace or open a workspace first.
-
Select Add Context (
+icon) > Files in the chat input. -
Choose one or more files, including text files or supported images, and then select Attach.
-
Confirm that the attachments appear in the chat input, then enter a prompt about them.
If the selected session supports only image attachments, Files filters the chooser to supported images. It doesn't enable ordinary local-file transfer for those sessions.
In sandboxed Copilot harness sessions, attaching a file can grant read access for the session without changing sandbox settings. It doesn't grant write permission or override organization restrictions. See Read attached files and folders.
Add project, session, and GitHub context
When you start a session in the Agents window, the first folder or repository you select is the primary execution workspace. It determines where the agent runs and changes files.
You can attach project, session, and GitHub context to a request:
-
In the Agents window, select Folder or Repository to attach another project. An attached project provides request context and doesn't become another workspace root.
-
In any chat input, select Add Context (
+icon), and then select Issue or Pull Request. If multiple GitHub repositories are available, select a repository before you choose the issue or pull request. -
Paste a GitHub issue or pull request URL directly into the prompt. VS Code automatically adds the item as a context attachment.
-
Select Add Context (
+icon) > Sessions to attach a previous compatible Copilot session as context.
You can attach multiple items. The attachments are preserved in a draft and included when you send the request. Learn more about starting an agent session in the Agents window.
With chat.inlineAttachments.enabled enabled (Experimental, on by default), attached context such as files, folders, images, and pull requests appears as inline pills inside your prompt text instead of above the input. For GitHub items in the Chat view, hover over a pill or highlight it with the arrow keys to preview its title, status, and description. Select it or press Enter while highlighted to open the item without sending the draft, or press Escape to dismiss the preview.
Reference content from the web
You can reference web pages in your chat prompts, for example to check the latest API reference or migration guide.
Include the URL directly in your prompt and describe what you want the agent to check. For example:
"Summarize the breaking changes in https://learn.microsoft.com/en-us/aspnet/core/migration/80-90 and check whether this project is affected."
VS Code prompts for confirmation before accessing external URLs to protect your privacy and security. Learn more about configuring URL auto-approval and using tools with agents.
Vision
Chat supports vision capabilities, which means you can attach an image as context to your chat prompt and ask questions about it. For example, attach a screenshot of a block of code and ask to explain it, or attach a sketch of a UI and ask the agent to implement it.
Select a model that supports images to ask questions about visual content. Vision analyzes image input and doesn't generate image output. To generate an image or ask an image model to edit one, use image generation in a Copilot harness session. To highlight details yourself before sending an image, mark up the attachment.
You can drag and drop an image from a web browser onto the Chat view to add it as context.
Capture the VS Code window
On desktop, capture the whole VS Code window or a selected area without saving an image file first:
- Select a model that supports images. Screenshot Window is only available when the selected model and session support image attachments.
- In the chat input, select Add Context (
+icon) > Screenshot Window. - When the cursor becomes a camera, select anywhere in the window or press Enter to capture the whole window. Drag to capture an area instead. Press Escape to cancel.
The screenshot is attached to the chat input. Add a prompt describing the problem or change you want, then send it.
Capture another app window
On desktop, attach a screenshot of another app, such as a browser or simulator, to show the agent what you're building.
- Enable chat.appWindowScreenshots.enabled if needed. It is on by default in Insiders and off by default in Stable.
- Focus the chat input where you want the screenshot, then switch to the app you want to capture.
- Press ⌃⌘S (Windows, Linux Ctrl+Shift+Alt+S). VS Code comes to the front with the screenshot attached. If you use the shortcut while VS Code is in front, it captures the app window you just left.
The shortcut works system-wide while the feature is enabled. To choose a window instead, select Add Context > Screenshot App Window, or run Chat: Pick App Window to Screenshot from the Command Palette.
On macOS, follow the setup dialog to grant Screen Recording permission, then restart VS Code. On Wayland, choose the window in the system's window picker.
The shortcut attaches to the chat input that last had focus. In the Agents window, this can differ from the session selected in the sessions list. Confirm the destination before sending.
Mark up an image
On desktop, draw, add shapes, arrows, or text, and crop any image attached to the chat input. This works for screenshots and for images you paste or drop into chat.
- Select Mark Up (pencil icon) at the end of the image attachment. Alternatively, open the image preview and select Mark Up in its toolbar.
- Use the drawing and crop tools to highlight the relevant details.
- Select Done to update the attached image, then add your prompt and send it.
Taking a screenshot or marking up an image doesn't send a chat request. Review the image for sensitive content before sending it.
Add browser context
Use the integrated browser to preview web pages and attach information from the current page to a prompt.
The browser toolbar has an Add to Chat split button with actions that let you attach different types of context from the current page to your chat prompt:
- Add Element to Chat: select HTML elements from the page to add as context, including their CSS styles and screenshots.
- Add Screenshot to Chat: capture a screenshot of the current browser viewport and attach it as an image.
- Add Console Logs to Chat: capture console output from the page and attach it as context for debugging runtime errors.
Learn how to add browser context to chat. To let an agent interact with a page instead of attaching it as prompt context, see browser tools for agents.
Local harness context options (Deprecated)
The Local harness is deprecated and will be removed. The following context pickers and mentions apply only to Local harness sessions and aren't supported in the default Copilot harness:
| Local-only context option | What to use in the Copilot harness |
|---|---|
Tool #-mentions (#codebase, #fetch, #read/..., Add Context > Tools) |
Describe what you want in natural language or paste a URL directly so the agent selects its built-in tools. |
Code symbols (#<symbol>, Add Context > Symbols) |
Attach the file (#<file>) or select the code in the editor and use #selection. |
| Terminal output (Add Context > Terminal, terminal command decorations) | Copy and paste terminal output into the prompt, attach a log file with Add Context > Files, or ask the agent to run the command directly. |
| Source Control changes (Add Context > Source Control, Graph Add to Chat) | Mention the commit SHA, branch, or uncommitted changes in your prompt so the agent inspects them with Git. |
| Problems, Search Results, Open Editors, and Instructions picker | Ask the agent to inspect current errors or workspace files directly, or attach the specific files you want it to check. |
@-mentions (Chat participants) |
Ask Copilot directly with relevant files, or use plugins, skills, MCP servers, or extension tools. See Replace chat participants. |
Plan to move from the Local to the Copilot harness before the Local harness is removed.
Next steps
- Adapt a prompt to your project with relevant files, errors, and expected results.
- Explore a codebase and verify the explanation against source references.
- If the response misses your intent, get the agent back on track with focused feedback or a fresh conversation.