AI SummaryPR Metrics is a cross-platform GitHub Action and Azure DevOps task that analyzes pull request size and test coverage, updating PR titles with indicators (XS, S, M, L, XL, 2XL, etc) and test coverage symbols (✔ or ⚠️).
Install
Copy this and paste it into Claude Code, Cursor, or any AI assistant:
I want to add the "PR-Metrics — Copilot Instructions" prompt rules to my project. Repository: https://github.com/microsoft/PR-Metrics Please read the repo to find the rules/prompt file, then: 1. Download it to the correct location (.cursorrules, .windsurfrules, .github/prompts/, or project root — based on the file type) 2. If there's an existing rules file, merge the new rules in rather than overwriting 3. Confirm what was added
Description
A GitHub Action & Azure Pipelines task for augmenting pull request titles to let reviewers quickly determine PR size and test coverage.
Project Overview
PR Metrics is a cross-platform GitHub Action and Azure DevOps task that analyzes pull request size and test coverage, updating PR titles with indicators (XS, S, M, L, XL, 2XL, etc) and test coverage symbols (✔ or ⚠️).
Multi-Platform Abstraction Pattern
The codebase uses a unique dual-platform architecture with dependency injection: • Runners: src/task/src/runners/ - Abstracts GitHub Actions vs Azure Pipelines execution • runnerInvoker.ts routes to gitHubRunnerInvoker.ts or azurePipelinesRunnerInvoker.ts • Detection: process.env.GITHUB_ACTION determines platform • Repos: src/task/src/repos/ - Abstracts GitHub vs Azure DevOps repository APIs • reposInvoker.ts routes to gitHubReposInvoker.ts or azureReposInvoker.ts • Both extend baseReposInvoker.ts, which provides shared API error handling (e.g., mapping 401/403/404 to access-error messages) • tokenManager.ts handles workload identity federation as an alternative to Personal Access Tokens • Single codebase handles both GitHub and Azure DevOps repositories
Core Components
• Entry Point: src/task/index.ts - Simple DI container resolution and error handling • Main Logic: src/task/src/pullRequestMetrics.ts - Orchestrates the workflow, calling codeMetricsCalculator.updateDetails() and codeMetricsCalculator.updateComments() in parallel via Promise.all() • Metrics Engine: src/task/src/metrics/codeMetricsCalculator.ts - Validates conditions, calculates PR metrics, and defines updateDetails() and updateComments() • Git Integration: src/task/src/git/gitInvoker.ts - Executes Git commands for diff analysis (numstat-based metrics) • Diff Parsing: src/task/src/git/octokitGitDiffParser.ts - Uses the parse-git-diff library to determine, for each file, the first diff hunk start line (a diff line suitable as a comment anchor) for precise comment placement on GitHub PRs
Key Patterns
• Dependency Injection: Uses tsyringe with @singleton() and @injectable() decorators • Interface Abstraction: All major components implement interfaces (e.g., ReposInvokerInterface, RunnerInvokerInterface) • Localization: Resource strings in the src/task/Strings/resources.resjson/ folder with runnerInvoker.loc() calls
Discussion
Health Signals
My Fox Den
Community Rating
Sign in to rate this booster
Works With
Any AI assistant that accepts custom rules or system prompts