Command Line Interface (CLI)
Review code locally from your terminal before pushing
Review your code changes locally before pushing. The CLI gives you the same AI-powered reviews as the GitHub App, but in your terminal.
#Installation
npm install -g @codereviewr/cli
#Authentication
Get your API token from the CodeReviewr dashboard under Settings → API Tokens.
codereviewr auth login cr_your_token_here
Tokens start with cr_. The token is stored in ~/.codereviewr/config.json.
Check your authentication status:
codereviewr auth status
#Reviewing code
Review all uncommitted changes in your current repository:
codereviewr review
The CLI analyzes your changes and prints issues directly to the terminal, categorized by severity (Critical, High, Medium, Low, Info).
#Compare against a branch
Review changes compared to a specific branch, commit, or tag:
# Compare against main branch
codereviewr review --ref main
# Compare against a specific commit
codereviewr review --ref abc123
# Compare against a tag
codereviewr review --ref v1.0.0
#Review only staged changes
codereviewr review --staged
#Verbose output
See detailed debug information including which files are being read for context:
codereviewr review --verbose
#Exit codes
The CLI returns exit codes based on review results, making it useful for CI/CD pipelines and pre-commit hooks:
0- No critical or high severity issues found1- High severity issues found2- Critical severity issues found
Example in a CI pipeline:
codereviewr review --ref main || exit 1
#Configuration
#Max iterations
The review process may need multiple iterations to gather context. Default is 25 iterations. Increase for complex codebases:
# Set globally
codereviewr auth set-max-iterations 50
# Or per-review
codereviewr review --max-iterations 50
#Custom API URL
For development or self-hosted instances:
codereviewr auth set-url http://localhost:5174
#Remove authentication
codereviewr auth logout
#Use cases
#Pre-commit reviews
Run a quick review before committing:
codereviewr review --staged
#Pre-push reviews
Review all changes on your branch before pushing:
codereviewr review --ref main
#CI/CD integration
Add to your CI pipeline to catch issues before merge:
# GitHub Actions example
- name: Code Review
run: |
npm install -g @codereviewr/cli
codereviewr auth login ${{ secrets.CODEREVIEWR_TOKEN }}
codereviewr review --ref ${{ github.base_ref }}
#Command reference
#codereviewr review
| Option | Description |
|---|---|
-r, --ref <ref> | Compare against a specific git ref |
--staged | Only review staged changes |
-v, --verbose | Show verbose debug output |
--max-iterations <n> | Maximum review iterations (default: 25) |
#codereviewr auth
| Command | Description |
|---|---|
login <token> | Set your API token |
logout | Remove your API token |
status | Show authentication status |
set-url <url> | Set custom API URL |
set-max-iterations <n> | Set default max iterations |
#Global options
| Option | Description |
|---|---|
-v, --verbose | Enable verbose logging for any command |