Skip to content
| Marketplace
Sign in
Azure DevOps>Azure Pipelines>Copilot Code Review
Copilot Code Review

Copilot Code Review

Little Fort Software

|
1,331 installs
| (6) | Free
Automated pull request code reviews powered by agentic AI. Get feedback on your PRs directly in Azure DevOps by leveraging the official GitHub Copilot CLI or Claude Code.
Get it free

Copilot Code Review for Azure DevOps

Azure DevOps Marketplace License: GPL v3

Automated pull request code reviews powered by the official GitHub Copilot CLI or Claude Code CLI. Get automated feedback on your PRs while leaving your code hosted in Azure DevOps repos.

Overview

This Azure DevOps extension provides a pipeline task that automatically reviews pull request code changes using GitHub Copilot or Claude Code. When triggered, the task:

  1. Fetches pull request details, changed files, and linked work item details from Azure DevOps
  2. Invokes the configured CLI agent (GitHub Copilot or Claude Code) to analyze the changes
  3. Posts review comments directly to the pull request

This brings AI-powered code review capabilities to Azure DevOps, helping teams improve code quality through AI-assisted reviews.

Pull Request with comments generated by Copilot

Prerequisites

This extension supports Windows and Linux Azure DevOps agents. Compatible with MS-hosted and self-hosted agents. Before using, ensure you have:

  • AI Agent (one of the following):
    • GitHub Copilot (default): An active GitHub Copilot subscription and a GitHub PAT with Copilot access permissions
    • Claude Code: An Anthropic API key with access to Claude Code, or a Claude subscription OAuth token generated with claude setup-token
  • Azure DevOps Authentication (one of the following):
    • System Access Token (Recommended): Use the pipeline's built-in OAuth token for Azure DevOps Services. Must grant permissions to Build Service Identity (see below).
    • Personal Access Token: Required for Azure DevOps Server (on-prem) or if you prefer explicit token management. Needs permissions to read pull requests, write comments, and read code.
  • PowerShell 7+: This extension requires PowerShell 7 or later (pwsh) to be installed on the agent. PowerShell 7 is pre-installed on Microsoft-hosted agents.

Installation

  1. Install the extension from the Azure DevOps Marketplace
  2. Navigate to your Azure DevOps organization settings
  3. Go to Extensions and verify the extension is installed

Usage

Using System Access Token

The recommended approach for Azure DevOps Services uses the pipeline's built-in System Access Token and a personal access token for a GitHub account with Copilot access:

trigger: none

pool:
  vmImage: 'ubuntu-latest'  # or 'windows-latest'

steps:
- checkout: self
  fetchDepth: 0

- task: CopilotCodeReview@1
  displayName: 'Copilot Code Review'
  inputs:
    githubPat: '$(GITHUB_PAT)'
    useSystemAccessToken: true

IMPORTANT: When using useSystemAccessToken, ensure the Build Service identity has "Contribute to pull requests" permission on your repository. See Granting Build Service Permissions below.

Using Personal Access Token

For Azure DevOps Server (on-prem) or if you prefer explicit token management:

trigger: none

pool:
  vmImage: 'ubuntu-latest'  # or 'windows-latest'

steps:
- checkout: self
  fetchDepth: 0

- task: CopilotCodeReview@1
  displayName: 'Copilot Code Review'
  inputs:
    githubPat: '$(GITHUB_PAT)'
    azureDevOpsPat: '$(AZURE_DEVOPS_PAT)'

Using Claude Code CLI

To use Claude Code instead of GitHub Copilot, enable useClaudeCode and provide an Anthropic API key (or a Claude Code OAuth token):

trigger: none

pool:
  vmImage: 'ubuntu-latest'  # or 'windows-latest'

steps:
- checkout: self
  fetchDepth: 0

- task: CopilotCodeReview@1
  displayName: 'Claude Code Review'
  inputs:
    useClaudeCode: true
    anthropicApiKey: '$(ANTHROPIC_API_KEY)'
    useSystemAccessToken: true
    model: 'sonnet'
    maxTurns: '50'
    maxBudget: '5.00'

NOTE: Claude Code CLI is installed automatically via npm install -g @anthropic-ai/claude-code. Node.js is available on all Azure DevOps agents. Output is streamed to the pipeline logs in real time.

TIP: To bill reviews against a Claude subscription (Pro/Max/Team/Enterprise) instead of Anthropic API usage, run claude setup-token locally to generate a long-lived OAuth token, store it as a secret pipeline variable, and pass it via claudeCodeOAuthToken instead of anthropicApiKey. Provide one or the other — not both.

Set Trigger

Use branch policies on your protected branches to specify the pipeline as a build validation that must finish before the PR can be completed:

Branch policy with code review trigger

With Custom Prompt

You can customize the review prompt to focus on aspects tailored to your needs:

