8000 GitHub - longvv/codereview-cli Β· GitHub
[go: up one dir, main page]

Skip to content

About

No description, website, or topics provided.

Resources

Stars

0 stars

Watchers

0 watching

Forks

Latest commit

Β 

History

1 Commit

Folders and files

NameName
Last commit message
Last commit date
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 

Repository files navigation

CodeReview CLI

A simple, local command-line tool for automated code review using LLM providers (Gemini, Claude).

Features

  • πŸ” 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 --diff option
  • πŸ› οΈ Configurable: YAML-based configuration with project-specific overrides

Installation

Prerequisites

  • Python 3.8 or higher
  • pip package manager
  • Git (optional, for diff functionality)

Install from Source

  1. Clone or download the project:

    git clone <repository-url>
    cd codereview-cli
  2. Run the installation script:

    chmod +x install.sh
    ./install.sh

    Or install manually:

    pip3 install -e .

Configuration

API Keys Setup

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

Get API Keys

Configuration File

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

Usage

Basic Usage

# 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

Advanced Examples

# 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

CI/CD Integration

# 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

Command Line Options

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 -

Supported Languages

  • 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)

Review Focus Areas

Security

  • SQL injection vulnerabilities
  • XSS vulnerabilities
  • Authentication/authorization issues
  • Input validation problems
  • Cryptographic weaknesses

Quality

  • Code complexity
  • Maintainability issues
  • Design patterns
  • Error handling
  • Code organization

Performance

  • Algorithm efficiency
  • Memory usage
  • Database query optimization
  • Caching opportunities
  • Resource management

Style

  • Code formatting
  • Naming conventions
  • Documentation
  • Best practices
  • Language-specific idioms

Privacy & Security

  • 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

Troubleshooting

Common Issues

API Key Not Found

Error: GEMINI_API_KEY environment variable not set

Solution: Set your API key in .env file or environment variables.

Git Not Available

Warning: Git not available, --diff option disabled

Solution: Install Git or use without --diff option.

Configuration File Not Found

Warning: Configuration file not found, using defaults

Solution: Create .codereview.yml file or specify path with --config.

Debug Mode

# Enable verbose logging
codereview --verbose

# Check configuration
codereview --config /path/to/config.yml --verbose

Development

Running Tests

# Install development dependencies
pip install -e ".[dev]"

# Run tests
pytest tests/ -v

# Run with coverage
pytest tests/ --cov=src --cov-report=html

Project Structure

codereview-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

Contributing

  1. Fork the repository
  2. Create a feature branch
  3. Make your changes
  4. Add tests for new functionality
  5. Run the test suite
  6. Submit a pull request

License

MIT License - see LICENSE file for details.

Changelog

v1.0.0

  • Initial release
  • Support for Gemini and Claude providers
  • Multi-language code analysis
  • Git diff integration
  • Configurable review focus areas
  • Terminal and JSON output formats

About

No description, website, or topics provided.

Resources

Stars

0 stars

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages

0