AI-powered Pull Request reviewer that scores, comments, auto-fixes, and blocks bad code from reaching production.
PRGuard is a GitHub bot that automatically reviews every Pull Request using LLaMA 3.3 running on Groq. It scores your code 0β10, posts inline comments on problem lines, creates auto-fix branches with AI-applied corrections, and sets a green β or red β commit status β all within seconds of opening a PR.
No configuration required. Just add the webhook and it works.
Here is the complete step-by-step flow from PR to review:
Developer pushes code β GitHub sends webhook β PRGuard reviews β Results posted
Step 1 β Developer opens a Pull Request
A developer pushes code to a branch and opens a PR on GitHub.
Step 2 β GitHub sends a webhook event
GitHub instantly sends a POST request to PRGuard's webhook endpoint with the PR payload.
Step 3 β Signature verified
PRGuard verifies the HMAC-SHA256 webhook signature to confirm the request is genuine.
Step 4 β Diff fetched
PRGuard calls the GitHub API to fetch the full code diff of the PR.
Step 5 β Custom rules loaded
PRGuard checks if a
prguard.ymlfile exists in the repo root and loads any custom rules and threshold.
Step 6 β AI reviews the code
The diff + custom rules are sent to LLaMA 3.3 via Groq. The model scores the code 0β10 and identifies issues across 8 categories.
Step 7 β Inline comments posted
PRGuard posts a comment directly on each problem line in the diff with severity, category, description, and fix.
Step 8 β Summary comment posted
A formatted summary comment is posted on the PR with the score bar, verdict, and all issues in collapsible sections.
Step 9 β Auto-fix branch created (if PR failed)
PRGuard creates a new branch
prguard/fix-pr-{number}-{sha}, applies AI corrections to each affected file, and pushes the fixes.
Step 10 β Review saved to database
The review result is saved to PostgreSQL for dashboard analytics and chat history.
Step 11 β Commit status set
GitHub commit status is set to β
success(score β₯ threshold) or βfailure(score < threshold).
Step 12 β Developer can chat with the bot
Developer comments
/prguard <question>on the PR and the bot replies with a context-aware answer.
βββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ
β PRGuard Pipeline β
ββββββββββββ¬βββββββββββ¬βββββββββββ¬βββββββββββ¬βββββββββββββββββ€
β Step 1 β Step 2 β Step 3 β Step 4 β Step 5 β
β PR Open β Webhook β Verify β Fetch β Load Rules β
β β Event β Sig β Diff β prguard.yml β
ββββββββββββΌβββββββββββΌβββββββββββΌβββββββββββΌβββββββββββββββββ€
β Step 6 β Step 7 β Step 8 β Step 9 β Step 10-12 β
β AI Reviewβ Inline β Summary β Auto-Fix β Save + Status β
β Groq βComments β Comment β Branch β + Chat β
ββββββββββββ΄βββββββββββ΄βββββββββββ΄βββββββββββ΄βββββββββββββββββ
| Feature | Description |
|---|---|
| π€ AI Code Review | Scores every PR 0β10 across 8 quality categories |
| π¬ Inline Comments | Posts issues directly on the affected line in the diff |
| π₯ Auto-Fix Branch | Creates a prguard/fix-pr-* branch with AI-applied corrections |
| π Team Dashboard | Live dashboard with score trends, pass rates, and issue breakdown |
| βοΈ Custom Rules | Define team standards in prguard.yml β bot enforces them automatically |
| π¬ PR Chat | Comment /prguard <question> to ask the bot anything about the review |
| π Smart Retry | Handles API rate limits with exponential backoff (4 attempts) |
| β Commit Status | Sets GitHub green β or red β check on every PR |
PRGuard checks 8 categories on every PR β plus any custom rules you define:
| Category | What It Checks |
|---|---|
| π·οΈ Naming | Single letters, abbreviations, misleading variable names |
| π§© Complexity | Functions >30 lines, deeply nested conditionals |
| β»οΈ Duplication | Repeated logic blocks without abstraction |
| Missing try/except on I/O, network, and DB calls | |
| π’ Magic Values | Hardcoded strings/numbers that should be constants or config |
| π Security | Secrets in code, SQL injection, missing input validation |
| π‘οΈ Type Safety | Missing type hints in Python, implicit any in TypeScript |
| π Dead Code | Commented-out blocks, unused imports and variables |
| π Custom | Your team's own rules from prguard.yml |
| Score | Grade | Meaning |
|---|---|---|
| 9β10 | β Excellent | Near-perfect. Ready to merge. |
| 7β8 | β Good | Acceptable. Minor issues only. |
| 5β6 | Real problems. Fix before merging. | |
| 3β4 | β Poor | Multiple critical issues. Do not merge. |
| 0β2 | π¨ Unacceptable | Rewrite required. |
Multiple HIGH severity issues cannot score above 6.
Drop a prguard.yml file in your repo root to enforce team-specific standards:
rules:
- "All functions must have docstrings"
- "No print() statements allowed in production code"
- "All HTTP calls must have timeout set explicitly"
- "Database calls must use transactions"
threshold: 8PRGuard picks this up automatically on every PR β no restarts needed.
Comment /prguard <question> directly on any PR:
/prguard what is the most critical issue to fix first?
/prguard how do I fix the complexity issue in main.py?
/prguard why did this PR fail?
The bot replies with a detailed, context-aware answer based on the actual review results.
GitHub PR Event
β
βΌ
βββββββββββββββ ββββββββββββββββ βββββββββββββββ
β Webhook ββββββΆβ FastAPI App ββββββΆβ Groq API β
β (GitHub) β β (Railway) β β LLaMA 3.3 β
βββββββββββββββ ββββββββ¬ββββββββ βββββββββββββββ
β
ββββββββββββββΌβββββββββββββ
βΌ βΌ βΌ
ββββββββββββ ββββββββββββ ββββββββββββ
β Inline β β Auto-Fix β βDashboard β
β Comments β β Branch β β(Postgres)β
ββββββββββββ ββββββββββββ ββββββββββββ
PRGuard/
βββ app/
β βββ main.py # FastAPI app & webhook handler
β βββ ai_reviewer.py # Groq review engine + retry logic
β βββ auto_fixer.py # Auto-fix branch creator
β βββ github_client.py # GitHub API wrapper
β βββ formatter.py # PR comment formatting
β βββ database.py # PostgreSQL storage
β βββ dashboard.html # Mission Control UI
β βββ home.html # Landing page
β βββ rules.py # prguard.yml parser
β βββ chat.py # /prguard chat handler
β βββ models.py # Pydantic data models
β βββ config.py # Settings & env vars
βββ prguard.yml # Custom rules example
βββ Procfile # Railway start command
βββ requirements.txt
- Python 3.11+
- GitHub account & personal access token
- Groq API key (free tier available)
- ngrok for local development
git clone https://github.com/AtharvaVavhal/PRGuard.git
cd PRGuard
python -m venv venv
source venv/bin/activate # Windows: venv\Scripts\activate
pip install -r requirements.txtCreate a .env file in the project root:
GITHUB_TOKEN=your_github_personal_access_token
GITHUB_WEBHOOK_SECRET=your_webhook_secret
GROQ_API_KEY=your_groq_api_key
GROQ_MODEL=llama-3.3-70b-versatile
PASS_SCORE_THRESHOLD=7
LOG_LEVEL=INFO
DATABASE_URL=postgresql://... # Railway provides this automatically# Start ngrok tunnel
ngrok http 8000
# Start the server
uvicorn app.main:app --port 8000- Go to your repo β Settings β Webhooks β Add webhook
- Payload URL:
https://your-ngrok-url/webhook/github - Content type:
application/json - Secret: your webhook secret
- Events: select
Pull requestsandIssue comments
# prguard.yml β place in your repo root
rules:
- "All functions must have docstrings"
- "No hardcoded API keys"
threshold: 7# 1. Fork this repo on GitHub
# 2. Go to railway.app β New Project β Deploy from GitHub repo
# 3. Add PostgreSQL database to the project
# 4. Set all environment variables in the Variables tab
# 5. Railway auto-deploys on every push β
Update your GitHub webhook URL to https://your-app.up.railway.app/webhook/github.
| Layer | Technology |
|---|---|
| API Framework | FastAPI + Uvicorn |
| AI Model | LLaMA 3.3 70B via Groq |
| GitHub Integration | GitHub REST API v3 |
| Database | PostgreSQL |
| HTTP Client | httpx |
| Config Parsing | PyYAML |
| Deployment | Railway |
| Language | Python 3.11 |
Contributions are welcome!
# 1. Fork the repo
# 2. Create your feature branch
git checkout -b feature/my-feature
# 3. Commit your changes
git commit -m 'add my feature'
# 4. Push and open a PR
git push origin feature/my-featurePRGuard will automatically review your PR. Meta. π€
MIT License β see LICENSE for details.
Built with β€οΈ Β Β·Β Powered by Groq + LLaMA 3.3 Β Β·Β Deployed on Railway
β Star this repo if PRGuard saved your codebase!
π Live Demo Β Β·Β π Report Bug Β Β·Β π‘ Request Feature