CLI Reference¶
AI Code Reviewer command reference.
Main Command¶
Behavior:
- In CI (GitHub Actions / GitLab CI) โ automatically detects context
- Manually โ need to specify
--provider,--repo,--pr
Subcommands
ai-review (without subcommand) runs a review โ backward-compatible. Use ai-review discover to run discovery standalone.
Options¶
| Option | Short | Description | Default |
|---|---|---|---|
--provider |
-p |
CI provider | Auto-detect |
--repo |
-r |
Repository (owner/repo) | Auto-detect |
--pr |
PR/MR number | Auto-detect | |
--help |
Show help | ||
--version |
Show version |
Providers¶
| Value | Description |
|---|---|
github |
GitHub (GitHub Actions) |
gitlab |
GitLab (GitLab CI) |
Usage Examples¶
In CI (automatic)¶
Manual for GitHub¶
export AI_REVIEWER_GOOGLE_API_KEY=your_key
export AI_REVIEWER_GITHUB_TOKEN=your_token
ai-review --provider github --repo owner/repo --pr 123
Where to get values:
--repoโ from repository URL:github.com/owner/repoโowner/repo--prโ number from URL:github.com/owner/repo/pull/123โ123
Manual for GitLab¶
export AI_REVIEWER_GOOGLE_API_KEY=your_key
export AI_REVIEWER_GITLAB_TOKEN=your_token
ai-review --provider gitlab --repo owner/repo --pr 456
Where to get values:
--repoโ project path from URL:gitlab.com/group/projectโgroup/project--prโ MR number from URL:gitlab.com/group/project/-/merge_requests/456โ456
Short Syntax¶
Environment Variables¶
CLI reads configuration from environment variables:
Required¶
| Variable | Description |
|---|---|
AI_REVIEWER_GOOGLE_API_KEY |
Gemini API key |
AI_REVIEWER_GITHUB_TOKEN |
GitHub token (for GitHub) |
AI_REVIEWER_GITLAB_TOKEN |
GitLab token (for GitLab) |
Fallback
Old names without prefix (e.g., GOOGLE_API_KEY) still work as fallback.
Optional¶
| Variable | Description | Default |
|---|---|---|
AI_REVIEWER_LANGUAGE |
Response language | en |
AI_REVIEWER_LANGUAGE_MODE |
Language mode | adaptive |
AI_REVIEWER_GEMINI_MODEL |
Gemini model | gemini-2.5-flash |
AI_REVIEWER_LOG_LEVEL |
Log level | INFO |
AI_REVIEWER_GITLAB_URL |
GitLab URL | https://gitlab.com |
Auto-detection¶
GitHub Actions¶
CLI automatically uses:
| Variable | Description |
|---|---|
GITHUB_ACTIONS |
Environment detection |
GITHUB_REPOSITORY |
owner/repo |
GITHUB_EVENT_PATH |
JSON with PR details |
GITHUB_REF |
Fallback for PR number |
GitLab CI¶
CLI automatically uses:
| Variable | Description |
|---|---|
GITLAB_CI |
Environment detection |
CI_PROJECT_PATH |
owner/repo |
CI_MERGE_REQUEST_IID |
MR number |
CI_SERVER_URL |
GitLab URL |
Exit Codes¶
| Code | Description |
|---|---|
0 |
Success |
1 |
Error (configuration, API, etc.) |
Logging¶
Levels¶
| Level | Description |
|---|---|
DEBUG |
Detailed information for debugging |
INFO |
General information (default) |
WARNING |
Warnings |
ERROR |
Errors |
CRITICAL |
Critical errors |
Configuration¶
Output¶
CLI uses Rich for formatted output:
[12:34:56] INFO Detected CI Provider: github
[12:34:56] INFO Context extracted: owner/repo PR #123
[12:34:57] INFO Fetching PR diff...
[12:34:58] INFO Analyzing code with Gemini...
[12:35:02] INFO Review completed successfully
Errors¶
Configuration Error¶
Cause: Invalid configuration.
Solution: Check environment variables.
Context Error¶
Cause: Workflow not running for PR.
Solution: Make sure workflow has on: pull_request.
Provider Not Detected¶
Cause: Running outside CI.
Solution: Specify all parameters manually.
Discover Command¶
Run project discovery standalone (without creating a review):
Arguments¶
| Argument | Description |
|---|---|
REPO |
Repository (owner/repo) |
Options¶
| Option | Short | Description | Default |
|---|---|---|---|
--provider |
-p |
Git provider | github |
--json |
Output as JSON | false |
|
--verbose |
-v |
Show all details (conventions, CI tools, watch-files) | false |
Examples¶
# GitHub repository
ai-review discover owner/repo
# JSON output
ai-review discover owner/repo --json
# Verbose mode
ai-review discover owner/repo -v
# GitLab project
ai-review discover group/project -p gitlab
Example Output¶
๐ Discovering project context...
Stack: Python (FastAPI) 3.13, uv
CI: โ
.github/workflows/tests.yml โ ruff, mypy, pytest
Attention Zones:
โ
Formatting โ ruff format in CI
โ
Type checking โ mypy --strict in CI
โ Security scanning โ No security scanner detected
โ ๏ธ Test coverage โ no coverage threshold
Docker¶
Run via Docker:
docker run --rm \
-e AI_REVIEWER_GOOGLE_API_KEY=your_key \
-e AI_REVIEWER_GITHUB_TOKEN=your_token \
ghcr.io/konstziv/ai-code-reviewer:1 \
--provider github \
--repo owner/repo \
--pr 123
Version¶
Help¶
Usage: ai-review [OPTIONS]
Run AI Code Reviewer.
Automatically detects CI environment and reviews the current Pull Request.
Can also be run manually by providing arguments.
Options:
-p, --provider [github|gitlab] CI provider (auto-detected if not provided)
-r, --repo TEXT Repository name (e.g. owner/repo). Auto-detected in CI.
--pr INTEGER Pull Request number. Auto-detected in CI.
--help Show this message and exit.