AI-powered code review before you commit. Uses the GitHub Copilot SDK to analyze your staged changes and provide actionable suggestions.
- π AI-Powered Review - Uses GitHub Copilot SDK (Claude, GPT-5, Gemini, Grok) to review your code
- π― Interactive Workflow - Fix, skip, or review suggestions one by one
- πͺ Git Hook Integration - Automatically runs before each commit
- βοΈ Configurable - Customize models, strictness, and ignore patterns
- π¨ Beautiful Terminal UI - Clean, colorful output with lipgloss
-
GitHub Copilot subscription (Free, Pro, Business, or Enterprise)
-
Copilot CLI installed:
brew install copilot-cli
-
Logged in to GitHub:
copilot auth login
go install github.com/emilushi/prereview@latestgit clone https://github.com/emilushi/prereview.git
cd prereview
go build -o prereview .
sudo mv prereview /usr/local/bin/-
Review staged changes:
git add . prereview -
Install as pre-commit hook:
prereview install
-
Create config file:
prereview config init
| Command | Description |
|---|---|
prereview |
Review staged changes interactively |
prereview review |
Same as above |
prereview doctor |
Check dependencies and setup |
prereview install |
Install as git pre-commit hook |
prereview uninstall |
Remove git pre-commit hook |
prereview config init |
Create default config file |
prereview config list |
Show current configuration |
prereview config set <key> <value> |
Set a config value |
prereview config get <key> |
Get a config value |
| Flag | Description |
|---|---|
--model |
AI model to use (claude, gpt-4, gemini, grok) |
--strict |
Require all issues to be fixed before committing |
--tolerance |
Review tolerance: strict, moderate, relaxed (default: moderate) |
--force |
Force commit even with unresolved suggestions |
--verbose |
Show detailed output |
--config |
Path to config file |
PreReview supports three tolerance levels to reduce false positives:
| Level | Description |
|---|---|
strict |
Reports all potential issues including style nitpicks |
moderate |
Reports bugs, security issues, and significant quality concerns (default) |
relaxed |
Only reports definite bugs and critical security issues |
# Use relaxed mode for less noise
prereview --tolerance relaxed
# Or set in config
prereview config set tolerance relaxedEach suggestion includes a confidence level:
- high - Definite issue, should be fixed (>95% confident)
- medium - Likely an issue but could be intentional (70-95% confident)
- low - Possible issue, may be false positive (<70% confident)
Only high-confidence errors block commits by default. Low-confidence suggestions are shown but don't prevent you from committing.
When reviewing, you have these options for each suggestion:
[f]ix- Apply the suggested fix (if available)[s]kip- Skip this suggestion[v]iew- View the diff for context[q]uit- Abort the review
After reviewing all suggestions:
[y]es- Proceed with commit[n]o- Abort[r]e-review- Review again (after making manual fixes)
Create a .prereviewrc.yaml in your project root or ~/.prereviewrc.yaml for global settings:
# AI model to use
model: gpt-4
# Require all issues to be fixed
strict: false
# Review tolerance: strict, moderate, relaxed
# - strict: Report all potential issues
# - moderate: Report bugs and significant issues (default)
# - relaxed: Only report definite bugs and security issues
tolerance: moderate
# What severity level blocks commits: errors, warnings, all, none
# Default: errors (only high-confidence errors block)
block_on: errors
# Show detailed output
verbose: false
# Files to ignore
ignore_patterns:
- "*.min.js"
- "vendor/*"
- "node_modules/*"
# Max file size to review (bytes)
max_file_size: 100000
# Additional coding standard files to detect (beyond auto-detected ones)
# These are file paths relative to repo root
coding_standards:
- ".custom-lint.json"
- "config/phpcs-custom.xml"
# Project-specific hints for the AI reviewer
# Use this to provide context that reduces false positives
project_hints:
- "Factory methods may return different subtypes based on input"
- "Data is sanitized at input time, not output time"
- "We use dependency injection throughout the codebase"If you're experiencing too many false positives:
-
Use relaxed tolerance:
prereview config set tolerance relaxed -
Add project-specific context:
project_hints: - "This project uses the Repository pattern" - "getEntity() returns different entity types based on the ID prefix" - "All user input is sanitized before storage"
-
Change what blocks commits:
block_on: errors # Only block on high-confidence errors
-
Force commit when needed:
git commit # Will prompt: "Proceed despite issues? [y/N]" # Or bypass completely: prereview --force git commit --no-verify
PreReview uses the GitHub Copilot CLI for authentication. The CLI handles all authentication automatically using your GitHub Copilot subscription.
-
Install Copilot CLI:
brew install copilot-cli
-
Login to GitHub:
copilot auth login
-
Verify authentication:
copilot auth status
That's it! PreReview will use your Copilot CLI credentials automatically.
$ git add src/utils.js
$ prereview
π Reviewing 1 changed file(s)...
βββββββββββββββββββββββββββββββββββββββββββββββ
π src/utils.js [1/2]
βββββββββββββββββββββββββββββββββββββββββββββββ
Line 45
β Missing null check
Accessing property on potentially null value.
Suggested fix:
if (user?.email) { ... }
best-practice
[f]ix | [s]kip | [v]iew diff | [q]uit: f
β Applied fix
βββββββββββββββββββββββββββββββββββββββββββββββ
Summary
β 1 fixed
β 0 skipped
βββββββββββββββββββββββββββββββββββββββββββββββ
Proceed with commit? [y]es | [n]o | [r]e-review: y
β Review complete: 1 fixed, 0 skippedprereview --strictIn strict mode, you cannot proceed with commit if any suggestions are skipped.
- Go 1.21+
- GitHub Copilot license
go build -o prereview .go test ./...MIT License - see LICENSE for details.
- Fork the repository
- Create a feature branch
- Make your changes
- Run tests
- Submit a pull request
- GitHub Copilot for AI capabilities
- Cobra for CLI framework
- Viper for configuration
- Lipgloss for terminal styling
