如何为 AI 驱动的代码现代化项目做好准备
How to organize AI-driven modernization projects for critical systems and regulated enterprises. 如何为关键系统和受监管企业组织 AI 驱动的现代化项目。
How to organize AI-driven modernization projects for critical systems and regulated enterprises. 如何为关键系统和受监管企业组织 AI 驱动的现代化项目。
In our Notes from the Field series, Anthropic forward deployed engineers share best practices inspired by real customer deployments. In this article, we share our experience managing large code modernization projects.在我们的“实地笔记”(Notes from the Field)系列文章中,Anthropic 的前线部署工程师们分享了从真实客户部署中总结的最佳实践。本文将分享我们在管理大型代码现代化项目方面的经验。
Code modernizations once scoped as multi-year, all-hands efforts can now finish in months (or weeks), but the organizational work on either side often remains the same. 过去需要多年、全员参与的代码现代化项目,现在可以在几个月(甚至几周)内完成,但项目前后的组织工作往往保持不变。
For example, every change to a critical banking system must go through change management, review, and approval. It is a robust process because regulators, auditors, and the business require it. 例如,对关键银行系统的每一次变更都必须经过变更管理、审查和批准。这是一个稳健的流程,因为监管机构、审计人员和业务部门都有此要求。
Those processes are what make critical systems trustworthy, and they were built on the assumption that a human wrote each change and a human would review each diff. Once agents accelerate writing the changes, the bottleneck shifts from producing changes to mobilizing the organization around them.正是这些流程使关键系统值得信赖,而它们建立的前提是:每一项变更都由人工编写,每一处差异(diff)都由人工审查。一旦 AI 智能体加速了变更的编写,瓶颈就会从生产变更转移到围绕变更进行组织动员上。
This article covers the work enterprises must do before the modernization takes place: defining what done means, what evidence a change must carry, how certified changes will reach production, and what has to be staged so the run can start. 本文涵盖了企业在现代化实施前必须完成的工作:定义“完成”的标准、变更必须携带的证据、经过认证的变更如何进入生产环境,以及为了启动运行必须准备就绪的事项。
We break this process into six steps:我们将此过程分为六个步骤:
The target is the end state of the modernization. The desired end state determines which of the three kinds of modernization you are doing, detailed in the table below. 目标是现代化的最终状态。预期的最终状态决定了您正在进行哪种类型的现代化,详见下表。
Determining which type of modernization to do is often debated inside an organization. In our experience, the people closest to production want the stack swapped with behavior held constant to contain risk (transform modernization). On the other side are often the engineers who have lived with the codebase and want the modernization to pay down tech debt, plus other business stakeholders who want to take the opportunity to name new requirements (reimagine modernization). 在组织内部,确定采用哪种现代化类型通常会引发争论。根据我们的经验,最接近生产环境的人员希望在保持行为不变的情况下替换技术栈,以控制风险(转换式现代化)。另一方通常是长期维护代码库的工程师,他们希望通过现代化来偿还技术债务,此外还有其他业务利益相关者,他们希望借此机会提出新的需求(重构式现代化)。
Both positions are reasonable, but if the question is left unresolved it resurfaces later as an argument over whether a given change is “correct.” Building consensus on which path to take adds initial friction, but streamlines the project as a whole.这两种立场都有其合理性,但如果问题悬而未决,稍后就会演变成关于特定变更是否“正确”的争论。就采取哪种路径达成共识会增加初始阻力,但能使整个项目更加顺畅。
Understanding the current system is often a good first step for defining the target. Extracting what the old code actually does and creating an inventory of current behavior makes it easy to decide if parts should be changed or dropped, and so whether the modernization is a transform or a reimagine. This also often reveals unknown business logic and edge cases. 了解当前系统通常是定义目标的第一步。提取旧代码的实际功能并盘点当前行为,可以轻松决定是否应更改或删除某些部分,从而确定现代化是属于转换式还是重构式。这通常还能揭示未知的业务逻辑和边缘情况。
Claude can do much of that discovery by mapping dependencies and documenting workflows that nobody remembers building. The code modernization plugin’s assess, map, and extract-rules commands mine business rules with source citations that engineers can then review. Claude 可以通过映射依赖关系和记录无人记得如何构建的工作流来完成大部分此类发现工作。代码现代化插件的 assess(评估)、map(映射)和 extract-rules(提取规则)命令可以挖掘带有源引用的业务规则,供工程师审查。
However, Claude’s discovery alone may not capture how a legacy system fully behaves. Interviews with business users and developers, and internal documentation, can fill those gaps. Context gathering may take some time upfront, but the quality of that context shapes every decision the workflow makes later.然而,仅靠 Claude 的发现可能无法完全捕获遗留系统的行为。与业务用户和开发人员的访谈以及内部文档可以填补这些空白。收集背景信息可能需要一些前期时间,但这些背景信息的质量决定了工作流后续所做的每一个决定。
For a reimagine, defining the target requires additional work: a detailed behavioral spec should be written down and agreed with user groups.对于重构式现代化,定义目标需要额外的工作:应编写详细的行为规范并与用户组达成一致。

