跳到正文
DEV Community· jamilxt·· 6 小時前精選AI 評分78

Claude Approvals 安全部署指南:政策檔案逐步解析

How to Roll Out Claude Approvals Safely: A Policy File Walkthrough

AI 導讀

文章提出的 Claude Approvals 部署方案,先在單一儲存庫以 observe mode 試行,再啟用政策檔案並要求 GitHub 執行 Claude Approvals 狀態檢查。政策例子要求非作者的人類審批,並説明如何避免作者或機械帳戶佔用審批席位。文中亦整理七類可能在沒有人工審核下合併的情況及相應修正,並提醒不要把 Claude GitHub App 列入分支保護的豁免名單。

推薦理由

文章把政策檔案規則與 GitHub 分支保護設定連在一起,整理出排除作者佔用審批席位、涵蓋所有變更路徑及分階段啟用的方法。

正文 · 原文

On November 23, 2026, Anthropic launched Claude Ship in beta. It is a set of three agents for GitHub pull requests. One reviews the change, one fixes it, and one decides whether it is ready to merge.

As TechCrunch noted, AI coding tools already offered code review. The new part is the third agent. Claude Approvals reads a policy file kept in the repository and can post an approving review on its own, which delegates approval authority to an AI agent.

That makes the policy file a security control. A careless policy can let a pull request merge when no person other than its author has looked at it. Anthropic's documentation lists the ways this can happen, so you can design around each one.

This guide covers the policy file, those failure cases, the GitHub settings that matter, and a rollout order. It is built from Anthropic's launch post and the Claude Ship documentation as of November 24, 2026, not from a live test. Treat the YAML below as a starting draft. Approvals checks a policy file for errors in its pull request, so the tool will tell you if something is wrong.

What Claude Ship is made of

The Claude Ship docs describe three agents:

  • Code Review looks for logic errors, security vulnerabilities, and broken edge cases. It posts findings as inline comments, ranked by severity. It is generally available, with Quick, Standard, and Deep review levels.
  • PR Steward works on failing checks, merge conflicts, and review comments, and pushes commits with its fixes. It is in beta.
  • Claude Approvals is a check that reports who still has to approve a pull request, following a policy file you write. It is in beta.

There is also a new /ship command in the Claude Code CLI. Per the /ship docs, it opens the pull request, reviews it, and keeps working on failing checks and comments. The developer still merges.

Some limits to know before you plan anything:

  • Claude Ship is for Team and Enterprise plans, on GitHub repositories only.
  • It is not available to organizations with Zero Data Retention, the HIPAA configuration, or customer-managed encryption keys.
  • Each agent is billed on tokens through usage credits, separately from the plan's included usage.

Anthropic's launch post says that on the Claude Code team, merged pull requests "more than doubled" from June to September while the share reverted "fell by more than 40%". Those are Anthropic's own figures from a team where Claude's review was "one layer of a broader process", not an independent benchmark.

Separation of duties: the fixer cannot approve

Before touching the policy file, look at who is allowed to do what.

PR Steward is "designed not to approve or merge pull requests". The PR Steward access page is more specific. In an Anthropic-hosted session, Anthropic's service refuses these requests from Steward:

  • Approving a pull request
  • Changing branch protection, rulesets, or statuses, or writing check runs
  • Deleting a branch
  • Pushing tags

Merging, turning on auto-merge, and force-pushing are left to your GitHub branch rules. For those, two checks run on Claude's commands: permission rules that match the command text, and auto mode's model-based check. The docs say plainly that "a command that's written another way can pass both".

So the real wall between the agent that writes fixes and the code that merges is GitHub branch protection. Require reviews with branch rules, and keep the Claude GitHub App off every bypass list. In a classic branch protection rule, that is the "Allow specified actors to bypass required pull requests" list.

How a policy file works

A policy lives at .claude/approvals.yml in the repository root. Approvals only reads policy files from the default branch, so a policy change in an open pull request is checked for errors but does not apply until it merges.

This is the starter policy from the setup guide that keeps two people on each change:

# .claude/approvals.yml
version: 1
mode: observe
rules:
  - purpose: "A change takes two people."
    paths: ["**"]
    verdict: { claude: comments, seats: 2 }
    advisory: [claude/code_review]
  - purpose: "A change to the review rules takes two people."
    paths: ["**/.claude/**"]
    nested: inherit
    verdict: { claude: comments, seats: 2 }

Here is what each key does, per the policy file reference:

  • mode: observe makes the check report what the policy would decide without enforcing it. Delete the line to enforce. A file with no mode line is enforced by default.
  • paths lists the changed files a rule matches. ** matches any number of folders. A pattern starting with "!" takes files out of that rule.
  • verdict.claude is approves, comments, or blocks. Only approves lets Claude post an approving review.
  • verdict.seats is how many people have to approve, from 0 to 16. A plain number means "this many humans".
  • override swaps in a different verdict while its if condition is true. The first true override wins.
  • advisory runs a classifier, such as claude/code_review, without letting it decide anything.

