如何为 AI 驱动的代码现代化项目做好准备 | Claude by Anthropic
原题How to prepare for AI-driven code modernization projects | Claude by Anthropic
推荐理由Anthropic 前置部署工程师把真实客户项目的开工前准备拆成六步,核心判断很硬:Agent 加速写变更之后,瓶颈转移到围绕变更动员组织。最值得抄的是两件事,一是「证书」,即每个变更必须满足、且无需人在回路即可自动检查的条件集合,从原测试套件、对抗式评审到新旧版本同输入同输出;二是「晋升策略」,按影响半径与 Agent 置信度分层评审,关键路径仍保留完整人审。 适合谁:要在受监管或高风险系统上跑 Agent 迁移的工程负责人
读前速览
Anthropic 前置部署工程师根据真实客户项目,给出 AI 驱动代码现代化的开工前六步:定义目标、定义「证书」、设定晋升策略、铺好前置条件、构建 agentic workflow、小范围跑通再扩量,核心判断是瓶颈已从产出变更转移到围绕变更动员组织。
Agent 加速写变更之后,瓶颈转移到围绕变更动员组织
现代化项目的时间线被压缩到几个月甚至几周,但变更管理、评审与审批流程没有变,它们是按「人写每一次变更、人审每一个 diff」的假设建立的。真正的准备工作是回答:什么算完成、变更要带什么证据、认证过的变更如何进生产、开跑前要铺好什么。
先判断现代化类型,再决定目标与验收方式
分为 uplift、transform、reimagine 三类,类型直接决定证书怎么写:uplift 与 transform 的对标是原代码库,前者可以把原测试套件当核心,后者多靠生产流量回放、新旧差分测试与生产并行部署;reimagine 锚定在行为规格上,最难,模型判断占比更高,结果更不稳定。
「证书」是每个变更必须满足、且无需人在回路即可自动检查的条件集合
常见条件包括原测试套件通过、Claude 新写测试通过、覆盖率达标、性能在约定区间、多次独立对抗式评审无阻断问题、新旧版本同输入同输出、持久化状态与线上格式可往返、staging 期间错误率与延迟无回退、静态分析与安全扫描无新增发现。证书要和最终评审并放行的人一起写,检验标准是他们是否愿意仅凭证书证据就合并。
「晋升策略」用分层评审换取可接受的交付时间线
Agent 产出变更的速度会远超任何人类团队逐个 diff 评审的速度,因此需要预先写下并达成一致的分层路径:按影响半径与 Agent 置信度分层,关键路径保留完整人工评审;反复出现的告警要回到工作流或证书里修根因;输出格式与评审者共同设计;把稀缺的领域专家时间集中到最高风险层与被标记的变更上。
风险削减通常比降本更值得作为立项理由
作者称在他们的经验里,降本并不是多数现代化项目的驱动目标;未修补漏洞可能意味着足以危及业务的入侵或宕机,不再受支持的运行时与懂这套系统的工程师减少会进一步放大风险。真正的难点是在拥有系统与依赖系统的团队之间建立共识与承诺,而「不做的风险」正是分歧时的配重。
其余 1 个要点
最后两步是搭工作流与小范围验证
围绕目标、证书与晋升策略构建定制的 Claude Code 动态工作流,把现代化拆给大量并行子 Agent 产出变更;然后先在代码库的一个小分区上把工作流端到端跑通,再扩大规模。
完整摘要
这是 Anthropic「Notes from the Field」系列文章,由前置部署工程师根据真实客户部署总结大型代码现代化项目的准备工作。作者指出,过去按数年、全员投入规划的现代化项目如今可能几个月甚至几周完成,但项目两端的组织工作并没有变:关键银行系统的每一次变更仍要走变更管理、评审与审批,而这些流程正是让关键系统可信的原因,它们建立在「人写每一次变更、人审每一个 diff」的假设之上。当 Agent 加速了变更的产出,瓶颈就从产出变更转移到围绕变更动员组织。文章把开工前的准备拆成六步。第一步定义目标,先判断属于 uplift、transform 还是 reimagine 三类现代化中的哪一类,绘制代码库依赖图并写下行为规格;作者强调风险削减通常比降本更重要,讨论要不要做时应先考虑不做的风险,例如未修补漏洞、不再受支持的运行时以及懂这套系统的工程师越来越少。第二步定义「证书」,即每个变更必须满足的一组条件,每条都要能在无人参与的情况下自动检查,来源包括原测试套件通过、Claude 新写测试通过、覆盖率达标、性能在约定区间、多次独立对抗式评审无阻断问题、新旧版本同输入同输出、持久化状态与线上格式可往返、staging 期间错误率与延迟无回退、静态分析与安全扫描无新增发现等;证书要和最终评审并放行变更的人一起写,检验标准是他们是否愿意只凭证书的证据就合并。第三步设定晋升策略,即预先写下并达成一致的分层评审路径,按影响半径与 Agent 置信度分层,关键路径保留完整人工评审,反复出现的告警应回到工作流或证书里修根因而不是逐个评审,并把稀缺的领域专家时间集中到高风险层。第四步铺好前置条件:环境、代码库与 CI/CD、团队与评审带宽、安全与合规。第五步围绕目标、证书与晋升策略构建定制的 Claude Code 动态工作流,把现代化拆给大量并行子 Agent。第六步先在代码库的一个小分区端到端跑通,再扩量。
目录 · 16 节
在我们的《一线笔记》系列中,Anthropic 的前线部署工程师会分享从真实客户部署中获得启发的最佳实践。在本文中,我们将分享管理大型代码现代化项目的经验。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.
曾经被规划为多年、全员参与的代码现代化工作,如今几个月(甚至几周)就能完成,但前后两端的组织工作往往依然不变。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.
本文涵盖企业在现代化改造开始前必须完成的工作:定义“完成”的含义、变更必须附带哪些证据、经过认证的变更将如何进入生产环境,以及必须预先安排哪些事项才能启动运行。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:
- 定义目标:明确现代化代码必须采用的技术栈和具备的行为。Define the target: the tech stack and behavior the modernized code must have.
- 创建证书:这些变更必须满足的条件,才能被视为符合目标状态。Create the certificate: the conditions that the changes must meet to be considered correct in the target state.
- 设置晋级策略:规定经过认证的变更以其生成速率进入生产环境的路径。Set the promotion policy: the path by which certified changes get into production at the rate they’re produced.
- 落实前置条件:环境、CI/CD、评审能力和审批。Put the prerequisites in place: environment, CI/CD, review capacity, and approvals.
- 构建并完善智能体工作流:定制的 Claude Code 动态工作流,将现代化工作分配到多个更小的并行子智能体工作流中,由它们产出变更内容。该工作流围绕目标、证书和晋级策略构建。Build and refine the agentic workflow: the custom Claude Code dynamic workflow that distributes the modernization across many smaller parallel subagent workstreams that produce the changes. This is built around the target, certificate, and promotion policy.
- 执行现代化改造:先在代码库的一小部分上端到端验证整个工作流,然后再扩大范围。Run the modernization: prove the workflow end to end on a small partition of the codebase, then scale.
步骤 1:定义目标Step 1: Define the target
目标是现代化改造的最终状态。期望的最终状态决定了你所进行的三种现代化改造中的哪一种,具体内容详见下表。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.
确定现代化类型Determine the modernization type
| Type | What it is | Choose when | The target is |
|---|---|---|---|
| Uplift | Same-stack version bump (e.g., C++11 → C++20). | The stack is fine but the version has fallen behind: end-of-life runtimes, unpatched security issues, dependencies you can no longer upgrade. | A runtime version and package set. |
| Transform | Cross-stack rewrite that keeps behavior fixed (e.g., COBOL → Java). | The stack is the problem to resolve and the behavior is trusted. | Everything needed for an uplift, plus the language, frameworks, and architectural conventions the new code must follow. |
| Reimagine | Greenfield rebuild on a new architecture with modified behavior. | The behavior needs to be changed alongside the code. | Everything needed for a transform, plus a written behavioral spec for the new system. |
确定要进行哪种类型的现代化改造,往往会在组织内部引发争论。根据我们的经验,最接近生产环境的人员希望在保持行为不变的情况下替换技术栈,以控制风险(变革式现代化)。而另一方通常是那些长期维护该代码库的工程师,他们希望借现代化改造之机偿还技术债务;此外,还有其他业务利益相关者希望借此机会提出新的需求(重构式现代化)。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.
梳理代码库并创建行为规范Map the codebase and create the behavioral spec
了解当前系统通常是定义目标的良好第一步。提取旧代码实际执行的内容,并整理当前行为清单,可以轻松判断哪些部分应当更改或舍弃,从而确定现代化改造究竟是转换还是重新构想。这一过程还常常会揭示未知的业务逻辑和边界情况。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 可以通过映射依赖关系并记录那些无人记得曾经构建过的工作流程,完成其中许多探索工作。代码现代化插件的 assess、map 和 extract-rules 命令会挖掘业务规则,并提供来源引用,供工程师随后审查。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 的探索可能无法完整捕捉遗留系统的行为。与业务用户和开发人员进行访谈,以及查阅内部文档,可以填补这些空白。前期收集上下文可能需要一些时间,但上下文的质量会影响工作流之后所做的每一个决策。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.
对于重新构想的项目,定义目标需要额外的工作:应当写下详细的行为规范,并与用户群体达成一致。For a reimagine, defining the target requires additional work: a detailed behavioral spec should be written down and agreed with user groups.
阐明项目的合理性和目标Establish the project’s justification and goals
除了定义目标之外,组织还应考虑现代化究竟为何值得开展。现代化改造遗留系统可以降低持续维护成本和运营成本;然而,根据我们的经验,降低成本并不是大多数现代化项目的主要驱动力。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.
像 Claude Code 这样的智能体编码工具缩短了现代化改造的周期,但预算仍然难以估算,从而导致项目迟迟无法推进。我们已经公布了部分大规模现代化改造的成本,其他公司也采取了类似做法。这些数据可以作为粗略的基准,本指南末尾还提供了有关预算预测的更多指导。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.
启动这些项目的主要挑战通常在于,在负责维护系统的团队以及依赖该系统的团队之间建立内部共识和承诺。通常在领导层面论证项目的商业价值并设定项目目标,能够让这一环节更顺利。这也有助于为后续证书和晋升政策中的权衡提供依据。当利益相关者对于一次变更可以承受多大风险存在分歧时,不进行现代化改造的风险就是平衡这一考量的另一端。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.
步骤 2:定义证书Step 2: Define the certificate
证书是一组每项现代化变更都必须满足的条件或测试。选择能够针对目标为变更正确性提供最有力累积证据的条件。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:
- 原始测试套件通过了The original test suite passes
- 现代化过程中由 Claude 编写的测试全部通过了Claude-authored tests written during the modernization all pass
- 测试覆盖率达到约定的阈值Test coverage meets an agreed threshold
- 性能基准保持在约定范围内Performance benchmarks stay within an agreed bound
- Claude 在各个全新的上下文窗口中进行的独立对抗性评审未发现任何阻碍性问题Independent adversarial reviews by Claude, each in a fresh context window, find no blocking issues
- 对于用户界面,Claude 驱动的计算机使用未发现回归 સમસ্যাFor user interfaces, Claude-driven computer use finds no regressions
- 当前版本和目标版本对相同输入产生相同的输出,输入可以是实时的、录制的或由 Claude 生成的Current and target versions produce the same output from the same input, which can be live, recorded, or Claude-generated
- 持久化状态和线路格式可在当前版本与目标版本之间往返转换Persisted state and wire formats round-trip between current and target versions
- 变更在预发布环境中运行了约定的时间段,错误率、延迟或告警均未出现回退Changes run in staging for an agreed period with no regressions in error rates, latency, or alerts
- 静态分析和安全扫描未发现新问题Static analysis and security scans show no new findings
- 对于编译目标,构建过程无误,类型检查也已通过。For compiled targets, the build is clean and type checks pass
编写证书时,应纳入将审核变更并将其部署到生产环境的相关人员。在证书和代理式工作流仍处于设计阶段时,就让当前依赖该代码库的开发人员、用户群体和业务负责人参与进来。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.
他们的专业能力决定了证书衡量的内容,而他们的早期参与则是在变更进入评审时赢得其认同的关键。检验成品证书是否完善的一种好方法,是看他们是否仅凭证书中的证据就愿意放心合并。如果他们能在其中看到自己的标准,那么第 3 步中的晋升政策就可以更宽松一些。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.
证书检查的对象和方式取决于现代化类型。What the certificate checks against, and how, depends on the modernization type.
- 对于一次提升式现代化改造,基准应是原始代码库,而原始测试套件可以作为认证的核心。For an uplift modernization, parity is against the original codebase, and the original test suite can be the core of the certificate.
- 对于转换现代化改造,兼容性对照的对象同样是原始代码库,但原始测试套件很少能在新技术栈上运行。相反,生产流量回放、新旧系统之间的差分测试,以及与生产环境并行部署,承担了其中大部分工作。For a transform modernization, parity is also against the original codebase, but the original test suite rarely runs on the new stack. Replay of production traffic, differential testing between old and new, and a prod-parallel deployment do most of the work instead.
- 对于重新构想式现代化改造,证书以行为规范为依据。这是最困难的情况。与可以进行差异比较的现有系统相比,规范的客观性较低,因此需要更大程度地依赖模型判断,这可能导致结果更加不稳定。在这种情况下,证书依靠根据规范编写的测试、由 Claude 独立进行的对抗性审查(检查每项变更是否符合 sec),以及差异检查(确保新系统保留旧系统的行为)。预计需要随着规范的明确而不断修订证书:规范中的缺口会最先在这里暴露出来。For a reimagine modernization, the certificate is anchored in the behavioral spec. This is the hardest case. A spec is less objective than an existing system to diff against, so a larger degree of model judgement is involved, which can lead to more variable outcomes. Here, the certificate leans on tests written from the spec, independent adversarial reviews by Claude that check each change against the sec, and differential checks where the new system keeps the old one’s behavior. Expect to revise the certificate as the spec is clarified: gaps in the spec show up here first.
较老的系统通常测试覆盖率不足、测试不稳定,而且遥测数据很少。定义证书的一部分工作,就是识别这些缺口。如果难以提供有力的证书,那么在这一步最有用的做法之一,就是使用 Claude 来补齐缺失的证据,无论是搭建与生产环境并行的设置、构建回放工具,还是编写更多测试。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.
步骤 3:设置晋升策略Step 3: Set the promotion policy
代理生成变更的速度远超任何人类团队逐个差异进行审查的能力。晋级策略是一条分层审查路径——事先明确记录并达成一致——用于规定对变更进行人工审查的深度,从而让现代化工作能够在可接受的时间内完成。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.
与证书一样,与评审人员共同完成这一步,并尽可能将其纳入组织现有的变更管理流程中。具体做法会因组织及其面临的风险权衡而有所不同,但有几条规则在任何地方都适用: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:
- 层级会根据影响范围和代理的信心程度而变化。如果你的组织已有变更或风险分类体系,请使用组织自己的分类。对于关键路径,仍应保留完整的人工审核。Tier changes by blast radius and agent confidence. Use your organization's own change or risk classification if it has one. Keep full human review for critical paths.
- 从源头修复反复出现的标记。对一段时间内被标记的更改进行分组和分析。当同类标记持续反复出现时,应在代理工作流或证书中修复根本原因,而不是逐一审核每个标记。Fix recurring flags at the source. Group and analyze the flagged changes over time. When the same kind of flag keeps recurring, fix the cause in the agentic workflow or the certificate rather than reviewing each one.
- 与评审人员一起设计输出格式。就哪些信息和格式能让评审最快完成,以及哪些信号比其他信号更能增强信心达成共识。让他们在第 5 步中尽早评审样例输出。Design the output format with the reviewers. Agree on what information and format make review the fastest, and what signals give more confidence than others. Have them review early sample outputs in Step 5.
- 有效分配主题专家(SME)的时间。SME 不会阅读每一处最终差异,但他们的判断仍然是稀缺资源。应让他们能够直接查看最高风险层级中的变更,以及每个层级内被标记的代理决策,而无需在大量差异中费力筛选。这样,少量专家工时就能覆盖风险最高的变更。Allocate SME time effectively. SMEs won't read every final diff, but their judgment is still the scarce input. Make it easy for them to go straight to the changes in the highest-risk tiers, and to the flagged agent decisions within each one, without wading through large diffs. A small number of expert hours then covers the changes that carry the most risk.
其中许多规则通过在项目早期让主题专家(SME)参与进来,提前投入他们的工时。他们的反馈会在全面现代化开始前,调整证书和智能体工作流。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.
他们对样品的签字确认也进一步成为在高置信度情况下采用更轻量审核流程的依据。这与传统的非代理模式正好相反,后者是在最后才进行审核。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.
这一切仍然取决于一份足够详尽、能够作为真实证据的证书,以及一批充分理解 Claude 如何完成变更、从而能够信任该变更的审查人员。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.
第 4 步:准备好先决条件Step 4: Put the prerequisites in place
这一步的大部分工作都需要通过现代化项目之外的团队来完成:由平台或基础设施团队负责主机,由 QA 或发布工程团队负责测试容量,由安全与合规团队负责审批。这些团队通常各自都有待办事项或审批流程,因此应尽早展开沟通——一旦确定了需求就开始,通常在第 1 至第 3 步仍在进行时就应着手。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.
环境Environment
- 一个专用的远程主机,用于运行工作流,Claude 可以访问代码库及其他相关资源A dedicated remote host for running the workflow with the codebase and other relevant sources reachable by Claude
- 按照证书要求测试容量Test capacity as required by the certificate
- 任何能够增强该证书的内容:生产遥测数据、与生产环境并行的设置,或用于重放的生产数据Anything that strengthens the certificate: production telemetry, a prod-parallel setup, or production data for replay
代码库与 CI/CDCodebase and CI/CD
- 基于构建和编译日志、导入分析或运行时跟踪信息绘制的代码库依赖关系图。注意:该插件的 map 命令是一个很好的起点,但根据代码库的规模和历史,可能需要在前期进行更广泛的工作。A dependency map of the codebase, grounded in build and compile logs; import analysis; or runtime traces. Note: The plugin’s map command is a good starting point, but depending on the size and age of the codebase, more extensive upfront work may need to be done
- 作为目标定义一部分的任何依赖项或软件包的计划处理方式Planned treatment of any dependencies or packages, as part of the target definition
- 一个可在需要时添加到 CI/CD 中的兼容性检查A compatibility check ready to add to CI/CD, if needed
- 如果你是在原地进行现代化改造,一项达成一致的代码冻结政策An agreed code-freeze policy, if you are modernizing in place
- 一份面向活跃开发者的沟通计划,涵盖任何代码冻结和新的兼容性要求A communication plan for active developers covering any code freezes and new compatibility requirements
团队与评审Teams and review
- 与依赖该代码库的其他团队达成共识,明确他们参与的方式,例如签署证书或根据晋级政策进行审查,并预留审查人员的时间。Agreement from other teams that depend on the codebase on how they take part, like signing off on the certificate or reviewing under the promotion policy, with reviewer time set aside
安全与合规Security and compliance
- 一种经批准用于源代码的 Claude Code 模型访问路径A model access path for Claude Code approved for source code
- 代理工作流的最小权限访问:仅写入现代化分支,不使用任何生产凭据Least-privilege access for the agentic workflow: write only to modernization branches and no production credentials
- 已从现代化分支中清除或屏蔽机密信息和个人身份信息 (PII)Secrets and PII scrubbed or masked from the modernization branch
- 每项变更均可追溯,并且 PR 均关联到代理对话记录和证书证据Every change traceable and PR linked to an agent transcript and certificate evidence
- 对新依赖项进行许可证和漏洞检查License and vulnerability checks on new dependencies
步骤 5:构建并完善智能体工作流Step 5: Build and refine the agentic workflow
使用 Claude Code 为代码库现代化开发定制的动态工作流。Use Claude Code to develop a customized dynamic workflow for modernizing the codebase.
我们建议从代码现代化插件开始,并将工作流可能需要的所有内容放在文件系统上或通过 MCP 提供,以便 Claude 能够访问。这包括目标、证书、推广政策、代码库、文档,以及证书所需的任何数据源或工具。您也可以将本文作为上下文提供给 Claude。这将构成该项目的核心知识库。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.
有了这些基础,构建现代化工作流就是容易的部分了。根据需要请领域专家(SME)审查 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)审查它所产生的更改、代理的处理过程,以及证明证书要求已满足的证据。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.
当问题出现时,你应该修改工作流,而不是逐一修改每项变更。目标是确保规模化后,这些变更几乎都能满足证书要求,并让审阅者能够放心地依据晋级政策合并它们。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.
第 6 步:运行现代化工具Step 6: Run the modernization
首先,在代码库的一小部分上端到端地完成现代化改造,包括根据推广策略审查并合入变更。在修复问题的成本仍然较低时及时解决所有不正常之处,反复执行这一流程,直到你确信方案可靠,然后再推广到整个代码库。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.
当系统不能停机,或者代码库变化如此迅速以至于难以让单独的现代化副本保持最新时,通常会选择这种方式。根据我们的经验,此时可行的方法是:从叶节点向内将代码库划分为逻辑分区;一次冻结并现代化一个分区;并设置 CI/CD 门禁,确保分区完成现代化后,新的提交无法将其恢复到原来的状态。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.
关于成本的说明A note on cost
我们经常被问到,像这样的现代化改造会消耗多少 token。每项现代化改造工作各不相同,但主要的成本驱动因素包括:We often get asked what a modernization like this will cost in tokens. Each modernization effort is different, but the main cost drivers include:
- 需要阅读与需要修改的代码库部分分别有多少;How much of the codebase has to be read versus changed;
- 证书的复杂程度(在受监管环境中,验证通常占据更大的工作量,而不是编写变更本身);How involved the certificate is (verification, not writing the change, is usually the larger share in a regulated environment);
- 证书要求编写多少新测试以及修复多少测试;以及How much new test writing and test repair the certificate demands; and
- 在运行过程中,其他团队在你周围合并所带来的协调工作量。How much reconciliation work comes from other teams merging around you while the run is in progress.
在完成代码库一小部分的现代化改造后,测量令牌使用量,并据此推算整个运行过程的情况。将试点无法看到的任何内容(例如在实时代码库上进行协调)视为未知因素。这样,你就能估算出完整现代化改造的最低成本。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.
试点测量结果还显示了应在何处优化智能体工作流以降低成本。找出工作流中消耗代币最多的部分,并考虑如何提高其效率。将计算密集型的验证信号置于成本更低的门控机制之后,使其仅在较为简单的检查通过后才运行。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.
可以考虑使用 Sonnet 之类在成本与能力之间取得平衡的模型,来处理证书全面检查的机械性、高负荷工作。将更智能的模型留给困难的转换任务,以及用于验证正确性的对抗性审查。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.
当较便宜的模型无法满足证书要求时,你也可以升级到更昂贵的模型,但在试运行期间要仔细分析重试率,因为多次使用廉价模型的尝试可能比一次使用昂贵模型的尝试成本更高。如果让 Claude 同时访问工作流和试运行数据,它可以协助你完成其中的大部分分析。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.
超越现代化Beyond the modernization
现代化后的代码库只是其中一种产出。其他产出还包括生成它的工作流、用于界定正确标准的书面证明、变更管理流程已经接受的推广政策,以及每一项已落地变更的证据链。将这套操作手册编纂为可复用资产,从而为下一次升级或重写预先建立好这一模式。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.
其他资源Additional resources
- Claude Code 的公开代码修改插件
- AI 原生 SDLC 实战指南
- 代码现代化实战指南
- 借助 AI 实现 COBOL 现代化:打破成本壁垒