- task: CopilotCodeReview@1
  displayName: 'Copilot Code Review'
  inputs:
    githubPat: '$(GITHUB_PAT)'
    useSystemAccessToken: true
    prompt: |
      Review this code focusing only on:
      - Security vulnerabilities
      - Performance bottlenecks
      - Code simplification
      Avoid lengthy explanations, keep comments concise and direct.

For longer custom prompts, create a .txt file in your repository and pass the file path as a task input:

- task: CopilotCodeReview@1
  displayName: 'Copilot Code Review'
  inputs:
    githubPat: '$(GITHUB_PAT)'
    useSystemAccessToken: true
    promptFile: '$(Build.SourcesDirectory)/.copilot/review-prompt.txt'

If your prompt tells the agent how to post comments, have it write the text to a file in the working directory and pass the file with -CommentFile: during a review the comment scripts refuse text passed inline with -Comment (see Security Model).

Manual Trigger for Specific PR

If you don't want to setup an automatic trigger, you can instead set up a pipeline with a Pull Request ID parameter to run reviews on demand:

parameters:
  - name: pullRequestId
    displayName: 'Pull Request ID'
    type: string
    default: ''

trigger: none

pool:
  vmImage: 'ubuntu-latest'

steps:
  - checkout: self
    fetchDepth: 0

  - task: CopilotCodeReview@1
    displayName: 'Copilot Code Review'
    inputs:
      githubPat: '$(GITHUB_PAT)'
      useSystemAccessToken: true
      pullRequestId: '${{ parameters.pullRequestId }}'

Input Reference