Two rules about combining matter a lot:

  1. The strictest verdict wins. blocks outranks comments, which outranks approves, and every applying rule's seats must be filled. If one rule on a file says comments, Claude cannot approve that pull request.
  2. The author can count. On a pull request opened by someone with write access, the author can fill one seat without approving. So seats: 2 usually means the author plus one more person, and seats: 1 can mean nobody else.

One side effect: once a policy file is on the default branch, automatic Code Reviews normally stop for files whose rules do not name claude/code_review. That is why the starter keeps it under advisory.

The documented ways a change merges with no human review

The Approvals and GitHub rules page has a section called "Merges without human review". It lists cases where a pull request can merge with only its author looking, or with nobody if a bot wrote it. Here they are, with a fix for each.

1. The check is not required. The Claude Approvals check only blocks a merge where GitHub requires it. Fix: add it as a required status check on the default branch and on every other branch you want gated.

2. seats: 0 or seats: 1. With seats: 1, the author fills the seat. With seats: 0, a bot's pull request can merge with nobody looking. Fix: exclude authors explicitly with from: [humans, "!pr/authors"].

3. A from list that admits bots. If a seat's from includes bots, everyone, or bot:claude, and every applying rule says approves, Approvals counts that seat as filled before Claude approves. The check can then pass with no person. Fix: use humans for seats on anything that matters.

4. Machine users. A user account driven by a script or agent counts as a person. Fix: exclude its login, for example [humans, "!pr/authors", "!acme-ci"].

5. reuse keeping seats after a push. reuse lets earlier approvals survive a new push. The docs warn that people who held the author's seat at earlier commits can keep counting, so two of them "can fill seats: 2 with nobody approving". Fix: leave reuse out at first, or exclude authors.

6. Files no rule covers. If no rule covers any changed file, normally no check appears. Where GitHub requires the check, it ends neutral with the title "Nothing ran, not blocking: no file is covered", and GitHub counts that as passing. Fix: keep a root rule on ["**"] with no if.

7. Conditions that read a classifier. A classifier such as claude/code_review reads text the pull request's author wrote, and "that text can try to steer the classifier's answer". If an if or override lowers the required seats when a classifier says pass, a steered answer lowers the bar. Fix: on paths that matter, use a rule that reads no classifier.

Two GitHub-side notes sit next to this list. A direct push to the default branch gets no check, so require pull requests there. And Claude's approving review can satisfy a GitHub rule that requires one approval.

One more trap: claude: approves "starts no review" by itself, so Claude can approve a change nothing has reviewed. Gate it with an override on claude/code_review = pass.

A stricter starting policy

