Maintainers drown in pull requests. Triage consumes hours. A free model can pre-filter the noise.
This article shows a reproducible PR triage workflow. It uses MonkeyCode's free server and free model access. The script is small. The output is structured. Humans stay in control.
Disclosure: This article was prepared as part of MonkeyCode's product outreach.
The Problem
Every PR asks for attention. Most do not deserve it. Title says "fix bug". Diff changes 40 files. Tests are missing. Maintainers still read every line.
A model reads faster. It can summarize intent, spot missing tests, and flag oversized diffs. That is not code review. It is pre-review classification.
The Workflow
Four steps. Pull metadata. Summarize. Score risk. Queue for human review.
1. Collect PR metadata
GitHub CLI gives you everything.
gh pr view 123 --json title,body,additions,deletions,changedFiles
gh pr diff 123 | head -200 > pr.diff
Keep only the first 200 lines of diff. Free models have context limits. The summary does not need every line.
2. Build a structured prompt
Ask for JSON. Make the schema explicit.
prompt = f"""
You triage a pull request. Return JSON only.
Title: {title}
Body: {body[:1000]}
Changed files: {changed_files}
Additions: {additions} Deletions: {deletions}
Diff (first 200 lines):
{diff}
Return this exact JSON:
{{
"risk": "high|medium|low",
"missing_tests": true|false,
"summary": "one sentence",
"questions": ["first", "second"]
}}
"""
Constraint: JSON only. No markdown. No apologies.
3. Call the free model
The script uses any OpenAI-compatible endpoint. Set the base URL and key via environment variables.
import os
import json
import urllib.request
api_base = os.getenv("MC_API_BASE")
api_key = os.getenv("MC_API_KEY")
model = os.getenv("MC_MODEL")
payload = {
"model": model,
"messages": [{"role": "user", "content": prompt}],
"temperature": 0
}
req = urllib.request.Request(
api_base.rstrip("/") + "/chat/completions",
data=json.dumps(payload).encode(),
headers={
"Content-Type": "application/json",
"Authorization": f"Bearer {api_key}"
},
)
with urllib.request.urlopen(req) as resp:
data = json.loads(resp.read().decode())
result = json.loads(data["choices"][0]["message"]["content"])
MonkeyCode provides the free server and free tokens. Check the current docs for endpoint and model identifiers. The script stays portable.
4. Assign a triage action
Use a simple decision table.
| Risk | Missing tests | Action |
|---|---|---|
| high | true | Request changes now |
| high | false | Full human review |
| medium | true | Ask author for tests |
| medium | false | Normal queue |
| low | true | Low priority queue |
| low | false | Merge candidate |
Print the table line. Stick to it.
Test It Yourself
Run the script against three fake PRs. Use these titles and bodies.
- "Update README" — small diff, no tests expected. Risk low.
- "Refactor auth module" — 600 additions, 300 deletions, no tests. Risk high.
- "Fix typo in error message" — one line. Risk low.
Expected output matches the rule above. If the model disagrees, inspect the prompt. Often the title is ambiguous.
Limitations
Free models fail. They miss subtle logic. They invent file names. They cannot run the test suite.
Never merge based on model output. Never skip human review for security or payment code. This workflow only orders the queue.
Also watch rate limits. MonkeyCode's free tier has its own quota. Set a delay between requests if you hit errors.
Who Should Not Use This
Solo maintainers with five PRs a week do not need automation. Manual triage is faster. Use this tool only when the queue exceeds your attention span.
Projects with strict legal or regulatory review should not delegate any summary step. Read everything yourself.
Wrap Up
The script is on your machine. The model is free. The bottleneck is still human judgment.
Try it on one repository. Measure saved minutes. Then decide if automation earns its place.
Top comments (0)