Self-improving PR intelligence platform. Reviews pull requests, generates descriptions, scores codebase health, and learns from your team's engineering patterns.
AutoPR-AI/
├── app.py FastAPI entry point
├── config.py Centralized settings (Pydantic)
├── webhooks.py GitHub App webhook handler
│
├── core/
│ ├── db.py Async SQLAlchemy (SQLite/PostgreSQL)
│ ├── llm.py Unified LLM client (5 providers)
│ ├── github_app.py GitHub App JWT auth + API client
│ └── models.py Pydantic request/response contracts
│
├── modules/
│ ├── pr_description/ Phase 1 — PR Description as a Service
│ │ ├── analyzer.py Diff + context extraction
│ │ ├── generator.py Structured description generation
│ │ ├── learner.py Team format learning
│ │ └── routes.py /api/describe endpoints
│ │
│ ├── pr_review/ Phase 2 — Self-Improving Review Agent
│ │ ├── reviewer.py Full-context PR reviewer
│ │ ├── team_dna.py Team pattern extraction
│ │ ├── feedback.py Accept/reject tracking + prompt tuning
│ │ └── routes.py /api/review endpoints
│ │
│ ├── code_health/ Phase 3 — Codebase Credit Score
│ │ ├── scanner.py 5-dimension code scanner
│ │ ├── scorer.py Weighted 0-100 scoring
│ │ ├── reporter.py PR comments + GitHub status checks
│ │ └── routes.py /api/health endpoints
│ │
│ └── refactor/ Legacy — AI Code Refactoring
│ ├── agent.py Clone → refactor → PR pipeline
│ └── routes.py POST /refactor endpoint
│
└── tests/
├── test_pr_description.py
├── test_pr_review.py
└── test_code_health.py
Generates structured PR descriptions from diff context. Reads the diff, commit messages, and linked issues. Outputs: Summary, Why, What Changed, How to Test, Risks. Learns your team's preferred format from historical PRs.
Reviews PRs with full codebase context, not just the diff. Builds a Team DNA model from merged PRs — naming conventions, architectural patterns, review culture. Tracks which suggestions get accepted vs rejected and self-tunes prompting based on feedback.
Scans a repository across 5 dimensions: cyclomatic complexity, security vulnerabilities, dependency health, code smells, and documentation coverage. Produces a weighted 0-100 score with letter grades. Updates on every PR merge. Posts score impact as a GitHub status check.
Points at a GitHub repo, clones it, scans for code smells, refactors with AI, and opens a PR with clean code. Supports 5 LLM providers with free models available.
When installed as a GitHub App, AutoPR-AI reacts to events automatically:
pull_request.opened→ generates description + runs review + health scanpull_request.synchronize→ re-runs health scan on force-pushpull_request_review_comment→ detects accept/reject feedback, feeds learning loop
git clone https://github.com/ixchio/AutoPR-AI && cd AutoPR-AI
python3 -m venv venv
./venv/bin/pip install -r requirements.txt
cp .env.example .env # fill in your keys
./venv/bin/python -m uvicorn app:app --host 0.0.0.0 --port 8080Copy .env.example to .env. Required:
| Variable | Purpose |
|---|---|
GITHUB_TOKEN |
Personal access token for GitHub API |
OPENROUTER_API_KEY |
LLM provider key (at least one required) |
DATABASE_URL |
sqlite+aiosqlite:///autopr.db (default) |
Optional (for GitHub App mode):
| Variable | Purpose |
|---|---|
GITHUB_APP_ID |
GitHub App installation ID |
GITHUB_APP_PRIVATE_KEY |
GitHub App private key (PEM) |
GITHUB_WEBHOOK_SECRET |
Webhook signature verification |
Interactive docs available at /docs when the server is running.
| Endpoint | Method | Description |
|---|---|---|
/api/describe/ |
POST | Generate PR description |
/api/describe/learn |
POST | Learn team format |
/api/review/ |
POST | Run AI code review |
/api/review/build-dna/{owner}/{repo} |
POST | Build Team DNA model |
/api/review/feedback |
POST | Record feedback |
/api/health/scan |
POST | Scan codebase health |
/api/health/trend/{owner}/{repo} |
GET | Health score trend |
/refactor |
POST | Trigger code refactoring |
/webhooks/github |
POST | GitHub App webhook receiver |
| Provider | Env Variable | Free Tier |
|---|---|---|
| OpenRouter | OPENROUTER_API_KEY |
Yes |
| OpenAI | OPENAI_API_KEY |
No |
| Anthropic | ANTHROPIC_API_KEY |
No |
| DeepSeek | DEEPSEEK_API_KEY |
No |
| Grok (xAI) | XAI_API_KEY |
No |
./venv/bin/python -m pytest tests/ -v14 tests covering PR description parsing, review output parsing, feedback guidance, and health scoring.
- Runtime: Python 3.12, FastAPI, uvicorn
- Database: SQLAlchemy async (SQLite default, PostgreSQL ready)
- Auth: PyJWT for GitHub App authentication
- Formatting: black + isort