Alongside defining the target, the organization should consider why the modernization is worth undertaking at all. Modernizing legacy systems can reduce ongoing maintenance and operational costs, however, in our experience, cost reduction has not been the driving goal of most modernization projects.在定义目标的同时,组织应考虑为什么这项现代化工作值得进行。现代化遗留系统可以减少持续的维护和运营成本,但根据我们的经验,成本削减并不是大多数现代化项目的主要驱动目标。
Risk reduction is often the most important modernization benefit. Consider the risk of not doing the modernization when debating whether or not to undergo the project. 降低风险往往是现代化最重要的益处。在讨论是否进行项目时,请考虑不进行现代化的风险。
For example, a system carrying unpatched vulnerabilities can mean a cyber breach or an outage severe enough to put the business itself at risk. An unsupported runtime or a shrinking pool of engineers who understand the system exacerbates the risk. 例如,携带未修补漏洞的系统可能意味着网络入侵或足以危及企业自身的严重中断。不受支持的运行时或了解该系统的工程师群体不断缩减,加剧了这种风险。
Agentic coding tools like Claude Code have shortened modernization timelines, but budgets are still hard to estimate, which leads to inertia. We have released the costs of some of our large-scale modernizations as have others. These can serve as a rough baseline, and we have additional guidance on budget projections at the bottom of this guide. 像 Claude Code 这样的智能体编码工具缩短了现代化时间表,但预算仍然难以估算,这导致了惰性。我们已经发布了一些大型现代化项目的成本,其他人也一样。这些可以作为粗略的基准,我们在本指南底部提供了有关预算预测的额外指导。
The main challenge in initiating these projects is usually building the internal consensus and commitment from the teams that own the system, and the teams that depend on it. Building the business case and setting the goals of the project, often at the leadership level, make this part of the process easier. This also helps anchor the tradeoffs in the certificate and promotion policy that follow. When stakeholders disagree over how much risk a change can carry, the risk of not modernizing is the counterweight. 启动这些项目的主要挑战通常是建立内部共识,并获得系统所属团队以及依赖该系统的团队的承诺。建立商业案例并设定项目目标(通常在领导层层面)可以简化此过程。这也有助于巩固后续证书和推广策略中的权衡。当利益相关者对变更所能承受的风险存在分歧时,不进行现代化的风险就是平衡点。
The certificate is the set of conditions or tests that every modernization change must meet. Pick the conditions that give the strongest cumulative evidence that the change is correct against the target. 证书是每一项现代化变更都必须满足的条件或测试集。选择那些能提供最强有力累积证据的条件,以证明变更相对于目标是正确的。
Each condition should be checkable without a human in the loop, so the agentic workflow can iterate on a change until it meets the certificate or flag it for human review if it can’t. 每个条件都应在无需人工干预的情况下可检查,以便智能体工作流可以对变更进行迭代,直到满足证书要求,或者在无法满足时将其标记为人工审查。
What goes into the certificate depends on the target, but will usually draw from this list:证书中包含的内容取决于目标,但通常会从以下列表中选取:
Write the certificate with the people who will review and promote changes into production. Bring in the developers, user groups, and business leads who depend on the codebase now, while the certificate and agentic workflow are still being designed. 与将审查并推广变更到生产环境的人员一起编写证书。在设计证书和智能体工作流时,尽早引入目前依赖该代码库的开发人员、用户组和业务主管。
Their expertise shapes what the certificate measures, and their early involvement is what earns their buy-in when changes reach review. A good check on the finished certificate is whether they would be comfortable merging on the certificate's evidence alone. If they see their own bar in it, the promotion policy in Step 3 can be lighter. 他们的专业知识决定了证书的衡量标准,他们的早期参与是变更到达审查阶段时获得支持的关键。对已完成证书的一个很好的检验标准是:他们是否愿意仅凭证书的证据进行合并。如果他们看到了自己设定的标准,第 3 步中的推广策略可以更轻松。
What the certificate checks against, and how, depends on the modernization type. 证书对照检查的内容和方式取决于现代化类型。
Older systems often have thin test coverage, flaky tests, and little telemetry. Part of defining the certificate is identifying these gaps. If it will be difficult to support a strong certificate, one of the most useful things to do at this step is to use Claude to build the missing evidence, whether that’s standing up a prod-parallel setup, building a replay harness, or writing more tests. 旧系统通常测试覆盖率低、测试不稳定且遥测数据很少。定义证书的一部分就是识别这些差距。如果难以支持强有力的证书,此步骤中最有用的做法之一是使用 Claude 来构建缺失的证据,无论是建立生产并行设置、构建重放工具还是编写更多测试。
Agents will produce changes far faster than any human team can review them diff-by-diff. The promotion policy is a tiered review path–written down and agreed in advance–that sets the depth of human review for a change, so the modernization can finish on an acceptable timeline. 智能体产出变更的速度将远超任何人工团队逐个差异(diff-by-diff)审查的速度。推广策略是一种分层审查路径——事先书面记录并达成一致——它设定了人工审查变更的深度,以便现代化能在可接受的时间表内完成。
Like the certificate, work this step with the reviewers, and fit it into your organization's existing change-management process wherever you can. The details will differ by organization and the risk tradeoffs it faces, but a few rules hold everywhere:像证书一样,与审查人员共同制定此步骤,并尽可能将其纳入组织现有的变更管理流程中。细节会因组织及其面临的风险权衡而异,但有几条规则在任何地方都适用:
Many of these rules front-load SME hours by engaging them early in the project. Their feedback tunes the certificate and the agentic workflow before the full modernization begins.这些规则中有许多通过让 SME 尽早参与项目,将他们的工时前置。他们的反馈会在全面现代化开始前调整证书和智能体工作流。
Their sign-off on the samples also becomes further justification for a lighter review path where there is high confidence. This is the reverse of the traditional, non-agentic pattern, where review happens at the end.他们对样本的签字确认也成为在置信度高的情况下采用更轻量审查路径的进一步理由。这与传统的非智能体模式相反,传统模式中审查发生在最后。