Input Required Default Description
githubPat Conditional - GitHub Personal Access Token with Copilot access. Required when using GitHub Copilot CLI with GitHub-hosted models (default). Optional when useCustomModelProvider is true.
githubHost No - GitHub Enterprise hostname (e.g., subdomain.ghe.com) for enterprise accounts with data residency (see GitHub Enterprise Accounts)
useClaudeCode No false Use Claude Code CLI (Anthropic) instead of GitHub Copilot CLI
anthropicApiKey Conditional - Anthropic API key (API usage billing). Provide this or claudeCodeOAuthToken when useClaudeCode is true.
claudeCodeOAuthToken Conditional - Claude Code OAuth token from claude setup-token (subscription billing). Provide this or anthropicApiKey when useClaudeCode is true.
maxTurns No - Maximum agentic turns for Claude Code CLI
maxBudget No - Maximum cost in USD for a Claude Code session
useCustomModelProvider No false Use a custom model provider (BYOK) with the GitHub Copilot CLI instead of GitHub-hosted models (see Custom Model Providers)
copilotProviderBaseUrl Conditional - Base URL of the custom provider's API endpoint. Required when useCustomModelProvider is true.
copilotProviderType Conditional - Custom provider type: openai, azure, or anthropic. Required when useCustomModelProvider is true.
copilotProviderApiKey No - API key for the custom provider. Optional for providers that do not require authentication (e.g., a local Ollama instance).
useSystemAccessToken No false Use pipeline's System.AccessToken instead of a PAT (recommended for Azure DevOps Services)
azureDevOpsPat Conditional - Azure DevOps PAT for API access. Required if useSystemAccessToken is false.
organization No $(System.CollectionUri) (inferred) Azure DevOps organization name for cloud-hosted teams
collectionUri No $(System.CollectionUri) Azure DevOps collection URI for on-prem instances
project No $(System.TeamProject) Azure DevOps project name
repository No $(Build.Repository.Name) Repository name
pullRequestId No $(System.PullRequest.PullRequestId) PR ID (auto-detected in PR builds)
timeout No 15 Timeout in minutes
model Conditional - Preferred model to use (see valid options below). Required when useCustomModelProvider is true.
reasoningEffort No model default Reasoning effort level to balance review depth against token spend. Copilot: none, minimal, low, medium, high, xhigh, max. Claude Code: low, medium, high, xhigh, max. If the selected model doesn't support the requested level, the CLI fails with a clear error rather than silently ignoring it.
promptFile No - Path to custom prompt file
prompt No - Inline custom prompt (overrides promptFile)
promptFileRaw No - (Advanced) Path to custom prompt file that will be passed as-is with no supportive direction.
promptRaw No - (Advanced) Inline custom prompt that will be passed as-is with no supportive direction.
authors No - Comma-separated list of email addresses to filter reviews (see below)
includeWorkItems No true Fetch and include linked work item details as review context
jiraBaseUrl No - Jira Cloud site URL (e.g., https://yourorg.atlassian.net). With jiraEmail + jiraApiToken, work items are fetched from Jira instead of Azure Boards (see Jira Work Items)
jiraEmail Conditional - Atlassian account email for the API token. Required when jiraBaseUrl is set.
jiraApiToken Conditional - Jira Cloud API token. Required when jiraBaseUrl is set.
jiraProjectKeys No - Comma-separated Jira project keys (e.g., PROJ,CORE) to restrict issue key lookup
jiraCustomFields No - Comma-separated Jira custom fields to include as review context, by display name or ID (see Jira Work Items)
resolveThreads No all Which existing comment threads the agent may resolve: all or agentOnly (see Review Behavior Options)
suppressPositiveFeedback No false Skip praise/"looks good" comments — post nothing when no issues are found (see Review Behavior Options)
maxMinorIssues No 5 Cap on Minor-severity findings in the consolidated minor-suggestions comment per pass; 0 suppresses Minor findings. Critical/Major findings are never capped.
diffOnlyReview No false Restrict the review to only the PR diff (see Diff-Only Review Mode)
skipReviewedIterations No true Finish immediately when this review configuration already reviewed the PR's current iteration; set false to force a fresh review (see Incremental Re-Reviews)
ignoreCustomInstructions No false Keep the repository's own instruction files (CLAUDE.md, AGENTS.md, .github/copilot-instructions.md, ...) and Copilot repository skills away from the agent (see Security Model)
autoUpdateCli No false Run copilot update / claude update on an already-installed CLI before the review; a failed update only logs a warning
publishPromptArtifacts No false Publish context files and the final prompt as pipeline artifacts for debugging

Copilot Models

As of November 2026 (Copilot CLI 1.0.105), these are the models GitHub Copilot offers in the CLI:

  • auto — lets Copilot pick the best available model for each request
  • claude-sonnet-5.5 (default)
  • claude-sonnet-5
  • claude-opus-5.5
  • claude-opus-5
  • claude-opus-4.8
  • claude-opus-4.8-fast (preview)
  • claude-fable-5.1
  • claude-fable-5
  • claude-haiku-5.5
  • claude-haiku-4.5
  • gpt-6.1-sol
  • gpt-6.1-terra
  • gpt-6-sol
  • gpt-6-luna
  • gpt-6-astra
  • gpt-5.6-sol
  • gpt-5.6-terra
  • gpt-5.6-luna
  • gpt-5.3-codex
  • gemini-4-argon
  • gemini-3.8-flash
  • grok-4.7
  • grok-4.6
  • kimi-k3
  • mai-code-1.1-flash

Model availability varies by Copilot plan and organization policy, so some models may still be rejected at runtime if your subscription doesn't include it. See supported AI models in Copilot for the full availability matrix.

Custom Model Providers

The GitHub Copilot CLI supports bring-your-own-key (BYOK) model providers, letting the review run against any OpenAI-compatible endpoint (including Ollama and vLLM), Azure OpenAI, or Anthropic instead of GitHub-hosted models. Enable it with useCustomModelProvider and supply the provider details:

- task: CopilotCodeReview@1
  displayName: 'Copilot Code Review'
  inputs:
    useCustomModelProvider: true
    copilotProviderBaseUrl: 'https://api.openai.com/v1'
    copilotProviderType: 'openai'
    copilotProviderApiKey: '$(OPENAI_API_KEY)'
    model: 'gpt-5.2'
    useSystemAccessToken: true

Notes:

  • model is required in this mode and must be a model identifier your provider serves.
  • copilotProviderApiKey may be omitted for providers that do not require authentication (e.g., a local Ollama instance on a self-hosted agent).
  • githubPat is optional in this mode. No GitHub authentication is needed to run the review against your own provider, but supplying a PAT additionally enables GitHub-backed CLI features such as code search.
  • reasoningEffort may be rejected for custom-provider models — the Copilot API is known to refuse reasoning parameters for BYOK models. If the review fails with a reasoning-related error, remove the reasoningEffort input.
  • The provider's model must support tool calling and streaming; a context window of at least 128k tokens is recommended. See GitHub's BYOK documentation for details.

Claude Code Models

As of August 2026, here are the model options supported by the Claude Code CLI:

Alias Description
default Recommended model setting, depending on your account type
best Uses Fable 5 where your organization has access to it, otherwise the latest Opus model
fable Uses Claude Fable 5, the most capable model for the hardest and longest-running tasks (requires organization access)
sonnet Uses the latest Sonnet model (currently Sonnet 5) for daily coding tasks
opus Uses the latest Opus model (currently Opus 5) for complex reasoning tasks
haiku Uses the fast and efficient Haiku model for simple tasks
sonnet[1m] Uses Sonnet with a 1 million token context window for long sessions (no effect when sonnet already resolves to Sonnet 5, which has a native 1M window)
opus[1m] Uses Opus with a 1 million token context window for long sessions
opusplan Special mode that uses opus during plan mode, then switches to sonnet for execution

Aliases always point to the latest version available to your account. To pin to a specific version, use the full model name (for example, claude-opus-5).

Author Filtering

Use the authors input to limit code reviews to PRs created by specific users. This is useful when you want to:

  • Only review code from certain team members (e.g. junior developers)
  • Exclude automated bot PRs from review
  • Limit Copilot usage to a subset of contributors
  • Use separate prompts/models for certain team members
- task: CopilotCodeReview@1
  displayName: 'Copilot Code Review'
  inputs:
    githubPat: '$(GITHUB_PAT)'
    useSystemAccessToken: true
    authors: 'alice@example.com, bob@example.com, charlie@example.com'

When configured:

  • The task compares $(Build.RequestedForEmail) against the provided email list
  • If the PR author's email matches any in the list, the review proceeds normally
  • If no match is found, the task completes successfully without running the code review
  • Email comparison is case-insensitive

Review Behavior Options

Three inputs tune how the review agent behaves across iterations. All of them apply to Copilot and Claude Code alike, and all work by adjusting the built-in review prompt — so none of them apply to raw prompt modes (promptRaw/promptFileRaw), where the prompt is passed through unmodified.

resolveThreads controls which existing comment threads the agent may resolve when a new iteration addresses them:

  • all (default) — the agent may resolve any thread the current changes clearly address, including threads opened by human reviewers, replying with an explanation before marking the thread fixed. This matches the behavior the extension has had since thread resolution was introduced.
  • agentOnly — the agent only resolves threads created by previous automated reviews. Threads opened by human reviewers are never touched.

suppressPositiveFeedback disables courtesy feedback. By default, a review that finds no issues posts a single "looks good to merge" comment; with this enabled, the agent posts nothing at all unless it has actionable feedback.

maxMinorIssues bounds low-severity noise. The review prompt instructs the agent to triage the full diff first, score every finding by severity (Critical/Major/Minor/Nit) and confidence, and then post: Critical and Major findings always get individual comments and are never capped, while high-confidence Minor findings are consolidated into a single compact "Minor suggestions" comment containing at most this many items (0 drops Minor feedback entirely). Nits and low-confidence speculation are never posted.

- task: CopilotCodeReview@1
  displayName: 'Copilot Code Review'
  inputs:
    githubPat: '$(GITHUB_PAT)'
    useSystemAccessToken: true
    resolveThreads: 'agentOnly'
    suppressPositiveFeedback: true

Jira Work Items

Teams that track work in Jira but host code in Azure DevOps can pull review context from Jira instead of Azure Boards. When the three Jira inputs are set (and includeWorkItems is enabled), the task:

  1. Scans the PR's source branch name, title, and description for Jira issue keys (e.g., PROJ-123) — the same convention Jira's own development panel uses. Lowercase keys in branch names are recognized.
  2. Fetches each candidate issue from the Jira Cloud REST API. Keys that don't resolve (HTTP 404) are skipped silently, so key-shaped false positives like UTF-8 never break the run.
  3. Writes the issue details into the same work-item context file the review prompt already consumes: summary, type, status, priority, assignee/reporter, due date, labels, components, fix versions, parent, description, environment, subtasks, linked issues, and the 10 most recent comments. Empty fields are omitted.
- task: CopilotCodeReview@1
  displayName: 'Copilot Code Review'
  inputs:
    githubPat: '$(GITHUB_PAT)'
    useSystemAccessToken: true
    jiraBaseUrl: 'https://yourorg.atlassian.net'
    jiraEmail: 'service-account@example.com'
    jiraApiToken: '$(JIRA_API_TOKEN)'
    jiraProjectKeys: 'PROJ,CORE'                                # optional
    jiraCustomFields: 'Acceptance Criteria,customfield_10031'   # optional

Custom fields. Fields like acceptance criteria are site-specific custom fields in Jira, so they are opt-in via jiraCustomFields: list the fields to include by display name (case-insensitive) or by customfield_NNNNN ID. Display names are resolved against the site's field catalog once per run; names that don't resolve are skipped with a warning and never fail the review. Rich-text values are converted to plain text the same way descriptions are. If a field's display name contains a comma, use its ID instead (the Jira admin field list shows IDs, or append ?fields=*all&expand=names to any issue's REST URL).

