rasitha.DevOpsCodeReviewAgent 1.4.1

dotnet tool install --global rasitha.DevOpsCodeReviewAgent --version 1.4.1
                    
This package contains a .NET tool you can call from the shell/command line.
dotnet new tool-manifest
                    
if you are setting up this repo
dotnet tool install --local rasitha.DevOpsCodeReviewAgent --version 1.4.1
                    
This package contains a .NET tool you can call from the shell/command line.
#tool dotnet:?package=rasitha.DevOpsCodeReviewAgent&version=1.4.1
                    
nuke :add-package rasitha.DevOpsCodeReviewAgent --version 1.4.1
                    

ai-code-review

An AI-powered .NET code review agent that runs as a global CLI tool inside Azure Pipelines. It uses Azure OpenAI to autonomously explore a pull request, identify real issues, and post findings as inline comments on the PR.

How it works

The tool runs an agentic loop powered by the Microsoft Agent Framework (MAF). Given an Azure OpenAI endpoint, it:

  1. Uses git diff to discover what changed in the PR
  2. Reads any repository review guidelines (AGENTS.MD, CLAUDE.MD, .cursorrules, etc.) and honours them
  3. Detects the current OS/shell and reviews each changed file using targeted git and shell commands appropriate for that environment
  4. Calls report_finding for every issue it finds (bugs, security vulnerabilities, performance problems, .NET anti-patterns)
  5. Posts findings as inline threads on the Azure DevOps PR, grouped by file, plus a top-level summary comment

Authentication uses DefaultAzureCredential throughout — no API keys or PATs are needed.

Installation

dotnet tool install --global rasitha.DevOpsCodeReviewAgent

To install from a private feed:

dotnet tool install --global rasitha.DevOpsCodeReviewAgent \
  --add-source https://pkgs.dev.azure.com/<org>/<project>/_packaging/<feed>/nuget/v3/index.json

If you want reproducible installs, pin an explicit published version such as --version 1.3.2.

Usage

ai-code-review [OPTIONS]

Options:
  --endpoint <URL>        Azure OpenAI endpoint URL                  (required)
  --deployment <NAME>     Azure OpenAI deployment name, e.g. gpt-4o  (required)
  --base-branch <BRANCH>  Branch to diff against (default: main, or auto-detected from pipeline)
  --working-dir <PATH>    Repository root (default: current directory)
  --devops-comment        Post findings as Azure DevOps PR comments
  --org <ORG>             Azure DevOps organization (auto-detected in pipeline)
  --project <PROJECT>     Azure DevOps project      (auto-detected in pipeline)
  --repository <REPO>     Repository name or ID     (auto-detected in pipeline)
  --pr-id <ID>            Pull request ID           (auto-detected in pipeline)
  --fail-on <SEVERITY>    Exit code 1 when findings reach this level: critical|high|medium|low|none (default: none)
  --verbose, -v           Print each tool call as the agent works, plus auth diagnostics
  --max-tokens <N>        Max tokens per LLM response (default: 4096)

Local usage

Make sure you are logged in to Azure CLI with an identity that has the Cognitive Services OpenAI User role on your Azure OpenAI resource:

az login

Then run against any local git repository:

ai-code-review \
  --endpoint "https://my-resource.openai.azure.com/" \
  --deployment "gpt-4o" \
  --working-dir "/path/to/repo" \
  --base-branch "main" \
  --verbose

Use --verbose to print auth diagnostics (which identity was resolved, token audience, object ID) and each tool call the agent makes. Useful for diagnosing 401 errors.

Azure Pipelines

Add to your PR validation pipeline. The AzureCLI@2 task logs in with the service connection before the script runs, so DefaultAzureCredential and AzureCliCredential both resolve automatically — no secrets or PATs required.

- task: AzureCLI@2
  displayName: Run AI Code Review
  inputs:
    azureSubscription: your-service-connection-name
    scriptType: bash
    scriptLocation: inlineScript
    inlineScript: |
      ai-code-review \
        --endpoint   "$(AZURE_OPENAI_ENDPOINT)" \
        --deployment "$(AZURE_OPENAI_DEPLOYMENT)" \
        --devops-comment \
        --fail-on high
  env:
    AZURE_OPENAI_ENDPOINT:   $(AZURE_OPENAI_ENDPOINT)
    AZURE_OPENAI_DEPLOYMENT: $(AZURE_OPENAI_DEPLOYMENT)

