AI code review that works with any model.
Inline review comments, one-click suggestions, a walkthrough of every pull request and quality scores, using OpenAI, Anthropic, Gemini, AWS Bedrock, Ollama or your own gateway. Runs from the command line or in CI, with no server to host.
go install github.com/divmora/code-review-bot/cmd/codereview@latestA reviewer that reads the diff the way your team does
Every comment is checked against the real diff before it's posted, so the bot never comments on code a pull request didn't touch.
Inline comments and suggestions
Findings on the exact lines, with severity and a one-click committable suggestion on GitHub and GitLab.
Walkthrough summary
A summary of what changed, file groups, review effort and a description check. It's edited in place on every run, never reposted.
Quality scores
Quality, Security and Maintainability from 1 to 100, capped by the findings, with optional PR labels and a commit status.
Verification pass
A second, skeptical model, optionally from another provider, checks every finding. Disputed major issues become questions instead of disappearing.
Incremental, never repetitive
New pushes are reviewed for what changed. Issues already on the PR aren't posted again, even when worded differently.
Secret scanner and guardrails
Leaked keys are caught without a model call. PR content is treated as untrusted, and review rules come from the target branch.
Reads your AGENTS.md
Guideline files (AGENTS.md, CLAUDE.md, Copilot instructions) are applied, including folder-level AGENTS.md, nearest first.
GitHub, GitLab, Bitbucket
GitHub and GitHub Enterprise, gitlab.com and self-managed GitLab, and Bitbucket Cloud, with each host's own Markdown and limits.
Large PRs, handled
Token-budgeted batches run in parallel. Big files get context excerpts around each change, and one failing batch doesn't sink the review.
From diff to review in eight steps
Each run reviews one pull request. The model only proposes findings: deterministic checks decide what gets posted.
Read the PR
Diff, description and the repo's
.codereview.yaml, read from the target branch.Pick up where it stopped
The last reviewed commit is read from the bot's own comment, so only new changes are sent.
Filter and scan
Lockfiles, generated, vendored and binary files are skipped. Added lines are scanned for secrets.
Batch with context
Small files go whole, large ones as excerpts around each change, in token-budgeted batches.
Review in parallel
Batches go to your model with structured output, retries and fallback models.
Check against the diff
Comments on lines the PR didn't change, or on unknown files, are dropped.
Verify
A skeptical second pass removes false positives and turns uncertain findings into questions.
Post
Inline comments, the walkthrough summary, scores, labels and a commit status. Only with
--post.
Switch providers with one line
Pick a model with --model, CODEREVIEW_MODEL or model: in the config: a provider:model spec or a named profile. Add fallbacks, and use a different model for verification.
model: claude # change this line to switch provider fallback: [backup] models: claude: { provider: bedrock, model: <model-or-inference-profile-id>, region: us-east-1 } backup: { provider: openai, model: <model>, api_key_env: OPENAI_API_KEY } local: { provider: ollama, model: "qwen2.5-coder:14b" } review: verify_model: "bedrock:moonshotai.kimi-k2.5" # a second opinion from another family
# the provider's usual key variable is read automatically export CODEREVIEW_MODEL=anthropic:claude-sonnet-5-5 ANTHROPIC_API_KEY=... export CODEREVIEW_MODEL=openai:<model> OPENAI_API_KEY=... export CODEREVIEW_MODEL=gemini:<model> GEMINI_API_KEY=... export CODEREVIEW_MODEL=bedrock:<model-id> AWS_REGION=us-east-1 export CODEREVIEW_MODEL=ollama:qwen2.5-coder:14b # local, no key codereview ping # check every model in the chain
Review a pull request in a minute
Nothing is written to a pull request unless you pass --post. Try it as a dry run first.
# install (or download a binary from Releases, or use the Docker image) go install github.com/divmora/code-review-bot/cmd/codereview@latest codereview review --local # your uncommitted changes codereview review --local --base origin/main # your branch vs main codereview review https://github.com/org/repo/pull/123 # dry run codereview review https://gitlab.com/group/proj/-/merge_requests/9 --post codereview review https://bitbucket.org/team/repo/pull-requests/7 --post --commit-status codereview ask https://github.com/org/repo/pull/123 "Is the retry loop safe?"
# the image's entrypoint is the codereview binary docker run --rm -e CODEREVIEW_MODEL -e ANTHROPIC_API_KEY -e GITHUB_TOKEN \ ghcr.io/divmora/code-review-bot:0.4.0 review https://github.com/org/repo/pull/123 # review local changes: mount the repository at /workspace docker run --rm -v "$PWD:/workspace" -e CODEREVIEW_MODEL -e ANTHROPIC_API_KEY \ ghcr.io/divmora/code-review-bot:0.4.0 review --local
Review every push, with no server
The PR is detected from the CI environment. State lives on the PR itself, so each run picks up where the last one stopped.
name: AI code review on: pull_request: types: [opened, reopened, synchronize, ready_for_review] permissions: contents: read pull-requests: write jobs: review: if: ${{ !github.event.pull_request.head.repo.fork }} runs-on: ubuntu-latest steps: - uses: divmora/code-review-bot@v0.4.0 with: model: anthropic:claude-sonnet-5-5 # fail-on: critical env: ANTHROPIC_API_KEY: ${{ secrets.ANTHROPIC_API_KEY }}
ai-code-review: stage: test image: name: ghcr.io/divmora/code-review-bot:0.4.0 entrypoint: [""] rules: - if: $CI_PIPELINE_SOURCE == "merge_request_event" variables: CODEREVIEW_MODEL: "openai:<model>" # GITLAB_TOKEN (api scope) and OPENAI_API_KEY as masked CI/CD variables script: - codereview review --auto --post --format markdown --output review.md artifacts: { when: always, paths: [review.md] } allow_failure: true # a failed review never blocks the pipeline
image: atlassian/default-image:4 pipelines: pull-requests: '**': - step: name: AI code review script: - VERSION=0.4.0 - curl -fsSL -o crb.tgz "https://github.com/divmora/code-review-bot/releases/download/v${VERSION}/code-review-bot_${VERSION}_linux_amd64.tar.gz" - tar -xzf crb.tgz codereview - export CODEREVIEW_MODEL="openai:<model>" # + BITBUCKET_TOKEN and the model key as secured variables - ./codereview review --auto --post --commit-status
- Drafts and repeats skipped: with
--auto, draft PRs, closed PRs and commits already reviewed are skipped. Setauto_review.drafts: trueto review drafts. - Self-managed GitLab: the instance comes from
CI_SERVER_URL. If it uses a private CA, add the CA to the image or pointSSL_CERT_FILEat it.skip_tls_verify: trueundergitlab:incodereview.yamlis a last resort. - Gate merges if you want:
--fail-on criticalexits with code 3. Leave it off for advisory reviews.
Your rules, from your target branch
Commit .codereview.yaml to the default branch. It's read from the target branch, like CODEOWNERS, so a pull request can't loosen the rules it's reviewed against. The keys for the PR description and title match CodeRabbit's.
profile: balanced # chill | balanced | assertive instructions: | Flag fmt.Println outside tests; we use log/slog. path_instructions: - path: "migrations/**" instructions: Migrations must be reversible. path_filters: ["!docs/**"] max_comments: 20 high_level_summary: true # "Summary by codereview" in the description auto_title_placeholder: "@codereview" auto_review: drafts: false base_branches: [main, "release/*"]
- AGENTS.md and friends: project guidelines, plus folder-level AGENTS.md, are checked against every change.
- Description check: the bot says when the description misses or misstates what the code does, and suggests a title.
- Never rewrites authors: its summary goes in its own block; titles change only when you add the placeholder.
- Noise control: profiles, severity thresholds, a comment budget, and lockfiles, generated and vendored files skipped.
- Scores and status:
--score-labelssetsQuality Score::85-style labels, and--commit-statusmarks each reviewed commit.
Review profiles
chillfewest comments
Likely bugs, security problems, data loss and serious performance issues only. No style or naming points.
balanceddefault
Bugs, security and performance, plus maintainability problems that will clearly cause trouble. Skips pure style preferences.
assertivemost thorough
Adds readability, naming, missing tests and documentation gaps. Small polish items are marked as nitpicks.
CLI
| Command | What it does |
|---|---|
review [URL] | Review one PR/MR: --local, --base, --post, --full, --auto, --format text|markdown|json|sarif, --fail-on, --profile, --max-comments, --min-severity, --score-labels, --commit-status, --verify-model |
ask URL "question" | Answer a question about a PR using its diff (--post to reply on it) |
models | List providers, profiles and the active model chain |
ping | Test each model in the chain with a tiny structured request |
version | Print the version |
Exit codes: 0 success, 1 error, 3 a finding met --fail-on. The JSON output is a stable contract for other tools.
Need it as a service?
Divmora Code Review Console adds webhooks, a review queue, chat commands (@codereview), SSO, a repository allowlist, history and dashboards. It runs this CLI through local, Docker or Kubernetes executors.
SQL injection through the customer filter
User input is formatted into the query string. Pass it as a parameter so the driver escapes it.