Notes:

  • Jira Cloud only. Authentication uses an API token with Basic auth (email:token), which Jira Server/Data Center does not support.
  • Works with both Classic and Scoped tokens. Classic tokens authenticate against your site URL directly. Scoped tokens must include the classic scopes read:jira-work and read:jira-user. If using a service account, make sure the account is added to the project as Viewer.
  • The Jira account needs browse access to the referenced projects. Store the token as a secret pipeline variable.
  • A custom field whose display name matches a built-in section (e.g. "Description") will produce a duplicate-looking section label; prefer distinct names or the field ID.
  • A failed Jira fetch never blocks the review: the run continues without work item context, and the task finishes as partially succeeded (orange) with the fetch error surfaced in the pipeline's warnings.

Diff-Only Review Mode

By default, the CLI agent has full access to the repository and can explore files beyond the PR diff. This equips the agent with more contextual awareness, leading to more relevant feedback. However, for large codebases this can result in excessive token consumption as the agent reads unrelated files for context.

Enable diffOnlyReview to restrict the review to only the code changes in the PR:

- task: CopilotCodeReview@1
  displayName: 'Copilot Code Review'
  inputs:
    githubPat: '$(GITHUB_PAT)'
    useSystemAccessToken: true
    diffOnlyReview: true

When enabled:

  • The PR diff is pre-computed via git diff (using merge-base / three-dot syntax to match the ADO PR UI) and embedded directly in the prompt along with all PR context (details, iteration info, work items)
  • Built-in file-browsing tools (Read, Glob, Grep) are removed from the agent's tool set; the agent is restricted to PowerShell shell commands only
  • The prompt explicitly directs the agent to use only the embedded diff and to refrain from reading files or running git commands to explore the repository
  • Token usage becomes proportional to the size of the actual code changes, not the size of the repository

