Review AI-generated code edits

When you interact with chat in Visual Studio Code, the agent can generate code edits across multiple files in your project. This article explains how to review, accept, or discard these AI-generated code edits.

Note

You can review AI-generated edits in both the Chat view and the Agents window. The review experience follows the same concepts but the user interface might differ between the two surfaces.

Pending changes

After the agent updates your files, VS Code applies and saves the edits to disk. VS Code keeps track of which files have pending edits and lets you review them individually or all at once.

In the Agents window, the dedicated Changes panel lists the edited files and shows their diff stats. Select a file to open its diff view.

Screenshot showing the Changes panel in the Agents window, highlighting the Changes and Files tabs and the list of edited files.

For more information about the Changes panel, see Manage and review file changes.

When you close VS Code, the status of the pending edits is remembered and restored when you reopen VS Code.

Review changes

How you review AI-generated edits depends on which surface you use. In the Chat view, you review edits directly in the editor. In the Agents window, you review edits in the dedicated Changes panel.

In the Agents window, you review edits in the dedicated Changes panel instead of the editor overlay:

  1. Select a file in the Changes tab to open a diff view of the agent's edits.

    Screenshot showing the Changes panel in the Agents window, highlighting the list of edited files and the diff view.

    By default, selecting a file opens a multi-file diff editor with all the changes. To open a focused single-file diff editor for the selected file instead, enable the sessions.changes.openSingleFileDiff Open in VS Code Open in VS Code Insiders setting.

  2. Select Add Feedback in the diff view to comment on a specific edit and signal the agent to make adjustments.

    Screenshot showing the Add Feedback button in the Changes diff view.

  3. Use the Commit, Merge, Checkout, or Discard actions to act on the edits.

For more information, see Manage and review file changes.

Source Control integration

If you stage your changes in the Source Control view, any pending edits are automatically accepted. If you discard your changes, any pending edits are also discarded.

Auto-accept edits

You can configure VS Code to automatically accept AI-generated code edits after a configurable delay with the chat.editing.autoAccept Open in VS Code Open in VS Code Insiders setting. Hover over the editor overlay controls to stop the auto-accept countdown.

Important

If you automatically accept all edits, review the changes before you commit them in source control. Learn more about the security considerations of using AI in VS Code.

Edit sensitive files

To prevent inadvertent edits to sensitive files, such as workspace configuration settings or environment settings, VS Code prompts you to approve edits before they are applied. In chat, you can see a diff view of the proposed changes and choose to approve or reject them.

Use the chat.tools.edits.autoApprove Open in VS Code Open in VS Code Insiders setting to configure which files require approval. The setting uses glob patterns to match file paths in your workspace.

The following example configuration automatically allows edits to all files except for JSON files in the .vscode folder and files named .env, which you are prompted to approve:

"chat.tools.edits.autoApprove": {
  "**/*": true,
  "**/.vscode/*.json": false,
  "**/.env": false
}

Review file changes from the sessions list

When a session completes and makes code changes to your project, the sessions list shows the file change statistics for that session. To review the changes, select the session from the list to open the session details.

Screenshot of the file changes diff editor in an agent session.

Depending on the agent type, you have options to apply the changes to your local workspace, or to check out the branch from the session (for cloud agents).