Pull Request Reviewer
The pull request reviewer is a GenAIScript that runs in the context of a pull request. It can be used to review the changes in the pull request and provide feedback to the author. The reviewer can also suggest changes to the code, documentation, or other files in the pull request.
The output of the LLM is inserted as a comment in the pull request conversation (and updated as needed to avoid duplicates).
Here is an pull request in the GenAIScript repository with genai-generated description, comments and reviews.
Step 1: The script
You can prototype the pull request reviewer script in a branch with known changes so that you can assess the quality of the results. As you start using it in your build, you will be able to also refine it later on.
git diff
The script starts by running git diff
to get the changes in the pull request. Since we also know which folder
to ignore and which file we care about, we can provide additional filters to git to minimize the generated diff.
The diff is then inserted in the prompt using the def function.
Task
The second part of the prompt consists of creating the task and the persona for the LLM.
Since we are reviewing TypeScript, we also pre-load the system prompt that prepares the TypeScript mindset of the LLM.
Access to the file system
The diff is a partial view of the files and the LLM needs to access the full content of the files to provide a meaningful review. To enable this scenario,
All together
Step 2: Automation in Github Actions
Add this step to your Github Actions workflow to automate the pull request review process.
The -prc
flag stands for —pull-request-comment
and takes care of upserting a comment in the pull request conversation.