跳到主内容
@wquguru
精选70Claude Code 文档(sitemap)产品发布/更新多源精选 ×6

Claude Code PR Steward功能配置指南

Set up PR Steward

原文
发到 X

Turn on PR Steward for your Claude organization: require reviews, add a repository, set spend limits, and choose when it starts and for which authors

为您的 Claude 组织启用 PR Steward:要求审核、添加仓库、设置支出限额,并选择其启动时间及适用的作者

To set up PR Steward, turn it on for your Claude organization and then for each repository. You need an Owner role.

要设置 PR Steward,请为您的 Claude 组织启用它,然后为每个仓库启用。您需要拥有 Owner(所有者)角色。

Once it's on in a repository, PR Steward pushes commits to pull requests there to address review feedback, and attempts to fix failing checks and resolve merge conflicts. It starts by itself or when someone asks for it, as you choose for each repository.

在仓库中启用后,PR Steward 会向该仓库的拉取请求推送提交,以处理审核反馈,并尝试修复失败的检查及解决合并冲突。它会根据您在每个仓库中的设置,自动启动或在有人请求时启动。

Prerequisites

前提条件

Check that your organization qualifies for PR Steward.

检查您的组织是否符合使用 PR Steward 的资格。

In your Claude organization, which you manage at claude.ai, you need:

在您于 claude.ai 管理的 Claude 组织中,您需要:

* An Owner role * Usage credits, which pay for PR Steward's work * The GitHub connector, turned on at Organization settings > Connectors. With it on, people in your organization can connect their GitHub accounts to Claude

* Owner(所有者)角色 * 使用额度,用于支付 PR Steward 的工作费用 * GitHub 连接器,需在“组织设置 > 连接器”中开启。开启后,您组织中的人员可以将他们的 GitHub 账户连接到 Claude

On GitHub, you need this access, or someone who has it:

在 GitHub 上,您需要以下权限,或者由拥有以下权限的人操作:

* Owner of the GitHub organization, to install the Claude GitHub App and link it to your Claude organization * Admin of the repository, to add branch rules. A private repository also needs a paid GitHub plan * Push access to the repository, from the GitHub account that you connect to Claude

* GitHub 组织的所有者,以便安装 Claude GitHub App 并将其链接到您的 Claude 组织 * 仓库的管理员,以便添加分支规则。私有仓库还需要付费的 GitHub 计划 * 对您连接到 Claude 的 GitHub 账户具有对该仓库的推送访问权限

Require reviews with branch rules

通过分支规则要求审核

Add these rules in GitHub before you turn on PR Steward.

在启用 PR Steward 之前,请在 GitHub 中添加这些规则。

1. Require an approval

1. 要求批准

Add a ruleset rule on the default branch that requires a pull request with at least one approval.

在主分支上添加一条规则集规则,要求拉取请求至少获得一次批准。

2. Require a new approval after a push

2. 推送后要求新的批准

In that rule, dismiss stale approvals when new commits are pushed, or require approval of the most recent push.

在该规则中,当推送新提交时撤销过期的批准,或要求对最新推送进行批准。

3. Check the ruleset's bypass list

3. 检查规则集的绕过列表

Keep the Claude GitHub App off the ruleset's bypass list. On GitHub Enterprise Server, that's the app that your organization created. If PR Steward runs in a self-hosted environment, keep the runner's git identity off it.

将 Claude GitHub App 保留在规则集的绕过列表之外。在 GitHub Enterprise Server 上,这是您组织创建的应用程序。如果 PR Steward 在自托管环境中运行,请将运行器的 git 身份保留在绕过列表之外。

4. Protect other branches

4. 保护其他分支

Add rules to any other branch that PR Steward shouldn't push to, and block force pushes where you don't want them.

为 PR Steward 不应推送到的任何其他分支添加规则,并在不需要强制推送的地方阻止强制推送。

> [!NOTE] > > Where a Claude Approvals policy lets Claude approve, Claude's review can count as the approval in step 1. An approval from a session in a self-hosted environment can count as well.

> [!NOTE] > > 在 Claude Approvals 策略允许 Claude 批准的情况下,Claude 的审核可视为第 1 步中的批准。自托管环境中的会话产生的批准也可以算作有效批准。

Turn on PR Steward and add repositories

启用 PR Steward 并添加仓库

Start on Organization settings > Claude Ship.

从“组织设置 > Claude Ship”开始操作。

The Repositories table on that page lists each repository with its Steward setting:

该页面上的“仓库”表格列出了每个仓库及其 Steward 设置:

> [!WARNING] > > Adding a repository can start Code Review there, which is billed. > > * No repository is listed yet: a dialog asks what Claude does on the repositories that you add, and Code review is selected by default. If you select Steward in the dialog, PR Steward turns on for the organization and those repositories before you've set a spend limit. > * Others are already listed: no dialog opens, and the new one is set up for review at every push by default. > > To change that, set when reviews run or turn off Code Review for the repository.

