AI-powered PR analysis for smarter code review
Free and open source. Built to help developers everywhere. π
Get PRBrain running on your repository in 3 easy steps:
Create .github/workflows/prbrain.yml in your repository:
name: PRBrain
on:
pull_request:
types: [opened, synchronize]
permissions:
contents: read
pull-requests: write
issues: read
jobs:
analyze:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: buildthingsuseful/prbrain@main
with:
openai-api-key: ${{ secrets.OPENAI_API_KEY }}
github-token: ${{ secrets.GITHUB_TOKEN }}Add your OpenAI API key as a repository secret:
- Go to Settings β Secrets and variables β Actions
- Click New repository secret
- Name:
OPENAI_API_KEY - Paste your OpenAI API key
That's it! PRBrain will automatically analyze every PR and post a comment.
Every time a PR is opened, PRBrain analyzes it and posts a comment like this:
## π§ PRBrain Analysis
π€ **AI-Generated:** High confidence (72%)
*Signals: methodical approach, generic comments, perfect formatting*
π **Inferred Intent:** "Add rate limiting to API endpoints"
π― **Summary:** Adds middleware-based rate limiting to all public API routes
π **Scope:** 4 files changed | +180 -12 | Medium change
β οΈ **Gaps:** No tests, hardcoded rate limits, no distributed support
### π Similar PRs/Issues
- #234 "API rate limiting" (92% similar) β OPEN
- #189 "Throttle requests" (78% similar) β CLOSED
### π Vision Alignment
β
Aligned with project goals
### π Quality Score: 7/10
- β
Reasonable scope
- β
Well-structured changes
- β οΈ No docs update
- β Missing tests- π― Intent Extraction β Reverse-engineers the likely prompt/goal from the diff
- π€ AI Detection β Identifies AI-generated PRs with confidence scores
- π Duplicate Detection β Finds similar open PRs and issues via embeddings
- π Vision Alignment β Checks PR against your project's
VISION.md - π Quality Scoring β Scores PRs on tests, size, structure, docs, and complexity
Optionally create .prbrain.yml in your repository root:
# LLM model (default: gpt-4o-mini)
model: gpt-4o-mini
# Similarity threshold for duplicate detection (0.0 - 1.0)
similarity_threshold: 0.80
# Path to your project vision document
vision_doc: VISION.md
# Quality scoring settings
quality:
require_tests: true
max_files_changed: 50
max_lines_changed: 1000
# Auto-apply labels
labels:
ai_generated: "π€ ai-generated"
duplicate: "duplicate"
vision_misaligned: "β οΈ scope-creep"
# Ignore patterns
ignore:
paths: ["*.lock", "*.generated.*"]
authors: ["dependabot[bot]", "renovate[bot]"]See Configuration Reference for all options.
Add a VISION.md to your repo root describing your project's goals and principles. PRBrain will check every PR against it and flag scope creep. See VISION.md for an example template.
git clone https://github.com/buildthingsuseful/prbrain.git
cd prbrain
npm install
npm test # Run tests (vitest)
npx tsc --noEmit # Type check
npm run build # Bundle with nccsrc/core/β Analysis engines (intent, AI detection, dedup, quality, vision)src/adapters/β GitHub API, OpenAI, vector storagesrc/utils/β Diff parser, tokenizer, loggertest/β Test suite with fixtures
Contributions welcome! See CONTRIBUTING.md.
MIT License β see LICENSE for details.
Built with β€οΈ to help open source maintainers manage the flood of AI-generated PRs.