Claude Code 工作流如何从逐步审批走向多会话监督|Lydia Hallie
原题Rethinking Claude Code Best Practices — Lydia Hallie, Anthropic
看前速览
Lydia Hallie 讲解如何用权限控制、验证和编排来监督长期运行的 Claude Code 会话。
只把模型无法自行发现的背景写进指令
例如代码里没有直接引用的旧依赖。提示审计有助于找出新版模型已经不需要的指令。
给高风险操作设置多层控制
自动模式判断命令,拒绝规则拦截特定调用,操作系统沙箱限制获准命令及其子进程能访问的范围。
设置独立的验证节点
明确什么才算完成,并按任务检查。钩子可强制执行关键测试,CI 则给不同会话提供统一检查。
区分编排和执行的职责
编排会话拆分工作、检查返回结果,把尚未满足检查要求的任务退回处理。
完整摘要
随着 Claude 模型能连续完成更长的任务,开发者的工作从逐步干预变成监督多条会话。Lydia Hallie 示范如何精简 CLAUDE.md、调整自动模式,并用显式拒绝规则和沙箱限制后果严重的操作。她引用 Anthropic 的研究比较人工与自动分类器,再用认证迁移说明为什么要设置任务检查、钩子、CI 和按风险分配的人工审查。编排会话可以独立派工,并把尚未通过检查的任务退回重做。
文字稿
简要描述Brief Description
Lydia Hallie 解释了随着模型运行时间变长、承担更多自身工作的监督任务,Claude Code 工作流会如何变化,并通过权限管理、沙箱、验证、CI 和编排等示例加以说明。Lydia Hallie explains how Claude Code workflows change as models run longer and supervise more of their own work, with examples of permissions, sandboxing, verification, CI, and orchestration.
目录Table of Contents
- 从审批到监督From approval to supervision
- 调整指令和权限Tune instructions and permissions
- 安全保障从何而来Where safety guarantees come from
- 会话期间的验证Verification during a session
- CI 与编排CI and orchestration
从审批到监督From approval to supervision
今天早上演讲时,我遇到了一些技术问题。所以我赶紧跑回家,打算直接用电脑录下来。大家好,我是 Lydia,在 Anthropic 的 Claude Code 团队工作。最近模型变得非常强大。比如 Opus 5.5,它是我最喜欢的日常主力模型。本周早些时候,我们还发布了 Fable 5.2。这些模型非常擅长处理长时间运行的任务,也很善于理解你的代码库。尤其是 Fable,它还很擅长验证自己的输出。但随着模型不断进步,我们在 Claude Code 中与它们协作的方式也在改变。今年早些时候,不知道大家还记不记得,那时的会话大概是这样的。我们会使用像 Opus 4.5 这样的模型,老实说,在当时它已经非常出色了。我很喜欢用 Opus 4.5。I had some technical difficulties during my talk this morning. So, I ran back home and I'm just going to record it from my computer instead. So, hi everyone. I'm Lydia. I work on the Claude Code team at Anthropic. And the models have gotten really good lately. So, we have Opus 5.5, which is my favorite daily driver. And earlier this week, we also launched Fable 5.2. And these models are extremely good at long-running tasks and understanding your code base. Especially Fable is also really good at verifying its own output. But as these models get better, the way that we work with them in Claude Code also changes. So earlier this year, I don't know if you remember, but sessions kind of used to look like this. So we'd use a model like Opus 4.5, which honestly for its time was really good. I really enjoyed working with Opus 4.5.
但与今天相比,它只是会更早停止,也就是说,运行时间会短得多。我们也会不断纠正它,不停地提醒它该做什么,还会把诸如“重要!”之类的内容添加到 CLAUDE.md 文件中。此外,当时还没有自动模式这样的功能。所以我们要么手动批准所有操作,要么冒险使用 --dangerously-skip-permissions。也就是说,我们作为人类仍然深度参与其中。但随着这些模型越来越擅长承担更大的任务,我们的会话方式也发生了变化。如今,至少在 Anthropic,我们的会话大致是这样的:同时运行数十个会话,持续数小时,一路验证各自的结果,甚至还会让会话去协调其他会话。But compared to today, it would just stop a lot earlier. So it would just run for shorter amounts of time. And we'd also keep correcting it. We'd keep reminding it to do things, add things like IMPORTANT!, all these things to our CLAUDE.md file. And also features like auto mode didn't exist yet. So we were either approving everything manually or taking the riskier approach with --dangerously-skip-permissions. So we were still very much in the loop as humans. But as these models got better at taking on bigger tasks, our sessions also changed. So nowadays, at least at Anthropic, our sessions look more like this. So we're running dozens of sessions at the same time, running for hours, verifying their own results along the way, and we even have sessions orchestrate other sessions.
因此,以前我们几乎每一步都要参与其中,一次只运行一个或几个会话;而现在,我们基本上成了数十个会话的管理者。不过,我们的工作效率也大幅提高了。你可能看过我们十月份发布的博客文章,文中提到 Anthropic 每天的变更量从五月份的约 2,500 次增至九月份的 30,000 多次。但这也意味着,作为开发者,我们必须重新思考应该把精力放在哪里。回顾今年早些时候的最佳实践,重点主要是引导会话、批准命令、拒绝某些操作或限制 Claude 的能力、检查输出,以及启动会话。如今,我们在流程中的每个环节退出参与后,都必须有其他东西接手。这可能是模型、工具框架,或者模型运行的环境。So whereas we used to be in the loop for almost every step and running one or just a couple sessions at a time, we've now essentially become managers for dozens of sessions. We also get a lot more done, though. Now, you may have seen our blog post in October about how Anthropic went from about 2,500 changes a day in May to more than 30,000 a day in September. But this also means that we as developers just have to rethink on what we're focused on instead. So, if you think about our best practices from earlier this year, it was mainly about steering sessions, approving commands, saying no to certain things or restricting what Claude could do, checking the output and also starting the sessions. So everywhere that we now step out of that loop, something else has to take over. And this is either the model, the harness, or the environment that it's running in.
所以,如果我们不再逐条审批每条命令,而是同时运行这么多会话,该如何确保它编写的代码仍然具备高质量?更重要的是,如果这些会话在无人监督的情况下运行数小时,我们该如何确保它们安全运行?接下来,我们就从这个旧会话入手,看看要做哪些调整,才能达到我之前展示的效果。首先,我们来使用如今启动会话时实际采用的默认设置。所以,这其实不是你需要操心的事情。我们把这里的模型从 Opus 4.5 更新为 Opus 5.5,并将手动权限模式改为自动模式。Opus 5.5 更善于理解你的意图和代码库,因此我们现在不必再像以前那样在会话过程中频繁引导它了。So if we are not in a loop to approve every command, and we're running so many sessions at the same time, how can we make sure that the code it's writing is still high quality? And most importantly, if these sessions are running for hours without our supervision, how can we make sure that they're running safely? So let's go through that by taking this old session and seeing what we have to change to get to that end result that I showed earlier. Well, first of all, let's use the actual defaults we start sessions in nowadays. So that's not really something you should think about. So let's update the model here from Opus 4.5 to Opus 5.5 and change the manual permission to auto mode. And Opus 5.5 is a lot better at understanding your intent and understanding your code base. So we really don't have to steer it as much anymore midsession.
调整指令和权限Tune instructions and permissions
而且,由于我们从 8 月起就开始将自动模式设为默认权限模式,你也不再需要批准每一条命令。如今模型更善于理解你在代码库中的意图,这也意味着我们必须重新思考写在代码库中的指令。因此,如果你遵循了我们今年早些时候分享的最佳实践,CLAUDE.md 文件里可能还留着诸如“重要”或“绝对不要这样做!”之类的内容。但对于现在的模型来说,这些真的没必要,反而可能让模型偏离方向。结果就是工具调用变多,整体效果也更差。如今,CLAUDE.md 文件里只应该包含 Claude 无法从代码中看出来的信息。比如,你可能有一项服务仍在某处使用旧版源码,但代码中并未直接引用它。And you also no longer have to approve every command because we started making auto mode the default permission mode back in August. Now being better at understanding your intent in your codebase also means that we have to rethink the instructions we have in our codebase. So if you followed our best practices from earlier this year, you may still have things like important or never do this exclamation mark all these things in your CLAUDE.md file. But with today's models, you really don't need that and it can actually make the model go off track. So you end up with more tool calls and overall a worse result. So nowadays your CLAUDE.md file should only include the things that Claude cannot see from your code. So for example, maybe you have a service that's still using some legacy source somewhere, but it's not directly referenced in the code.
这部分保留着还是有用的。但其他内容,比如你用的技术栈,或者该去哪里查找,就真的没必要再写了。实际上,我们有一个专门的命令叫 /doctor prompt audit,可以很轻松地针对特定模型优化你的环境。所以,如果你这里用的是 Opus 5.5,运行这个命令后,它会自动检查你的 CLAUDE.md 和技能,看看新模型已经不再需要哪些内容。
现在,自动模式是一种权限模式,它会对几乎所有操作运行一个单独的分类器,只有读取或编辑项目文件这类操作除外。它会自动允许已知安全的命令,比如运行测试或安装依赖,但对于无法确定是否安全的命令,仍然会拦截。通常这已经相当不错了。通常来说,这也算是我们想要的。That's still good to keep in there. But everything else like what stack you're on or where to look, you really don't need that anymore. And we actually have a command for this called /doctor prompt audit which makes it really easy to optimize your environment for a specific model. So if you're on Opus 5.5 here and you run this command, it will automatically check your CLAUDE.md and your skills to see what the new model no longer needs. Now auto mode is a permission mode that runs a separate classifier on pretty much everything that isn't just reading or editing files in your project. So it automatically allows commands that it knows are safe, like running tests or installing dependencies, but it still blocks commands where it's unsure whether they're safe. And normally that's pretty good. Normally that's kind of you know what we want.
但比如说,如果我们在这里要求它把某些东西部署到 staging,我们就得批准它推送到我们的部署仓库;而默认情况下,自动模式只信任这个文件夹和这个仓库,所以它会拦截这条命令。这样我们就又得人工介入了。现在的默认设置在大多数情况下应该都够用。但如果你发现即使在自动模式下,还是有很多命令需要你批准,首先要看看这里的设置,因为你可以直接用普通英语在自己的设置中配置自动模式。这些设置会发送给分类器,由它来决定拒绝还是允许某些命令。所以在这里,我们只要写明信任哪些仓库、存储桶和域名,以及它应该始终允许做什么或绝不做什么。好了,说实话,这其实很简单。只用今天的默认设置,我们就已经减少了大部分需要人工介入的工作,因为模型接管了方向把控,而自动模式接管了所有审批。But for example here if we ask it to ship something to staging we would have just you know approved the push to our deploy repo but by default auto mode only trusts this folder and this repo. So it would block that command. So we're back in the loop. Now the defaults should be good in most cases. But if you still notice that you have to approve a lot of commands even in auto mode. The first thing to look at is settings here because you can configure auto mode in your own settings just in plain English. And this is what gets sent to the classifier which then decides whether to reject or allow certain commands. So here we can just write which repos, buckets, domains we trust and what it should always allow or never do. Okay, so honestly this was pretty easy. By just using today's defaults, we've already gotten rid of most of our in the loop stuff because the model took over the steering and auto mode took over all the approving.
安全保障的来源Where safety guarantees come from
所以,退出这个循环很容易。但现在更难的问题是,如何确保我们不再参与其中也没问题。首先是确保安全,其次是验证。我们先从确保安全说起,因为到目前为止,升级模型、使用自动模式,都只是与模型协作。大多数情况下,它会按你的要求行事,但这并非保证。我们在去年 8 月发布的一项研究中,对比了自动模式和有人参与其中的情况。结果发现,只有约 14% 的人识别出了明显危险的命令,而自动模式拦截了其中的 89%。所以,它在这方面确实比我们强得多。但仍有大约十分之一的这类命令成功执行了。如果你确实需要保证,就只能在执行框架中强制落实。这时,我们一些沿用已久的最佳实践仍然很重要,那就是权限管理。So getting out of the loop is easy. But the harder question now is how do we make sure it's okay that we're not there anymore. So first is keeping it safe and then also verification. So let's start with keeping it safe because everything so far so upgrading the model and using auto mode is just working with a model. And in most cases it does what you tell it to do. But that's not a guarantee. So in a study we published back in August we tested auto mode versus real people in the loop. And only about 14% of people caught a clearly dangerous command. Auto mode blocked 89% of them. So it is a lot better at it than we were. But about one in 10 of those commands still went through. So if you do want the guarantee, you can only enforce that in the harness. And this is where some of our older best practices still matters and that's permissions.
例如,如果你的项目中针对某个特定工具调用设置了拒绝规则,Claude Code 会先检查这条规则,然后自动模式分类器才会检查该调用。事实上,如果某个工具调用符合拒绝规则,分类器甚至根本不会看到它。因此,设置拒绝规则仍然是确保 Claude 绝不会做某件事的最佳方式。但接下来,怎么判断哪些内容应该在项目中设为规则,哪些内容可以交给已经足够聪明的模型自行处理呢?我觉得关键在于:如果 Claude 有一次做错了,我能不能挽回?如果它写错了代码,你还可以撤销更改,所以这类事情仍然可以交给模型处理。但如果它丢弃了我们尚未提交的更改,或者读取了一个现在已经出现在对话记录中的密钥,而你又不希望它这么做,那就仍然应该设为规则。So for example, if you have a deny rule for a specific tool call in your project, Claude Code looks at this rule before the auto mode classifier even looks at it. In fact, if a tool call matches a deny rule, the classifier never even sees it. So having deny rules is still the best way to make sure Claude actually never does something. But then how do you know what needs to be a rule in your project versus what the model can just know because they've gotten so good at it? I think it kind of just comes down to if Claude gets it wrong once, can I take it back? So if it writes the wrong code, you can still revert that. So you can still leave that to the model, but if it throws away our uncommitted changes or it reads a key that's now in your transcript and you don't don't want that, that should still be a rule.
比如说,我们绝不希望 Claude 读取我们的 .env 文件。默认情况下,自动模式对此是放行的,所以它会直接批准。如果你想确保 Claude 永远无法读取这个文件,只要添加一条拒绝规则即可。这样一来,像 cat 这样的命令也无法打开这个文件。不过,事情并不总是这么简单,因为有些命令可能会产生副作用。比如说,npm test 是一个很常见的命令,只是用来跑测试,所以自动模式会运行它,这没问题。但在脚本运行时,它也会执行一些不是你编写的代码,比如依赖项里的代码;或者 Claude 可能会快速运行一个自己写的脚本,只是为了检查某件事。如果其中某个脚本被攻破了,它就可能打开同一个 .env 文件,或者你的 SSH 密钥,并把它们发送到一个你从未听说过的服务器上,对吧?So for example, let's say that we just never want Claude reading our .env file. Now, by default, auto mode is fine with this. So it would have just approved it. So, if you want to make sure that Claude can never read this file, you should just add a deny rule. And then commands like cat cannot open this file either. But it's not always that straightforward because sometimes certain commands can have side effects. So for example, let's say that npm test here a very normal command. It's just a test. So auto mode runs it. That's fine. But when the script is running, it runs code that you didn't write like your dependencies or maybe Claude runs a script real quick that it wrote just to quickly check something. So, if one of those scripts is compromised, it could just open that same .env file or your SSH keys and send those to a server you've never heard of, right?
即使我们还像以前一样由人来审批所有操作,说实话,我们也只会点击“允许”,因为没有任何理由拒绝。这种情况下,运行 npm test 只是脚本的一部分。权限只能决定是否运行某个工具调用,却无法限制它运行后能访问什么。因此,我们希望这类脚本仍然可以运行,因为运行测试是 Claude 检查自身工作的一部分。所以,我们不能直接禁止运行 npm test,而是要限制它可能造成的副作用。说到底,我们只是想限制它运行的环境。如果你在本地或自己的机器上运行,就可以在沙箱中执行这类命令。这样,你就能控制命令可以读取哪些文件、可以写入哪些文件夹、可以连接哪些主机,而这些限制会由操作系统强制执行。And even if we were still there as humans approving everything, honestly, we would have just clicked allow because there's nothing to say no to. It's just part of the script that in this example case, npm test runs. And permissions only decide if a tool call runs, but they cannot limit what it can reach once it's running. So we want to make sure that these kinds of scripts can still run because this is just part of you know how Claude can check its own work running tests. So we cannot just block npm tests but we want to limit its side effects. So really we just want to limit the environment that it's running in. So if you're running it locally or on your own machine you can run commands like that in a sandbox. So then you have control over which files in a command it can read, which folders it can write to, which hosts it can reach and the operating system enforces that.
这也适用于该命令随后启动的一切,也就是所有子进程。单看这一点,Claude 会在命令运行前检查这条拒绝规则。但它能看到的只有 `npm test`,看不到脚本最终会打开哪些文件。启用沙箱后,同一条规则会被传递给操作系统。因此,当那个依赖尝试打开我们的 .env 文件时,操作系统就会直接阻止它。默认情况下,它仍然可以读取你机器上的大部分内容。所以,如果你在意 SSH 密钥的安全,就需要再添加一条规则。它也无法连接到未经批准的主机。不过,沙箱只涵盖 Claude 运行的 shell 命令及其启动的任何程序。Claude 自身的文件、MCP 服务器和所有钩子仍然在沙箱之外运行。Also this also applies to everything that command then starts. So any child processes. So on its own that deny rule got checked by Claude before the command runs. But all it sees there is npm test. So it doesn't see which files that scripts ends up opening. But with the sandbox on that same rule gets passed on to the operating system. So now when that dependency tries to open our .env file, the operating system just doesn't let it. And by default, it can still read most of your machine. So you'd want to add another rule for your SSH keys if you care about that. And it also cannot reach a host that wasn't approved. But the sandbox only covers the shell commands that Claude runs and whatever those start. But Claude's own files, your MCP servers, and all of your hooks still run outside of it.
因此,你会话的其余部分仍然在你自己的机器上运行,使用那台机器上的所有内容。理想情况下,你希望整个流程运行在一个一开始就不包含这些内容的地方,也就是云端会话。在云端,它会获得一台配有全新仓库副本的独立机器,而且即使我们合上笔记本电脑,任务也会继续运行。这对于那些需要运行数小时的长会话来说,绝对是你想要的。因此在这种情况下,.env 文件的问题会自动消失,因为它不在 Git 中。我的 SSH 密钥和 GitHub 令牌也不在其中。如果它仍然需要 API 密钥,你可以将其添加为网络密钥;如果会话进行到一半时缺少 API 密钥,它会提示你。这样它就能使用密钥,而不会真的把密钥发送给模型。另外,在 Claude 云端会话中,默认情况下网络访问仅限于软件包注册表和 GitHub 等服务。So the rest of your session still runs on your own machine and everything that's on there. So ideally you want this whole thing to run somewhere where none of that is even there in the first place and that is a cloud session because there it gets its own machine with a fresh copy of a repo and this runs even when we close our laptop which is definitely something you want for these longer running sessions that run for hours. So in this case, this automatically gets rid of the .env file issue because it's not in git. And neither are my SSH keys or GitHub token. And if it still needs an API key, you can add that as a network secret where it will it will tell you like, hey, I'm missing an API key midsession. So it can use it without actually ever sending it to the model. And by default, also in a Claude cloud session, network access is limited to things like package registries and GitHub.
因此,你必须将这些域名显式添加到环境中,Claude 才能访问其他主机。好。有了云端会话,即使笔记本电脑关着,我们也能运行这些长时间会话;而且由于会话运行在独立环境中,我们也更安全。现在,还是要记住,这台机器是一次性的,但离开它的东西不是。比如推送的提交,或通过连接器发送的消息。所以我们仍然在自动模式下运行,并使用拒绝规则。只需提交到仓库,这些规则就会随之保留。因此,它仍然可以拦截强制推送、提交中的密钥之类的情况。除了安全性之外,我们还需要确保 Claude 确实在做正确的事。接下来是验证。处于循环中有个好处:我们大概知道工作做得不错,因为我们其实已经看过每一处改动。So you have to explicitly add those domains to your environment for Claude to reach other hosts. Okay. So with a cloud session, we can run these long running sessions even with our laptop closed and it keeps us safe because it runs in its own environment. Now it's still good to remember that this machine is disposable, but the things that leave it aren't. So a commit pushed or a message sent through a connector. So we still run it in auto mode with our deny rules. Just commit into the repo. So they come along. So it could still catch things like a force push or a secret in a commit, all that kind of stuff. And beyond just safety, we also need to make sure that Claude is actually working on the right thing. So next is verification. And the nice thing about being in a loop, like we kind of know knew the work was good because we'd already kind of seen every change.
会话期间的验证Verification during a session
以前我们什么都要审批一遍。但现在 Claude 会在后台运行好几个小时,我们已经不会再这样做了。而且我们也不太可能在最后把每个文件都读一遍。所以,你知道,比如我们让它把认证迁移到一个新的 API 上。Claude 很擅长理解我们的需求,但在整个过程中,它还是得做很多小决定。所以,即使用完全相同的提示词,你知道,一次运行可能会完成迁移,但把旧 API 留在那里;另一次可能会迁移,但只用于新登录;还有一次可能会迁移,但把所有人都登出。这些结果看起来都挺合理,但在过程中设置这些验证节点确实很有帮助。这样 Claude 就能不断验证自己的结果。验证方式可以是任何能得出通过或失败的东西,比如测试、构建、截图,或者你手头有的其他东西。We'd approved everything. But now Claude works for hours in the background. We don't have that anymore. And we're not really going to read every file at the end either. So, you know, say that we ask it to move our auth to a new API. Well, Claude is very good at understanding what we want, but there are still a lot of small decisions that it has to make along the way. So, with the exact same prompt, you know, one run might move it over, but leave the old API in there, or one might move it, but only for new login, and another one might move it, but log everyone out. And these all look pretty reasonable, but it really helps to set up these verification points along the way. So Claude keeps verifying its own results. And those can be anything that comes back as a pass or fail. So tests, a build, a screenshot, whatever you have.
所以现在我们只需要确保检查这些验证点。与其等到最后才审核整个改动,这些验证点要短得多,也更容易检查。这挺合理的。如果其中某次运行仍然会把所有人都登出,它就过不了第一项检查,然后就得另想办法。设置这种流程有几种方法。最简单的当然是在提示词里说明。比如,你描述完成的标准,然后让它把工作拆分成多个任务,这样每个任务都有自己的测试。我也喜欢让它展示实际输出,因为你并没有亲眼看到它的执行过程。不过,提示词并不能保证模型一定会照做。因此,对于必须确保运行的检查,我会使用钩子。钩子就是 Claude Code 在特定时机运行的脚本,它们能让你获得很大的控制权,因为你可以决定它们何时运行、运行什么,以及检查什么。So now we just want to make sure that we review these verification points. They're a lot shorter to review than if we just had to, you know, review the whole change at the end. So that's pretty reasonable. So, if one of these runs would still log everyone out, it doesn't get past that first check and then it just has to find another way. And there's a couple ways to set this up. The easiest one is, of course, just in your prompt. So, you know, you say what done looks like and ask it to split that into tasks so they have their own tests. And I also like to ask it to show the actual output because you weren't there to see it. But again, prompting is not a guarantee that a model will do it. So for the ones that have to run guaranteed run, I would use hooks which are just you know scripts that Claude Code runs at a specific point and those give you a lot of control because you decide when they run and what they run and what they check.
例如,每次它编辑文件时,我们都可以运行 linter;每次它想把某项任务标记为完成时,我们都可以针对它所做的更改运行测试。比如说,如果它改动了我们的身份验证代码,就必须通过身份验证测试;等它想结束整个会话时,我们可以直接运行完整的测试套件。如果其中任何一项失败,它就会意识到还有问题没解决,然后回去继续修改,直到测试通过。所以有一点要注意:测试失败时,大多数工具默认会以退出码 1 退出,但 Claude Code 会把以退出码 1 结束的任务直接标记为已完成。因此,请确保你的脚本以退出码 2 退出,因为只有这样才会让 Claude 回去修复问题。好了,现在我们有一个可以放心放着不管的会话了。接下来,我们可以再启动几个这样的会话,因为它们各自都有自己的机器。So for example every time it edits a file we can run our linter every time it wants to mark a task as complete we can run the tests for what it changed. So you know if it touched our auth code or something it has to pass the auth tests and when it wants to finish the whole session we can just run the entire test suite and if one of those fails it goes oh that's still broken it goes back until it passes so it fixes it. Now just one thing when a test fails by default most tools they exit with exit code 1 but with exit code 1 that task by Claude Code just gets marked as completed anyway. So, make sure that your scripts exit with a exit code 2 because that's what actually sends Claude back to fix it. So, okay, now we have one session that I'm pretty comfortable with leaving alone. So, now we can start with a few more of those because they've all got their own machine.
CI 与编排CI and orchestration
所以,它们并不是都在同一个文件夹里工作,我们自己也不太需要再操心工作树了。不过,我们仍然会亲自启动每个会话,并逐一审查。说实话,这已经是个相当不错的状态了。对于启动什么任务,以及何时认定任务完成,我们仍然完全掌握主动权。但即便如此,你知道,还是由我们来启动每个会话,而且所有会话我们都得参与其中。所以我觉得,现在最重要的是把 CI 配置好,因为这些会话最终都会创建 PR,而 CI 会对每个 PR 运行相同的检查,不管会话是如何设置的,也不管 Claude 在过程中决定做什么。如果开启自动修复,我们还有 CI 自动修复功能。So, they're, you know, not all working in the same folder and we don't really have to think about work trees too much ourselves anymore. But then we still start every session ourselves and we review every one of them. And honestly, this is already a pretty good place to be. We are still fully in control over what gets started and when we call a task done. But even there, you know, we're still the ones kicking off every session and we're still in the loop for all of them. So, I think the most important thing to have in place here now is your CI because all of these sessions eventually open a PR and your CI runs the same checks on every one of them, no matter how that session was set up or, you know, what Claude decided to do along the way. And if you turn on autofix, we have like CI Autofix.
Claude 也能看到其中某项检查失败,然后回去修复。因此,你就不必把审查时间花在那些检查本来就能发现的问题上。对于其中一些 PR,你甚至可以开启“准备就绪后合并”。这样一来,所有检查通过后,GitHub 就会自动合并 PR,你也就不用一直陷入审查循环。不过,再强调一次,这不是默认设置,具体取决于改动的风险程度。比如在我们团队,每个 PR 都会先由 Claude 审查,而不是由编写它的那个会话来审查。这样它就能以全新的上下文进行检查,并由另一组代理逐一复核它发现的每个 bug。至于我们自己要审查多少,则取决于风险。像文档文案这样的小改动,就不需要人工审查。只要自动化检查都通过了,我们基本就可以放心合并。Claude can also see when one of those checks fails and then go back to fix it. So you're not the one spending your review on things that you know a check could have already caught. And for some of them, you can even turn on merge when ready. So then GitHub merges a PR once all of the checks have passed. So you're not in a loop to review. But again, that's not the default and that really depends on how risky the change is. So for example on our team every PR gets reviewed by Claude first. So not by the session that wrote it. So it comes with a fresh context and also a separate group of agents to just double check every bug it finds. And then how much we review ourselves just depends on the risk. So smaller changes like documentation copy, they don't need a person. So once the automated checks are green, we're pretty good to go.
也许普通的产品改动只需要一位审核者,而风险较高的改动可能需要两位。最终,我们认为事情会朝这个方向发展;而且在 Anthropic,我们已经在更多地这么做了:你不必再亲自启动所有这些会话,因为如果你跟我一样,就会发现自己很不擅长在不同任务间切换。因此,同时管理这么多会话往往不太顺利。你只需要一个主会话来充当编排器。你现在已经能在 Claude Code Projects 这类功能中看到这种做法了;它目前仍处于测试阶段。你只要告诉它需要完成什么,编排器就会把任务拆分开来,为每项任务启动其他会话,并跟踪返回的结果。这样,它就会自动启动并验证这些线程,也就是新的会话。Maybe ordinary product changes just need one reviewer and then risky changes might need two. Now ultimately kind of where we see things going and we're already kind of doing more of that at Anthropic is that you're not really starting all of those sessions yourself either because if you're anything like me, I'm terrible at context switching. So having to manage so many sessions at the at the same time doesn't always go well. So instead you just have one main session that's your orchestrator. And you can already see this in things like Claude Code projects which is still in beta but you just tell it what it needs to be done and the orchestrator splits that up and then starts other sessions for each task and it keeps track of what comes back. So it automatically starts and verifies these threads which are just new sessions.
所以,你不再是和八个会话交谈,而是只和一个会话交谈。主会话本身并不编写代码。因此,你需要一个特别擅长决定该做什么、评估返回结果的模型,比如 Fable。如果返回的结果实际上还没完成,它就会把任务发回去,直到任务真正完成并通过所有检查。线程则需要一个擅长实际执行工作的模型,比如 Opus 5.5。你可以分别设置它们:一个模型用于主会话,另一个用于线程。另一个好处是,特别是在这种代码项目的设置中,我们不再需要管理上下文了,这一切都会自动处理。因此,我们不必再操心什么时候该压缩上下文,或者清理这些内容。So instead of talking to eight sessions, you're just talking to one. And the main session doesn't write the code itself. So there you want a model that's really good at deciding what to do and judging what comes back. A model like Fable and if something comes back that isn't actually done, it just, you know, sends it back. So until it's actually done and passes everything and the threads need a model that's good at actually doing the work like Opus 5.5. And you can set those separately. So you know, one model for the main session and then another one for the threads. And another benefit is that with this setup with code projects specifically, we don't manage context anymore. That's all done automatically for us. So, we no longer have to think about, you know, when to compact or clear all of that stuff.
好。所以,如果你回顾一下那些旧的最佳实践,会发现它们都还在,只不过转移到了别的地方。现在由模型来引导整个流程。自动模式会审批你的拒绝规则,而环境会限制可行的操作。你的测试、钩子和 CI 会对它进行检查。最后,Claude 也可以直接启动它们。所以,我们以前亲自做的事情,几乎现在都交给了模型、harness 或环境。我们基本上只需要启动第一个任务,然后检查产出的结果。如果你想在自己的环境中试试,我建议你挑一件规模远超平时交给 Claude 的任务。确保你的 CI 确实能捕获你在意的问题,然后花点时间配置一下环境,比如网络访问、密钥,以及……设置脚本。Okay. So, if you look back at those old best practices, they're all still there, but they've just moved. So, the model steers it now. Auto mode approves your deny rules and the environment restrict what's possible. Your test, your hooks, and your CI checks it. And then ultimately, Claude can just start them as well. So almost everything we used to do ourselves is now either the model, the harness or the environment. And we're really just here to start that first one and to just review what comes out. So if you want to try this in your own setup, I would say just take one thing that's way bigger than you normally give Claude. Make sure your CI actually catches the things you care about and then spend a bit of time just configuring your environment like its network access, its secret, and its, you know, setup scripts.
然后先从云端开始,看看你的会话卡在哪些地方,以及哪些环节仍然需要你参与,因为这些就是接下来要交给 Claude 处理的事情。我也强烈建议你看看文档中的最佳实践。非常感谢。Then start in the cloud and see where your sessions get stuck and where you're still in the loop because that's the next thing to hand over to Claude. I also highly recommend checking out our best practices in the docs as well. Thank you so much.