Limitations: The agent retains shell access to pwsh because it needs to invoke the comment-posting scripts (Add-CopilotComment.ps1, Update-CopilotComment.ps1). Because pwsh is a general-purpose shell, this technically permits arbitrary command execution; the diff-only behavior is enforced by the combination of removed file-browsing tools, embedded context, and explicit prompt instructions rather than by hard tool-level constraints alone.

Requirements:

  • The pipeline must use fetchDepth: 0 (full clone) so that both source and target commits are available for diff computation
  • When using raw prompt modes (promptRaw or promptFileRaw), prompts should be constructed assuming that all diff context will be appended to the end

Trade-off: The agent loses the ability to check broader codebase patterns and conventions. This is the intended trade-off for users prioritizing token efficiency over deep contextual review.

If the diff cannot be computed (e.g., missing commits due to a shallow clone), the task will fail with a descriptive error rather than silently consuming excessive tokens.

Incremental Re-Reviews

After a review, the task records which pull request iteration it reviewed, so later runs don't spend tokens repeating work:

  • Already-reviewed iterations are skipped. When a run finds that the PR's current iteration was already reviewed — for example a re-queued build, or a branch policy re-running the build after the target branch moved — it finishes immediately, before installing the CLI or running the agent. Set skipReviewedIterations: false to force a fresh review.
  • Re-reviews focus on what changed. When new commits were pushed since the last review, Iteration_Details.txt gains a [Changes Since Last Review] section listing the files changed since then, with the git diff command that shows exactly those changes. In diff-only mode that smaller diff is also embedded in the prompt. The review prompt limits new non-Critical findings to those changes.

When a run is recorded: only when it provably reviewed the iteration — the agent finished successfully, every comment it attempted to post went through (none was refused by the review policy), all review context (threads, work items, the changed-file list) was fetched, and the reviewed code is confirmed to be that iteration (in a PR validation build, System.PullRequest.SourceCommitId must match; otherwise the iteration must be checked out). A review that posted nothing is recorded as well — for example a re-review that found nothing new while earlier threads are still open. Anything else simply means the next run reviews the iteration again.

When the "changes since last review" section is omitted (and the whole PR is reviewed as usual): after a rebase or a merge from the target branch (the merge base changed, so the commit-to-commit diff would mix in target-branch changes), after the PR is retargeted, or when the change lists could not be fully retrieved. In diff-only mode the extra diff is also left out when the last reviewed commit isn't in the local clone (e.g. after a force push) or when it would be more than half the size of the full diff.

Notes:

  • Recording uses the same "Contribute to pull requests" permission as posting comments. If it fails, the task logs a warning and keeps working as before (every run reviews the whole PR).
  • A re-queued build skips even if someone replied to a review comment in the meantime; set skipReviewedIterations: false (or push a commit) to have the agent respond.
  • The hash also covers the built-in prompt, so a task update that changes it (1.7.0 does) starts a fresh record: each open PR gets one full review after the upgrade.
  • Without a record for the current configuration — for example the first review after upgrading, or a token that cannot write PR properties — the prompt falls back to treating any earlier automated review threads as a sign of a re-review. That fallback cannot tell which configuration wrote those threads, so a second, differently configured review of a PR is also treated as a re-review on its first run.
  • Raw prompt modes are skipped and recorded too. Only posting attempts made through the comment scripts are checked, so a raw prompt that posts some other way is recorded whether or not its posts went through.
  • A comment-script call that PowerShell rejects before the script starts (for example a misspelled parameter name) leaves no trace for the task to detect. If the agent then gives up on that comment instead of retrying, the iteration can still be recorded, even when that was the only comment of the run.

Publishing Prompt Artifacts

Enable publishPromptArtifacts to publish all generated context files and the final assembled prompt as pipeline artifacts. This is useful for debugging prompt construction, verifying what context the CLI agent received, or inspecting the diff content in diff-only mode.

