Skip to main content

Provider-agnostic code review toolkit for GitLab merge requests

Project description

git-review-cli

Tests PyPI Python License

Provider-agnostic code review toolkit. Gathers merge/pull request data, verifies file ownership, runs analysis, and outputs structured reports — all from the CLI.

Providers

Provider Status Backend
GitLab Implemented glab CLI
GitHub Planned gh CLI

Currently implemented: GitLab. The provider/formatter/analyzer architecture makes adding new forges straightforward — one file implementing BaseProvider.

Why not just the native CLI?

The same workflow applies regardless of provider. Compared to running raw glab/gh commands:

Raw CLI git-review-cli
4+ commands to gather MR/PR context Single command
Raw JSON diffs, hard to scan Structured markdown table
All files in diff treated equally Ownership: MR commits vs branch drift
Lockfiles, binaries clutter the view Auto-excluded noise files
No analysis Deep mode: large changes, configs, missing tests
Full URL required every time Shorthand: git-review-cli 123
Must manually checkout branch Auto-checkout branch locally
Separate commands for notes --post writes + posts in one step

Before: raw glab output

$ glab api projects/org%2Frepo/merge_requests/123/diffs --paginate
[{"old_path":"src/api/handler.go","new_path":"src/api/handler.go",
  "diff":"@@ -12,7 +12,9 @@ func ...\n-  old code\n+  new code\n...
  "new_file":false,"renamed_file":false,"deleted_file":false},
 {"old_path":"package-lock.json","new_path":"package-lock.json",
  "diff":"@@ -1,500 +1,520 @@ ...",
  "new_file":false,...}]

Hard to scan. Manual cross-reference with glab api .../commits to check ownership. Lockfiles and noise mixed in.

After: git-review-cli output

$ git-review-cli https://gitlab.com/org/repo/-/merge_requests/123
# MR !123 — Add healthcheck endpoint

- **Author:** Jane Doe
- **State:** opened
- **Source branch:** `feat/healthcheck`
- **Target branch:** `main`

### Description
Adds a /health endpoint with DB ping.

## Commits

- `a1b2c3d4` Add healthcheck handler (Jane Doe)

## Changed Files

| File | Changes | Owned by MR |
|------|---------|-------------|
| `src/api/handler.go (new)` | +45/-0 | ✅ 1 commit(s) |
| `src/api/handler_test.go (new)` | +30/-0 | ✅ 1 commit(s) |
| `package-lock.json` | +520/-500 | 🚫 excluded |

_3 files: 2 owned, 0 not owned, 1 excluded_

## Existing Comments

_2 non-system comments on MR_

One command. Clean table. Ownership verified. Noise filtered.

Architecture

src/
├── cli.py              # CLI entry point
├── git.py              # Shared git operations
├── providers/          # Code forge backends
│   ├── base.py         # Abstract provider interface
│   └── gitlab.py       # GitLab via glab CLI
├── formatters/         # Output plugins
│   ├── base.py         # Abstract formatter interface
│   ├── markdown.py     # Full / caveman markdown
│   └── json.py         # Machine-readable JSON
├── analyzers/          # Analysis plugins
│   ├── ownership.py    # File ownership verification
│   └── patterns.py     # Pattern-based findings
└── __version__.py

Adding a new provider (e.g. GitHub)

  1. Implement providers/base.py::BaseProvider
  2. Add platform detection in BaseProvider.resolve()
  3. That's it — formatters and analyzers work with any provider's data

Requirements

  • Python 3.9+
  • glab (brew install glab)
  • Authenticated to GitLab (glab auth login)

Installation

pip install git-review-cli

Usage

Arguments

git-review-cli <input> [options]
Argument Required Description
input Yes Full MR URL (https://gitlab.com/org/repo/-/merge_requests/123) or just the MR number (123) for shorthand mode

Shorthand mode auto-detects the repo from the current directory's git remote get-url origin. Works from any GitLab repo clone.

Options

Flag Description
--json Output raw JSON instead of markdown. Useful for piping into jq or feeding to other tools. Contains MR metadata, commits, and changed files with additions/deletions.
--caveman Concise markdown output. Skips commit list, skips deep analysis. Just MR metadata + changed files table. Ideal for quick scans.
--deep Full analysis markdown output. Includes commit list, categorized findings (large changes, config/infra changes, missing tests, all changes grouped by category). Mutually exclusive with --caveman.
--post <file> Post the contents of a markdown file as a comment on the MR. The file is read as-is and posted via glab mr note. The review file content is also appended to stdout so you can review before posting.
--base <branch> Override the base branch for git diff operations. Defaults to the MR's target branch from the API. Useful when the target branch differs from what's configured in the remote (e.g., a custom release/ branch).
--version Print version and exit.

Examples

# Full MR URL — works from any directory
git-review-cli https://gitlab.com/org/repo/-/merge_requests/123

# Shorthand number — auto-detects repo from git origin
git-review-cli 123

# Quick scan, no fluff
git-review-cli 123 --caveman

# Deep dive with analysis
git-review-cli 123 --deep

# JSON for scripting
git-review-cli 123 --json | jq .files[].path

# Custom base branch
git-review-cli 123 --base release/2026-q3

# Write and post a review in one step
cat > /tmp/review-123.md << 'REVIEW'
## Review findings
- Tests cover the new endpoint
- Consider extracting the helper to a shared module
REVIEW
git-review-cli 123 --post /tmp/review-123.md

Exit Codes

Code Meaning
0 Success
1 Usage / parse error
2 glab not found
3 Git operation failed
4 Posting failed

Planned

  • GitHub providergh CLI backend. Implements BaseProvider to fetch PR metadata, diffs, commits, and reviews. All existing formatters, analyzers, and CLI flags work unchanged. Estimated: ~80 lines of new code.

License

MIT

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

git_review_cli-1.6.tar.gz (15.9 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

git_review_cli-1.6-py3-none-any.whl (16.9 kB view details)

Uploaded Python 3

File details

Details for the file git_review_cli-1.6.tar.gz.

File metadata

  • Download URL: git_review_cli-1.6.tar.gz
  • Upload date:
  • Size: 15.9 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.1.0 CPython/3.13.12

File hashes

Hashes for git_review_cli-1.6.tar.gz
Algorithm Hash digest
SHA256 167626cd7c2a89c3c798e072c01a46430231c43f8afcd7ba5ae17c0a3ecb94a2
MD5 37c074024df44a233bb12dac04bbf8dd
BLAKE2b-256 4fb410ef60365e7e5d1a3bf6279a4ae774798f50fa7fc504913b2b5cb9c1d331

See more details on using hashes here.

File details

Details for the file git_review_cli-1.6-py3-none-any.whl.

File metadata

  • Download URL: git_review_cli-1.6-py3-none-any.whl
  • Upload date:
  • Size: 16.9 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.1.0 CPython/3.13.12

File hashes

Hashes for git_review_cli-1.6-py3-none-any.whl
Algorithm Hash digest
SHA256 8f409fc8ec18d55aff26c1b5cc3eaecaf0cc28d0a7213e3f2b7fa4e06878d6dd
MD5 9fdbb6660165427fbd56d71801eb0e13
BLAKE2b-256 c3f974956b605de28084483b60faa71d2acd3247d76aa4571f33b9ed6fa07b0a

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page