Introducing the PR Review CLI Tool: An Extra Pair of Eyes for Your Code
A CLI tool that fetches GitHub PR diffs, analyzes them with OpenAI, and generates a Markdown code review to streamline the review process.
This is a Proof of Concept (POC) tool. It is not intended for general use in production environments. Use it at your own risk. The tool is provided "as is" with no warranty, and any feedback or improvements are welcome.
- Fetches a pull request's diff from GitHub.
- Uses OpenAI's GPT to generate code review feedback.
- Saves the generated review in a Markdown file.
- Option to override existing reviews or create new ones.
- Easy-to-use command-line interface with configurable options.
- Clone this repository
git clone /~https://github.com/NikosTsompanides/pr-reviewer-cli.git
- Install the required dependencies:
npm i
- Build the script
npm run build
- Create a .env file in the root of the project:
cp .env.sample .env
- Update the .env file
GITHUB_TOKEN=<GH_TOKEN>
OPENAI_API_KEY=<OPENAI_API_KEY>
Run the tool with the following command:
npm run start -- \
--owner "your-github-username" \
--repo "your-repository-name" \
--pr 1234 \
### Optional cli options
--filename "PR_1234_Review" \
--folder "./reviews" \
--override true
--owner
(string): GitHub repository owner (your username or organization).--repo
(string): GitHub repository name.--pr
(number): Pull request number to review.--filename
(string/ optional): Name for the generated review file (default: PR_<pr_number>_Review).--folder
(string / optional): Folder where the review file will be saved (default: ./reviews).--override
(boolean / optional): Whether to overwrite existing review files (default: false).
- The tool fetches the PR diff from GitHub.
- It sends the diff to OpenAI to generate a code review.
- The review is saved as a Markdown file in the specified folder.
- Integrate with GitHub Actions to automatically trigger the review process.
- Enhance the AI’s ability to handle more complex review scenarios.
- Add more customizable options, like review categories (e.g., performance, security, etc.).
- Implement more advanced error handling and logging features.
Feel free to fork the repository and submit pull requests. Contributions and suggestions are always welcome!
This project is licensed under the MIT License.