⚡ PromptLoot

Home › AI Agents

Agent Auto-Approve Policy: What AI Agents May Merge Alone

A policy file that sorts every PR an AI agent reviews into auto-merge, human review, or blocked: docs and tests yes; payments, auth, and secrets never.

Added

Save as .github/agent-merge-policy.md (or POLICY.md) and reference it from AGENTS.md and from your review or merge agent's system prompt. Edit every [BRACKETED] item. The agent reads this; your CI and branch protection ENFORCE it.

# Agent auto-approve policy for [REPO]
Owner: [NAME] · Last reviewed: [DATE] · Review again after any incident or every [30] days.

## How to use this policy (instructions to the review agent)
1. For every PR, list the changed paths, the diff size, and which checks passed.
2. Assign exactly ONE tier: AUTO, HUMAN, or BLOCKED, using the rules below. When rules conflict, the strictest tier wins.
3. Post a short comment: tier, the rule that decided it, and anything a human should look at.
4. Never change this file, CI config, branch protection, or CODEOWNERS, and never approve a PR that does.
5. If unsure, choose HUMAN. Being wrong in the safe direction costs minutes; the other direction can cost the company.

## Tier AUTO: agent may approve and merge alone
All of these must be true:
- Only touches: [docs/**, *.md (except AGENTS.md / CLAUDE.md / this file), tests/** (adding tests only), comments, typo fixes, [locales/** text]]
- OR is a dependency PATCH update from [Dependabot / Renovate] with a passing lockfile check
- Diff is under [150] changed lines and [10] files
- All required checks green: [build, typecheck, lint, tests]; coverage did not drop
- No new dependencies, no new environment variables, no deleted tests
- Author is not the same agent session that is approving (no self-review in one session)

## Tier HUMAN: agent reviews, a person approves
- Any application logic under [src/**, app/**]
- New or upgraded (minor/major) dependencies
- Database migrations, schema or index changes
- Public API, CLI flags, or config format changes
- Performance-sensitive paths: [LIST]
- Any change to AGENTS.md, CLAUDE.md, rules files, or prompts the product uses
- Anything AUTO would allow but where checks are flaky or were re-run to pass

## Tier BLOCKED: agent must not approve, even with human request in a comment
- Payments, billing, pricing, refunds: [paths]
- Auth, sessions, permissions, roles, row-level security, CORS
- Secrets, keys, .env files, CI/CD workflows, deploy and infrastructure config: [.github/workflows/**, infra/**, terraform/**]
- Data deletion, retention, export, or anything touching personal data: [paths]
- Disabling, skipping, or deleting tests, lint rules, or security checks
These need [CODEOWNER / two humans] via the normal review UI.

## Required comment format
Tier: [AUTO / HUMAN / BLOCKED]
Rule: [the line above that decided it]
Changed: [N files, N lines; paths summary]
Checks: [passed / failed / flaky]
Risks a human should check: [list or "none found"]

## Audit
- Log every AUTO merge: PR, paths, checks, time. Review the log [weekly].
- One bad AUTO merge = move that path pattern to HUMAN until the policy is reviewed.

## Enforcement checklist (for the human setting this up)
- [ ] Branch protection on [main]: required checks + CODEOWNERS review for BLOCKED paths
- [ ] The merge bot's token can only merge PRs labeled agent-auto; a CI job re-checks the AUTO path rules and fails otherwise
- [ ] The agent's credentials cannot edit workflows, branch protection, or this file
- [ ] Start in dry-run: the agent comments its tier for [2] weeks; you compare with your own call before allowing any auto-merge

How to use it

  1. Click Copy template.
  2. Paste into ChatGPT, Claude, Grok, Cursor, or your agent framework.
  3. Replace the [BRACKETED] parts with your details.

Pairs well with: This Codebase Is Yours: Ownership Rules for Coding Agents

Sponsor this page · Reach builders who use AI daily. Get details

FAQ

Should an AI agent be allowed to merge its own pull requests?

Only for low-risk changes with a written policy and real enforcement. Docs, typo fixes, added tests, and patch dependency updates with green checks are reasonable to auto-merge. Logic changes need a human, and payments, auth, secrets, and CI config should never be agent-approved.

Isn't the policy file just a prompt the agent can ignore?

On its own, yes. Treat it as the agent's instructions, and enforce the same rules with branch protection, CODEOWNERS on sensitive paths, a CI job that re-checks the AUTO path list, and a merge token that can't touch workflows or this file.

How do I roll out agent auto-approve safely?

Run it in dry-run mode first: the agent labels each PR AUTO, HUMAN, or BLOCKED but merges nothing. After two weeks of matching your own judgment, allow AUTO merges for docs and tests only, review the audit log weekly, and widen the list slowly.

Does this work with Claude Code, Codex, Copilot, and other review agents?

Yes. It's plain Markdown, so any review or merge agent can read it from the repo or its system prompt. The enforcement side uses standard GitHub or GitLab features like branch protection, CODEOWNERS, and required checks.

Get 3 new templates every week

Free. Unsubscribe anytime.

Related templates

Agent Autonomy Rules: Stop Asking Permission for Reversible Work

A rules-file block telling Claude Code, Codex, or Cursor when to just act and when to ask, so it stops pausing for permission on safe, reversible steps.

AI Agent Guardrails Checklist: Prompt Rules vs. Tool Permissions

Reviews your AI agent's rules and moves every limit that matters (money, data, deletes, messages) out of the system prompt and into permissions and code.

Headless Agent Run Prompt: Guardrails for CI, Cron & claude -p

Task prompt and checklist for unattended Claude Code, Codex, or Gemini CLI runs in CI or cron: turn and spend caps, restated guardrails, a JSON report.

Agent Template Safety Check: Permissions, Cost & Data

A prompt that reviews any agent template, skill pack, or MCP setup before you run it: what it can access, what it can spend, where your data goes, and what to lock down.

Browse all AI Agents templates

New on PromptLoot

Check Current Docs First: Stop Agents Using Outdated APIs

Rules that make Claude Code, Cursor, and Codex check your installed versions and current docs before calling any API, cite the version, and flag deprecations.

Minimal Diff Rules: Stop AI Agents Rewriting Unrelated Code

Rules for Claude Code, Cursor, and Codex: change only what you asked, no drive-by renames, refactors, or reformatting, and list every changed file.
PromptLoot Pro Pack · 200+ advanced templates, agent workflows, and Cursor rules bundles. Coming soon