AI-powered pull request analysis tool that provides comprehensive code reviews, impact analysis, and documentation updates.
Features β’ Quick Start β’ Documentation β’ Contributing
- π Analyzes file changes in pull requests
- π Provides detailed statistics (files changed, lines added/deleted)
- π§ Uses OpenRouter AI models (default: Claude 3.5 Sonnet) to:
- Analyze code changes and their impact
- Identify potential risks and concerns
- Suggest improvements
- Generate documentation updates
- π¬ Posts formatted summaries as PR comments
- π Maintains documentation requirements
- π Supports authentication via GitHub token
- π Available as a GitHub Action
- Create
.github/workflows/pr-analysis.yml
in your repository:
name: PR Analysis
on:
pull_request:
types: [opened, synchronize]
jobs:
analyze:
runs-on: ubuntu-latest
permissions:
pull-requests: write
contents: read
steps:
- name: PR Diff Analysis
uses: sudo-whodo/pr-genius@v1
with:
github_token: ${{ secrets.PAT_TOKEN }}
openrouter_key: ${{ secrets.OPENROUTER_API_KEY }}
-
Add required secrets to your repository:
a. Personal Access Token (PAT):
- Go to GitHub Settings > Developer settings > Personal access tokens > Tokens (classic)
- Generate new token with:
repo
scope (for repository access)pull_requests
scope (for commenting on PRs)
- Add to repository secrets as
PAT_TOKEN
b. OpenRouter API Key:
- Get your API key from https://openrouter.ai/
- Add to repository secrets as
OPENROUTER_API_KEY
That's it! PR Genius will now analyze your pull requests automatically.
- Usage Guide - Detailed setup and configuration
- Example Configurations - Ready-to-use workflow examples
- Release Process - Understanding our versioning
Input | Description | Required | Default |
---|---|---|---|
github_token |
Personal Access Token (PAT) | Yes | - |
openrouter_key |
OpenRouter API key | Yes | - |
repository |
Repository name (owner/repo) | No | Current repository |
pull_request_number |
PR number to analyze | No | Current PR number |
model |
OpenRouter model to use | No | anthropic/claude-3.5-sonnet |
These inputs are mapped to environment variables inside the action:
- Required inputs:
GITHUB_TOKEN
: From github_token inputOPENROUTER_API_KEY
: From openrouter_key input
- Optional inputs:
REPOSITORY
: From repository input (defaults to current repository)PR_NUMBER
: From pull_request_number input (defaults to current PR)MODEL
: From model input (defaults to claude-3.5-sonnet)
The workflow needs these permissions:
permissions:
pull-requests: write # For posting comments
contents: read # For accessing repository contents
Additionally, your PAT_TOKEN must have:
repo
scope for repository accesspull_requests
scope for commenting on PRs
PR Genius adds a comment to your pull request with:
Click to see example output
## π€ Pull Request Analysis
### π Statistics
- Files changed: 3
- Lines added: 150
- Lines deleted: 50
### π§ AI Code Review
Analysis by anthropic/claude-3.5-sonnet:
[Detailed code review with impact assessment, risks, and suggestions]
### π Documentation Updates Needed
[Documentation suggestions based on changes]
### π Notable Changes
- Major changes in src/main.py: +100/-30 lines
- New file: tests/test_feature.py
-
Permission Issues (403 Forbidden)
- Ensure you're using PAT_TOKEN, not GITHUB_TOKEN
- Verify PAT has required scopes (repo, pull_requests)
- Check that the token hasn't expired
-
Missing OpenRouter API Key
- Ensure you've added the
OPENROUTER_API_KEY
to your repository secrets - Check that the secret name matches exactly
- Ensure you've added the
-
Rate Limits
- OpenRouter has rate limits based on your plan
- GitHub API also has rate limits
-
Token Security
- Never commit tokens directly in workflow files
- Always use repository secrets
- Regularly rotate your PAT for security
We welcome contributions! Here's how you can help:
- Fork the repository
- Create a feature branch (
git checkout -b feature/amazing-feature
) - Commit your changes using conventional commits:
feat: add new feature
fix: resolve issue
docs: update documentation
- Push to the branch (
git push origin feature/amazing-feature
) - Open a Pull Request
Please read our Contributing Guidelines for details.
- Python 3.8+
- GitHub Personal Access Token
- OpenRouter API Key
This project is licensed under the MIT License - see the LICENSE file for details.