A Free-Tier AI PR Reviewer: A GitHub Actions Workflow That Actually Works
Automated code review is one of the few AI workflows that pays for itself on the first pull request, and you can run it entirely on a free model allowance if you design the pipeline around the model's limits rather than against them. I built a GitHub Actions workflow that calls the open source MonkeyCode project's free model access to comment on pull requests, and the result is a reviewer that…
The MonkeyCode project offers a free model allowance of ten million tokens and a free server option, allowing users to run automated code reviews without incurring costs. A GitHub Actions workflow has been developed to utilize this free model access for commenting on pull requests, catching real issues without overwhelming the conversation. The workflow is designed simply, focusing on the pipeline's value rather than the model's capabilities.
To begin, the workflow triggers on pull_request events, specifically when a pull request is opened or synchronized. It checks out the repository with full history and passes a unified diff between the base branch and the head branch to a Python script. The diff ensures accurate computation of changes using fetch-depth: 0. The environment variables carry the MonkeyCode API key and GitHub token, keeping secrets secure within the repository.
The Python script processes the diff, truncating it to a reasonable size for model input, and constructs a prompt asking for structured feedback with path, line, and body for each issue. The model is instructed to return an empty array if no issues are found, simplifying parsing logic. The script also deduplicates comments, preventing duplicate feedback due to the trigger on both opened and synchronize events.
It limits the total number of comments to five, prioritizing the most important findings and maintaining low noise levels.
Written by urgent.news from Dev.to's reporting — not their text. Machine-written — may contain errors; check the original before relying on it.