A simple, local command-line tool for automated code review using LLM providers (Gemini, Claude).
- π Multi-language support: Python, JavaScript, TypeScript, Java, Go, C/C++
- π€ Multiple LLM providers: Google Gemini and Anthropic Claude
- π― Focused reviews: Security, quality, performance, and style analysis
- π Rich output: Terminal with colors/tables or JSON for CI/CD integration
- π Privacy-first: Code sanitization removes sensitive data before review
- β‘ Git integration: Review only changed files with
--diffoption - π οΈ Configurable: YAML-based configuration with project-specific overrides
- Python 3.8 or higher
- pip package manager
- Git (optional, for diff functionality)
-
Clone or download the project:
git clone <repository-url> cd codereview-cli
-
Run the installation script:
chmod +x install.sh ./install.sh
Or install manually:
pip3 install -e .
Create a .env file in your project root or set environment variables:
# For Google Gemini
GEMINI_API_KEY=your_gemini_api_key_here
# For Anthropic Claude
ANTHROPIC_API_KEY=your_anthropic_api_key_here- Google Gemini: Get your API key from Google AI Studio
- Anthropic Claude: Get your API key from Anthropic Console
Create a .codereview.yml file in your project root to customize settings:
# LLM Provider settings
llm:
provider: "gemini" # or "claude"
gemini:
model: "gemini-1.5-flash"
max_tokens: 8192
temperature: 0.1
claude:
model: "claude-3-5-sonnet-20241022"
max_tokens: 8192
temperature: 0.1
# Review focus areas
review:
performance: true
style: true
security: true
quality: true
# File exclusions
exclusions:
directories:
- "node_modules"
- ".git"
- "__pycache__"
files:
- "*.min.js"
- "*.log"
# Output settings
output:
format: "terminal" # or "json"
colors: true
icons: true# Review all files in current directory
codereview
# Review specific files
codereview file1.py file2.js
# Review only changed files (Git diff)
codereview --diff
# Quick review (faster, less detailed)
codereview --quick
# Focus on specific areas
codereview --focus security,performance
# Use specific LLM provider
codereview --provider claude
# Output as JSON for CI/CD
codereview --output json# Review with custom config
codereview --config /path/to/custom-config.yml
# Verbose output with detailed logging
codereview --verbose
# Quiet mode (minimal output)
codereview --quiet
# Review specific directory
codereview /path/to/project# GitHub Actions example
name: Code Review
on: [pull_request]
jobs:
review:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- name: Setup Python
uses: actions/setup-python@v4
with:
python-version: '3.9'
- name: Install CodeReview CLI
run: |
pip install -e .
- name: Run Code Review
env:
GEMINI_API_KEY: ${{ secrets.GEMINI_API_KEY }}
run: |
codereview --diff --output json > review-results.json| Option | Description | Default |
|---|---|---|
--config |
Path to custom configuration file | .codereview.yml |
--focus |
Comma-separated focus areas (security,quality,performance,style) | All areas |
--quick |
Enable quick review mode | False |
--output |
Output format (terminal/json) | terminal |
--diff |
Review only Git diff changes | False |
--verbose |
Enable verbose logging | False |
--quiet |
Minimal output mode | False |
--provider |
LLM provider (gemini/claude) | From config |
--version |
Show version information | - |
--help |
Show help message | - |
- Python (.py)
- JavaScript (.js, .jsx)
- TypeScript (.ts, .tsx)
- Java (.java)
- Go (.go)
- C/C++ (.c, .cpp, .h, .hpp)
- C# (.cs)
- PHP (.php)
- Ruby (.rb)
- Rust (.rs)
- SQL injection vulnerabilities
- XSS vulnerabilities
- Authentication/authorization issues
- Input validation problems
- Cryptographic weaknesses
- Code complexity
- Maintainability issues
- Design patterns
- Error handling
- Code organization
- Algorithm efficiency
- Memory usage
- Database query optimization
- Caching opportunities
- Resource management
- Code formatting
- Naming conventions
- Documentation
- Best practices
- Language-specific idioms
- Local Processing: Code analysis happens locally
- Data Sanitization: Sensitive data is removed before sending to LLM
- No Code Storage: Your code is not stored by LLM providers
- API Key Security: Store API keys securely in environment variables
API Key Not Found
Error: GEMINI_API_KEY environment variable not setSolution: Set your API key in .env file or environment variables.
Git Not Available
Warning: Git not available, --diff option disabledSolution: Install Git or use without --diff option.
Configuration File Not Found
Warning: Configuration file not found, using defaultsSolution: Create .codereview.yml file or specify path with --config.
# Enable verbose logging
codereview --verbose
# Check configuration
codereview --config /path/to/config.yml --verbose# Install development dependencies
pip install -e ".[dev]"
# Run tests
pytest tests/ -v
# Run with coverage
pytest tests/ --cov=src --cov-report=htmlcodereview-cli/
βββ src/
β βββ cli.py # Main CLI interface
β βββ config/ # Configuration management
β βββ analyzer/ # Code scanning and analysis
β βββ llm/ # LLM provider implementations
β βββ output/ # Output formatting
βββ config/
β βββ default.yml # Default configuration
β βββ templates/ # Configuration templates
βββ tests/ # Test suite
βββ requirements.txt # Dependencies
- Fork the repository
- Create a feature branch
- Make your changes
- Add tests for new functionality
- Run the test suite
- Submit a pull request
MIT License - see LICENSE file for details.
- Initial release
- Support for Gemini and Claude providers
- Multi-language code analysis
- Git diff integration
- Configurable review focus areas
- Terminal and JSON output formats