@blockdeepanshu/ai-pr-review-cli
v1.2.0
Published
π€ AI-powered Pull Request reviewer - Get instant feedback on your code changes using GPT
Maintainers
Readme
π€ AI PR Review CLI
An intelligent command-line tool that uses AI to review your code changes and provide instant feedback on issues, typos, and improvements. Perfect for any programming language and project type.
β¨ Key Features
- π Smart Code Analysis - Uses GPT to find bugs, security issues, and improvements
- π― Auto Branch Detection - Automatically detects your base branch (main/master/develop)
- π Intelligent Batching - Processes ALL files in manageable batches (5 files per batch)
- π No File Limits - Reviews unlimited files without losing any data
- β‘ Rate Limit Protection - Smart delays between batches prevent API errors
- π¨ Beautiful Output - Clean, colorful results with progress tracking
- π Universal Support - Works with any language, framework, or project type
- βοΈ Flexible Config - Multiple ways to customize behavior
- π‘οΈ Error Recovery - Continues processing even if one batch fails
π Quick Start
1. Install
# Install globally
npm install -g @blockdeepanshu/ai-pr-review-cli
# Or use without installing
npx @blockdeepanshu/ai-pr-review-cli review2. Get OpenAI API Key
Get your API key from OpenAI
3. Set API Key
Windows:
# PowerShell - current session
$env:OPENAI_API_KEY="your-api-key-here"
# Permanent (via System Properties > Environment Variables)
# Variable name: OPENAI_API_KEY
# Variable value: your-api-key-hereMac/Linux:
# Current session
export OPENAI_API_KEY="your-api-key-here"
# Permanent (add to ~/.bashrc or ~/.zshrc)
echo 'export OPENAI_API_KEY="your-api-key-here"' >> ~/.bashrc4. Use in Any Git Repository
# Navigate to your project
cd my-project
# Review your changes
ai-pr-review review
# Short alias also works
aipr reviewπ» Usage Examples
Small Projects
# Simple review - auto-detects base branch
ai-pr-review review
# Review against specific branch
ai-pr-review review --base main
# Use GPT-4 for higher quality
ai-pr-review review --model gpt-4oLarge Projects (Multiple Approaches)
Method 1: Automatic Batching (Built-in)
# The standard review now automatically batches files
ai-pr-review review # Processes ALL files in batches of 5
# With verbose output to see batching progress
ai-pr-review review --verboseMethod 2: Advanced Batch Mode
# Smart batching by file type (React, Vue, Angular, etc.)
ai-pr-review batch --frontend
# Custom batch size for different project needs
ai-pr-review batch --batch-size 6
# Preview what would be reviewed (no API calls)
ai-pr-review batch --dry-runMethod 3: Selective Review
# Review only specific files
git add src/important-file.js src/critical-component.js
ai-pr-review review # Only reviews staged filesπ Common Workflows
Feature Development
# Create feature branch
git checkout -b feature/new-feature
# Make changes, then review before committing
ai-pr-review review
# Address feedback, then commit
git add .
git commit -m "Implement new feature"Large Codebase Updates
# Stage all changes
git add .
# Smart automatic batching handles everything
ai-pr-review review --verbose
# Example output for 23 files:
# π Processing 5 batches of files (5 files per batch)...
# --- Batch 1/5 ---
# Files: auth.js, login.js, middleware.js, routes.js, config.js
# β
Batch 1 completed: 3 issues, 1 typo, 4 improvements
# β³ Waiting 3 seconds before next batch...
# [continues for all batches...]
# Final consolidated results:
# π¨ Issues: bugs, security, performance
# βοΈ Typos: spelling, grammar
# π‘ Improvements: best practices, refactoringDifferent Project Types
# Works automatically for any project:
cd react-frontend && ai-pr-review batch --frontend
cd node-api && ai-pr-review batch
cd python-ml && ai-pr-review batch
cd java-enterprise && ai-pr-review batch
cd devops-terraform && ai-pr-review batchβοΈ Configuration Options
Global Config (One-time Setup)
# Set default preferences
ai-pr-review config --model gpt-4o-mini --base main
# Creates ~/.aiprconfig.json with your defaultsProject Config (.aiprconfig.json)
{
"provider": "openai",
"model": "gpt-4o-mini",
"baseBranch": "develop"
}Command Line Options
| Option | Description | Example |
|--------|-------------|---------|
| --base <branch> | Compare against specific branch | --base origin/develop |
| --model <model> | Use specific AI model | --model gpt-4o |
| --verbose | Show detailed analysis info | --verbose |
| --batch-size <n> | Files per batch (default: 8) | --batch-size 4 |
| --frontend | Optimize for frontend projects | --frontend |
| --dry-run | Preview without API calls | --dry-run |
π― What Gets Analyzed
Code Changes
- β Committed changes (between branches)
- β
Staged changes (
git add) - β Working directory changes (uncommitted)
File Types Supported
- Web: JavaScript, TypeScript, HTML, CSS, SCSS
- Backend: Python, Java, Go, Ruby, PHP, C#
- Mobile: React Native, Flutter, Swift, Kotlin
- DevOps: Terraform, Docker, Kubernetes, YAML
- Data: SQL, R, Jupyter notebooks
- Config: JSON, YAML, TOML, XML
- Documentation: Markdown, reStructuredText
π How Batching Works
Automatic Batching (Default)
The tool automatically processes files in batches to handle any number of files efficiently:
ai-pr-review review # Automatically batches files
# Example with 23 files:
π Found 23 changed files: auth.js, login.js, config.js...
π Processing 5 batches of files (5 files per batch)...
--- Batch 1/5 ---
Files: auth.js, login.js, middleware.js, routes.js, config.js
β
Batch 1 completed: 3 issues, 1 typo, 4 improvements
β³ Waiting 3 seconds before next batch...
--- Batch 2/5 ---
Files: utils.js, helpers.js, constants.js, api.js, db.js
β
Batch 2 completed: 2 issues, 0 typos, 3 improvements
β³ Waiting 3 seconds before next batch...
[... continues for all files ...]
π Final Summary: 12 issues, 4 typos, 18 improvementsBenefits
- β No File Limits - Reviews unlimited files
- β Rate Limit Safe - 3-second delays prevent API errors
- β Progress Tracking - See which batch is processing
- β Error Recovery - If one batch fails, others continue
- β Memory Efficient - Processes files in manageable chunks
π§ Troubleshooting
Rate Limit Errors (429)
# The tool now automatically handles rate limits with batching
ai-pr-review review # Built-in 3-second delays between batches
# For very large projects, use advanced batch mode
ai-pr-review batch --batch-size 3 # Smaller batches
# Or wait 1-2 minutes and retry
ai-pr-review review
# Consider upgrading OpenAI plan for higher limitsNo Changes Found
# Check git status
git status
# Make sure you're not on the main branch
git checkout -b feature/my-changes
# Or specify different base branch
ai-pr-review review --base origin/masterAPI Key Issues
# Verify key is set
echo $OPENAI_API_KEY # Mac/Linux
echo $env:OPENAI_API_KEY # Windows PowerShell
# Test with simple review
ai-pr-review review --verboseπ‘ Pro Tips
Efficient Workflows
# Review before committing
git add changed-files/
ai-pr-review review
# Fix issues, then commit
# Review large changes in batches
ai-pr-review batch --dry-run # Preview
ai-pr-review batch # ExecuteCost Optimization
# Use mini model for regular reviews (cheaper)
ai-pr-review review --model gpt-4o-mini
# Use GPT-4 for critical reviews (more thorough)
ai-pr-review review --model gpt-4o
# Set as default
ai-pr-review config --model gpt-4o-miniShell Aliases
# Add to ~/.bashrc or ~/.zshrc
alias review="ai-pr-review review"
alias batch-review="ai-pr-review batch"
alias quick-review="ai-pr-review review --model gpt-4o-mini"
# Usage
review --base develop
batch-review --frontend
quick-reviewπ Platform Support
| Platform | Status | Notes |
|----------|--------|-------|
| GitHub | β
| Full support |
| GitLab | β
| Full support |
| Bitbucket | β
| Full support |
| Azure DevOps | β
| Full support |
| Local Git | β
| Works without remote |
π Sample Output
Single File Review
git add problematic-file.js
ai-pr-review review
π€ AI PR Review
ββββββββββββββββββββββββββββββββββββββββ
π Analyzing changes on branch: feature/auth-fixes
π Found 1 changed file: problematic-file.js
π Processing 1 batch of files (5 files per batch)...
--- Batch 1/1 ---
Files: problematic-file.js
β
Batch 1 completed: 3 issues, 1 typo, 2 improvements
β Review completed!
π¨ Issues
1. Invalid JavaScript syntax: unexpected semicolon and commas
2. Missing input validation for user input
3. Use const instead of var for better scoping
βοΈ Typos
1. "recieve" should be "receive" in comment
π‘ Improvements
1. Add proper error handling
2. Remove unused variables
π Review Summary: 3 issues, 1 typo, 2 improvementsLarge Project Review
git add . # 23 files
ai-pr-review review --verbose
π€ AI PR Review
ββββββββββββββββββββββββββββββββββββββββ
π Analyzing changes on branch: feature/auth-system
π Found 23 changed files: auth.js, login.js, middleware.js, routes.js...
π Processing 5 batches of files (5 files per batch)...
--- Batch 1/5 ---
Files: auth.js, login.js, middleware.js, routes.js, config.js
π Debug - Files with content:
1. auth.js (1,240 chars): "const jwt = require('jsonwebtoken'); const bcrypt..."
2. login.js (856 chars): "// Login component with validation..."
β
Batch 1 completed: 4 issues, 1 typo, 3 improvements
β³ Waiting 3 seconds before next batch...
--- Batch 2/5 ---
Files: utils.js, helpers.js, constants.js, api.js, db.js
β
Batch 2 completed: 2 issues, 0 typos, 4 improvements
β³ Waiting 3 seconds before next batch...
[... continues for all 5 batches ...]
β Review completed!
π¨ Issues
1. Missing input validation in auth.js:15
2. Potential SQL injection in routes.js:42
3. Password stored in plain text - use bcrypt
[... 9 more issues ...]
βοΈ Typos
1. "recieve" should be "receive" in comment (auth.js:8)
[... 2 more typos ...]
π‘ Improvements
1. Add rate limiting to login endpoint
2. Use environment variables for JWT secret
[... 16 more improvements ...]
π Review Summary: 12 issues, 3 typos, 19 improvementsπ Security & Privacy
- Code is sent to OpenAI's API for analysis
- No permanent storage of your code
- Use
.gitignoreto exclude sensitive files - Review OpenAI's data usage policies
- Consider using on non-production codebases first
π Performance for Any Repository Size
Smart Handling of Large Codebases
| Repository Size | Processing Method | Time | Success Rate | |----------------|------------------|------|--------------| | 1-5 files | Single batch | ~10 seconds | β 100% | | 6-25 files | 2-5 batches | ~30-60 seconds | β 100% | | 26-100 files | 5-20 batches | 2-5 minutes | β 100% | | 100+ files | Smart batching | 5-15 minutes | β 100% |
Before vs After
- Old Approach: Limited to 10 files = Many files ignored β
- New Approach: Unlimited files in smart batches = All files reviewed β
Real-World Examples
# Small project (5 files)
π Found 5 files β π 1 batch β β
~15 seconds
# Medium project (23 files)
π Found 23 files β π 5 batches β β
~90 seconds
# Large project (87 files)
π Found 87 files β π 18 batches β β
~8 minutes
# Enterprise project (200+ files)
π Found 234 files β π 47 batches β β
~15 minutesEfficiency Features
- β No File Limits - Review unlimited files
- β Smart Rate Limiting (3-second delays between batches)
- β Progress Tracking for long reviews
- β Error Recovery - continues even if one batch fails
- β Memory Efficient - processes in manageable chunks
π License
MIT License - see LICENSE file for details.
π€ Contributing
Contributions welcome! Feel free to:
- Report bugs or request features
- Submit pull requests
- Improve documentation
- Share usage examples
π Support
- Issues: GitHub Issues
- Discussions: GitHub Discussions
Made with β€οΈ for developers who want smarter code reviews
Save time, catch bugs, and improve code quality with AI-powered reviews π
