DEV Community

Quinn Sun
Quinn Sun

Posted on

Free Models + Free Server = A PR Review Bot You Can Actually Run

The refactoring PR arrived at 4:47 PM on a Friday. It touched fifteen files, rewrote three internal APIs, and every single test passed on the first run. That alone was suspicious. I pulled up the diff and my brain started to fog up around line 300. So instead of pretending I could review it all, I decided to offload the first pass to a robot.

Here is what I built: a minimal review gateway that runs on a free server, calls a free model for each changed file, and posts short, focused comments back to the pull request. It is not a magic bullet. It is a starting point that caught real issues the moment it went live.

Disclosure: This article was prepared as part of MonkeyCode's product outreach. The experiment used MonkeyCode's free model access and their free server option, which together removed the two biggest excuses for not automating this kind of review: cost and infrastructure.

Why a gateway instead of a CLI script

A CLI script works fine when you are sitting in front of your own machine. The moment you want every teammate to get the same feedback, you need something that lives outside your laptop. A small webhook service can sit on a free server, listen for GitHub events, and fire off model requests without anyone having to install anything.

That is exactly the setup I wanted. I run a tiny Flask app on MonkeyCode's free server, point a GitHub webhook at it, and let the free model do the tedious parts of a first-pass review. The script itself is embarrassingly short, but the design pattern is what matters.

The core artifact: a review gateway in ~40 lines

The complete logic fits in a single file. I stripped out auth and error handling to keep the idea visible, but the shape is what you would deploy in production.

# gateway.py (illustrative)
import os
import requests
from flask import Flask, request

app = Flask(__name__)
MODEL_ENDPOINT = os.getenv("MODEL_ENDPOINT", "https://free-model-api.example.com/complete")

def review_file(patch_text):
    prompt = f"Review this code diff for bugs, dead code, and missing error handling:\n\n{patch_text}"
    response = requests.post(
        MODEL_ENDPOINT,
        json={"prompt": prompt, "max_tokens": 250},
        timeout=30,
    )
    return response.json().get("text", "")

@app.post("/webhook")
def webhook():
    payload = request.json
    if payload.get("action") != "opened":
        return "ok", 200

    comments = []
    for file_diff in payload.get("files", []):
        patch = file_diff.get("patch", "")
        if patch:
            comments.append(review_file(patch))

    # Post comments via the GitHub REST API (omitted for brevity)
    # Use GITHUB_TOKEN to avoid rate limits.
    return {"status": "ok", "comments": len(comments)}

if __name__ == "__main__":
    app.run(host="0.0.0.0", port=int(os.getenv("PORT", 5000)))
Enter fullscreen mode Exit fullscreen mode

How did I get this onto the free server? I cloned a repo, installed Flask and Requests, and set two environment variables: MODEL_ENDPOINT and a GitHub token for posting comments. Then I started the service and exposed it via the free server's public URL. No Docker, no Kubernetes, no nonsense.

A decision table for what a free model can actually do

Before you hook this up to your entire engineering org, you need a sober view of what a free model handles well and where it will confidently hallucinate. My first week produced a useful table, and I stuck it in a README so nobody over-trusted the bot.

Task Free model verdict My notes
Syntax errors and obvious typos Yes Catches null derefs and mismatched braces reliably
Dead code and unused imports Mostly Needs a clean diff context or it starts commenting on your comments
Missing error handling Sometimes Great at spotting bare except: blocks
Logic correctness Risky Use the comment as a hint, never as a verdict
Security vulnerability analysis No Free models are not your CVE scanner
Architecture or design review No They cannot see the trade-offs you see
Test coverage suggestions Yes Surprisingly good at proposing missing edge cases

That table saved me from a very embarrassing afternoon. The bot once flagged a perfectly valid if statement as a potential infinite loop. A human read the comment and trivially dismissed it. The system only works when people know its limits.

How the gateway caught a real bug in hour two

The first PR that hit the gateway contained a function that parsed a JSON response from an external service. The code looked clean, but the free model noticed something I had skipped: the function only handled the data key and silently returned None when the key was missing. The model suggested adding an explicit error type and a log line.

That was a legit catch. The external service had occasionally omitted that key under load, and the old code would have turned a minor hiccup into a mysteriously empty result. The comment from the bot was short and actionable. I merged the fix, and the gateway earned its place in the CI pipeline.

Does that mean the model is smart? No. It means the prompt gave it enough context to notice a common pattern. That is the whole trick.

Deployment steps that worked for me

If you want to replicate this, here is the exact sequence I used on MonkeyCode's free server. The same steps apply to any free VPS, as long as you have SSH access.

  1. Create a new directory and set up a virtual environment.
  2. Install dependencies: pip install flask requests.
  3. Save the gateway script as gateway.py.
  4. Set the model endpoint and GitHub token via environment variables.
  5. Start the app with python gateway.py in a tmux session so it stays alive.
  6. Configure a GitHub webhook that sends pull_request events to https://<your-free-server>/webhook.
  7. Add a filter so the webhook only fires on opened actions, otherwise you will burn your free model quota on every synchronize event.

That last point matters more than you think. A PR with three commits can trigger multiple webhook calls. My first version processed every single push and ate through a day of free tokens in one afternoon. Adding one condition fixed the leak immediately.

Why I still keep a human in the loop

A free model can produce plausible feedback every single time, but plausible is not the same as correct. The gateway works best as a filter that tags suspicious lines, not as a judge that blocks merges. I configured it to post comments with a label like ai-review and gave the team a simple rule: ignore the bot when a human disagrees, but never ignore it silently.

That rule has a nice side effect. The bot surfaces questions that people were too polite to ask in a crowded review thread. Anonymous feedback from a machine often gets more honesty than feedback from a peer.

Limitations I discovered (and real-world constraints)

The free model and free server both carry constraints you should respect. I cannot tell you the exact rate limits because they may change, and I did not run a benchmark. What I can say: do not rely on this setup for critical production decisions without adding your own retries, timeouts, and fallbacks.

Second, the free server is perfect for a low-traffic webhook, but it is not a distributed compute farm. If you are reviewing three thousand files at once, this architecture will either time out or hit memory limits. Keep your diffs small, or split the review into batches.

Third, the model's quality depends heavily on the prompt. I iterated four times before I got comments that were concise and actionable. The first version returned a 300-word essay full of generic advice. You will need to tune your own prompt for your codebase.

Who should not use this

Solo developers who already know every line of their code will find the bot annoying. It will comment on their carefully written abstractions and suggest trivial renames. If you are the only maintainer, skip the gateway and use the free model interactively instead.

Teams with existing commercial code-review tools already get much of this value from a vendor. The gateway is most useful for small open-source projects and internal side-systems where a paid solution is overkill.

A natural next step: turn the comments into a dataset

Once you have a few hundred real reviews from the bot, you can download them and analyze which patterns the model flags most often. That gives you a crude map of what your team's code keeps getting wrong. My next experiment will feed those results back into the prompt as few-shot examples. The free model gets slightly better with each iteration.

Try the boring version first

You do not need a fancy framework or a custom AI platform to start. Copy the script, point it at your webhook, and run it on a free server. Then, after it produces exactly one useful comment, you will feel the same click I felt at 4:47 PM on a Friday when I realized the robot could do the first pass for me.

If you want to test it on a disposable repo before touching your main project, even better. The whole setup takes under an hour, and the free model quota is more than enough for a weekend of experiments. Just remember to keep a human at the merge button.

Top comments (0)