Beyond Git Worktree
Cloud AgentsLong read

Wiring Agent YAML Into Your Existing Pull Request Approval Gates

Base-branch policy, CODEOWNERS, and CI keep agent PRs under human control.

· 9 min read · Updated
Cover illustration for “Wiring Agent YAML Into Your Existing Pull Request Approval Gates”
Cloud Agents · November 4, 2026 · 9 min read · 1,959 words

Defining AI coding agents as version-controlled YAML in a repository makes their configuration reviewable, but configuration alone does not enforce policy. To bring agent YAML into existing pull request approval gates, the repo-resident policy must be read from the base branch and enforced through CI, CODEOWNERS, and branch protection. This lets humans control agent output without having to trust the agent to follow its own instructions.

Why agent pull requests break the assumptions behind your current approval gates

In the discussion thread, the author glances at the first few changes and submits the PR, leaving the reviewer expected to check everything. Traditional review assumes that producing a change required some deliberation from its author, giving the reviewer a basis for assessing intent and understanding. An agent can produce dozens of changed files, passing CI, and a confident commit message without the submitter understanding the result.

That breaks more than the division of labor. A contributor’s clean track record once supported lighter scrutiny, but agent output provides no consistent equivalent signal of competence or intent. Its mistakes can look like senior work, with idiomatic structure and passing tests even when an authorization check is missing. Morgan Stanley’s Khalid Elsawaf described how a single prompt could generate a thousand-file, ten-thousand-line PR that no human would meaningfully review. When agents also review the output, a required human approval becomes the last structural defense against a merge history containing no human judgment.

What AGENTS.md actually is and what it cannot do on its own

AGENTS.md is an open Markdown convention. Compatible tools read it at the repository root and can apply instructions from nested files closer to the directory being edited. That makes it useful in monorepos, where different parts of the code need different instructions. It has no required schema. The same context and boundaries can therefore serve different compatible agents without binding the policy to one vendor.

The file sets out scope boundaries, review instructions, and rules for how a cooperative agent should behave before it acts. It cannot impose consequences on an agent that ignores them. For that reason, instructions should stay short, specific, and close to the code they govern rather than burying relevant guidance in a long document. Once enforcement exists, a Code review section can state requirements such as “every new HTTP handler under src/api/ must check resource authorization.” A reviewing tool can read that guidance from the base branch and raise scrutiny when it detects a violation. AGENTS.md records context and boundaries for the agent, while CODEOWNERS, required reviews, and CI provide the actual enforcement. Ellipsis, a cloud agent platform that runs Claude Code and Codex on managed infrastructure from YAML files kept in the repo, is one option for the execution side.

Reading policy from the base branch, not the PR branch

The policy judging a PR must come from the base branch tip, never the PR branch. Otherwise, the submitted change can weaken the rule used to evaluate it. Reading from the base branch keeps a policy change under the existing rules until it has been reviewed and approved. Human-approved governance changes can then enter the repository through the same review process as application changes.

MergeJudge’s documentation makes this property explicit. It reads .mergejudge.yml and policy files such as AGENTS.md from the base branch, and changes to .mergejudge.yml always go to review, preventing a PR from enabling lanes.code_auto for itself. The AI reviewer must respect the same boundary. Its role can raise scrutiny, but it must never lower the human approval requirement.

That architecture also constrains the machinery executing the policy. Agents must be blocked from changing CI/CD configuration files by default because a change to workflow YAML can turn off enforcement without changing the policy’s wording. Every action and container pulled into the workflow should also be pinned to a commit SHA or image digest. Otherwise, the enforcement process depends on code that can change outside the reviewed configuration.

The policy file structure that turns scope into a deterministic gate

The two-file pattern separates guidance from executable policy. AGENTS.md holds the instructions the agent reads before it acts, while an enforcement file such as .ai-code-gate.yml or .mergejudge.yml gives CI its deterministic rules. In this pattern, the agent does not read the enforcement file, and CI does not use AGENTS.md as its enforcement source. A reviewing tool may still use the Markdown guidance to request more scrutiny. The hard gate remains independent of that interpretation.

The YAML fields should describe observable conditions and their consequences. For example, max_files caps changed files, while max_lines_added caps total additions. These names illustrate a pattern to adapt. These limits enforce a preference for small diffs by rejecting work that is too large for a person to review with care. The blocked_patterns field lists the paths the agent is not allowed to change.

Risk tiers then map the remaining changes to approval requirements. LOW permits auto-merge eligibility when scans are clean, tests pass, and the diff is small, while MEDIUM requires at least one human reviewer and HIGH requires two reviewers, including one from security. Branch protection still controls whether merging is possible. Labels such as needs-review and do-not-merge can hold or release a PR using the cached verdict for that commit, without rerunning the model.

Composing the YAML gate with CODEOWNERS and branch protection rules

CODEOWNERS names the owners for each path, and branch protection requires their approval before a merge. An agent touching authentication code or a migration cannot substitute a more confident explanation for the required owner’s approval. The YAML file’s blocked_patterns and the ownership paths should align. A sensitive path should have a named owner for any change that reaches review, even when agent modification is blocked by default.

