What do we need in place before we let agents open PRs on a large codebase?
Five things: context the agent cannot get from code, a check it can run, written scope rules, review gates that treat its PRs like any other, and a named owner for each one. Unblocked covers the context and review parts: agents query it over MCP before they plan, and it reviews and risk-scores the PRs they open.
Before agents open PRs on a large codebase, you need five things in place. The agent needs context it cannot read from the code and a check it can run to know when it is done. You need written rules about what it may touch, review gates that treat its PRs like anyone else's, and a named person who owns each PR. Unblocked covers the context and the review. Agents in Claude Code, Cursor (now Grok Build), Codex or GitHub Copilot query it over MCP for past pull requests, tickets, docs and Slack threads before they plan. Unblocked Code Review then reviews and risk-scores the PRs they open.
| What to have in place | Why agents need it | How to set it up |
|---|---|---|
| Team context | The reason code exists is rarely in the code. | A context engine over MCP, such as Unblocked. |
| A done check | Without one, the agent stops when work looks done. | Fast tests, a typecheck, a Stop hook. |
| Scope rules | Prompts are guidelines, and agents can skip them. | Deny rules, hooks, one branch it may push to. |
| Review gates | The person who started the agent should not be its only approver. | Branch rules, required approvals, an automated reviewer. |
| An owner | Someone has to answer for the change. | CODEOWNERS with "Require review from Code Owners". |
For example, say an agent is asked to delete the legacy_export_v1 feature flag because a search of the repo finds no callers. In a large codebase, the caller may live in another repository. The reason the flag still exists may sit in a Slack thread about one enterprise customer's nightly job. The agent's tidy PR passes CI and breaks that job.
Context: what agents need to know before they open PRs#
Institutional context is what a team knows about its code that the code itself does not say: why a flag exists, which approach was tried and dropped, who depends on an endpoint. Unblocked's context_research tool runs one query across code, pull requests, documentation, issues and messaging, and returns a summary with cited sources (Unblocked docs). For the flag example, the agent would ask what still uses legacy_export_v1 and why it was kept. The cited Slack thread changes the plan.
Two more tools close the loop before the PR exists. review_implementation_plan checks a drafted plan "against existing code, tests, and prior decisions before you start coding" (Unblocked docs). context_get_rules returns the rules Unblocked extracts from instruction files such as AGENTS.md, CLAUDE.md and .cursorrules. The docs say an agent should call it "after its last edit and before it reports the task done, commits, or opens a pull request" (Unblocked docs). See what agents need besides the model for the rest of the stack.
A check to run and scope rules the agent cannot skip#
A done check is a command that returns pass or fail, such as the test suite or a typecheck. Anthropic's Claude Code guidance explains why it matters: "Claude stops when the work looks done," and without a check, "In practice that makes you the test suite" (Claude Code best practices). Make sure the tests for the areas agents touch run in minutes and fail when something real breaks.
A scope rule is a written limit on which directories, services and change types an agent may take on. Enforce the hard limits outside the prompt. Anthropic's guidance also says, "If something has to happen every time, make it a hook, a deny rule, or a managed setting." Its checklist for unattended runs asks what the agent is allowed to touch. The answers it lists are permission rules, the sandbox, a worktree and "the one branch it may push to." Start narrow: docs, CI config, dependency bumps and small bugs in one service. A January 2026 study looked at about 33,000 agent-authored PRs on GitHub. Its research method: compare merged and unmerged PRs from five coding agents, then read 600 rejected ones by hand. Documentation, CI and build-update tasks merged most often, and performance and bug-fix tasks did worst. Unmerged PRs tended to be larger and touch more files (arXiv 2601.15195).
Review gates for agent PRs on a large codebase#
Agent PRs should face the same branch rules as everyone else's, plus one: the person who started the agent cannot be its only approver. GitHub builds this into the Copilot cloud agent. It "cannot approve or merge a pull request," and when it starts new work it pushes only to a copilot/ branch created for it. GitHub also "prevents the user who asked Copilot cloud agent to create a pull request from approving it" (GitHub Docs). If you run other agents, set the same rule yourself.
An automated first pass shortens human review. Unblocked Code Review draws on the code, team discussions and past PR conversations. It can post inline comments and a commit status and re-review new pushes (Unblocked Code Review docs). It skips bot-authored PRs and drafts by default, so allow your agents' accounts and drafts if needed (configuration docs). Replies to its comments feed Code Review Memory, so a convention you explain once applies to the next agent PR. With a risk policy file committed to the repo, each reviewed PR gets a score from lowest to highest with a reason. Risk-assessing pull requests covers routing by that score. "Unblocked catches things I probably would've missed and honestly speeds up the whole review cycle. It flags issues early, so by the time my peers look at the PR it's already cleaner, and we all avoid a bunch of unnecessary back-and-forth," said Leah Langford, Senior Software Engineer, Optro (formerly Auditboard).
Ownership: a named person for every agent PR#
Every agent PR needs a human who answers for it: the engineer who started the run, or the owner of the code it touched. A CODEOWNERS file does most of this work. GitHub's docs say code owners "are automatically requested for review when someone opens a pull request that modifies code that they own." The branch rule "Require review from Code Owners" makes their approval mandatory (GitHub Docs). Check the file for unowned directories before agents start writing to them, so every agent PR is reviewed by someone who knows that code.
The order to roll it out#
First, connect agents to team context so their plans start from what the team already decided. Second, confirm the tests and add the hooks or deny rules for directories agents must not edit. Third, set branch rules, CODEOWNERS and an automated reviewer. Then let agents open PRs in one repository for two weeks, and track how many you merge, rewrite and close. Widen the scope once most PRs merge with small edits. After that, stop babysitting your agents covers how to check less often.