- task: CopilotCodeReview@1
  displayName: 'Copilot Code Review'
  inputs:
    githubPat: '$(GITHUB_PAT)'
    useSystemAccessToken: true
    publishPromptArtifacts: true

The published artifact contains files such as PR_Details.txt, Iteration_Details.txt, commit SHA files, work item details (if enabled), the review state and the review policy the comment scripts enforced, and the final prompt file sent to the CLI agent.

Setting Up Authentication

Option 1: System Access Token (Recommended)

The system access token is the Microsoft-recommended authentication method for Azure DevOps Services. It uses OAuth and requires no PAT management.

Granting Build Service Permissions

The Build Service identity needs permission to contribute to pull requests:

  1. Navigate to Repos
  2. From the repository dropdown, go to Manage repositories
  3. Go to the Security tab
  4. Find the [Project Name] Build Service ([Org Name]) identity
  5. Set Read to Allow
  6. Set Contribute to pull requests to Allow

Update Build Service identity permissions

TIP: If you don't see the Build Service identity, run a pipeline first to ensure it's been created.

Option 2: Personal Access Token

Create a personal access token:

  1. Navigate to User settings > Personal access tokens
  2. Click New token
  3. Click Show all scopes
  4. Create a new token with the following scopes:
    • Code: Read
    • Pull Request Threads: Read & Write
    • Work Item: Read (Optional)
  5. Store the token as a secret variable in your Azure DevOps pipeline

NOTE: When using a PAT, PR comments will be attributed to the account that created the PAT. For large teams, consider using a dedicated service account.

GitHub Personal Access Token (for Copilot CLI)

  1. Go to GitHub Settings > Developer Settings > Personal Access Tokens
  2. Generate a new Fine-grained token with the following options:
    • Repository access: Public
    • Permission: Copilot Requests
  3. Store the token as a secret variable in your Azure DevOps pipeline

IMPORTANT: If your user account is part of a GitHub organization, ensure the organization admin goes to GitHub Policies > Copilot > Copilot CLI and sets the policy to Enabled everywhere

GitHub Enterprise Accounts

If your Copilot subscription lives on a GitHub Enterprise account with data residency (subdomain.ghe.com), a PAT from that instance will fail validation against github.com with a "Bad credentials" error. Set the githubHost input so the Copilot CLI authenticates against your enterprise instance:

- task: CopilotCodeReview@1
  displayName: 'Copilot Code Review'
  inputs:
    githubPat: '$(GITHUB_ENTERPRISE_PAT)'
    githubHost: 'subdomain.ghe.com'
    useSystemAccessToken: true