To make this composition enforceable, branch protection should require Code Owner review, at least one approval, and successful mandatory CI checks, including the policy gate job. The resulting record connects the sensitive-path change to its approver, the checks that ran, and the job enforcing policy. That supports audits and access reviews. Checking the approval history for each path from time to time can also show where the same deviations keep happening. If the same deviation appears twice, the instruction should be tightened, while a security-impacting deviation calls for an external control.

The rule “behavior changed, test changed” belongs in CI too. A script can fail when a production file appears in the diff but no test file does, turning the instruction into an enforceable check. Beyond checking test presence, the additional accountability boundary is that a person owns the tests defining the expected behavior, and the agent cannot edit them merely to make its implementation pass.

Blocking the paths where agent PRs escalate their own permissions

An agent that modifies .github/workflows/ can alter the job enforcing its own policy. The dangerous change is therefore not necessarily defective application code. It can be a workflow edit that disables review of the next agent PR, which base-branch policy reading alone does not fully prevent. Before other policy is written, blocked_patterns should cover CI/CD workflow files, CODEOWNERS, branch protection configuration, and the enforcement YAML file itself. These are the controls governing the agent’s authority.

Workflow permissions should reinforce that separation of authority. A reasonable default is read-all for the workflow’s permissions setting, with any necessary write access declared explicitly by individual jobs. Analysis and execution must also remain separate. Model output must never be run as code, and untrusted content must be sanitized before it goes into a prompt. These boundaries prevent an analysis result from becoming an unreviewed instruction to the execution environment.

Custom Semgrep rules can check for missing authorization checks on API routes, eval() with input that a user controls, and file system operations on paths that come from request parameters. Each added dependency must be checked in the lockfile, registry, and official documentation. These checks inspect the application change, while the blocked paths protect the machinery that decides whether the change can go ahead.

Tying agent sessions to human identity so the approval trail is auditable

A passing gate cannot answer who authorized an agent run unless the session is bound to a human identity. Every request must map to a person through an identity provider such as Okta, Entra, or Google Workspace. Access reviews and offboarding need that attribution. Immutable records of prompts, actions, and merges must be retained according to regulatory policy, capturing what the agent did and whether CI passed. NIST launched the AI Agent Standards Initiative in February 2026 to work on identity, authorization, security, and interoperability for agents.

Sonarr and stashapp require submitters to explain any line and any design decision, regardless of how the code was produced. OpenTofu’s registry repository takes a stricter position. It closes AI-generated PRs from community contributors without further review, citing limits on maintainer attention and difficulty auditing model training provenance after Terraform’s move to a source-available license. These policies place responsibility on the submission process regardless of the apparent fluency of generated code.

Session credentials provide the infrastructure counterpart to that responsibility. They should be scoped to the session and revoked when it ends, rather than remaining as standing permissions beyond the approved work. Managed platforms designed for this purpose log tool calls, diffs, and tokens with attribution to a person or trigger. That observability makes the gate’s decision reconstructable during an investigation.

Keeping gate jobs from becoming the bottleneck that teams route around

The velocity objection to mandatory gates is legitimate. A docs typo should not queue through the same scrutiny as an authentication change simply because both came from an agent. A uniform five-job pipeline can make governance feel like bureaucracy, encouraging teams to disable it. Parallel execution helps, but it does not resolve unnecessary review requirements. Deterministic risk tiers in the YAML policy address that problem by assigning scrutiny according to the change.

Linting, type checking, security scanning, and tests can start simultaneously, with lint failures surfaced in under two minutes before slower work wastes compute. This shortens feedback without weakening the approval rules. An unfinished draft or an agent session that has been stopped needs a different response. If a session limit leaves a partial PR, the task’s scope should shrink and the gate’s requirements should remain unchanged.

Size limits protect velocity from the other direction. A PR that goes over max_files or max_lines_added should fail at once, before review jobs run. The limit prevents automation from consuming review capacity with a change no person can meaningfully evaluate in a sitting. It is both a governance boundary and a protection for reviewer time.

How do agent definitions stored in Git go through normal code review?

Agent configuration stored in the repo goes through normal review when changes to what the agent is allowed to do need the same approval as changes to application code. A blocked-path rule or risk-tier threshold cannot quietly become more permissive without a reviewed and merged policy change. Git records the governance decision itself. When an auditor asks why an agent was allowed to touch a path on a given date, the policy history supplies the rule in force.

That is the operational distinction between a local prototype and governed production automation. Managed execution adds session-scoped credentials and attributable tool-call records, while the YAML configuration remains the authoritative policy source. The model is not the distinguishing feature. DORA identifies AI as an amplifier of existing engineering practices, magnifying both organizational strengths and dysfunctions. Teams with tests, CI, and small PRs already have the controls that agent YAML needs to compose with.

Start with four artifacts: an AGENTS.md containing scope and review instructions, a YAML enforcement file containing detection, blocked patterns, and risk tiers, a CODEOWNERS update aligning ownership with blocked paths, and a branch protection ruleset making the policy check mandatory.

Filed underCloud Agents

More in Cloud Agents