# AZD: Review pull requests with AI

> For the complete documentation index, see [llms.txt](https://edgafner.github.io/llms.txt).

> **TL;DR**
> Start: `Pull Request Actions (⋮) | Review with AI` in the pull request details
>
>
>
> Requires: Enable AI assistance in `Settings | Version Control | AZD | AI Settings`
>
>
>
> MCP tools require Node.js

AZD offers four ways to review a pull request with AI:

* [AI Chat](#ai-chat) analyzes the whole pull request and answers your follow-up questions.

* [AI Auto Review](#ai-auto-review) finds issues and walks you through them in the diff, one decision at a time.

* [AI draft comments](#ai_draft_comments) are draft comments that AI adds to the file that you are viewing.

* [Generate AI Code Review](#ai_generated_comments) writes one comment for the lines you select.

AI never posts a comment or casts a vote without your action.

## Before you start

These features work with the built-in AZD provider without any setup. To use your own OpenAI, Claude, Gemini or Ollama model, see [Configure AI providers](azd-ai.html#ai-providers). For what data AZD sends, see [Data and privacy](azd-ai.html#ai-privacy).

## Chat about a pull request

AI Chat sends the changes of the pull request to the AI provider and opens the answer in a chat tab.

Procedure: Start AI Chat

1. In the pull request details, right-click the changed files tree and select `Review with AI | AI Chat`, then a provider. In the Pull Request Actions (⋮) menu, `Review with AI | AI Chat` always uses the active provider.

2. Wait for the analysis. It appears in the AI Review (!N) - provider tab of the AZD Pull Requests tool window.

3. Type a follow-up question in the Ask about the Pull Request field and click Send. Click Stop to cancel an answer.

Keep the chat open to ask more questions about the pull request. To attach a file or image to a question, the active model must accept images. Otherwise, the attach button shows Current Model Does Not Support File Attachments. The built-in AZD provider is text-only.

## Run AI Auto Review

AI Auto Review analyzes the pull request, then shows each finding as a card next to the code in the diff. For each finding, you decide whether to keep it as a draft, post it, or skip it.

In the right-click menu of the changed files tree, AI Auto Review appears only when AI assistance is on, the Diff Comment Review prompt is enabled, at least one provider is enabled and you are a reviewer of the pull request. The comments it creates are authored by you.

Procedure: Review a pull request with AI Auto Review

1. In the pull request details, click Pull Request Actions (⋮) and select `Review with AI | AI Auto Review`, then a provider.

2. Wait for the analysis. The AI Code Review card reports how many issues AI found, for example AI found 3 issue(s) across 2 file(s). Choose how to continue:

Start (Step by Step)
: Go through the findings one by one.

Just Post All
: Post all findings as comments after a confirmation. Posted comments cannot be undone.

Create Drafts for All
: Save all findings as draft comments that only you see.

Skip
: Close the review without creating comments.

3. For each finding, read the card in the diff. The severity is risk, high, medium or low. Click Save as Draft, Post Comment Now or Skip This Issue. To stop early, click End Tour. You can drag a card to move it.

4. In the Review Complete card, check the suggested stance and your decisions. When you vote here, AZD first publishes all your draft comments. Click Approve or Request Changes to vote, or Just Close to finish without voting. Request Changes votes Wait For Author.

If you end the tour without voting, the drafts that you saved stay unpublished. To publish them, see [Review with draft comments](azd-pr-comments.html#draft-comments).

Only one AI Auto Review can run in a project at a time. To show a cover image on the first card, select Show illustrations in AI review tour in `Settings | Version Control | AZD | AI Settings`.

## Generate draft comments for a file

Procedure: Let AI draft comments for the open file

1. Open the diff of a file in the pull request.

2. On the diff toolbar, click the AI button (Post Draft Comments with AI). To use another provider, click the arrow next to the button and select it.

3. Check the AI draft at the top of the file. It lists the issues that AI found in the file, grouped by severity, with a suggestion where AI has one. The draft has a PENDING tag and shows the highest severity of its issues. AZD adds one AI draft per file and does not add another while it exists. Edit or delete the draft as needed.

4. Click Post now on a draft, or Submit Comments on the toolbar to publish all drafts.

For more about drafts, see [Review with draft comments](azd-pr-comments.html#draft-comments).

## Generate a comment for selected lines

Procedure: Let AI write a review comment

1. In the diff, select the lines and start a new comment.

2. In the comment editor, click the AI button (Generate AI code review for this change).

3. In the Generate AI Code Review dialog, set Context lines, the number of lines above and below that AI reads. Check the Code context preview.

4. Optional: enter a Review Focus, such as "error handling". AZD adds it to the Diff Comment Review prompt. To replace the Diff Comment Review prompt with your own instructions, clear Use default prompt template. AZD then sends your Review Focus text and the selected code.

5. Click Generate Review, then edit the text in the comment editor and post it.

## Customize AI reviews

* For a single comment, use Review Focus in the Generate AI Code Review dialog.

* To change the default instructions of that dialog, edit the Diff Comment Review prompt; see [Configure prompts](azd-ai.html#configure-prompts).

* In AI Chat, ask follow-up questions to focus the review on what matters to you.

## Let AI act on Azure DevOps with MCP tools

With MCP tools, AI Chat can use the Azure DevOps MCP server to read and change data in your organization, for example to create work items, manage pull requests or run pipelines. AZD bundles the server and loads its core, work item, repository and pipeline tools.

> **Warning:**
> When you click Allow in the Azure DevOps MCP Authentication Required prompt, AI Chat can use every MCP tool without asking you first, including the tools that change data or run pipelines. To stop AI Chat from using the tools, clear Enable MCP Tools.

Procedure: Turn on MCP tools

Install [Node.js](https://nodejs.org) first; AZD runs the MCP server with it. If AZD does not find Node.js, enter its location in Node.js Path; see [Set up Node.js for the language server](azd-pipeline-yaml.html#yaml-nodejs).

1. In `Settings | Version Control | AZD | AI Settings`, select Enable MCP Tools and click OK.

2. Start AI Chat on a pull request. The chat shows Azure DevOps MCP Authentication Required.

3. Click Allow. AZD starts the server and opens the browser, where you sign in with your Microsoft account.

The permission lasts until you restart the IDE, for up to 8 hours and only for the same Azure DevOps organization. After that, AZD asks again. If you click Deny, or if the server cannot start, AZD clears Enable MCP Tools.

## Troubleshooting

Review with AI is missing
: Select Enable AI assistance in `Settings | Version Control | AZD | AI Settings`.

AI Auto Review or the AI draft button is missing or disabled
: Enable the Diff Comment Review prompt under Configure Prompts, and make sure that at least one provider is enabled. In the right-click menu, AI Auto Review also requires that you are a reviewer of the pull request.

A review tour is already in progress
: Finish or skip the AI Auto Review that is already running. The message names its pull request.

AI-Review error: PR has N files, but maximum supported is 200
: AI Auto Review handles pull requests with up to 200 changed files. For a larger pull request, AZD also shows AI found no issues to discuss, although AI did not review it. To use AI on a larger pull request, generate draft comments one file at a time; see [Generate draft comments for a file](#ai_draft_comments).

AI found no issues to discuss
: AI Auto Review found nothing to comment on; no comments are created.

A provider fails
: Open the provider in the AI Providers table and click Test Connection.

## See also

### Related topics

[AZD: AI assistant](azd-ai.html) [AZD: Comment and suggest changes](azd-pr-comments.html) [AZD: Vote, complete and merge](azd-pr-complete.html) [AZD: Generate titles, descriptions and commit messages](ai-title-description-generation.html)

### Useful resources

[Azure DevOps MCP server (GitHub)](https://github.com/microsoft/azure-devops-mcp) [AZD on JetBrains Marketplace](https://plugins.jetbrains.com/plugin/22319-azd)

