Autonomous Agents: A PR label that summons an AI reviewer that learns what not to flag
A PR opens in the morning and gets its first human review the next afternoon. When it arrives, half the comments are things a machine could have spotted: a new code path without a test, a value that can go negative, two
A PR opens in the morning and gets its first human review the next afternoon. When it arrives, half the comments are things a machine could have spotted: a new code path without a test, a value that can go negative, two writes that belong in one transaction. The reviewer burns their time on those, and the author waits a day for them.
Here's a setup that gives the first pass to an agent, triggered by a label, with a human gate before anything hits GitHub. It also handles the part most AI review bots get wrong: when a developer says "we don't do that here", the agent remembers it.
TL;DR
- Add the
agent-reviewlabel → GitHub webhook → AgentRQ's github hook (filters on that label) →review_requestedevent → a task in areviewerworkspace. - The agent runs
gh pr checkout,gh pr diffand the tests, then replies with a findings card: counts by severity, file:line per finding, and Post review / Skip buttons. -
Post review → the agent asks to run one
gh apicall → you click Allow Once → one COMMENT review with inline comments. - Disagree with a finding → reply in the task → the agent writes the rule to a
review-exceptions.mdmemory and skips it from then on. - The review playbook is a shared skill, so every reviewer workspace follows the same rules.
How do the pieces fit?
PR gets label "agent-review"
│ pull_request webhook (signed)
▼
github hook ── base branch main, repo acme/shop, label agent-review
│ pr.labeled → review_requested
▼
trigger ── "Review GH P#<n>: <title>" in reviewer
▼
agent ── load memory + code-review skill
── gh pr checkout, go test ./..., read diff
── findings card [Post review] [Skip]
▼ Post review
asks: gh api .../pulls/<n>/reviews (you: Allow Once)
▼
COMMENT review with inline comments on GitHub
developer pushes back → reply in task → memory: review-exceptions.md
Why a label, a skill and memory?
- A label is an explicit opt-in. You control which PRs get reviewed, and removing and re-adding it is a clean way to ask for a second pass after new commits.
- A hook keeps it secure and quiet. The built-in github hook verifies GitHub's signature and only passes labels you list. Any other label fires nothing.
- A skill is the team's review, written once. Skills live in your AgentRQ account rather than in one machine's folder. Every workspace you turn the skill on for reviews the same way, and one edit updates all of them.
- Memory turns pushback into policy. Workspace memory keeps what a developer said, so one correction holds for every later review in that repo.
There are also two human gates: the Post review button, and the per-command approval for the gh api call that actually posts.
What do I need?
- An AgentRQ account and a machine for the agent.
- An agent that connects to AgentRQ: Claude Code over MCP, or Codex, Gemini CLI and others via the ACP Gateway.
-
A separate clone for the reviewer (
~/code/shop-review), sogh pr checkoutnever switches branches under someone's open editor. -
ghsigned in with a fine-grained token: Pull requests: Read and write, Contents: Read-only. That's enough to check out and post reviews, but not enough to push or merge. - Your test toolchain (the example runs
go test ./...inacme/shop) and repo admin rights for the webhook and label.
How do I set it up?
1. Save the code-review skill
Ask your agent to save this as code-review, or paste it under Settings → Skills:
---
name: code-review
description: How the team reviews a pull request. Check it out, run the tests, rank findings by severity, ask before posting, then post one review with inline comments.
---
# Code review
1. Load memory first. Never raise anything listed in the memory review-exceptions.md.
2. gh pr checkout <number>, then gh pr diff <number>, then run the tests (go test ./...).
3. Read the whole diff before you comment. Comment only on lines the pull request changed.
4. Rank each finding:
- critical: a wrong result, lost data, a security hole
- major: a bug in an edge case, new behavior with no test
- minor: naming, a simpler way, a missing comment
Skip what a linter or formatter already catches.
5. Reply in the task with a card: the counts by severity, each finding with file:line,
and two buttons, Post review and Skip. Post nothing before Post review.
6. On Post review, write .agentrq/review-<number>.json:
{"event": "COMMENT", "body": "<summary>", "comments": [{"path": "...", "line": 0, "side": "RIGHT", "body": "..."}]}
and run gh api repos/<owner>/<repo>/pulls/<number>/reviews --input .agentrq/review-<number>.json.
Always COMMENT: approving and requesting changes is for people.
7. Reply with the review's link, then complete the task.
8. When a developer disagrees and is right, save the rule to the memory review-exceptions.md:
the repository, what not to flag, why, and who said so.
Turn it on for the reviewer workspace, and for any others you want reviewing the same way. Teams can share it with every member.
2. The reviewer workspace
Create reviewer, point it at the review clone, start the agent, YOLO off. The mission is your checklist, in priority order:
You review pull requests in acme/shop when someone labels them agent-review.
Check, in this order:
1. Correctness: wrong results, missed edge cases, error and nil handling.
2. Security: secrets, injection, missing authorization checks.
3. Money and data: amounts in integer cents, writes that must happen together.
4. Tests: new behavior has a test, and go test ./... passes on the branch.
5. Readability, only where it hides a bug.
Rank every finding critical, major or minor. Never approve, merge or push.
For Claude Code, allow the read-only commands and gate the one that posts:
{
"permissions": {
"allow": ["Bash(gh pr checkout:*)", "Bash(gh pr diff:*)", "Bash(gh pr view:*)", "Bash(go test:*)", "Edit(.agentrq/**)"],
"ask": ["Bash(gh api:*)"]
}
}
Add .agentrq/ to the clone's .git/info/exclude so review files never get committed.
3. Event and trigger
Create review_requested, add a trigger for reviewer titled Review {{EVENT_SUBJECT}} (the hook fills in "GH P#" plus number and title), YOLO off:
Review this pull request in acme/shop.
{{EVENT_PAYLOAD}}
{{EVENT_FAQ}}
Load the code-review skill and follow it.
1. Check the branch out and run go test ./...
2. Reply with the findings card. Post nothing until I click Post review.
3. Post review: post one review with inline comments, reply with its link and complete this task.
4. Skip: complete this task without posting.
4. Register the github hook
Events → Hooks → New registration, pick github:
- Generate and copy a webhook secret.
-
Branches:
main. For PRs, this is the base branch, the one being merged into. -
Repositories:
acme/shop. Labels (for pr.labeled):agent-review. -
Routes:
pr.labeled→review_requested. Leavepr.review_requestedNot routed: it has no reviewer filter, so it would fire every time anyone asks any colleague for a review.
Copy the payload URL; it's shown once.
5. Webhook and label in GitHub
Settings → Webhooks → Add webhook: the payload URL, application/json (form encoding is rejected), the webhook secret, and individual events with Pushes unticked and Pull requests ticked. Then create the agent-review label. Matching is case-insensitive.
What does a review look like?
Priya opens #245, "checkout: pay part of an order with a gift card", and labels it. A task appears with the PR number, author, branches (feat/gift-card-checkout → main) and link.
The agent loads memory and the skill, checks out the branch, runs the tests, reads the diff, and replies with a card, not a wall of text:
The critical finding is the kind humans miss in a skim: the gift card balance check and the debit run outside a transaction, so two simultaneous checkouts can spend the same $50. The findings are in the reply text too, so a push notification or email carries everything. Nothing has touched GitHub yet.
Click Post review and the agent writes the review JSON, then asks to run gh api repos/acme/shop/pulls/245/reviews --input .agentrq/review-245.json.
Careful with Always Allow here. It saves a rule on the command's first word, gh, so from then on every gh command in that workspace runs without asking, including gh pr merge. If you clicked it by accident, delete the gh * rule under Settings → Automations. Or keep it and rely on the token: with Contents read-only, gh can't push or merge no matter what the rule allows.
The agent only ever posts COMMENT reviews. Approving and requesting changes stays with the people who own the code.
How does it learn what not to flag?
Priya disagrees with the minor finding: in acme/shop, each package's tests share one Postgres database, so t.Parallel() makes them flaky. You reply in the task, even though it's completed; a reply reopens it.
The agent writes that rule to memory, answers the inline comment on GitHub, and completes the task again:
Next, Lee labels #248, "shipping: free shipping over $50 for members". Its new tests skip t.Parallel() too, but this time the card has a single real finding: cart and checkout compare the $50 threshold against different subtotals. It also says explicitly what it left out and which memory told it to.
Each disagreement makes later reviews a little quieter. Skim review-exceptions.md now and then; deleting a stale rule is one line.
What are the traps?
-
pr.review_requestedhas no reviewer filter. Route it and the agent gets a task whenever anyone requests anyone. -
Labels and Authors only filter
pr.labeled. They do nothing forpr.openedorpr.review_requested. -
Branches = base branch. A PR into
release/1.4is dropped while Branches ismain. - Pull requests not ticked / content type left as form → no events, or every request Rejected with "the body is not JSON".
- Re-labeling means a new review, which is handy after new commits.
-
Memory names must end in
.md(lowercase, hyphenated) or the save is refused. -
Use a separate clone.
gh pr checkoutin your working copy switches your branch.
The registration's Deliveries list shows published deliveries, GitHub Redeliver caught as Duplicate, and wrong-secret requests Rejected with the reason. Unrouted labels leave no row at all.
Ways to extend it
-
Review on request: give the agent its own GitHub account, route
pr.review_requested, and have it complete in one line unless it was the reviewer asked. -
Review everything: route
pr.openedwith no label filter. This works better for small teams than busy repos. - Only some authors, such as new hires, via Authors for pr.labeled.
- More repos: turn the same skill on for another workspace. Memory stays per workspace.
- A "Fix it" button that pushes a commit, with a token that can push and YOLO still off.
FAQ
Can it approve or merge? Not here: the skill says COMMENT only, gh api waits for Allow Once, and the token can't merge.
Does it post before I click? No. Both the trigger and the skill forbid it, and the post itself still needs approval.
How long does a review take? As long as checkout, tests and reading take on your machine: minutes for a PR like #245.
Which agents can run it? Any that connect to AgentRQ: Claude Code, Codex, Gemini CLI and others.
What's the one rule your team would put in review-exceptions.md on day one? Share it in the comments.
Originally published on agentrq.com. The full tutorial has every screenshot and step.
Originally published by Dev.to AI. Aggregated on AIWithGhost for educational purposes — full credit and traffic to the original publisher.


