A Go program that intelligently finds and assigns reviewers for GitHub pull requests based on code context and reviewer activity.
- Smart reviewer selection: Context-based matching using code blame analysis and activity patterns
- Workload balancing: Filters out overloaded reviewers (>9 non-stale open PRs)
- Stale PR filtering: Only counts PRs updated within 90 days for accurate workload assessment
- Resilient API handling: 25 retry attempts with exponential backoff (5s-20min) and intelligent caching
- Bot detection: Comprehensive filtering of bots, service accounts, and organizations
- Multiple targets: Single PR, project-wide, or organization-wide monitoring
- Polling support: Continuous monitoring with configurable intervals
- Graceful degradation: Continues operation even when secondary features fail
- Comprehensive logging: Detailed decision tracking and performance insights
- Dry-run mode: Test assignments without making changes
go build -o better-reviewers
- Go 1.21 or later
- For personal use: GitHub CLI (
gh
) installed and authenticated - For GitHub App mode:
- GitHub App ID (found in your app settings)
- GitHub App private key file (.pem file downloaded when creating the app)
- GitHub token with appropriate permissions (repo access)
./better-reviewers -pr "https://github.com/owner/repo/pull/123"
./better-reviewers -pr "owner/repo#123"
./better-reviewers -project "owner/repo"
./better-reviewers -org "myorg"
Monitor all organizations where your GitHub App is installed:
# Using command-line flags
./better-reviewers --app-id "123456" --app-key "/path/to/private-key.pem"
# Using environment variables with file path
export GITHUB_APP_ID="123456"
export GITHUB_APP_KEY_PATH="/path/to/private-key.pem"
./better-reviewers
# Using Google Secret Manager (recommended for production)
export GITHUB_APP_ID="123456"
# GITHUB_APP_KEY should be stored in Google Secret Manager
./better-reviewers
./better-reviewers -project "owner/repo" -poll 1h
./better-reviewers -pr "owner/repo#123" -dry-run
-pr
: Pull request URL or reference-project
: GitHub project to monitor-org
: GitHub organization to monitor--app-id
: GitHub App ID for authentication--app-key
: Path to GitHub App private key file-poll
: Polling interval (e.g., 1h, 30m)-dry-run
: Run without making changes-min-age
: Minimum time since last activity (default: 1h)-max-age
: Maximum time since last activity (default: 180d)-max-prs
: Maximum open PRs per reviewer (default: 9)-pr-count-cache
: Cache duration for PR counts (default: 6h)
For GitHub App authentication:
GITHUB_APP_ID
: Your GitHub App's IDGITHUB_APP_KEY
: Secret name in Google Secret Manager (recommended for production)GITHUB_APP_KEY_PATH
: Path to your app's private key file (for local development)
- Create a GitHub App in your organization settings
- Required permissions:
- Repository: Read & Write (for PR assignments)
- Pull requests: Read & Write
- Organization members: Read
- Download the private key when prompted
- Note your App ID from the app settings page
- Install the app on your organization(s)
- Analysis: Examines PR changes, file history, and contributor patterns
- Scoring: Rates candidates based on:
- Code overlap with changed files
- Recent activity and expertise
- Current workload (open PRs)
- Selection: Chooses optimal reviewers avoiding overloaded contributors
- Assignment: Adds reviewers to PRs (unless in dry-run mode)
- Private keys should have restricted permissions (not world-readable)
- JWT tokens are automatically refreshed before expiry
- All API responses are sanitized in logs
- Token validation ensures only valid GitHub tokens are accepted
Run in dry-run mode to preview reviewer assignments:
./better-reviewers --dry-run --pr https://github.com/owner/repo/pull/123
[License details here]