AI smart actions in Visual Studio Code
AI agents: See llms.txt for documentation discovery and navigation. Documentation articles are also available as Markdown by appending .md to the article URL. Join VS Code at Microsoft Ignite or catch the sessions online. A year of VS Code, wrapped. Explore the highlights. AI smart actions in Visual Studio Code View as Markdown Ask in VS Code Ask in VS Code Insiders Use smart actions for focused AI assistance while you work in the editor, terminal, or Source Control view.
Start from an action in the interface instead of writing an initial chat prompt, then review the explanation, suggested command, or code changes it produces. Choose an action Your task Action Where to start Understand a code selection Explain Editor context menu Fix a reported coding error Fix Editor context menu or Code Action Choose a better symbol name Generate New Name Suggestions Rename Symbol input Describe an image for screen readers Generate or refine alt text Code Action on a Markdown image Investigate a failing test Fix Test Failure Test Explorer Diagnose a failed command Explain or fix using Copilot Terminal Quick Fix Review code before committing Review Editor or Source Control view Draft a commit message or PR details Generate text from changes Source Control or GitHub Pull Requests extension Resolve a Git conflict Resolve Conflicts with AI Conflicted file in the editor Find code by meaning Search with AI Search view Find a setting from a description Show AI-recommended results Settings editor Before you start Set up GitHub Copilot and open your project.
The available actions depend on your account, enabled features, and the current context, such as a selection, diagnostic, failing test, or Git change. Language-aware actions such as renaming also depend on your project's language support. PR actions require the GitHub Pull Requests extension, and reviewing uncommitted changes requires access to Copilot code review. Some actions open chat or edit files. Inspect their results before you keep or commit changes, and review any proposed command before running it.
If an action doesn't match your task, write your own prompt . Explain code Use Explain when you want to understand a function or unfamiliar block before changing it. Open the source file and select the code you want to understand. Right-click the selection and select Explain . Read the explanation and ask follow-up questions if needed. Check the explanation against the source. An explanation isn't evidence that the code behaves correctly at runtime.
Fix coding errors Use Fix for a reported problem, such as a compiler error or lint warning. Select the code containing the diagnostic. Right-click and select Fix , or open the Code Action (lightbulb) menu and choose the AI Fix action when available. Inspect the resulting diff, then rerun the relevant build, lint check, or test to verify the fix. If the code produces incorrect results without a diagnostic, provide a reproduction and expected behavior in chat.
Follow the workflow to investigate and fix a bug in your project . Rename symbols Use AI name suggestions when a symbol's current name doesn't communicate its purpose. Place the cursor on the symbol and run Rename Symbol ( F2 ). Select Generate New Name Suggestions (sparkle icon) in the rename input if suggestions aren't already shown. Choose a suggestion or edit it, then confirm the rename. Review the changed references to ensure the name fits the symbol's role.
Automatic suggestions depend on your account and the github.copilot.renameSuggestions.triggerAutomatically Open in VS Code Open in VS Code Insiders setting. You can request suggestions with the sparkle action when it is available. Generate alt text for images in Markdown Use AI to draft an image description, then check it against the image and the surrounding document. Open a Markdown file and put the cursor on an image link.
Open the Code Action (lightbulb) menu and select Generate alt text . If the image already has alt text, select Refine alt text . Review the generated description for accuracy, useful context, and unnecessary detail before keeping it. The action provides the image as context to inline chat. Verify that the description communicates the image's purpose in your document rather than accepting every detail the model suggests.
Fix testing errors Use a failing test as the starting point for an investigation, while preserving the behavior its assertions are meant to check. In the Test Explorer, hover over a failing test. Select Fix Test Failure (sparkle icon). Review the proposed test and implementation changes, then rerun the failed test and related tests. Before accepting a fix, identify whether the failure comes from test setup, an incorrect expectation, or an implementation bug .
Don't weaken assertions solely to obtain a passing result. If the action isn't available, attach the failure output and expected behavior to a request in the Chat view. Fix terminal errors When shell integration detects a failed command that matches a Quick Fix provider, the terminal can offer AI assistance. Select the Quick Fix (sparkle) icon beside the command. Choose Explain using Copilot to investigate the failure, or Fix using Copilot to get suggested commands.
Review the explanation or proposed command, including its arguments and working directory, before running anything. Run the appropriate command and check the result. Not every failure has a Quick Fix. If none appears, provide the command, relevant output, and expected result in chat. Review code Review a selection for focused feedback, or review local Git changes before committing them. AI review can miss issues and doesn't replace running tests.
Review a code selection Open the source file and select the code you want to review. Right-click and select Review . Inspect the comments in the Comments panel and inline in the editor. Use the comment actions to apply or discard suggestions. Review any edits and run the relevant checks. Review uncommitted changes This workflow requires access to Copilot code review. Check the code review requirements . You don't need to create a pull request or install the GitHub Pull Requests extension to use the Source Control review actions.
Open the Source Control view ( ⌃⇧G (Windows, Linux Ctrl+Shift+G ) ) in your Git repository. Choose the scope to review: Hover over Staged Changes and select Code Review - Staged Changes . Hover over Changes and select Code Review - Unstaged Changes . Use Code Review - Uncommitted Changes in the Source Control title bar, when available, to review both. Follow the findings to the affected code and inspect each suggestion before applying it.
Rerun the relevant tests after making changes. Applying a suggestion doesn't commit it. A useful pre-commit workflow is to review local changes, inspect suggestions, and rerun tests. Then stage only the changes you intend to include and generate a commit message for that scope. For reviews on GitHub pull requests, follow the GitHub Copilot code review guide . Generate a commit message and PR information Use generated text as a draft that summarizes your verified changes, not as a substitute for reviewing them.
Generate a commit message Review your changes and stage the files or ranges you intend to commit. In the Source Control view, select Generate Commit Message (sparkle icon) beside the message input. Review and edit the generated message, then commit when you are ready. If staged changes exist, generation uses those changes. Otherwise, it uses working-tree and untracked changes. The action fills the message input. It doesn't stage files or create a commit.
Generate pull request details Install and sign in to the GitHub Pull Requests extension , then start creating a pull request . Select the sparkle icon next to the PR title field to generate a title and description. Review the draft against the changes and add context that a diff doesn't explain, such as the reason for the change or how you v
The rest of this page is on the live site.