AI-powered pull request code reviewer for Azure DevOps using GitHub Copilot
$ dotnet add package CopilotPrReviewerAI-powered pull request code reviewer for Azure DevOps using GitHub Copilot SDK.
Install as a global .NET tool for use anywhere:
# PowerShell / bash
dotnet tool install -g CopilotPrReviewer
Once installed, run from anywhere:
CopilotPrReviewer <pr-url> [options]
dnx (No Installation)Run directly without installation (similar to npx):
# PowerShell / bash
dnx CopilotPrReviewer <pr-url> [options]
This is useful for:
You have two authentication options for Azure DevOps:
No setup required! The app will automatically open your browser for authentication on first use.
CopilotPrReviewer <Pull Request URL>
Provide your PAT via CLI argument or environment variable:
Via CLI Argument:
CopilotPrReviewer <Pull Request URL> --pat "your-ado-pat-token"
Via Environment Variable:
PowerShell:
$env:AZURE_DEVOPS_PAT = "your-ado-pat-token"
CopilotPrReviewer <Pull Request URL>
Command Prompt (cmd.exe):
set AZURE_DEVOPS_PAT=your-ado-pat-token
CopilotPrReviewer <Pull Request URL>
Bash (Linux/macOS):
export AZURE_DEVOPS_PAT="your-ado-pat-token"
CopilotPrReviewer <Pull Request URL>
Creating an Azure DevOps PAT:
The GitHub Copilot SDK requires authentication via GitHub CLI or GITHUB_TOKEN environment variable.
Option A: GitHub CLI Authentication (Recommended)
Install GitHub CLI (has to be installed via npm):
npm install -g @github/copilot
Follow the prompts:
GitHub.comHTTPSOption B: Personal Access Token
You can also authenticate using a fine-grained PAT with the "Copilot Requests" permission enabled.
Set the environment variable:
PowerShell:
$env:GITHUB_TOKEN = "ghp_your-github-token"
Command Prompt (cmd.exe):
set GITHUB_TOKEN=ghp_your-github-token
Bash (Linux/macOS):
export GITHUB_TOKEN="ghp_your-github-token"
Note: For more details, see:
You can create an appsettings.json file in the execution directory to customize Copilot and Review settings:
{
"AzureDevOps": {
"BaseUrl": "https://dev.azure.com"
},
"Copilot": {
"Model": "gpt-5-mini",
"MaxTokensPerBatch": 90000,
"OverheadTokens": 20000,
"MaxParallelBatches": 4,
"TimeoutSeconds": 300
},
"Review": {
"GuidelinesPath": "",
"PostComments": true
}
}
All settings can be overridden with environment variables using the prefix COPILOT_PR_REVIEWER_:
PowerShell:
$env:COPILOT_PR_REVIEWER_Copilot__Model = "gpt-5"
$env:COPILOT_PR_REVIEWER_Copilot__MaxParallelBatches = "8"
Command Prompt (cmd.exe):
set COPILOT_PR_REVIEWER_Copilot__Model=gpt-5
set COPILOT_PR_REVIEWER_Copilot__MaxParallelBatches=8
Bash (Linux/macOS):
export COPILOT_PR_REVIEWER_Copilot__Model="gpt-5"
export COPILOT_PR_REVIEWER_Copilot__MaxParallelBatches="8"
Review a pull request with OAuth (interactive browser login):
CopilotPrReviewer <Pull Request URL>
Or with dnx (no installation required):
dnx CopilotPrReviewer <Pull Request URL>
For CI/CD (e.g., Azure Pipelines YAML with OAuth):
- script: |
dnx CopilotPrReviewer $(System.PullRequest.SourceRepositoryUri)/pullrequest/$(System.PullRequest.PullRequestId)
displayName: 'Review PR with AI (OAuth)'
env:
GITHUB_TOKEN: $(GITHUB_TOKEN)
Or using PAT (if interactive login is not possible):
- script: dnx CopilotPrReviewer $(System.PullRequest.SourceRepositoryUri)/pullrequest/$(System.PullRequest.PullRequestId)
displayName: 'Review PR with AI (PAT)'
env:
GITHUB_TOKEN: $(GITHUB_TOKEN)
AZURE_DEVOPS_PAT: $(AZURE_DEVOPS_PAT)
# OAuth (default, interactive browser login - no extra config needed!)
CopilotPrReviewer <Pull Request URL>
# PAT via CLI argument
CopilotPrReviewer <Pull Request URL> --pat "your-ado-pat"
# PAT via environment variable (from AZURE_DEVOPS_PAT)
CopilotPrReviewer <Pull Request URL>
# Explicit authentication type
CopilotPrReviewer <Pull Request URL> --auth-type oauth
CopilotPrReviewer <Pull Request URL> --auth-type pat
# Use a different AI model
CopilotPrReviewer <Pull Request URL> --model "gpt-5"
# Dry run (no comments posted)
CopilotPrReviewer <Pull Request URL> --no-comments
# Use custom guidelines
CopilotPrReviewer <Pull Request URL> --guidelines-path "./custom-guidelines"
# Maximum parallel batches
CopilotPrReviewer <Pull Request URL> --max-parallel 8
# Custom timeout
CopilotPrReviewer <Pull Request URL> --timeout 120
# GitHub token for Copilot authentication
CopilotPrReviewer <Pull Request URL> --github-token "github_pat_your-github-token"
Options:
--pr-url <pr-url> (REQUIRED) Azure DevOps pull request URL
--pat <pat> Azure DevOps personal access token (optional)
--auth-type <auth-type> Authentication type: 'pat', 'oauth' (default: auto-detect)
--model <model> AI model to use for review (default: gpt-5-mini)
--github-token <github-token> GitHub token for Copilot authentication (optional)
--guidelines-path <guidelines-path> Path to external guidelines folder
--max-parallel <max-parallel> Maximum parallel batch reviews (default: 4)
--no-comments Skip posting comments to PR (dry run)
--timeout <timeout> Timeout for the review process (in seconds, default: 300)
--version Show version information
-?, -h, --help Show help and usage information
Both Azure DevOps URL formats are supported:
https://dev.azure.com/{org}/{project}/_git/{repo}/pullrequest/{id}https://{org}.visualstudio.com/{project}/_git/{repo}/pullrequest/{id}dnx?dnx is the .NET equivalent of npx (Node.js). It allows you to run .NET global tools directly without installing them globally.
Benefits:
Requirements: .NET 10 SDK or later
Usage:
dnx CopilotPrReviewer <pr-url> [options]
Example:
# Run directly without installation
dnx CopilotPrReviewer <Pull Request URL> --no-comments
# In CI/CD (Azure Pipelines)
- script: dnx CopilotPrReviewer $(PR_URL)
env:
AZURE_DEVOPS_PAT: $(AZURE_DEVOPS_PAT)
GITHUB_TOKEN: $(GITHUB_TOKEN)
Recommended for:
The tool includes embedded guidelines for:
You can override the built-in guidelines by providing a custom guidelines folder:
CopilotPrReviewer https://dev.azure.com/... --guidelines-path "./my-guidelines"
Place your custom guideline files in the folder:
dotnet-guidelines.mdfrontend-guidelines.mdpython-guidelines.md| Severity | Description | Action Required |
|---|---|---|
| 🔴 Critical | Security vulnerabilities, data loss risks, production crashes, blocking bugs | Must fix before merge |
| 🟠 Major | Performance issues, code correctness problems, maintainability concerns, significant best practice violations | Should fix before merge |
| 🟡 Minor | Code style issues, minor optimizations, documentation gaps, suggestions for improvement | Can fix in follow-up PR |
The recommended approach for Azure Pipelines is to use OAuth since the tool automatically handles interactive authentication in supported environments:
- task: UseDotNet@2
displayName: 'Install .NET 10 SDK'
inputs:
packageType: 'sdk'
version: '10.x'
- script: |
dnx CopilotPrReviewer $(System.PullRequest.SourceRepositoryUri)/pullrequest/$(System.PullRequest.PullRequestId)
displayName: 'Review PR with AI (OAuth)'
env:
GITHUB_TOKEN: $(GITHUB_TOKEN)
If running in a non-interactive environment without browser access, use PAT:
- task: UseDotNet@2
displayName: 'Install .NET 10 SDK'
inputs:
packageType: 'sdk'
version: '10.x'
- script: |
dnx CopilotPrReviewer $(System.PullRequest.SourceRepositoryUri)/pullrequest/$(System.PullRequest.PullRequestId)
displayName: 'Review PR with AI (PAT)'
env:
GITHUB_TOKEN: $(GITHUB_TOKEN)
AZURE_DEVOPS_PAT: $(AZURE_DEVOPS_PAT)
- name: Setup .NET
uses: actions/setup-dotnet@v3
with:
dotnet-version: '10.0.x'
- name: Review PR
run: dnx CopilotPrReviewer ${{ github.event.pull_request.html_url }}
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
AZURE_DEVOPS_PAT: ${{ secrets.AZURE_DEVOPS_PAT }}
This error means the tool is set to use PAT authentication but no token was found. Provide it via:
--pat "your-ado-pat"AZURE_DEVOPS_PAT=your-ado-patOr switch to OAuth (default):
CopilotPrReviewer <Pull Request URL>
If you're in a non-interactive or headless environment (CI/CD), you can:
AZURE_DEVOPS_PAT environment variable)--auth-type patThe tool only reviews active PRs without merge conflicts. Resolve any conflicts first.
The PR only contains files that aren't in supported tech stacks (.NET, Frontend, Python). Config files (JSON, YAML) are excluded from review.
MIT License - See LICENSE file for details
Contributions are welcome! Please open an issue or submit a pull request.