Automate Pull Request Reviews with ChatGPT, Grok & Gemini
Welcome to AI Code Reviewer, a Python tool built by AnyMaint to streamline code reviews using large language models (LLMs). Catch issues, summarize PRs, and even comment directly on GitHub—all powered by ChatGPT, Grok or Gemini. We’re open-sourcing this to share with the community and grow our startup’s footprint!
- General Overview: Get a high-level summary of what a PR does, based on its description and changes.
- Issue Detection: Identify potential problems in diffs (ignores unchanged code by default).
- PR Comments: Automatically post issues as inline comments on open pull requests.
- Multi-LLM Support: Switch between ChatGPT, Grok and Gemini with a simple flag.
- Deep Review Mode: Use
--deepfor verbose reviews including non-bug feedback like data migration or documentation; default mode focuses on critical bugs only. - SVN Revisions: Review a single Subversion revision by passing its commit number; issues are printed to stdout (no inline comments).
- Repository-Specific Rules: Add
.ai-reviewer.ymlin the repository root to enforce custom review rules and ignore paths.
- Clone the repo:
git clone https://github.com/AnyMaint/code-reviewer.git
cd code-reviewer- Install dependencies:
pip install -r requirements.txt- Set environment variables:
export GITHUB_TOKEN="your-github-token" #
export BITBUCKET_APP_PASSWORD="your-bitbucket-app-password" #
export BITBUCKET_USERNAME="your-bitbucket-username" #
export BITBUCKET_WORKSPACE="your-bitbucket-workspace" # by default username will reused
export OPENAI_API_KEY="your-openai-key" # For ChatGPT
export GOOGLE_API_KEY="your-google-key" # For Gemini
export XAI_API_KEY="your-x-key" # For Grok
export GITLAB_TOKEN="your-gitlab-token" # For GitLab
export OPENAI_BASE_URL="http://localhost:11434/v1" # For ollama or self-managged instance of OpenAI-compatible LLM.
export OPENAI_MODEL=llama3.1:8b #There are 2 scripts - describe-pr.py for general PR summary and review.py for issues and comments.
There is an article how to use the tool. It may be outdated, but it is a good start: How to Use AI Code Reviewer
- General PR Summary using Gitlab::
python describe-pr.py "owner/repo" 123 --vcsp gitlab- **List Issues Only Using Grok **:
python review.py "owner/repo" 123 --mode issues --llm grok- List Issues with Verbose Feedback Using ChatGPT:
python review.py "owner/repo" 123 --mode issues --llm chatgpt --deep- Post Comments to PR in GitHub with Gemini:
python review.py "owner/repo" --pr 123 --mode comments --llm gemini- Add
--full-contextto include whole files, or--debugto see LLM requests. - Review an SVN Revision (no comments, issues printed):
python review.py "https://svn.example.com/repos/project/trunk" 527 --vcsp svnOptional: set SVN_USERNAME / SVN_PASSWORD (and SVN_TRUST_FAILURES for cert errors) to avoid interactive prompts.
Create .ai-reviewer.yml at repository root to customize review behavior:
version: 1
review:
global_must:
- "Flag SQL string interpolation as a bug."
global_avoid:
- "Do not suggest style-only improvements unless --deep is used."
ignore_paths:
- "docs/**"
- "migrations/**"
path_rules:
- paths: ["backend/**/*.py"]
must:
- "Flag broad except Exception without logging or re-raise."Behavior:
- Rules file is read from the PR head version (
head_sha) so PR updates to.ai-reviewer.ymlare applied immediately. - If
.ai-reviewer.ymlis not changed in the PR, it is still read from repository at PR head ref. - Files matching
ignore_pathsare excluded from review input. - If all changed files are ignored, no LLM API call is made.
We’re a small startup and love community help! Fork it, fix it, PR it—see CONTRIBUTING.md for details. Found a bug? Open an issue!
AnyMaint delivers a web-based CMMS for maintenance management, blending machine learning with modular design to monitor equipment, schedule calibrations, and optimize workflows. Tailored for industries like pharmaceuticals and medical devices, we simplify data-driven decisions for production floors.
Licensed under the BSD 3-Clause License - see the LICENSE file for details.
- Built with inspiration from Grok at xAI.
- Powered by ChatGPT (OpenAI), Grok (xAI) and Gemini (Google).