A teammate opened a PR. The diff said 400 added lines. The AI wrote it in one session.
It compiled. Tests passed. Something felt wrong.
Reading every line is slow. AI code is too smooth. You need a different review strategy.
Start with the diff. Then test the impact. Then decide what to trust.
The trap of smooth code
AI-generated patches often look plausible everywhere. They handle happy paths. They add sensible comments.
The failure hides in a changed boundary. A renamed variable. A swapped parameter order.
Your job is not to admire the code. Your job is to verify the delta.
The delta-based review workflow
I built a simple workflow. It runs on any CI system, including a free server.
It does three things:
- Extract the changed symbols from the diff.
- Ask a model to generate boundary tests for those symbols.
- Run the tests against the PR branch.
This shifts the review from reading to executing.
Step 1: Extract what actually changed
Git already knows the file list. You need the functions inside those files.
Here is a small script that works for Python and JavaScript:
#!/bin/bash
# impact_scope.sh — list changed functions and classes from a diff
# Usage: ./impact_scope.sh <base-branch> <head-branch>
BASE="$1"
HEAD="$2"
DIFF=$(git diff --unified=3 "$BASE" "$HEAD")
echo "$DIFF" | grep -E '^\+.*(def |class |function |export |const [A-Za-z]+ = )' | \
sed -E 's/^\+\s*//' | cut -c1-80
Run it in CI:
./impact_scope.sh origin/main origin/pr-head
You get a short list like:
# In auth.py
def normalize_email(email)
class TokenExpiredError
# In api/client.py
export async function fetchWithRetry
That list is your review checklist.
Step 2: Generate boundary tests with a free model
I used MonkeyCode's free model access. It is enough for this task. No paid plan needed.
Disclosure: This article was prepared as part of MonkeyCode's product outreach.
The model does not need your whole codebase. Feed it the function signatures and the diff context.
Here is the prompt template I use:
You are a hostile reviewer. Look at this function signature and the following diff. List the boundary conditions that could break. Then write one pytest test per boundary condition. Do not test happy paths. Focus on empty input, null values, off-by-one, and type mismatches.
Function: {signature}
Diff:
{diff_context}
Save the output to tests/test_impact.py. The model writes many tests fast.
Step 3: Run those tests on a free server
MonkeyCode also offers a free server tier. I put this pipeline there. It pulls the PR branch, runs the generated tests, and reports back.
A minimal GitHub Actions workflow does the same:
name: impact-tests
on: pull_request
type: free-server
jobs:
test:
runs-on: free-server
steps:
- uses: actions/checkout@v4
- name: Install dependencies
run: pip install -r requirements-dev.txt
- name: Generate impact list
run: ./impact_scope.sh origin/main ${{ github.head_ref }}
- name: Generate boundary tests
run: monkeycode-review --diff-file impact.txt --output tests/test_impact.py
- name: Run generated tests
run: pytest tests/test_impact.py -q
(The exact monkeycode-review command is a pseudocode example. Adjust it to your own wrapper.)
The idea is not the tool. The idea is that the artifact runs automatically, on infrastructure that costs nothing.
Step 4: Decide what to trust
Now you have three data points:
- The diff scan shows which code moved.
- The generated tests stress the touched edges.
- The test results show where the new code actually breaks.
Trust a change when all its boundary tests pass. Revert a change when a test fails and the model cannot explain a legitimate fix. Defer a change when the tests are impossible to write without deeper refactoring.
Most AI PR failures are not in the happy path. They are in the interplay between changed symbols. This method exposes that fast.
When not to use this
This workflow is not for:
- Simple doc updates or one-line fixes. Overkill.
- Legacy code with no test runner. You need a runner first.
- Security-critical patches. The model-generated tests are a starting point, not a replacement for manual audit.
The generated tests are only as good as the diff context you provide. If the diff is malformed, the tests will be garbage.
A boring but effective habit
You do not need to read every AI-added line. You need to know what changed and what could change that behavior.
Run the impact scan. Generate edge tests. Run them on a free server.
Then approve with evidence, not vibes.
If you want to try MonkeyCode's free models and free server for this, the docs walk through a basic test runner in ten minutes. That is the only CTA you need.
Top comments (1)
This delta-based review workflow is an innovative approach to managing AI-generated code, especially given the challenges of trusting "smooth" code. The idea of generating boundary tests automatically addresses a critical gap in traditional review processes, making it more efficient to catch edge cases. One potential improvement could be to incorporate static analysis tools into the pipeline, which could provide an additional layer of confidence in the code's quality before the tests are executed. If you're looking for help implementing or enhancing this approach, I’d be glad to discuss a paid collaboration. What challenges have you faced while integrating this process into your existing workflow?