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.2.tar.gz (16.0 kB view details)

Uploaded Source

Built Distribution

coderev-0.1.2-py3-none-any.whl (9.4 kB view details)

Uploaded Python 3

File details

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

File metadata

  • Download URL: coderev-0.1.2.tar.gz
  • Upload date:
  • Size: 16.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.2.tar.gz
Algorithm Hash digest
SHA256 b9c7033755acb6862a2ee49094e1bbf3fb0cd076670c1e3885b8495cfcc3bbe7
MD5 eb445ac9e51fa3c09a5a1bd91e20d7c1
BLAKE2b-256 86bdbf4d01d683e08686f4e33400899848c5a8c55c96e59da77f6757bc9e9cfd

See more details on using hashes here.

File details

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

File metadata

  • Download URL: coderev-0.1.2-py3-none-any.whl
  • Upload date:
  • Size: 9.4 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.2-py3-none-any.whl
Algorithm Hash digest
SHA256 c3bcdfd26f62002b6aef79021067353fa8d23005fac97bcab6588e5fd2fd08a2
MD5 f2c7fb4a83795a9876a26ab6d188be83
BLAKE2b-256 ca5449e2701b691cc7eb4bfc1767c61b36b64d8fe06e9a3075c0b30e1c350c22

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