co-pilot-review
v1.3.0
Published
AI-assisted code review tool that analyzes git changes and posts reviews to pull requests
Readme
co-pilot-review
AI-assisted code review tool that analyzes git changes and posts reviews to pull requests using GitHub Copilot.
💡 Why this tool? While there are more sophisticated commercial code review tools available, this solution provides similar functionality for free if you already have GitHub Copilot access. It's a creative(hacky 😁) workaround that leverages Copilot's capabilities for semi-automated code reviews without additional costs.
Prerequisites
Before using co-pilot-review, make sure you have:
- Git repository: Must be run from within a git repository
- GitHub CLI: Must have
ghCLI installed and authenticated (gh auth login) - GitHub Copilot: Must have access to GitHub Copilot Chat
- Pull Request: Must be run from a branch with an open pull request
- Custom guidelines (optional): Create a
co-pilot-coding-review-guidelines.mdfile in your project root
Installation
Install globally via npm:
npm install -g co-pilot-reviewOr install globally via yarn:
yarn global add co-pilot-reviewBasic Usage
Run the command in your git repository:
yarn cp-reviewOr if installed via npm:
npx cp-reviewHow it works
- Detects changes: Analyzes git diff between specified branches
- Generates prompt: Creates a structured prompt with your custom guidelines
- Copies to clipboard: Automatically copies the prompt to your clipboard
- Copilot interaction: You paste the prompt into Copilot Chat (Agent mode, Edit mode)
- Waits for response: Monitors for the JSON response file creation
- Posts review: Formats and posts the review as a pull request comment
Advanced Usage
Branch Selection Options
Compare specific branches:
# Compare feature-branch with main
cp-review --base main --target feature-branch
# Compare current branch with develop
cp-review --base origin/develop
# Compare two specific branches
cp-review -b origin/main -t feature/user-authInteractive mode:
# Launch interactive branch selection
cp-review --interactive
cp-review -iGet help:
cp-review --help
cp-review -hCommand Line Options
| Option | Short | Description | Default |
|--------|-------|-------------|---------|
| --help | -h | Show help message | - |
| --base <branch> | -b | Base branch to compare against | origin/main |
| --target <branch> | -t | Target branch to compare | HEAD |
| --interactive | -i | Interactive branch selection | false |
Examples
# Default: Compare current branch with origin/main
cp-review
# Compare with different base branch
cp-review --base origin/develop
# Compare specific branches
cp-review --base main --target feature-branch
# Compare with remote branch
cp-review --base origin/main --target origin/feature-branch
# Interactive mode (shows available branches)
cp-review --interactiveCustom Guidelines
Create a co-pilot-coding-review-guidelines.md file in your project root with your specific coding standards and review criteria. This file will be included in the AI prompt to ensure consistent reviews.
If no custom guidelines file is found:
- The tool will warn you and continue with example guidelines
- You can use the provided
custom-coding-review-guidelines.md.exampleas a starting point - Basic fallback guidelines will be used if no example file exists
To create your own guidelines:
- Copy the example file:
cp custom-coding-review-guidelines.md.example co-pilot-coding-review-guidelines.md - Edit the file to match your project's coding standards
- The tool will automatically use your custom guidelines
Example:
# Custom Coding Review Guidelines
## Code Quality
- Ensure proper error handling
- Use meaningful variable names
- Follow consistent formatting
## Security
- Validate all inputs
- Avoid hardcoded secrets
- Use secure coding practicesRequirements
- Node.js >= 14.0.0
- Git
- GitHub CLI (
gh) - GitHub Copilot access
Version History
See CHANGELOG.md for detailed version history.
License
ISC