> [!WARNING] > > 添加代码库可能会在那里启动代码审查,这需要计费。 > > * 尚未列出任何代码库:对话框会询问 Claude 在您添加的代码库上执行什么操作,默认选中“代码审查”。如果在对话框中选择“Steward”,则在您设置支出限额之前,组织及其代码库将启用 PR Steward。 > * 其他代码库已列出:不会打开对话框,新代码库默认在每次推送时设置为审查模式。 > > 要更改此设置,请设置审查运行时间或关闭代码库的代码审查。

1. Add a repository

1. 添加代码库

If the repository is already listed under Repositories, skip this step. Otherwise, click Add, connect your GitHub account if asked, and select the repository. If a dialog then asks what Claude does on it, click Not now, which keeps the repository listed.

如果代码库已列在“代码库”下,请跳过此步骤。否则,点击“添加”,如需则连接您的 GitHub 账户,然后选择代码库。如果随后出现对话框询问 Claude 在其上的操作,请点击“稍后处理”,这将保留该代码库的列表状态。

2. Set which authors PR Steward works for

2. 设置 PR Steward 服务的作者范围

Under the Steward switch, use Runs for to set whose pull requests PR Steward works on. Select All eligible authors, or select Listed users only to pilot with a few people, and enter their GitHub usernames.

在“Steward”开关下方,使用“Runs for”设置 PR Steward 处理哪些拉取请求。选择“所有符合条件的作者”,或选择“仅列出用户”以与少数人进行试点,并输入他们的 GitHub 用户名。

On GitHub Enterprise Server, select All eligible authors, because PR Steward doesn't start there with a list.

在 GitHub Enterprise Server 上,请选择“所有符合条件的作者”,因为 PR Steward 不会从列表开始。

3. Turn on PR Steward for the organization

3. 为组织启用 PR Steward

Click the Steward switch, then click Turn on.

点击“Steward”开关,然后点击“开启”。

4. Set PR Steward's monthly limit

4. 设置 PR Steward 的月度限额

Go to Organization settings > Usage. Under Services, set the limit in the PR Steward row. PR Steward has no spend limit of its own until you set one.

转到“组织设置” > “使用情况”。在“服务”下,在“PR Steward”行中设置限额。在您设置限额之前,PR Steward 没有自己的支出限额。

5. Turn on PR Steward for the repository

5. 为代码库启用 PR Steward

On the Claude Ship page, click Edit beside the repository. Set Steward to Manual (@claude steward). Click Change beside Steward spend cap and enter the cap, in US dollars. See how the cap works.

在 Claude Ship 页面上,点击代码库旁边的“编辑”。将 Steward 设置为“手动 (@claude steward)”。点击 Steward 支出上限旁边的“更改”并输入上限金额(美元)。了解上限的工作原理。

6. Test PR Steward

6. 测试 PR Steward

Open a pull request from an account that has write access and that Runs for covers. Comment `@claude steward`. The `claude-pr-steward-watching` label and a comment headed Claude PR Steward appear.

从具有写入权限且被“Runs for”覆盖的账户打开一个拉取请求。评论 `@claude steward`。将出现 `claude-pr-steward-watching` 标签和标题为“Claude PR Steward”的评论。

If they don't appear, see Troubleshoot PR Steward.

如果它们未出现,请参阅故障排除 PR Steward。

Roll out PR Steward to more pull requests

将 PR Steward 推广到更多拉取请求

When PR Steward's fixes match what your reviewers would do, set the repository to On. For each repository that you add later, require reviews there first. Then repeat these steps from Turn on PR Steward and add repositories: add the repository, turn on PR Steward for it, and test PR Steward. PR Steward can be on in up to 256 repositories.

当 PR Steward 的修复符合审查员的预期时,将代码库设置为“开启”。对于您后续添加的每个代码库,请先要求在那里进行审查。然后重复以下步骤:从“启用 PR Steward 并添加代码库”开始:添加代码库,为其启用 PR Steward,并测试 PR Steward。PR Steward 最多可在 256 个代码库中处于开启状态。

Choose when PR Steward starts in each repository

选择在每个代码库中何时启动 PR Steward

On the Claude Ship page, click Edit beside a repository and open the Steward menu:

在 Claude Ship 页面上,点击代码库旁边的“编辑”并打开 Steward 菜单:

Select when you want PR Steward to start:

选择您希望 PR Steward 启动的时间:

