现代化一个应用程序的请求,通常始于一个技术问题:应该用哪个框架来替换旧的?在做出选择之前,先弄清楚哪些部分仍然有效。然后收集能够作为该行为回归测试网的证据,并明确现代化必要的环节。
我采用了一种“以证据为先”的方法,对四个公开应用程序进行了分析,范围从小型的 Node.js 游戏到大型的 Java 企业资源规划(ERP)应用程序。每个应用程序都需要不同的处理方式,但我收集证据、选择下一个实验以及确定潜在证明点的方式是可重复的。
本文将逐步介绍这一过程,以便您将其应用于自己的某个应用程序。同时,本文还展示了如何在 GitHub Copilot 智能体技能中编码该流程,同时让负责该系统的人员保留架构判断权。
在选定目标之前构建证据
应用程序上的标签很少能提供足够的信息。“Java 微服务”并不能告诉你在生产环境中运行的是哪个 Java 开发工具包(JDK),该版本被锁定在哪里,测试是否执行,或者其他系统依赖哪些接口。“遗留单体应用”也不能告诉你业务核心是否已损坏,或者是一个已退役的平台依赖项阻止了应用程序的启动。
在建议进行更改之前,建立一个小型的证据清单:
清单文件、锁文件、入口点以及可部署组件
经过验证的安装、构建、测试、打包和运行命令
容器、CI 工作流、部署文件以及开发者工具中的运行时锁定版本
外部契约,如 API、数据库行为、文件格式和用户工作流
已停止支持的框架和依赖项,并附带应用程序仍在使用它们的证据
在工作过程中记录不确定性。我使用三个简单的标签:已记录、推断和未验证。如果两个文件关于 Java 版本的描述不一致,请解决矛盾。如果你无法确定某个 CI 检查是否会阻止合并,请如实说明。记录未知情况,而不是将猜测当作发现。
这份清单为你提供了具体的内容,以便在提出更改建议之前与应用程序的所有者一起审查。
选择可行且干扰最小的处理方式
一旦你理解了应用程序,就按组件做出决策。一个单一的系统可能包含应该保留的代码、需要替换的依赖项,以及确实需要重写的一个子系统。
首先,检查某项功能是否仍然必要。只有在验证其未被使用或已被取代,并与其所有者确认该决定后,才将其移除。移除是一个独立的决策,而且不一定是干扰最大的那个。
对于你仍然需要的功能,从变更最小的选项开始:
保留它。支持良好且仍适合当前工作的代码不需要现代化的故事。
升级它。迁移到受支持的主要版本,并修复破坏性更改。
替换它。在保持现有设计不变的情况下,替换已放弃的依赖项。
包装它。稳定一个有用的接口,并逐步替换其内部实现。
重写它。当不存在负责任的升级路径,或架构无法满足要求时使用此选项。
这是一个决策顺序,而不是对工作量或风险的普遍排名。询问是什么证据支持选择更具干扰性的选项。“代码很旧”是不够的。已知的漏洞且锁定版本没有补丁发布、在所需运行时环境中失败的依赖项,或者当前架构无法达到的可衡量可靠性目标,这些都可以证明升级的合理性。
决定哪些证明是可行的
下一个问题是,即使遗留 CI 流水线未通过,该组件是否仍能运行得足够好以产生证据。
进行限时可行性检查。尝试安装依赖项、在可用的工具链上构建、启动组件,并执行至少一个有意义的测试。当时间盒到期时停止。结果将引导你进入两条路径之一。
先捕获行为,然后进行升级。当旧应用程序仍能以可接受的成本运行时,请使用此路径。记录其对外可见的行为,在可行的情况下修复测试夹具,并利用这些检查来验证升级结果。
首先构建一个小型的现代切片。当旧组件必须经过修改后才能运行(即无法在不改变它的情况下运行)时,请使用此路径。将最薄层的有用工作流迁移到受支持的技术中,证明其可行性,并由此扩展。在这种情况下,要求拥有完整的遗留测试套件是循环论证。恢复测试套件本身就是现代化过程的一部分。
我使用以下安全级别,改编自“文档化与现代化”技能,来描述可用的最强回归保护:
级别 最强的真实保护
L0 无可用的回归检测网;将旧代码和现有文档视为规范。
L1 进行少量可逆的更改,新旧路径并行运行,执行冒烟测试,并进行领域审查。
L2 捕获输入和输出、快照或其他行为比较。
L3 自动化检查覆盖系统的一部分,并明确剩余的空缺。
L4 自动化的 CI 门禁将代码规范检查、单元测试、行为测试和端到端测试相结合,针对商定的范围进行验证。
说明你能证明的内容以及剩余的风险。即使是 L4 级别的门禁也无法确立所有可能的行为都是正确的。API、数据库影响、文件、渲染输出和业务工作流通常能作为持久的比较点,因为这些行为可以跨越框架或语言的变更而保持不变。
PiggyMetrics:先捕获行为,然后升级
PiggyMetrics 是最清晰的例子之一,展示了一个看起来比实际更糟糕的应用程序。该项目使用了 Java 8、Spring Boot 2.0.3、Spring Cloud Finchley、Zuul、Hystrix 以及旧的 spring-security-oauth2 库。
很容易就会断定该应用程序无法运作并着手设计新的架构。但可行性检查揭示了不同的故事。
记录的可行性结果显示了针对 JDK 8 的遗留签出的两项探测:
命令 记录结果 确立的内容
mvn -pl config -am compile 退出代码 0 选定的配置模块及所需的反应器依赖项已编译成功。
mvn -pl account-service -am test 运行了 14 个测试:5 个通过,9 个报错 部分服务逻辑通过;嵌入式 MongoDB 初始化阻止了其他测试。
这些是历史结果,并非旨在在现代签出中重现这些失败的命令。这九个错误追溯至“无法加载 ApplicationContext”,原因是嵌入式 MongoDB 下载返回了 HTTP 403 状态码。固定的二进制文件也针对 i386 架构,无法在 Apple Silicon 主机上运行。
这些探测并未确立整个应用程序正在运行或其集成行为正确。但它们为我提供了一个更狭窄的下一步:在更改生产堆栈之前,替换测试依赖项并重新运行受影响的测试。
这一结果使我避免了一个非常整洁但代价高昂的错误。我原本已经开始思考可能要替换架构中的哪些部分。一个损坏的测试依赖项并不足以证明重新设计应用程序是合理的,而五个通过的测试确立了我可以在现代化过程中检查以发现意外变更的行为基线。
现代化计划将这些证据转化为捕获后升级的流程:
使用 Testcontainers 替换嵌入式数据库依赖项,并在现有堆栈上建立绿色基线。
在更改生产运行时之前,将该基线放入 GitHub Actions。
从 Java 8 迁移到 Java 21 和 Spring Boot 3.3。
通过其现有接口替换过时组件:用 Spring Cloud Gateway 替换 Zuul,用 Resilience4j 替换 Hystrix,用 Spring Authorization Server 和 JSON Web Token (JWT) 资源服务器替换已退役的 OAuth 堆栈。
延续该基线,并在行为发生变化的部分周围添加契约检查。
第一个验收关卡是在旧技术栈上达到合格的基线,而不仅仅是成功安装替代依赖项。在持续集成(CI)中运行检查并将其作为合并要求强制执行,也是计划中的独立步骤。
结果摘要记录了 Java 和 Spring 的升级情况,同时保留了该应用程序旨在展示的微服务分解结构。Eureka 和 Cloud Config 得以保留;被退役的 Hystrix 和 Turbine 技术栈所使用的两个监控模块已被移除。范围内的构建模块从九个减少到七个。
这些版本描述的是实验过程,而非建议今天选择相同的版本。应根据您当前的支持需求来选择目标版本。其中有用的经验教训在于,仓库证据如何缩小了变更范围。
方法随系统而变化
相同的过程在两个较小的应用程序上产生了不同的答案。它们的锁定报告描述了这些选择:
| 应用程序 | 保留内容 | 变更内容 | 策略 |
|---|---|---|---|
| BrowserQuest | Canvas 渲染器、路径查找、世界模型、协议和游戏循环模型 | Node 0.4.7 升级至 Node 22,两个过时的 WebSocket 堆栈替换为 ws ,以及测试和 GitHub Actions | 升级并替换 |
| DOOM | 渲染器、35 Hz 仿真模型和 WAD 游戏数据格式 | X11 视频和 OSS 音频被 SDL2 替换;平台代码适配现代 64 位系统 | 保留核心并替换平台 |
比较需要重要的限定条件:DOOM 的检查冻结了来自现代化引擎本身的输出。它们用于防止后续的回归问题;并没有独立证明与符合当时标准的遗留二进制文件的等价性。指出这一局限性是选择诚实的安全水平的一部分。
在不假装产品已完工的情况下扩展该方法
随后,我将该方法应用于 ADempiere,这是一个涵盖企业资源计划(ERP)、客户关系管理、制造、供应链、会计和零售的大型 Java 套件。
规模改变了控制措施,但未改变方法。这项工作建立了可重复的构建,将运行时迁移至 JDK 21,在保留 SOAP Web 服务契约的同时用 CXF 和 Jakarta 替换了 XFire,捕获了遗留 Web 行为,并为选定用户引入了现代 Web 路径。首次现代业务合作伙伴写入与从遗留应用程序冻结的结果进行了比较。
固定的测量报告涵盖了 30 个合并的现代化拉取请求,以及通过首个被接受的便携式演示所重建的 102,587.72 个 Copilot 积分。该积分总额并非美元成本。更重要的是,报告明确说明了结果并非什么:它并非声称每个 ADempiere 屏幕或生产部署都已实现现代化。
我停止工作是因为概念验证的问题已经得到回答。结果证明了在选定运行时上的构建、新旧路径并行运行,以及针对遗留结果检查的真实业务写入。完成剩余部分将需要产品资金决策,而非另一个技术证明。在该边界处停止是方法的一部分。
将方法转化为代理技能
在重复这项工作后,我不希望证据清单和决策规则仅存在于我的笔记中。我将它们编码到了公开的 doc-and-modernize 代理技能中。
代理技能是 Copilot 在任务相关时可以加载的指令、脚本和资源文件夹。项目技能可以与单个仓库共存:
.github/skills/doc-and-modernize/
├── SKILL.md
├── references/
└── scripts/
仅 SKILL.md 是必需的;此处显示的资源文件夹是可选的。该文件需要包含名称和描述(解释技能的作用及使用场景)的 YAML frontmatter,随后是指令。创建指南包含了完整格式。
根据 commit-pinned 技能源 paraphrased(意译),其决策分支如下:
如果旧组件可以以可接受的成本运行,则在升级前捕获其行为。
如果它无法在不更改的情况下运行,则先构建并验证一个小的现代化切片,然后扩展它。
完整的技能增加了可行性检查、可测试性里程碑、安全级别、阶段关口以及证据要求。
有用的区分在于流程与政策。共享的技能可以要求提供仓库证据、受限实验、明确的安全级别和可执行的退出标准。您的组织仍需自行提供只有它才知道的部分:
已批准运行时、框架和托管服务
应用程序关键性及可接受的剩余风险
安全、合规性和变更控制要求
哪些遗留或生产结果可作为预期答案
谁有权批准架构并宣布生产变更完成
该技能应使这些决策可见。它不应替您做出这些决策。
从单个受限应用程序开始
选择一个具有明确负责人、已知业务价值且您可以观察其工作流的应用程序。首先运行文档工作流。与系统负责人一起审查架构、命令、运行时表面和未知因素。
然后批准一项实验,而非整个产品线的重写。
在将其添加到项目之前,检查该技能及其支持文件。GitHub CLI 的 gh skill 命令目前处于公开预览阶段;当您准备使用时,请查阅当前的安装指南。
作者
高级解决方案工程师
A request to modernize an application often starts with a technology question: Which framework should replace the old one? Before you choose, find out what still works. Then collect evidence that can act as a regression net for that behavior and show where modernization is necessary.
I used an evidence-first method on four public applications, from a small Node.js game to a large Java enterprise resource planning (ERP) application. Each needed a different treatment, but the way I collected evidence, chose the next experiment, and decided on possible proof points was repeatable.
This post walks through that process so you can apply it to one application of your own. It also shows how to encode the procedure in a GitHub Copilot agent skill while keeping architectural judgment with the people responsible for the system.
Build evidence before choosing a target
The label on an application rarely tells you enough. “Java microservices” doesn’t tell you which Java Development Kit (JDK) runs in production, where that version is pinned, whether the tests execute, or which interfaces other systems depend on. “Legacy monolith” doesn’t tell you whether the business core is broken or whether one retired platform dependency prevents the application from starting.
Before you recommend a change, build a small evidence inventory:
Manifests, lockfiles, entry points, and deployable components
Verified commands for installing, building, testing, packaging, and running
Runtime pins in containers, CI workflows, deployment files, and developer tooling
External contracts such as APIs, database behavior, file formats, and user workflows
End-of-life frameworks and dependencies, with evidence that the application still uses them
Record uncertainty while you work. I use three simple labels: documented, inferred, and unverified. If two files disagree about the Java version, resolve the contradiction. If you can’t determine whether a CI check blocks merges, say so. Record the unknown rather than treating a guess as a finding.
That inventory gives you something concrete to review with the people who own the application before you propose changes.
Choose the least disruptive treatment that works
Once you understand the application, make the decision per component. A single system can contain code that should stay, dependencies that should be swapped, and one subsystem that genuinely needs a rewrite.
First, check whether a capability is still needed. Remove it only after verifying that it is unused or superseded and confirming that decision with its owner. Removal is a separate decision, and it’s not necessarily the most disruptive one.
For a capability you still need, start with the option that changes the least:
Keep it. Supported code that still fits the job doesn’t need a modernization story.
Upgrade it. Move to a supported major version and fix the breaking changes.
Swap it. Replace an abandoned dependency while preserving the existing design.
Wrap it. Stabilize a useful interface and replace the internals in increments.
Rewrite it. Use this when no responsible upgrade path exists or the architecture cannot meet the requirement.
This is a decision order, not a universal ranking of effort or risk. Ask what evidence justifies choosing a more disruptive option. “The code is old” is not enough. A known vulnerability with no patched release for the pinned version, a dependency that fails on the required runtime, or a measured reliability target the current design cannot meet can justify escalation.
Decide what proof is possible
The next question is whether the component can run well enough to produce evidence, even if the legacy CI pipeline is not green.
Run a time-boxed feasibility check. Try to install dependencies, build on an available toolchain, start the component, and execute at least one meaningful test. Stop when the time box expires. The result sends you down one of two paths.
Capture behavior, then upgrade. Use this path when the old application can still run at an acceptable cost. Record its externally visible behavior, fix the test harness where practical, and use those checks to verify the upgrade.
Build a small modern slice first. Use this path when the old component cannot run until you have already changed it. Move the thinnest useful workflow to supported technology, prove it, and expand from there. Requiring a complete legacy test suite in this situation is circular. Restoring the test suite is part of the modernization.
I use the following safety levels, adapted from the doc-and-modernize skill , to describe the strongest regression protection available:
Level Strongest honest protection
L0 No usable regression net; treat the old code and available documentation as the specification.
L1 Small reversible changes, old and new paths in parallel, smoke checks, and domain review.
L2 Captured inputs and outputs, snapshots, or other behavioral comparisons.
L3 Automated checks cover part of the system, with the remaining gaps named.
L4 An automated CI gate combines lint, unit, behavioral, and end-to-end checks for the agreed scope.
State what you can prove and what risk remains. Even an L4 gate cannot establish that every possible behavior is correct. APIs, database effects, files, rendered output, and business workflows often make durable comparison points because those behaviors can survive a framework or language change.
PiggyMetrics: capture behavior, then upgrade
PiggyMetrics was the clearest example of an application that looked worse than it was. The project used Java 8, Spring Boot 2.0.3, Spring Cloud Finchley, Zuul, Hystrix, and the old spring-security-oauth2 library.
It would have been easy to call the application unworkable and start drawing a new architecture. The feasibility check told a different story.
The recorded feasibility results show these two probes against the legacy checkout with JDK 8:
Command Recorded result What it established
mvn -pl config -am compile Exit code 0 The selected config module and required reactor dependencies compiled.
mvn -pl account-service -am test 14 tests ran: five passed and nine errored Some service logic passed; embedded MongoDB initialization blocked the other tests.
These are historical results, not commands expected to reproduce those failures on the modernized checkout. The nine errors traced through Failed to load ApplicationContext to an embedded MongoDB download returning HTTP 403. The pinned binary also targeted i386, which would not run on the Apple Silicon host.
The probes did not establish that the whole application ran or that its integration behavior was correct. They did give me a narrower next step: replace the test dependency and rerun the affected tests before changing the production stack.
That result saved me from making a very tidy, very expensive mistake. I had already started thinking about which parts of the architecture I might replace. One broken test dependency did not justify redesigning the application, and five passing tests established behavior I could check for unintended changes during modernization.
The modernization plan turned that evidence into a capture-then-upgrade sequence:
Replace the embedded database dependency with Testcontainers and establish a green baseline on the existing stack.
Put that baseline in GitHub Actions before changing the production runtime.
Move from Java 8 to Java 21 and Spring Boot 3.3.
Replace obsolete components behind their existing interfaces: Zuul with Spring Cloud Gateway, Hystrix with Resilience4j, and the retired OAuth stack with Spring Authorization Server and JSON Web Token (JWT) resource servers.
Carry the baseline forward and add contract checks around the parts whose behavior changed.
The first acceptance gate was a passing baseline on the old stack, not merely the successful installation of a replacement dependency. Running checks in CI and enforcing them as merge requirements were also separate steps in the plan.
The result summary records the Java and Spring upgrades while retaining the microservice decomposition that the application exists to demonstrate. Eureka and Cloud Config stayed; the two monitoring modules used by the retired Hystrix and Turbine stack were removed. The in-scope build went from nine modules to seven.
Those versions describe the experiment, not a recommendation to select the same versions today. Choose targets against your current support requirements. The useful lesson is how the repository evidence narrowed the change.
The method changes with the system
The same process produced different answers on two smaller applications. Their pinned reports describe these choices:
Application What stayed What changed Strategy
BrowserQuest Canvas renderer, pathfinding, world model, protocol, and game-loop model Node 0.4.7 to Node 22, two obsolete WebSocket stacks to ws , plus tests and GitHub Actions Upgrade and swap
DOOM Renderer, 35 Hz simulation model, and WAD game-data format X11 video and OSS audio replaced with SDL2; platform code adapted for modern 64-bit systems Preserve the core and replace the platform
The comparison needs one important qualification: DOOM’s checks froze outputs from the modernized engine itself. They protected against later regressions; they did not independently prove parity with a period-correct legacy binary. Naming that limit is part of choosing an honest safety level.
Scaling the method without pretending the product is finished
I then applied the method to ADempiere , a large Java suite covering ERP, customer relationship management, manufacturing, supply chain, accounting, and point of sale.
The scale changed the controls, but not the method. The work established a reproducible build, moved the runtime to JDK 21, preserved SOAP web-service contracts while replacing XFire with CXF and Jakarta, captured legacy web behavior, and introduced a modern web path for selected users. The first modern business partner write was compared with a result frozen from the legacy application.
The fixed measurement report covers 30 merged modernization pull requests and 102,587.72 reconstructed Copilot credits through the first accepted portable demo. The credit total is not a dollar cost. More important, the report says exactly what the result was not: it was not a claim that every ADempiere screen or production deployment had been modernized.
I stopped because the proof-of-concept question had been answered. The result demonstrated a build on the selected runtime, old and new paths running together, and a real business write checked against the legacy result. Completing the rest would have required a product funding decision, not another technical proof. Stopping at that boundary was part of the method.
Turn the method into an agent skill
After repeating this work, I didn’t want the evidence checklist and decision rules to live only in my notes. I encoded them in the public doc-and-modernize agent skill .
Agent skills are folders of instructions, scripts, and resources that Copilot can load when a task is relevant. A project skill can live with one repository:
.github/skills/doc-and-modernize/
├── SKILL.md
├── references/
└── scripts/
Only SKILL.md is required; the resource folders shown here are optional. The file needs YAML frontmatter with a name and a description explaining what the skill does and when to use it, followed by the instructions. The creation guide includes the full format.
Paraphrased from the commit-pinned skill source , its decision fork is:
If the old component can run at an acceptable cost, capture its behavior before upgrading.
If it cannot run without changes, build and verify a small modern slice first, then expand it.
The full skill adds the feasibility check, testability milestone, safety levels, phase gates, and evidence requirements.
The useful distinction is procedure versus policy. A shared skill can require repository evidence, bounded experiments, explicit safety levels, and runnable exit criteria. Your organization still needs to supply the parts only it knows:
Approved runtimes, frameworks, and hosting services
Application criticality and acceptable residual risk
Security, compliance, and change-control requirements
Which legacy or production results may be used as the expected answer
Who can approve the architecture and declare a production change complete
The skill should make those decisions visible. It shouldn’t make them for you.
Start with one bounded application
Choose an application with an identified owner, known business value, and one workflow you can observe. Run the documentation workflow first. Review the architecture, commands, runtime surfaces, and unknowns with the people who own the system.
Then approve one experiment, not a portfolio rewrite.
Inspect the skill and its supporting files before adding it to a project. GitHub CLI’s gh skill commands are in public preview ; check the current installation guidance when you’re ready to use them.
Written by
Senior Solutions Engineer
| 刊期 | 得分 | 排名 | 结果 |
|---|---|---|---|
| 2026-11-30 | 7.41 | 17 | 入选 |
| 2026-11-29 | 7.65 | 21 | 未入选 |
| 2026-11-28 | 8.03 | 34 | 未入选 |
| 2026-11-27 | 8.63 | 26 | 未入选 |
| 2026-11-26 | 9.6 | 28 | 未入选 |