A full URL (e.g., https://subdomain.ghe.com/) is also accepted and normalized to the hostname automatically.

Anthropic Authentication (for Claude Code CLI)

Two options are supported — provide exactly one:

Option A — API key (billed against Anthropic API usage):

  1. Go to Anthropic Console
  2. Create an API key
  3. Store the key as a secret variable in your Azure DevOps pipeline (e.g., ANTHROPIC_API_KEY) and pass it via anthropicApiKey

Option B — OAuth token (billed against a Claude Pro/Max/Team/Enterprise subscription):

  1. On your local machine, run claude setup-token and complete the browser authorization
  2. Copy the long-lived token it prints (valid for about a year)
  3. Store it as a secret variable in your Azure DevOps pipeline (e.g., CLAUDE_CODE_OAUTH_TOKEN) and pass it via claudeCodeOAuthToken

Storing Tokens in Azure DevOps

  1. Navigate to Pipelines > Library
  2. Create a new Variable Group or edit an existing one
  3. Add the relevant variables:
    • GITHUB_PAT (mark as secret) — for Copilot CLI
    • ANTHROPIC_API_KEY (mark as secret) — for Claude Code CLI with API billing
    • CLAUDE_CODE_OAUTH_TOKEN (mark as secret) — for Claude Code CLI with subscription billing
    • AZURE_DEVOPS_PAT (mark as secret) — if not using System Access Token
  4. Link the variable group to your pipeline

Alternatively, you can create the pipeline first and then configure the pipeline-specific variables.

How It Works

  1. Fetch PR Context: The task retrieves the PR's iteration details and its review record, then pull request metadata, existing comments, and linked work item details via the Azure DevOps API (or from Jira, when the Jira inputs are configured). If this review configuration already reviewed the current iteration, the run ends here (see Incremental Re-Reviews).
  2. Install CLI Agent: The task ensures the configured CLI agent is installed on the build agent. GitHub Copilot CLI is installed via winget (Windows) or the official install script (Linux). Claude Code CLI is installed via npm install -g @anthropic-ai/claude-code. With autoUpdateCli: true, an existing install is updated first. The task logs the CLI version and warns when it is older than the versions it supports (see Security Model).
  3. Run Code Review: Using the PR context and local Git commands, the CLI agent analyzes the changes using the configured or default prompt
  4. Post Comments: Review findings are posted as comments on the pull request via the Azure DevOps API
  5. Record the Review: When the run provably reviewed the iteration, the task records it on the pull request so later runs can skip it or focus on what changed

Default Review Focus Areas

The default prompt instructs Copilot to focus on:

  • Performance: Identifying inefficient code patterns
  • Best Practices: Adherence to coding standards
  • Reusability: Opportunities for code reuse
  • Maintainability: Code clarity and documentation
  • Simplification: Reducing complexity
  • Security: Potential vulnerabilities
  • Code Consistency: Style and pattern consistency

Findings are triaged in two phases: the agent first enumerates every candidate issue across the full diff, then scores each by severity (Critical/Major/Minor/Nit) and confidence before posting. Critical and Major findings always post individually; high-confidence Minor findings are consolidated into a single capped comment (see maxMinorIssues); nits and speculation are dropped. On re-reviews, new comments are limited to newly pushed changes plus Critical findings, which keeps review rounds from surfacing endless new commentary on already-reviewed code.

Security Model

The review agent runs in your build, inside a checkout of the pull request it reviews. Everything in that checkout — code, instruction files, and CLI configuration files — can be written by the pull request's author, who may not be trusted. The task limits what that content can do:

  • Repository CLI configuration is not loaded. Claude Code runs with --setting-sources user, so a checkout's .claude/settings.json, .claude/settings.local.json, and .mcp.json are ignored: no hooks or helper commands from the repository run, its env block doesn't apply, and its MCP servers, skills, and subagents don't load. The build user's own ~/.claude settings still apply. The Copilot CLI loads a repository's hooks, MCP servers, and plugin settings only from folders it trusts; the task removes the environment variables that grant that trust (COPILOT_ALLOW_ALL, GITHUB_COPILOT_PROMPT_MODE_*) and warns when the build user's Copilot config already trusts a folder that contains the checkout (trust is inherited by subfolders).
  • No built-in GitHub MCP servers. Copilot runs with --disable-builtin-mcps.
  • GitHub credentials stay out of the agent's shell. Copilot runs with --secret-env-vars for GH_TOKEN, COPILOT_GITHUB_TOKEN, GITHUB_TOKEN, and the custom-provider keys: commands the agent runs don't see them, and their values are redacted from output.
  • Repository instruction files are optional. By default the agent still reads them: CLAUDE.md for Claude Code; AGENTS.md, CLAUDE.md, .github/copilot-instructions.md and related files, plus repository skills, for Copilot. A pull request can edit these files, so set ignoreCustomInstructions: true if you don't want the changes under review to shape their own review.
  • Untrusted text is marked. In the context files, the PR title, description, branch names, comments, commit messages, changed-file names, and linked work items (Azure Boards or Jira) are wrapped in <<<UNTRUSTED_CONTENT ...>>> markers that carry a random id for each run, and so are the diffs embedded in diff-only mode. The prompt tells the agent to treat marked text, and the code under review, as information, never as instructions. This makes prompt injection harder, not impossible. Raw prompt modes get the markers in the context files but not the instruction, since raw prompts are passed to the CLI as-is.
  • The comment scripts act only within the review. Before the agent starts, the task writes a review policy for the run, and the comment scripts (Add-CopilotComment.ps1, Add-AzureDevOpsPRComment.ps1, Update-CopilotComment.ps1, Delete-CopilotComment.ps1) check every action against it, before sending anything:
    • They call only the pull request under review, on the configured server, project, and repository.
    • They reply to and resolve only threads from earlier automated reviews and, with resolveThreads: all, active or pending human threads. Raw prompts may act on any thread, since resolveThreads doesn't apply to them. They edit or delete only comments an automated review wrote. Threads and comments created during the same run are not on the list.
    • They read comment text only from files inside the working directory — not inside .git, not through a link that leads elsewhere, at most 100,000 characters — and refuse text passed inline with -Comment or -Content: inline text travels through the agent's shell command line, where command substitution in text copied from the pull request could run.
    • They anchor inline comments only to files the pull request changes; a comment on any other file is posted as a general comment that names the file and line.
    • They never post the Azure DevOps token or another known credential (SYSTEM_ACCESSTOKEN, the Anthropic key or OAuth token, GitHub tokens, custom-provider keys), plain or Base64-encoded. This check also applies when you run the scripts yourself.

A refused action fails that script call, keeps the run from being recorded as reviewed (see Incremental Re-Reviews), and is reported as a pipeline warning, since it can mean the agent followed instructions planted in the pull request.

Treat a review of an untrusted pull request like any other build of untrusted code:

  • Prefer Microsoft-hosted or other ephemeral agents, so nothing a review does carries over to later runs.
  • On self-hosted agents, never save Copilot folder trust on the agent's work folder or any folder above it, and keep the checkout step's persistCredentials off.
  • Give the pipeline identity only the permissions the review needs ("Contribute to pull requests" on the repository).

CLI versions: tested with GitHub Copilot CLI 1.0.105 and Claude Code 2.1.316. The task warns when the installed CLI is older than 1.0.41 (Copilot) or 2.1.69 (Claude Code), the first versions known to honor the isolation above. Set autoUpdateCli: true to have the task run copilot update / claude update on an existing install before each review.

Limitations

  • GitHub Copilot CLI: On Windows, requires winget to be available. On Linux, requires curl and bash (standard on most systems). If using MS-hosted agents, these should be available by default.
  • Claude Code CLI: Requires npm to be available (pre-installed on all Azure DevOps agents). Requires an Anthropic API key or a Claude subscription OAuth token.
  • Inline Comment Fallback: Review comments are posted inline on the relevant file and lines. If Azure DevOps rejects an inline anchor, or the file isn't part of the pull request, the comment is posted as a general PR comment with the file and line reference included in the text instead.
  • Context Window: Very large PRs may exceed the agent's context limits

Troubleshooting

Task fails with "GitHub Copilot CLI not found"

  • Windows: Ensure your agent can access winget and has internet connectivity to install the Copilot CLI.
  • Linux: Ensure curl and bash are available, and the agent has internet connectivity to download from https://gh.io/copilot-install.

Task fails with "Claude Code CLI not found"

  • Ensure npm is available on the agent and the agent has internet connectivity to install @anthropic-ai/claude-code from npm.
  • On self-hosted agents, ensure the agent user has permission to install global npm packages.

Warning: the CLI "is older than" a supported version

The installed Copilot CLI or Claude Code CLI predates the version that honors the task's isolation of repository configuration (see Security Model). Update the CLI on the agent, or set autoUpdateCli: true. The review still runs.

Warning: the Copilot CLI "trusts the folder"

The build user's Copilot config (config.json in COPILOT_HOME, by default ~/.copilot) lists a trusted folder that contains the checkout, so the CLI will load hooks, MCP servers, and plugin settings committed in the pull request. Remove that folder from trustedFolders.

Warning: "The review policy refused an action by the review agent"

The agent tried something the comment scripts don't allow during a review (see Security Model); the warning gives the reason. Common causes:

  • A custom or raw prompt passes comment text inline with -Comment or -Content. Have the agent write the text to a file and pass -CommentFile / -ContentFile.
  • The agent tried to resolve a human reviewer's thread with resolveThreads: agentOnly, or to edit or delete a comment no automated review wrote. That's the policy working.
  • Anything else — another pull request or server, a file outside the working directory, a credential in the text — can mean the agent followed instructions planted in the pull request. Review the pull request content and the agent's output.

The run isn't recorded as reviewed, so the next run reviews the iteration again.

Authentication errors

Verify that:

  • Your GitHub PAT has Copilot access
    • If your user account is part of a GitHub organization, ensure the organization admin goes to GitHub Policies > Copilot > Copilot CLI and sets the policy to Enabled everywhere
  • If using azureDevOpsPat:
    • Your Azure DevOps PAT has Code (Read) and Pull Request Threads (Read & Write) permissions
    • The token is not expired
  • If using useSystemAccessToken:
    • The Build Service identity has "Contribute to pull requests" permission on the repository
    • Try explicitly mapping the SYSTEM_ACCESSTOKEN environment variable:
- task: CopilotCodeReview@1
  displayName: 'Copilot Code Review'
  inputs:
    githubPat: '$(GITHUB_PAT)'
    useSystemAccessToken: true
  env:
    SYSTEM_ACCESSTOKEN: $(System.AccessToken)

Timeout errors

For large PRs, increase the timeout input value. The default is 15 minutes.

No comments posted

Check the pipeline logs for Copilot's analysis output and determine if the agent experienced connectivity issues when posting comments. Even if Copilot finds no issues, it should still post a single comment indicating the PR looks good when using the default prompt — unless suppressPositiveFeedback is enabled, in which case a clean review intentionally posts nothing.

Contributing

Contributions are welcome! Please feel free to submit issues or pull requests on GitHub.

License

This project is licensed under GNU General Public License v3 - see the LICENSE file for details.

Support

For issues and feature requests, please use the GitHub Issues page.

Acknowledgments

  • Built with Azure Pipelines Task SDK
  • Powered by GitHub Copilot and Claude Code

Disclaimers

  • This project is not affiliated with or endorsed by Azure, GitHub, Anthropic, or the Microsoft Corporation.
  • All responses and interactions generated by GitHub Copilot or Claude Code remain subject to the probabilistic nature of the underlying LLM. As with all LLM-based interactions, there is a non-zero chance of unpredictable results. Use at your own discretion.
  • Contact us
  • Jobs
  • Privacy
  • Manage cookies
  • Terms of use
  • Trademarks
  • Your Privacy Choices
  • Consumer Health Privacy
© 2026 Microsoft