The docs include a rule that asks for one person who is not an author on every path. The policy below builds on it. It adds two-person review for a sensitive directory and for the files that control review, and lets Claude approve only documentation. The paths services/payments/** and docs/** are placeholders.

# .claude/approvals.yml
version: 1
mode: observe
rules:
  - purpose: "Every change outside docs needs one person who isn't an author."
    paths: ["**", "!docs/**"]
    nested: inherit
    verdict:
      claude: comments
      seats: [{ count: 1, from: [humans, "!pr/authors"] }]
    advisory: [claude/code_review]

  - purpose: "Payments code needs two people who aren't authors."
    paths: ["services/payments/**"]
    nested: inherit
    verdict:
      claude: comments
      seats: [{ count: 2, from: [humans, "!pr/authors"] }]

  - purpose: "Files that control review and CI need two people who aren't authors."
    paths: ["**/.claude/**", ".github/**", "CLAUDE.md", "AGENTS.md", ".mcp.json"]
    nested: inherit
    verdict:
      claude: comments
      seats: [{ count: 2, from: [humans, "!pr/authors"] }]

  - purpose: "Docs need one person who isn't an author, unless Claude's review passes."
    paths: ["docs/**"]
    verdict:
      claude: comments
      seats: [{ count: 1, from: [humans, "!pr/authors"] }]
    override:
      - { if: "claude/code_review = pass", verdict: { claude: approves, seats: 1 } }

Why it is shaped this way:

  • The root rule excludes `docs/.** Because the strictest verdict wins, a root rule saying comments` would stop Claude from ever approving a docs change. The docs rule still covers those files.
  • Docs are the one place where author plus Claude is enough. When claude/code_review reads pass, the override lowers the rule to seats: 1, which the author fills, and lets Claude approve. That is a deliberate trade-off. The override reads a classifier, which case 7 warns about, so keep this pattern away from code.
  • A missing review answer falls back to the strict verdict. If the review run gives no answer, the override is skipped and the rule's own verdict applies. So the strict verdict sits on the rule.
  • A pull request that touches docs and code gets the code rules, since the strictest verdict across all changed files decides.
  • The review-control files get their own rule. Approvals already treats policy files, .claude/classifiers/, REVIEW.md, CODEOWNERS, .gitmodules, and .gitattributes as "protected files". The docs say not to rely on other files being protected and name .github/, CLAUDE.md, AGENTS.md, and .mcp.json as examples to cover yourself.
  • nested: inherit keeps the strict rules in force if a team later adds a policy file in a subdirectory. Without it, the nearest policy file decides and "can ask for less than the root policy file".

One practical check: the setup guide lists two people with write access as a prerequisite before you enforce. With one, some changes can never pass.

Match your GitHub settings to the policy

The policy only reports. GitHub decides what merges. The setup and GitHub rules pages point to these settings:

  • Require pull requests on the default branch, since direct pushes get no check.
  • Require the Claude Approvals status check on the default branch and each branch you want gated. Set its source to the Claude app, not "any source". Otherwise GitHub accepts a check named Claude Approvals from anywhere. Through the API, the Claude app's ID is 1236702.
  • Require no more than one approval in GitHub, and ask for more people in seats. GitHub does not count an author who fills a seat, so a higher GitHub number can leave pull requests stuck after the check passes.
  • Turn on "Dismiss stale pull request approvals when new commits are pushed" or "Require approval of the most recent reviewable push". Otherwise GitHub can keep counting Claude's approval after a new push.
  • Restrict who can dismiss reviews, because PR Steward's dismiss requests are left to GitHub's rules.
  • For merge queues, accept the Claude app's Merge queues permission. Approvals does not evaluate the queue's own commits and normally marks them "Stamped for merge queue".

A rollout order that keeps you in control

The Claude Ship docs say to turn on one agent at a time, in one repository, in this order.

  1. Turn on Code Review for one repository from Organization settings, Claude Ship. This takes an Owner role.
  2. Turn on PR Steward with the manual start setting (@claude steward), so it only works where someone asks. The docs note that PR Steward "has no spend limit of its own until you set one", so set one.
  3. Add the policy file in observe mode, in a pull request of its own. Merge it when Claude comments that it "found the policy file in this change valid". An invalid file shows a failed check titled "This change breaks a policy file".
  4. Open a normal pull request and confirm a check titled "(observe mode)..." appears.
  5. Compare for a while. Check that the observe-mode titles match what your reviewers decide. Anthropic recommends this phase "to build confidence".
  6. Enforce. Delete the mode: observe line and merge. About five minutes later, comment @claude approvals rerun on each open pull request still showing an observe-mode title. Keep those pull requests out of the merge queue until then.
  7. Require the check in GitHub, with the Claude app as its source.
  8. Prove it blocks. Open a pull request that changes a file under .claude/. With the starter policy, the title should read "Waiting on human review from any person (1/2)", and GitHub should list the check as required. Stricter seats show a different count.

Observe mode is not free. Code Reviews and classifier runs that a policy starts are billed in observe mode too. A policy with claude/code_review inside an if can start a billed review at each push. Set spend limits for Code Review and for classifier runs under Organization settings, Usage.

Turning it off has an order too. Stop requiring the check in GitHub, then turn off Approvals, and only then Code Review, because a policy can start billed reviews where Code Review is off. Uninstall the Claude GitHub App last, or a required check can block merges.

Claude Approvals versus CODEOWNERS

Anthropic describes Approvals as working "like a smarter CODEOWNERS file". The difference, in short:

  • CODEOWNERS names who owns which paths, and a branch rule can require a code owner's review.
  • Claude Approvals sets how many people a path needs, can exclude authors, and can read facts such as pr/diff_lines, pr/files_changed, and pr/base, plus classifier answers. It can also let Claude approve.

To name owners in a policy, the docs suggest people lists in seats, such as a GitHub team like acme/payments. A condition cannot read CI results, so CI stays its own required check.

What developers said in the launch thread

The Hacker News thread had 63 points at the time of writing. Three comments are worth reading before a rollout.

One developer liked the provider split. They said a lot of code authoring on their side happens with OpenAI's models, and that "using a different provider's models to do the code review part seems like a pretty good separation of responsibilities."

Another was skeptical of the product itself, calling it a tool that "centralizes policy enforcement for teams with low-trust" and arguing that capable teams will build their own model-agnostic pipelines to avoid vendor lock-in.

A third reported a practical snag: the new built-in /ship command overwrote their team's own /ship skill. The /ship docs describe how an organization can turn off /ship and /steward through managed settings. If your team has a custom skill with that name, check before you update Claude Code.

The short version

Claude Ship's agents can find problems and fix them. Whether code merges without a person still comes down to your policy file and your GitHub branch rules.

Start in observe mode on one repository. Exclude authors from seats on anything that matters, and keep a root rule with no if so every file is covered. Keep classifier-based shortcuts for low-risk paths. Require the check with the Claude app as its source, and keep the app off every bypass list.

Which paths in a codebase you work on would you be comfortable letting an AI approve, and which ones would always need a second person?

來源:DEV Community · dev.to