Claude Code /ship 命令实操指南:自动化处理 PR 后续工作
A practical guide to shipping with Claude Code
Agent 落地开发的典型工作流,/ship 命令能显著减少 PR 阶段的上下文切换,有具体参数和安全边界说明,值得一线开发者收藏实践。
After you open a pull request, hand the follow up to Claude Code using /ship. Here's how to dial in your preferences to stay in flow.
打开拉取请求(Pull Request)后,使用 /ship 命令将后续工作交给 Claude Code。以下是如何调整你的偏好设置以保持心流状态。
- Author: Addy Osmani (Member of Technical Staff) - Published: 2026-11-24 - URL: <https://claude.dev/blog/the-work-after-you-open-a-pr/>
- 作者:Addy Osmani(技术员工成员) - 发布日期:2026-11-24 - URL:<https://claude.dev/blog/the-work-after-you-open-a-pr/>
When you open a pull request, there's usually a bunch of follow-up work to be done:
当你打开一个拉取请求时,通常有一堆后续工作需要完成:
- CI fails - A review comes back with six comments - A main merge creates a conflict
- CI 失败 - 审查反馈回来带有六个评论 - 合并到主分支产生冲突
They're all tiny little tasks, but each one takes you off your focus work.
它们都是些微小的任务,但每一个都会让你偏离专注的工作状态。
On the Claude Code team, an agent commonly does this follow-up work. For example, it can pick up an issue a reviewer found, so when the author gets back, the PR has already been updated once.
在 Claude Code 团队中,代理(agent)通常会处理这些后续工作。例如,它可以拾取审查者发现的问题,这样当作者返回时,PR 已经更新过一次了。
In my experience this is a more productive and enjoyable way to code. It minimizes context switching and keeps me in a flow state.
根据我的经验,这是一种更高效且更愉快的编码方式。它最大限度地减少了上下文切换,让我保持在心流状态。
We've talked about the process the Claude Code team uses for code review here, and about the verification process underneath it here. This post is about getting your own repository set up to do this using some of the new functionality we recently added with the Claude Ship launch.
我们之前在这里讨论过 Claude Code 团队用于代码审查的流程,以及在此处讨论其背后的验证流程。本文旨在介绍如何利用我们随 Claude Ship 发布的新功能,为自己的仓库设置此流程。
It's for a developer or tech lead whose team works on GitHub and who doesn't have admin privileges. You can start on your own right now by running a few commands, and save what you learn to files in your repo for the team to review. Admins only need to get involved if your team wants agents doing this automatically on the team's PRs.
这是为那些在 GitHub 上工作且没有管理员权限的开发人员或技术负责人准备的。你现在就可以通过运行几条命令开始操作,并将所学内容保存到仓库的文件中供团队审查。只有当团队希望代理自动在团队的 PR 上执行此操作时,管理员才需要介入。
You're still the architect of the process, so you're defining what to build, how to build it, and what the bar for merging is.
你仍然是该流程的架构师,因此由你来定义构建什么、如何构建以及合并的标准是什么。
The post-PR process
PR 后流程
After you've opened a PR, you want to find issues, address issues, and make a final decision on if the change can be merged.
打开 PR 后,你需要查找问题、解决问题,并对更改是否可以合并做出最终决定。
Claude Ship is three agents that tackle this work: Code Review, PR Steward (beta), and Claude Approvals (beta). Code Review is generally available, and the other two are in beta. `/ship` is a command you run yourself in Claude Code to try Claude Ship on your own pull requests. It comes with the latest version of Claude Code, and it works even before an admin has turned on any of the agents. You can partially automate the first two steps today. The last step is a decision that you set in your branch protections and (if your team adopts one) your policy file. Here is how it breaks down using the three agents that are part of Claude Ship:
Claude Ship 包含三个代理来处理这项工作:Code Review、PR Steward(测试版)和 Claude Approvals(测试版)。Code Review 已全面可用,另外两个处于测试阶段。`/ship` 是你在 Claude Code 中运行的命令,用于在自己的拉取请求上试用 Claude Ship。它包含在最新版本的 Claude Code 中,即使管理员尚未启用任何代理也能正常工作。你今天可以部分自动化前两个步骤。最后一步是一个决策,由你在分支保护设置中设定(如果你的团队采用策略文件的话,则由策略文件设定)。以下是使用 Claude Ship 中的三个代理进行的分解:
| You want Claude to | Run | Where it runs | ||
|---|---|---|---|---|
| Find bugs before anyone else looks | `/code-review` | Your session | ||
| Open a PR, review it and keep working on what comes back | `/ship` | Your session | ||
| Look after a PR you already opened | `/steward` | Your session | ||
| Do this across a team's PRs automatically | Claude Ship | Anthropic's cloud by default, set up by your team |
| 你希望 Claude 做 | 运行 | 运行位置 | ||
|---|---|---|---|---|
| 在其他人发现之前找到 Bug | `/code-review` | 你的会话中 | ||
| 打开 PR,审查它并继续处理返回的内容 | `/ship` | 你的会话中 | ||
| 照顾你已经打开的 PR | `/steward` | 你的会话中 | ||
| 自动跨团队的 PR 执行此操作 | Claude Ship | 默认情况下在 Anthropic 的云端,由你的团队设置 |
On your own PRs
在你的个人 PR 上
Getting started today with `/code-review`
今天通过 `/code-review` 开始使用
If you only do one thing from this post, review your branch before you push it. Bugs you catch here are less likely to come back as review comments or failed checks that pull you off your next task. At the Claude Code prompt, enter this command:
如果你只从这篇文章中做一件事,那就是在推送代码之前审查你的分支。在这里发现的 Bug 不太可能以审查意见或失败的检查形式回来,从而打断你的下一个任务。在 Claude Code 提示符下,输入以下命令:
/code-reviewIt reviews the commits on your branch and your uncommitted changes for correctness bugs. A few variations to keep in mind:
它会审查你分支上的提交以及未提交的更改中的正确性 Bug。记住几个变体:
/code-review high 1234 # review PR 1234 at high effort
/code-review --fix # apply the findings to your working tree
/code-review --comment 1234 # post the findings on the PR
/code-review ultra # run a deeper review in the cloudThe effort goes from low to max. At low you only see the findings the review is most sure about. Go higher and you see more, including some it's less sure about. Claude remembers the last level you used, so if the risk changes, set it again.
工作量从低到高。在低模式下,你只会看到审查最有把握的发现。调高后,你会看到更多,包括一些它不太确定的内容。Claude 会记住你上次使用的级别,因此如果风险发生变化,请重新设置。
A few caveats:
几点注意事项:
- You will want to take extra care when using the ultra setting, which runs in the cloud, needs a login at claude.ai, and can be billed separately from your plan. Read the ultrareview docs before trying it. - Edits made by `--fix` during a background review may not be caught by `/rewind`. Commit first if you want an easy way back. - Local `/code-review` reads your `CLAUDE.md` files, but not `REVIEW.md`. This matters later.
- 在使用 ultra 模式时要格外小心,该模式在云端运行,需要在 claude.ai 登录,并且可以单独于你的计划进行计费。尝试之前请阅读 ultrareview 文档。 - 后台审查期间由 `--fix` 进行的编辑可能不会被 `/rewind` 捕获。如果你想轻松回退,请先提交。 - 本地的 `/code-review` 会读取你的 `CLAUDE.md` 文件,但不会读取 `REVIEW.md`。这稍后会很重要。
The first thing you should do is run `/code-review` a few times to understand what it catches and where it gets things wrong. You'll use this later.
你应该做的第一件事是运行几次 `/code-review`,以了解它能捕捉到什么以及哪里会出错。你稍后会用到这一点。
Run `/ship` for your next PR
为你的下一个 PR 运行 `/ship`
Once you're ready, type:
准备好后,输入:
/shipIf you don't have a PR for your branch yet, `/ship` will:
如果你的分支还没有 PR,`/ship` 将会:
1. Commit your pending changes. It behaves as if you had run `git add -A`, so it will respect your `.gitignore`. It will create a branch if necessary, and it will use your session to write the commit message. You will be notified of this before the commit, and can abort by hitting Esc. 2. Push and create the PR as you. 3. Perform a code review using `/code-review`, unless the commit has already been reviewed by Code Review. If the code review reports any issues, it will fix the ones it judges as valid for you. 4. Watch the PR for up to seven days. It will work on failing checks, conflicts, and review comments, and will exit if the PR is merged or closed.
1. 提交你待处理的更改。它的行为就像你运行了 `git add -A`,因此会尊重你的 `.gitignore`。如有必要,它将创建一个分支,并使用你的会话来编写提交信息。在提交之前你会收到通知,可以通过按 Esc 中止。 2. 以你的身份推送并创建 PR。 3. 使用 `/code-review` 执行代码审查,除非该提交已经被 Code Review 审查过。如果代码审查报告任何问题,它将为你修复它认为有效的部分。 4. 观察 PR 长达七天。它将处理失败的检查、冲突和审查意见,如果 PR 被合并或关闭,则退出。
The first step, where `/ship` commits your pending changes as if you had run `git add -A`, sometimes catches people by surprise, so be sure to run `git status` before running `/ship`.
第一步,`/ship` 会像执行 `git add -A` 一样提交你的待处理更改,这有时会让用户感到意外,因此在运行 `/ship` 之前务必先运行 `git status`。
The command will not commit changes that touch files with names that look like secrets, or files that set rules, like `CLAUDE.md`, `REVIEW.md`, or anything in the `.claude/` or `.github/` directories. You will need to make these commits manually beforehand.
该命令不会提交涉及文件名看起来像密钥的文件的更改,也不会提交设置规则的文件的更改,例如 `CLAUDE.md`、`REVIEW.md` 或 `.claude/` 或 `.github/` 目录中的任何文件。你需要提前手动提交这些更改。
Also, if you are working in a public repository, the command will not commit any changes for you. You will need to commit any pending changes manually before you can proceed, and if the PR already exists, it won't include your pending changes.
此外,如果你正在公共仓库中工作,该命令不会为你提交任何更改。在继续操作之前,你需要手动提交所有待处理的更改;如果 PR 已经存在,它将不包含你的待处理更改。
Optional: specifying effort level, PR, or bot
可选:指定努力级别、PR 或机器人
/ship high # run at high effort
/ship 41 # work on pull request #41
/ship +my-lint-bot # also read comments from my-lint-bot
/ship stop # end the watchThe command will by default read comments by you, people with write access, and the Claude GitHub App. You can specify additional bots in the form `+name`. If that bot comments, it will be treated as an assertion to check against the code.
默认情况下,该命令会读取你、拥有写入权限的人以及 Claude GitHub App 的评论。你可以以 `+name` 的形式指定额外的机器人。如果该机器人发表评论,它将被视为需要针对代码进行检查的断言。
Letting Claude watch the PR
让 Claude 监控 PR
Claude watches the PR as you, on your machine, and uses your quota. Closing your laptop stops it, so keep the session open and the machine awake. You'll also need to be logged in to the GitHub CLI (run `gh auth login` first), and it only watches a PR that you opened.
Claude 会以你的身份在你的机器上监控 PR,并使用你的配额。关闭笔记本电脑会停止监控,因此请保持会话打开且计算机处于唤醒状态。你还需要登录到 GitHub CLI(先运行 `gh auth login`),并且它仅监控你创建的 PR。
For anything other than auto mode, the watch stops at every prompt and requires your response. It won't watch in bypass-permissions mode. Note that on Windows, `/ship` opens the PR and reviews, but the watch doesn't start.
对于除自动模式之外的任何情况,监控会在每个提示处停止并要求你的响应。它不会在绕过权限模式下进行监控。请注意,在 Windows 上,`/ship` 会创建 PR 并进行审查,但监控不会启动。
Ensure that the watch has its own checkout. You need to leave the branch checked out. If you're just going to jump straight into your next task, then make sure to use a separate worktree for one of them.
确保监控拥有自己的代码检出。你需要保持分支处于检出状态。如果你打算直接进入下一个任务,那么请确保为其中一个任务使用独立的工作树(worktree)。
If the watch fails to start, Claude will explain why but still review the PR. For example, you can't run a watch if you have a `PreToolUse` or `PermissionRequest` hook on Bash in the `.claude/settings.json` of your repo.
如果监控无法启动,Claude 会解释原因,但仍会审查 PR。例如,如果你的仓库的 `.claude/settings.json` 中对 Bash 设置了 `PreToolUse` 或 `PermissionRequest` 钩子,则无法运行监控。
Additionally, the watch uses up model turns while you're away, so it counts against your plan usage or API bill. The first time you use it, it's a good idea to be near your machine to make sure usage is within your expectations.
此外,当你不在时,监控会消耗模型轮次,因此会计入你的计划用量或 API 账单。首次使用时,最好待在计算机附近,以确保用量符合预期。
Only run the watch on repos you trust
仅在受信任的仓库上运行监控
The watch will merge the base branch into yours when necessary and then run commands like your tests. In other words, anyone who has the ability to land changes on the base branch has the ability to run commands on your machine during the watch. **Only run the watch locally on a repo where you trust everyone who can land changes on the base branch.**
Watch 会在必要时将基础分支合并到你的分支中,然后运行如你的测试等命令。换句话说,任何有权在基础分支上提交更改的人,都有权在你的机器上运行命令。**仅在你对基础分支的所有提交者都信任的仓库本地运行 watch。**
更进一步:量化金融体系
看懂新闻只是起点——沿量化金融路径,把它变成能交付的工程能力