Installation¶
The installation option depends on your use case and goals.
1. CI/CD โ Automated Review¶
The most common scenario: AI Code Reviewer runs automatically when a PR/MR is created or updated.
Set up in 5 minutes:
For fine-tuning see Configuration โ
2. Standalone Deployment: CLI/Docker¶
CLI and Docker image allow running AI Code Reviewer outside the standard CI pipeline.
Use Cases¶
| Scenario | How to implement |
|---|---|
| Manual run | Local terminal โ debugging, demo, evaluation |
| Scheduled review | GitLab Scheduled Pipeline / GitHub Actions schedule / cron |
| Batch review | Script iterating over open PR/MR |
| Own server | Docker on server with Git API access |
| On-demand review | Webhook โ container launch |
Required Environment Variables¶
| Variable | Description | When needed | How to get |
|---|---|---|---|
AI_REVIEWER_GOOGLE_API_KEY |
Gemini API key | Always | Google AI Studio |
AI_REVIEWER_GITHUB_TOKEN |
GitHub Personal Access Token | For GitHub | Instructions |
AI_REVIEWER_GITLAB_TOKEN |
GitLab Personal Access Token | For GitLab | Instructions |
Fallback
Old names without prefix (e.g., GOOGLE_API_KEY) still work as fallback.
Manual Run¶
For debugging, demo, evaluation before deployment, retrospective PR/MR analysis.
Docker (recommended)¶
No Python installation required โ everything is in the container.
Step 1: Pull the image
Step 2: Run the review
Docker images
Available from two registries:
ghcr.io/konstziv/ai-code-reviewer:1โ GitHub Container Registrykoszivdocker/ai-reviewbot:1โ DockerHub
pip / uv¶
Installation as a Python package.
Step 1: Install
Python version
Requires Python 3.13+
Step 2: Set up variables
export AI_REVIEWER_GOOGLE_API_KEY=your_api_key
export AI_REVIEWER_GITHUB_TOKEN=your_token # or AI_REVIEWER_GITLAB_TOKEN for GitLab
Step 3: Run
Optional Variables¶
Additional variables are available for fine-tuning:
| Variable | Default | Effect |
|---|---|---|
AI_REVIEWER_LANGUAGE |
en |
Response language (ISO 639) |
AI_REVIEWER_LANGUAGE_MODE |
adaptive |
Language detection mode |
AI_REVIEWER_GEMINI_MODEL |
gemini-2.5-flash |
Gemini model |
AI_REVIEWER_LOG_LEVEL |
INFO |
Logging level |
Scheduled Reviews¶
Running reviews on a schedule โ for resource savings or when instant feedback is not needed.
# .gitlab-ci.yml
ai-review-scheduled:
image: ghcr.io/konstziv/ai-code-reviewer:1
script:
- |
# Get list of open MRs
MR_LIST=$(curl -s --header "PRIVATE-TOKEN: $AI_REVIEWER_GITLAB_TOKEN" \
"$CI_SERVER_URL/api/v4/projects/$CI_PROJECT_ID/merge_requests?state=opened" \
| jq -r '.[].iid')
# Run review for each MR
for MR_IID in $MR_LIST; do
echo "Reviewing MR !$MR_IID"
ai-review --provider gitlab --repo $CI_PROJECT_PATH --pr $MR_IID || true
done
rules:
- if: $CI_PIPELINE_SOURCE == "schedule"
Schedule setup: Project โ Build โ Pipeline schedules โ New schedule
# .github/workflows/scheduled-review.yml
name: Scheduled AI Review
on:
schedule:
- cron: '0 9 * * *' # Daily at 9:00 UTC
jobs:
review-open-prs:
runs-on: ubuntu-latest
steps:
- name: Get open PRs and review
env:
AI_REVIEWER_GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
AI_REVIEWER_GOOGLE_API_KEY: ${{ secrets.AI_REVIEWER_GOOGLE_API_KEY }}
run: |
# Get list of open PRs
PRS=$(gh pr list --repo ${{ github.repository }} --state open --json number -q '.[].number')
for PR in $PRS; do
echo "Reviewing PR #$PR"
docker run --rm \
-e AI_REVIEWER_GOOGLE_API_KEY -e AI_REVIEWER_GITHUB_TOKEN \
ghcr.io/konstziv/ai-code-reviewer:1 \
--repo ${{ github.repository }} --pr $PR || true
done
Own Server / Private Environment¶
For deployment on your own infrastructure with Git API access.
Options:
- Docker on server โ run via cron, systemd timer, or as a service
- Kubernetes โ CronJob for scheduled reviews
- Self-hosted GitLab โ add
GITLAB_URLvariable (see example below)
Cron job example:
# /etc/cron.d/ai-review
# Daily at 10:00 run review for all open MRs
0 10 * * * reviewer /usr/local/bin/review-all-mrs.sh
#!/bin/bash
# /usr/local/bin/review-all-mrs.sh
export AI_REVIEWER_GOOGLE_API_KEY="your_key"
export AI_REVIEWER_GITLAB_TOKEN="your_token"
MR_LIST=$(curl -s --header "PRIVATE-TOKEN: $AI_REVIEWER_GITLAB_TOKEN" \
"https://gitlab.company.com/api/v4/projects/123/merge_requests?state=opened" \
| jq -r '.[].iid')
for MR_IID in $MR_LIST; do
docker run --rm \
-e AI_REVIEWER_GOOGLE_API_KEY -e AI_REVIEWER_GITLAB_TOKEN \
ghcr.io/konstziv/ai-code-reviewer:1 \
--provider gitlab --repo group/repo --pr $MR_IID
done
Self-hosted GitLab
For self-hosted GitLab add the AI_REVIEWER_GITLAB_URL variable:
3. Contributors / Development¶
If you have the time and inspiration to help develop the package, or want to use it as a foundation for your own development โ we sincerely welcome and encourage such actions!
Development Installation¶
# Clone the repository
git clone https://github.com/KonstZiv/ai-code-reviewer.git
cd ai-code-reviewer
# Install dependencies (we use uv)
uv sync
# Verify
uv run ai-review --help
# Run tests
uv run pytest
# Run quality checks
uv run ruff check .
uv run mypy .
Project Structure¶
ai-code-reviewer/
โโโ src/ai_reviewer/ # Source code
โ โโโ core/ # Models, config, formatting
โ โโโ integrations/ # GitHub, GitLab, Gemini
โ โโโ utils/ # Utilities
โโโ tests/ # Tests
โโโ docs/ # Documentation
โโโ examples/ # CI configuration examples
Requirements¶
System Requirements¶
| Component | Requirement |
|---|---|
| Python | 3.13+ (for pip install) |
| Docker | 20.10+ (for Docker) |
| OS | Linux, macOS, Windows |
| RAM | 256MB+ |
| Network | Access to generativelanguage.googleapis.com |
API Keys¶
| Key | Required | How to get |
|---|---|---|
| Google Gemini API | Yes | Google AI Studio |
| GitHub PAT | For GitHub | Instructions |
| GitLab PAT | For GitLab | Instructions |
Gemini API Limits¶
Free tier
Google Gemini has a free tier:
| Limit | Value |
|---|---|
| Requests per minute | 15 RPM |
| Tokens per day | 1M |
| Requests per day | 1500 |
This is sufficient for most projects.