Skip to main content

AI-powered code review tool using LLMs

Project description

Coderev

PyPI version Python versions License

An AI-powered code review tool that uses LLMs to provide intelligent feedback on your pull requests.

  • Supports multiple LLM providers (OpenAI, Anthropic, Gemini, Mistral)
  • Seamless Git integration
  • Customizable review focus and guidelines
  • Command-line interface with persistent configuration

Installation

pip install coderev

Requirements

  • Python ≥ 3.8
  • Git repository
  • One of the following:
    • OpenAI API key for GPT-4 models
    • Anthropic API key for Claude models
    • Mistral API key for Mistral models
    • Gemini API key for Google models
    • Local Ollama installation

Quick Start

  1. Initialize Coderev in your git repository:
coderev init
  1. Set up your preferred LLM provider (e.g., OpenAI):
export OPENAI_API_KEY='your-api-key'
  1. Review your changes:
coderev review

Usage

Basic Commands

# Review current branch
coderev review

# Review specific branch
coderev review feature/xyz

# Review specific files
coderev review -f src/main.py tests/test_main.py

# List available branches
coderev list

Command Options

coderev review [OPTIONS] [BRANCH_NAME]

Options:
  --base-branch TEXT          Base branch for comparison (default: main/master)
  -f, --review-files FILE     Review specific files
  --model TEXT               LLM model to use (default: gpt-4o)
  --temperature FLOAT        Model temperature 0-1 (default: 0.0)
  --system-message TEXT      Custom system message/persona
  --review-instructions TEXT Custom review guidelines
  --debug                    Enable debug mode
  --help                     Show this message and exit

Configuration

Configure defaults in .coderev.config:

# View configuration
coderev config list

# Set values
coderev config set model gpt-4o
coderev config set base_branch main
coderev config set temperature 0.0
coderev config set system_message "Custom reviewer persona"
coderev config set review_instructions "Custom review focus"

Supported Models

Coderev uses litellm for model integration and supports:

  • OpenAI models (requires OPENAI_API_KEY):

    • gpt-4o (recommended)
    • o1-mini (faster)
  • Anthropic models (requires ANTHROPIC_API_KEY):

    • claude-3-sonnet-20240320
  • Mistral models (requires MISTRAL_API_KEY):

    • mistral/mistral-large-latest
  • Gemini models (requires GEMINI_API_KEY):

    • gemini/gemini-1.5-pro-latest
  • Local models (requires Ollama):

    • ollama/qwen2.5-coder

Environment Variables

Variable Description Required For
OPENAI_API_KEY OpenAI API key OpenAI models
ANTHROPIC_API_KEY Anthropic API key Claude models
MISTRAL_API_KEY Mistral API key Mistral models
GEMINI_API_KEY Google API key Gemini models
CODEREV_DEBUG_ENABLED Enable debug mode Debugging (optional)

Development

Setup Development Environment

# Clone the repository
git clone https://github.com/isavita/coderev
cd coderev

# Create and activate virtual environment
python -m venv venv
source venv/bin/activate  # or `venv\Scripts\activate` on Windows

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

Running Tests

# Run tests with coverage
pytest

# Run specific test
pytest tests/test_main.py -k test_name

# Run with debug output
pytest -vv

Project Structure

coderev/
├── src/
│   └── coderev/
│       ├── __init__.py      # Package version and metadata
│       └── main.py          # Core functionality
├── tests/
│   ├── __init__.py
│   └── test_main.py        # Tests
├── setup.cfg               # Package metadata and config
├── pyproject.toml         # Build system requirements
└── README.md             # This file

Contributing

Contributions are welcome! Please feel free to submit a Pull Request.

License

This project is licensed under the Apache License 2.0 - see the LICENSE file for details.

Credits

  • litellm - LLM provider integration
  • Click - CLI framework
  • Rich - Terminal formatting

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

coderev-0.1.0.tar.gz (15.0 kB view details)

Uploaded Source

Built Distribution

coderev-0.1.0-py3-none-any.whl (9.1 kB view details)

Uploaded Python 3

File details

Details for the file coderev-0.1.0.tar.gz.

File metadata

  • Download URL: coderev-0.1.0.tar.gz
  • Upload date:
  • Size: 15.0 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/5.1.1 CPython/3.11.7

File hashes

Hashes for coderev-0.1.0.tar.gz
Algorithm Hash digest
SHA256 a2a2482ae8143d532a65afb7d53682f78d6c5efda7087756047e618578456a67
MD5 0b9d0351f9fac37e7e7d780ae750c118
BLAKE2b-256 6be5ca97cd05bee21956e4c62a2fd7587b5e3728cd90e7012256fbfc61bac5c3

See more details on using hashes here.

File details

Details for the file coderev-0.1.0-py3-none-any.whl.

File metadata

  • Download URL: coderev-0.1.0-py3-none-any.whl
  • Upload date:
  • Size: 9.1 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/5.1.1 CPython/3.11.7

File hashes

Hashes for coderev-0.1.0-py3-none-any.whl
Algorithm Hash digest
SHA256 a5c3ce88f3905ba277b1484bd4956942b4736109221eec1b2f6e301a5669fa88
MD5 59fced2daf45d04b6418a749c85f5d72
BLAKE2b-256 4a5f414d349bf3ff611b4bd3993edd65da4c5f115c71ed61e69988cb4c784b03

See more details on using hashes here.

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page