The promotion policy should also reflect where the modernization sits on the spectrum between speed and review depth. A modernization racing to a hard deadline, such as a runtime losing support, needs a faster policy with lighter human review and an explicit agreement to accept more risk per change. 推广策略还应反映现代化在速度与审查深度之间的位置。争分夺秒完成的现代化(例如运行时失去支持)需要更快的策略、更轻量的人工审查,并明确同意接受每个变更更多的风险。
A modernization on a longer timeline can afford deeper human review and a slower cutover. Stakeholders will land on different points of this spectrum depending on their risk appetite and constraints so it is worth locking in before the work starts.时间表较长的现代化可以负担更深入的人工审查和更缓慢的切换。利益相关者会根据其风险偏好和约束条件落在该谱系的不同点上,因此在工作开始前锁定这一点是值得的。
In a regulated environment, taking a lighter human review path for any change can cause real discomfort. Individual approvers hesitate to sign off because they carry the risk of a bad change, while leadership carries the larger risk of an aging system. 在受监管的环境中,对任何变更采取更轻量的人工审查路径都可能引起真正的不适。个人审批者犹豫是否签字,因为他们承担着错误变更的风险,而领导层则承担着老化系统的更大风险。
In our experience, it is best to have the directive for the promotion policy come from the top of the organization. It is also better to agree on it beforehand so responsibility for a bug that reaches production is shared, not pinned on whoever approved the change.根据我们的经验,最好让推广策略的指令来自组织高层。最好事先达成一致,以便对进入生产环境的错误承担责任时是共享的,而不是归咎于批准变更的人。
All of this still depends on a certificate detailed enough to serve as real evidence, and on reviewers who understand how Claude arrived at a change well enough to trust it. 这一切仍然取决于足够详细以作为真实证据的证书,以及足够了解 Claude 如何得出变更并足以信任它的审查人员。
Much of this step runs through teams outside the modernization: platform or infrastructure for the host, QA or release engineering for test capacity, security and compliance for approvals. Each of those teams often has its own backlog or approval process, so open the conversations early, as soon as you have identified the requirements, often while Steps 1 through 3 are still underway.此步骤的大部分工作由现代化团队之外的团队完成:平台或基础设施团队负责主机,QA 或发布工程团队负责测试能力,安全和合规团队负责审批。这些团队通常都有自己的积压工作或审批流程,因此一旦确定了需求,请尽早开启对话,通常在第 1 至第 3 步进行时就开始。
Use Claude Code to develop a customized dynamic workflow for modernizing the codebase. 使用 Claude Code 开发一个用于现代化代码库的定制化动态工作流。
We recommend starting with the code modernization plugin, and putting everything the workflow may need on the file system or over MCP, where Claude can reach it. This includes the target, certificate, promotion policy, codebase, documentation, and whatever data sources or tooling the certificate requires. You can give this article to Claude as context too. This forms the central knowledge base for the project.我们建议从代码现代化插件开始,并将工作流可能需要的一切放在文件系统上或通过 MCP 提供,以便 Claude 可以访问。这包括目标、证书、推广策略、代码库、文档以及证书所需的任何数据源或工具。您也可以将本文作为上下文提供给 Claude。这构成了项目的核心知识库。
With that in place, building the modernization workflow is the easy part. Have SMEs review Claude’s work as needed, including any codebase-specific skills or extracted rules before anything downstream relies on it. 准备好这些后,构建现代化工作流就是简单部分了。让 SME 根据需要审查 Claude 的工作,包括任何特定于代码库的技能或提取的规则,然后再让下游任何环节依赖它。
Refine what you've built by applying it to small parts of the codebase, with SMEs reviewing the changes it produces, the agents’ process, and the evidence the certificate was met. 通过将其应用于代码库的一小部分来优化您构建的内容,并由 SME 审查其产出的变更、智能体的流程以及证书满足的证据。
You should modify the workflow, not each change, when issues surface. The goal is confidence that, once scaled, changes will meet the certificate almost everywhere and reviewers will be comfortable merging under the promotion policy. 当问题出现时,您应该修改工作流,而不是修改每一个变更。目标是确保一旦扩展,变更几乎在所有地方都能满足证书要求,并且审查人员能够放心地在推广策略下进行合并。
First, complete the modernization end to end on a small part of the codebase, including reviewing and landing the changes through the promotion policy. Fix anything that doesn’t work while it’s still cheap, repeat the process until you are confident, then scale to the full codebase. 首先,在代码库的一小部分上端到端地完成现代化,包括通过推广策略审查和落地变更。在成本尚低时修复任何无效的部分,重复此过程直到您充满信心,然后扩展到整个代码库。
While transform and reimagine modernizations involve building the target alongside the existing system and cutting over once complete, an uplift has a second option: modernizing in place on the live codebase while development continues. 虽然转换式和重构式现代化涉及在现有系统旁边构建目标并在完成后进行切换,但升级式现代化有第二个选择:在实时代码库上原地现代化,同时开发工作继续进行。
This is the usual choice when the system cannot be down, or when the codebase changes so quickly that it’s difficult to keep a separate modernized copy up to date. What we have seen work in this case is splitting the codebase into logical partitions from the leaves inward; freezing and modernizing one partition at a time; and gating CI/CD so new commits cannot undo a partition once it has been modernized. 当系统不能停机,或者代码库变化太快以至于难以保持一个单独的现代化副本更新时,这通常是首选。在这种情况下,我们看到有效的方法是:从叶子节点向内将代码库划分为逻辑分区;一次冻结并现代化一个分区;并设置 CI/CD 门禁,以便新提交无法撤销已现代化分区的成果。

