Introduction
As development teams grow and repositories become larger, pull requests (PRs) often contain hundreds of lines of code changes spread across multiple files. Reviewing every change manually can be time-consuming, especially for engineering managers, senior developers, and DevOps teams responsible for maintaining delivery quality.
Artificial Intelligence is transforming software engineering workflows by automating repetitive tasks and improving developer productivity. One practical application is AI-powered pull request summarization, where an AI model analyzes code changes and automatically generates concise summaries, highlights risks, and explains modifications in natural language.
In this article, we'll explore how to build an AI-powered pull request summarization system using .NET, GitHub APIs, and Azure OpenAI.
Why Pull Request Summarization Matters
Modern development teams face several challenges during code reviews:
Large pull requests are difficult to understand quickly.
Reviewers may miss critical changes.
Engineering managers often need high-level summaries.
New team members require additional context.
Release notes creation becomes time-consuming.
An AI-powered summarization engine can automatically generate:
Change summaries
Risk assessments
Affected modules
Testing recommendations
Release note drafts
This significantly reduces review effort while improving collaboration.
Solution Architecture
A typical AI-powered PR summarization platform consists of the following components:
Components
GitHub Repository
GitHub Webhook
ASP.NET Core API
Azure OpenAI Service
Summary Storage Layer
Notification Service
Workflow
Developer creates a pull request.
GitHub webhook sends event data.
ASP.NET Core service retrieves changed files.
Code diffs are sent to Azure OpenAI.
AI generates a summary.
Summary is posted back to GitHub comments.
Creating the ASP.NET Core Project
Create a new Web API project.
dotnet new webapi -n PRSummarizer
Install required packages.
dotnet add package Octokit
dotnet add package Azure.AI.OpenAI
Retrieving Pull Request Data
GitHub provides APIs to access pull request information.
Example service:
public class GitHubService
{
private readonly GitHubClient _client;
public GitHubService(string token)
{
_client = new GitHubClient(
new ProductHeaderValue("PRSummarizer"));
_client.Credentials =
new Credentials(token);
}
public async Task<IReadOnlyList<PullRequestFile>>
GetFiles(string owner,
string repo,
int pullRequestNumber)
{
return await _client
.PullRequest
.Files(owner, repo, pullRequestNumber);
}
}
This service retrieves modified files and code differences from GitHub.
Preparing Code Changes for AI Analysis
Raw pull request data should be transformed into a structured format before sending it to an LLM.
Example:
public string BuildPrompt(
IReadOnlyList<PullRequestFile> files)
{
StringBuilder builder = new();
foreach(var file in files)
{
builder.AppendLine(
$"File: {file.FileName}");
builder.AppendLine(file.Patch);
}
return builder.ToString();
}
The generated prompt contains all code changes needed for summarization.
Join the conversation! Your thoughts help the community grow.