The tool auto-detects the PR context (base branch, PR ID, org, project, repository) from the Azure Pipelines environment variables that the platform sets on PR builds.

On Windows agents, the reviewer tells the model to use Windows-compatible commands instead of assuming Unix tools like sed. On Linux agents, commands are executed through /bin/sh.

See azure-pipelines.yml for a complete pipeline example with setup notes.

Azure setup

Azure OpenAI

The identity running the tool (your personal account locally, the service connection's service principal in pipelines) needs:

Role Scope
Cognitive Services OpenAI User The Azure OpenAI resource
az role assignment create \
  --role "Cognitive Services OpenAI User" \
  --assignee "<object-id-or-upn>" \
  --scope "/subscriptions/<SUB>/resourceGroups/<RG>/providers/Microsoft.CognitiveServices/accounts/<RESOURCE>"

Azure DevOps PR comments

For --devops-comment to work, the same service principal must also be added to the Azure DevOps organisation and granted Contribute to pull requests on the repository:

  1. Project Settings → Permissions — add the service principal as a member
  2. Project Settings → Repos → <repository> → Security — grant Contribute to pull requests

RBAC changes can take up to 5 minutes to propagate.

Repository review guidelines

If the repository contains any of the following files, their contents are automatically injected into the agent's system prompt before the review starts:

File Purpose
AGENTS.MD Agent-specific instructions
CLAUDE.MD Claude / AI coding guidelines
.cursorrules Cursor IDE rules
.github/copilot-instructions.md GitHub Copilot instructions
REVIEW.MD Custom review focus areas
CODEREVIEW.MD Custom review rules

Use these files to tell the agent which patterns matter most in your codebase, areas to focus on or skip, or project-specific conventions.

What the agent reviews

Issues are ranked by severity and reported with a specific file, line number, description, and suggested fix.

Severity Examples
Critical SQL injection, hardcoded secrets, insecure deserialization
High Missing authorization, async void, breaking API changes, N+1 queries
Medium IDisposable not disposed, missing CancellationToken, wrong DI lifetime
Low Missing ConfigureAwait, DateTime.Now vs DateTimeOffset.UtcNow
Info General observations

The agent deliberately skips: formatting, whitespace, naming conventions, auto-generated files (*.g.cs, *.Designer.cs, EF migrations), and issues in unchanged code.

Building from source

git clone <repo-url>
cd CodeReviewAgent

dotnet build src/CodeReviewAgent/CodeReviewAgent.csproj
dotnet run --project src/CodeReviewAgent/CodeReviewAgent.csproj -- --help

To pack and install locally:

dotnet pack src/CodeReviewAgent/CodeReviewAgent.csproj -c Release -o ./nupkg
dotnet tool install --global --add-source ./nupkg rasitha.DevOpsCodeReviewAgent

Tech stack

Component Technology
Runtime .NET 10
CLI Spectre.Console.Cli
Agent loop Microsoft Agent Framework 1.7 (Microsoft.Agents.AI)
Auth DefaultAzureCredential (Azure.Identity)
ADO comments Azure DevOps REST API 7.1 via AzureCliCredential
Product Compatible and additional computed target framework versions.
.NET net10.0 is compatible.  net10.0-android was computed.  net10.0-browser was computed.  net10.0-ios was computed.  net10.0-maccatalyst was computed.  net10.0-macos was computed.  net10.0-tvos was computed.  net10.0-windows was computed. 
Compatible target framework(s)
Included target framework(s) (in package)
Learn more about Target Frameworks and .NET Standard.

This package has no dependencies.

Version Downloads Last Updated
1.4.1 0 6/1/2026
1.4.0 63 5/29/2026
1.3.2 53 5/29/2026
1.3.1 57 5/28/2026
1.3.0 61 5/28/2026
1.2.2 59 5/28/2026
1.2.1 62 5/27/2026
1.2.0 38 5/27/2026
1.1.0 60 5/26/2026
1.0.0 41 5/26/2026