We often get asked what a modernization like this will cost in tokens. Each modernization effort is different, but the main cost drivers include:我们经常被问到这样的现代化需要花费多少 Token。每个现代化工作都不同,但主要的成本驱动因素包括:
When completing the modernization on a small part of the codebase, measure token-usage and use that to extrapolate for the rest of the run. Treat anything the pilot couldn’t see, such as reconciliation on a live codebase, as an unknown. This way you can get an estimate for the cost floor for the full modernization. 在代码库的一小部分上完成现代化时,测量 Token 使用量并以此推断其余部分的运行情况。将试点阶段无法看到的内容(例如实时代码库上的协调)视为未知数。通过这种方式,您可以获得整个现代化成本底线的估算。
Measurements from the pilot also show where to optimize your agentic workflow for cost. Find the parts of the workflow that consumed the most tokens and consider how to make them more efficient. Move compute-heavy verification signals behind cheaper gates so they only run once easier checks have passed. 试点阶段的测量结果还显示了在何处优化智能体工作流以降低成本。找出工作流中消耗 Token 最多的部分,并考虑如何使其更高效。将计算密集型验证信号放在更便宜的门禁之后,以便它们仅在较简单的检查通过后才运行。
Consider using models like Sonnet that balance cost and capability for the mechanical, high-volume work the certificate fully checks. Keep more intelligent models for hard transformations and the adversarial reviews that verify correctness. 考虑使用像 Sonnet 这样在成本和能力之间取得平衡的模型来处理证书完全检查的机械化、大批量工作。将更智能的模型保留用于困难的转换和验证正确性的对抗性审查。
You can also escalate to a more expensive model when a less expensive one fails to meet the certificate, but analyze retry rates carefully while piloting, since several cheap attempts can cost more than one expensive one. If you give Claude access to both the workflow and the pilot data, it can do much of this analysis with you. 当成本较低的模型无法满足证书要求时,您也可以升级到更昂贵的模型,但在试点时请仔细分析重试率,因为几次廉价的尝试可能比一次昂贵的尝试成本更高。如果您让 Claude 同时访问工作流和试点数据,它可以与您一起完成大部分此类分析。
The modernized codebase is one output. The others are the workflow that produced it, a written certificate for what counts as correct, a promotion policy your change-management process has already accepted, and an evidence trail for every change that landed. Codify the playbook as a reusable asset, so the pattern is already in place for the next upgrade or rewrite.现代化的代码库只是一个输出。其他输出包括:产生它的工作流、关于什么算作正确的书面证书、您的变更管理流程已经接受的推广策略,以及每一项已落地变更的证据追踪。将此手册编纂为可重用的资产,以便为下一次升级或重写准备好模式。
Our forward deployed engineers work through these steps with customers on their most critical systems. If you're preparing a modernization, talk to our team.我们的前线部署工程师会与客户一起完成这些步骤,处理他们最关键的系统。如果您正在准备现代化,请联系我们的团队。
Get the developer newsletter订阅开发者通讯
Product updates, how-tos, community spotlights, and more. Delivered monthly to your inbox.产品更新、操作指南、社区焦点等。每月发送到您的收件箱。