Skip to main content
Use the Greptile CLI to review historical changes without reopening a PR. The CLI reviews a local Git diff, not the PR’s state. Reviews are saved to your Greptile account; they do not post comments on the PR. CLI reviews default to Base, regardless of the repository’s tier. Add --plus or --apex to each run to evaluate another tier. Unavailable tiers fail rather than falling back. Each run uses review credits.

Before you start

  • Install the CLI. These examples use v3.8.0 and Bash.
  • Enable the repository in Greptile with an active trial or paid plan.
  • Run greptile login, or supply GREPTILE_API_KEY through your CI secret store. Do not put keys in scripts or command-line arguments.
  • For the GitHub examples below, install and authenticate the GitHub CLI.
Use a separate clone so switching commits does not disturb your work. Keep the full Git history:

Review a closed PR

Replace OWNER/REPO, 123, and main with your repository, PR number, and target branch.
Fetch the PR head even if its source branch was deleted. Choose the base, then create a local branch at the PR head:
This uses the target branch’s current history. For an exact historical evaluation, use a saved base commit from before the PR closed instead.
Check the diff, then run the review:
Do not use today’s default branch as the base for a merged PR: it already contains the change, so the diff may be empty. --branch accepts a commit SHA and reviews merge-base(BASE, HEAD)...HEAD. The CLI also requires a named local branch, not a detached HEAD.
Only committed, non-binary changes are sent. Check stderr for warnings about sensitive files held back from review. See sensitive files before overriding exclusions.

Read the results

--json writes one review object to stdout. Progress and errors go to stderr. With jq, extract the findings:
The object also includes summary, confidence, confidenceReasoning, and securitySummary. comments: [] means no findings. Exit code 0 means the review completed, not that it found no bugs. Treat any nonzero exit as an incomplete run; do not score it as a clean review.

Run a batch

Pin each case’s base and head to full commit SHAs. Use unique PR numbers and no header in dataset.csv:
Replace the placeholders with your evaluation commits. The base should be an ancestor of the head; record the merge base, not a moving branch name. For original-PR evaluations, use the original PR head rather than a merge or squash commit. Run this from a fresh evaluation clone with dataset.csv in its root. It needs jq and fetch access to each commit. Each successful case keeps its full JSON plus metadata in a JSONL file; failed cases keep a log and are skipped:
Git fetch, ancestry, or checkout errors stop the batch so it cannot review the wrong commit. For deleted GitHub branches, fetch refs/pull/PR_NUMBER/head to recover the PR head before building the dataset.

Score the evaluation

  • Label known bugs for each diff before reading Greptile’s output.
  • Match findings by behavior and location, not exact wording. Count each bug once.
  • Track precision (valid findings / all findings) and recall (known bugs found / known bugs).
  • Keep the CLI version, commit SHAs, tier, instructions, and review config with the results.
Use the same cases and settings across comparisons. Repeat runs to measure variation. Fixed SHAs fix the diff, not the service’s models or organization context; this is a fresh review of historical code, not a replay of the original PR review.