Claude Code pull request review with quality gates
Matt · · Last updated · 10 min read · Guides
Route Claude Code's work through gated AI CodeOps sessions over MCP, require the release gate check on the pull request, and stop pushes around it.
On this page
To put Claude Code's pull requests behind quality gates, have Claude Code start AI CodeOps sessions through the MCP server instead of writing and pushing the change itself, then make the AI CodeOps release gate a required check on the pull request. The session tests and reviews the change, a second person approves it, and the required check keeps the merge button locked until the gate allows it.
The problem: fast agent PRs, slow human review
Claude Code is very good at turning a sentence into a diff. What stands between that diff and your main branch is usually "a developer skims it", and that holds up until the volume goes up. An agent can open more pull requests in a morning than a team can read carefully in a day, and the careful read is the part that gets cut.
A gate doesn't get tired, but it has to see the change. It is worth being exact here, because getting it wrong gives you a false sense of safety.
The AI CodeOps release gate decides on evidence it recorded itself: the session that wrote the change, the AI review of its diff, the test run in its sandbox, and the approval. It finds that evidence by the pull request the session opened. The gate doesn't watch your repositories for pull requests opened somewhere else. So if Claude Code writes a change on your laptop and you push it and open a pull request, AI CodeOps knows nothing about it. Ask the gate about that pull request and it answers allowed: false with "No workflow runs found for …". That is the correct answer. It has nothing to judge, so it refuses.
That shapes the design. If you want Claude Code's work behind the gate, the work has to go through an AI CodeOps session. Claude Code stays the interface you type into. The session does the writing, testing and review on the platform, and opens the pull request.
Set up: connect the repo, choose gates, require the check
Connect the repository. In AI CodeOps, connect your GitHub account under Configure → Settings → Git Providers (GitHub setup) and create a project with the repository's URL under Plan → Projects. Sessions on that project write against a snapshot of the repository and open their pull requests there. The GitHub integration page covers what AI CodeOps does with the repository.
Choose the gates. By default the release gate refuses a change if a high or critical finding is still open, if a test run failed, if a session that changed code has no test result with counts, if a workflow it depends on failed or no run for it has finished, or if the AI review didn't complete. In the CI call you can add blockingSeverity, requiredWorkflows and minCoveragePct. A coverage floor needs a coverage number: if no test run on the change reported coverage, the gate denies, because it can't check the floor. The quality gates page has the full rules.
Require the AI CodeOps check. Asking the gate from Claude Code is useful, but advisory: somebody can still press Merge. The enforcement belongs on the Git host. Here it is for GitHub, with a plain workflow and no extra Action to install:
# .github/workflows/aicodeops-gate.yml
name: AI CodeOps gate
on:
pull_request:
permissions:
contents: read
jobs:
gate:
if: startsWith(github.head_ref, 'codeops/run-')
runs-on: ubuntu-latest
steps:
- name: Ask the AI CodeOps release gate
env:
AICODEOPS_API_KEY: ${{ secrets.AICODEOPS_API_KEY }}
PR_URL: ${{ github.event.pull_request.html_url }}
run: |
jq -n --arg pr "$PR_URL" '{pullRequestURL: $pr}' > request.json
curl -sS --fail-with-body -X POST "https://console.aicodeops.dev/api/release/check" \
-H "Authorization: Bearer $AICODEOPS_API_KEY" \
-H "Content-Type: application/json" \
--data @request.json -o gate.json
jq -r '.summary' gate.json
jq -r '.reasons[]' gate.json
jq -e '.allowed == true' gate.json > /dev/null
Add the key as a repository secret named AICODEOPS_API_KEY. Use a separate key for CI, not the one in your editor. The check only needs workspace:read, and where your plan has key scoping you can limit the key to the release gate check.
A few details matter here:
- Read
allowed, not the status code. The endpoint answers200for both verdicts. The last line makes the step fail unlessallowedistrue. - It fails closed. A missing or wrong key gets a 401 or 403, and
--fail-with-bodyturns that into a failed step. If the evaluation itself breaks, the API answersallowed: falsewith "Evaluation failed". More than 60 checks a minute for the workspace gets a 429, which also fails the step, so re-run it. jqandcurlare already there. GitHub'subuntu-latestrunner image ships both, so there is nothing to install.
The if: line is a choice you should make on purpose. It runs the gate only on branches AI CodeOps opened. GitHub's troubleshooting page for required checks says a job skipped by a job-level conditional reports "Success". So a human's pull request still merges under your normal rules, and an AI CodeOps pull request can't merge until the gate passes. Don't swap the if: for a branch filter under on:. The same page says checks skipped by branch or path filtering stay "Pending" and block merging.
If you drop the if: entirely, every pull request needs an AI CodeOps session behind it. That is a valid policy for a repository only agents should change, but it blocks every human pull request, so decide that deliberately.
Finally, make the check required. In the branch protection rule or ruleset for main, require status checks to pass and select the gate check. Also require a pull request before merging, so nothing reaches main without going through one. GitHub rulesets for AI agents covers the rest of the ruleset.
Use the AI CodeOps MCP server from Claude Code
AI CodeOps runs a remote MCP server at https://console.aicodeops.dev/mcp. It speaks the Streamable HTTP transport and takes a workspace API key as a Bearer token.
Create a key under Configure → API Keys. It starts with sk- and is shown once. Two tools need more than read access, and an unscoped key does not get them by default:
start_sessionspends model budget, so it only works for a key whose scope lists it. Choose Scope on the key and tick Start sessions from the MCP server (/mcp).get_evidence_packexports the audit record, so it needs Evidence packs from the MCP server (/mcp) ticked as well.
The other seven tools (list_projects, get_session, check_release_gate, list_findings, list_builds, get_build, list_saved_builds) only read. A key always acts as the member who created it, with that member's current role. A viewer's key can read and nothing more, whatever its scope says.
Then add the server. This is the command from the MCP server guide, in the syntax Claude Code's MCP docs give for a remote HTTP server with a header (checked on 24 October 2026):
claude mcp add --transport http aicodeops https://console.aicodeops.dev/mcp \
--header "Authorization: Bearer $AICODEOPS_API_KEY"
That stores the server at the default local scope, in ~/.claude.json, for the current project only. For a team, a project-scoped .mcp.json in the repository is better, because Claude Code expands environment variables in a remote server's url and headers. Everyone commits the same file and keeps their own key in their shell:
{
"mcpServers": {
"aicodeops": {
"type": "http",
"url": "https://console.aicodeops.dev/mcp",
"headers": { "Authorization": "Bearer ${AICODEOPS_API_KEY}" }
}
}
}
Claude Code asks each person to approve project-scoped servers from .mcp.json before it uses them. Run /mcp inside Claude Code and aicodeops should show as connected with nine tools.
Walkthrough: one pull request from prompt to merge
Say you type: "Add rate limiting to the login endpoint in the api project, then tell me when the PR is ready to merge." Here is what happens, tool by tool.
list_projects returns the workspace's projects and their repositories. Claude Code picks the project id for api.
start_session starts a session with your task and that project. With no workflow argument it runs plan-build-review-test. You can name another, such as security-sensitive-change, which adds a risk analysis before the change and an audit of the diff after. The call returns a session id and a link to the session in the console. It also counts against the workspace budget and the agent work-in-progress limit, exactly as a session started in the browser would.
From here the work happens on the platform, not on your laptop:
- Agents plan and write the change against a snapshot of the repository, each step handing its output to the next (the multi-agent patterns guide explains the hand-offs).
- The verify step runs your project's own tests on the proposed tree in an isolated sandbox. The repository's existing dependencies are installed first. Then the sandbox is cut off the network, and only then are the AI's edits written and run. If the sandbox can't be confirmed offline, the change isn't run at all. If the change touched a dependency manifest, the install runs again with the network still closed, so a package that wasn't there before can't be fetched and the suite is recorded as skipped rather than run.
- An AI reviewer reads the diff and records findings with a severity. A reply that isn't a readable list counts as a failed review, and the gate holds the change.
- An approval opens under Review & Gate → Approvals.
get_session is what Claude Code polls. It returns the status, the steps, and once it exists, the pull request and its change record.
The approval is the step people skip in other setups, so it is worth spelling out. The session was started with your key, so you are its launcher. Once the workspace has a second person who can approve, your own approval doesn't count. Someone else has to look at the diff. When they approve, AI CodeOps checks the change against the quality gate and opens the pull request on a branch named codeops/run-<id>. Rejecting is always allowed, and one rejection stops the change.
check_release_gate answers whether the pull request may ship, with the reasons. It is the same check as the CI workflow above, with the same defaults and options.
get_evidence_pack returns the signed record of the change: the prompt, the model, the runs, findings, tests and approvals, signed with Ed25519 and checkable at /evidence/verify. Exporting it is itself written to the audit log.
The point is that Claude Code can tell you "the gate says no, here is why" with real reasons, instead of telling you the tests pass because it believes they do.
Tips
Keep the local agent from going around the gate. The last gap is Claude Code itself. In an ordinary session on your laptop it can run git push and gh pr create like you can. If it does, you get exactly the ungated pull request this setup is meant to avoid.
Claude Code's permission rules can refuse those commands. Commit this to .claude/settings.json in the repository:
{
"permissions": {
"deny": ["Bash(git push *)", "Bash(gh pr create *)", "Bash(gh pr merge *)"]
}
}
The docs say rules are evaluated deny first, then ask, then allow, and that a deny in any settings file beats an allow in any other. Deny rules in the shared project file also apply right away, without waiting for each person to trust the folder.
Be clear about what this is (docs checked on 24 October 2026). The same docs say a Bash rule matches the command text Claude writes, so Bash(git push *) doesn't match git -C . push, and they state plainly that such a rule "isn't a security boundary around the program". Treat the deny list as a seatbelt for the common case. The boundary is on the Git host: a protected main, a required pull request, required reviews for human pull requests, and the required gate check for AI CodeOps ones.
Know what this setup doesn't do.
- It doesn't review pull requests AI CodeOps didn't open. A change you wrote with Claude Code locally and pushed yourself is your change. Your normal human review applies to it, and the gate has no opinion.
- It doesn't use commit trailers as a signal. Claude Code can add an attribution line to commits and pull requests, but its setting can change or hide it. A rule built on a trailer is a rule an agent can switch off.
- It doesn't make the AI review infallible. The review is a model reading a diff. That is why it sits next to real test runs and a second person, not instead of them.
Use a second key for CI. The editor key can start sessions; the CI key only needs to read the gate. If one leaks, you revoke it without breaking the other.
The other direction, connecting your own MCP servers to sessions, is on the MCP integration page.
Key takeaways
- The AI CodeOps gate only judges changes an AI CodeOps session made, so route Claude Code's work through sessions over MCP.
- Make the release gate a required check on
main, and run it only oncodeops/run-branches with a job-levelif:. - Read
allowedin the gate's answer, not the HTTP status, and let every error fail the step. - The person who started a session can't approve it alone once someone else can review.
- Claude Code's deny rules are a seatbelt; branch protection and the required check are the boundary.
Frequently asked questions
Can AI CodeOps gate a pull request Claude Code pushed from my laptop?
No. The release gate judges evidence from AI CodeOps sessions, so a pull request no session opened gets allowed false with "No workflow runs found". Have Claude Code start a session instead of pushing the change itself.
Does a human still review Claude Code's pull requests?
Yes. Once the workspace has a second person who can approve, the person who started the session can't cast the approving vote, so someone else reads the diff before the pull request opens.
Do Claude Code deny rules stop every git push?
No. A Bash rule matches the command text Claude writes, so another way of writing the push isn't matched. Treat the deny list as a seatbelt and rely on branch protection and the required check as the boundary.