OptionWhen PR Steward starts
Manual (@claude steward)When a person with write access comments `@claude steward` or adds the `claude-pr-steward-watching` label
OnWhen a pull request that PR Steward doesn't skip is opened, reopened, or marked ready for review. Also at the next push to an open one that it hasn't started on before
On (including drafts)The same as On, and on draft pull requests
OffPR Steward doesn't start in the repository
选项PR Steward 启动时机
手动 (@claude steward)当具有写入权限的人评论 `@claude steward` 或添加 `claude-pr-steward-watching` 标签时
开启当 PR Steward 不会跳过的拉取请求被打开、重新打开或标记为待审核时。此外,在之前未开始处理的已打开拉取请求的下次推送时也会启动
开启(包括草稿)与“开启”相同,并且适用于草稿拉取请求
关闭PR Steward 不在仓库中启动

In a Manual repository, a comment or the label can start PR Steward on a draft. It doesn't start PR Steward on the other pull requests that PR Steward skips.

在设置为“手动”的仓库中,评论或标签可以触发 PR Steward 处理草稿拉取请求。它不会在 PR Steward 会跳过的其他拉取请求上启动。

PR Steward also starts there on the pull requests of a developer who selects Act on its own.

PR Steward 还会在处理选择“自行操作”的开发者的拉取请求时启动。

Limit which authors PR Steward works for

限制 PR Steward 服务的作者范围

To skip an author, add their GitHub username to Excluded users, under the Steward switch.

要跳过某些作者,请在 Steward 开关下方的“排除用户”中添加其 GitHub 用户名。

Control what PR Steward spends

控制 PR Steward 的费用支出

Billing continues while usage credits are turned off.

即使使用额度已关闭,计费仍会继续。

See what PR Steward spent

查看 PR Steward 的费用支出

To see the average for each merged pull request, open a repository's Edit dialog. For your organization's total over the last 30 days, go to claude.ai/analytics/pr-steward.

要查看每个已合并拉取请求的平均费用,请打开仓库的编辑对话框。要查看组织过去 30 天的总费用,请访问 claude.ai/analytics/pr-steward。

Set PR Steward's spend limits

设置 PR Steward 的支出限额

Change the monthly limit in Organization settings > Usage, under Services, in the PR Steward row. The row appears after you first turn on PR Steward. Change the spend cap in the repository's Edit dialog. When PR Steward reaches a limit, look for its comment on the pull request:

在“组织设置”>“使用情况”>“服务”下的 PR Steward 行中更改月度限额。该行在您首次开启 PR Steward 后出现。在仓库的编辑对话框中更改支出上限。当 PR Steward 达到限额时,请查找其在拉取请求上的评论:

* Its monthly limit, or your organization's usage-credit limit: PR Steward pauses. It picks up again at the next push or comment once usage credits can pay again * The spend cap: PR Steward stops on that pull request. Spend can pass the cap before it stops. A person with write access can start it again, with the full cap. When PR Steward works on a pull request for more than about a week, it can start a new cloud session, and the full cap then applies again

* 月度限额,或您组织的使用额度限额:PR Steward 暂停。一旦使用额度再次可用,它将在下次推送或评论时恢复 * 支出上限:PR Steward 在该拉取请求上停止。在停止前,支出可能会超过上限。具有写入权限的人可以使用完整的上限重新启动它。当 PR Steward 处理拉取请求超过大约一周时,它可能会启动新的云会话,此时将再次应用完整上限

With no usage credits left to spend, PR Steward doesn't start, and the Claude Ship page shows Steward cannot start on pull requests. Add usage credits or raise the limit on the Usage page.

当没有剩余的使用额度可供支出时,PR Steward 不会启动,Claude Ship 页面会显示 Steward 无法在拉取请求上启动。请添加使用额度或在“使用情况”页面上提高限额。

Set up PR Steward's build environment

设置 PR Steward 的构建环境

Choose an environment for PR Steward when it needs more to build and test your code.

当 PR Steward 需要更多资源来构建和测试您的代码时,为其选择一个环境。

Choose the environment PR Steward runs in

选择 PR Steward 运行的环境

To add a setup script, environment variables, or different network access, use an organization-shared environment. On the Claude Ship page, select a Default environment under Where it runs. To override it for one repository, click Change beside Environment in the Edit dialog.

若要添加安装脚本、环境变量或不同的网络访问权限,请使用组织共享的环境。在 Claude Ship 页面上,选择“运行位置”下的默认环境。若要为一个存储库覆盖该设置,请在编辑对话框中点击“环境”旁边的“更改”。

With neither set, PR Steward can use your organization's default environment. Without one, it runs in an Anthropic-hosted environment with no setup script and no environment variables.

如果两者均未设置,PR Steward 将使用您组织的默认环境。若没有默认环境,它将在 Anthropic 托管的环境中运行,且无安装脚本和任何环境变量。

Run PR Steward in a self-hosted environment

在自托管环境中运行 PR Steward

更进一步:量化金融体系

看懂新闻只是起点——沿量化金融路径,把它变成能交付的工程能力

进入量化体系 →