AI-Powered Code Modernization: How My Team is Using Machine Learning to Transform Legacy Systems

By Peter Winston

founder and CEO

Integrated Computer Solutions

April 30, 2025

Blog

Image Credit: ICS

When I recently asked my team to share examples of how we're using AI and machine learning to modernize legacy codebases, I expected some good stories—but I was genuinely surprised by the sheer variety and ingenuity of their approaches.

We’ve had great success using Claude Code – an agentic tool that helps developers code faster – for new code creation, so I was curious to see how it handled refactoring legacy systems. My assumption was that the key to effective AI-assisted coding for complex projects would lie in a structured, "old-school" approach: detailed specs, comprehensive documentation, and rigorous test plans—all potentially auto-generated from existing legacy code.

Was my assumption correct?

Exploring the Power of AI in Code Modernization

We have used AI in many parts of the software development process over the past 18 months. If I were to grade our experiences overall, the results look something like this:

  • Write requirements for a project: C-
  • Read requirements and create a spec: B-
  • Write a test plan from requirements: A-
  • Get info from a detailed technical data sheet: A 
  • Create a UX/UI: D
  • Evaluate a UX/UI: B
  • Write a unit test: A
  • Write a function test plan: B
  • Write a code snippet: A
  • Write a code module: B-

In general, AI performs well, but it does have limitations—particularly when working with newer technologies. For example, because there’s far more code publicly available for Qt 5 than Qt 6, the AI tends to default to older patterns unless explicitly guided. While this can be managed, it’s something to watch for. And as with any automated tool, mistakes can creep in—catching them early is key to avoiding compounding issues.

To explore AI’s practical capabilities in software modernization, we ran an experiment: three developers were each given access to the same legacy Motif codebase and two weeks to see how far they could get using Claude Code. There was no requirement to port everything—just to dive in and make meaningful progress. The results were surprising, not just in how much they accomplished, but in how differently each developer approached the task—and in how AI either accelerated or complicated their workflows.

Developer #1: A Streamlined Approach to AI-Assisted Refactoring

Developer #1 provided Claude Code with a clear plan: document the existing code, create a test suite, port the legacy code, and validate everything. Claude Code delivered impressively, automating roughly 95% of the work.

This approach was streamlined since the developer knew in advance he was going from point A to point B, allowing him to focus on the actual requirements. He only needed to step in for some edge cases. This structured method clearly demonstrated the power of AI-assisted refactoring.

It’s important to clarify that the goal wasn’t to port the entire Motif codebase to Qt 6. Instead, the developer tasked Claude Code with reviewing 15 Motif applications, ranging from a simple "Hello Motif" to more complex, composite ones. The objective was to identify patterns across these applications and formulate a porting strategy. This process resulted in detailed documentation mapping Motif classes to their Qt 6 equivalents, covering both Qt 6 widgets and QML, and providing clear guidance for how the functionality should be translated.

During the porting phase, Claude worked through the list of applications, largely preserving functionality with minimal developer intervention. Challenges emerged in more nuanced examples—for instance, there was a “spinning globe” demo that required additional guidance when a direct mapping wasn't available. After being prompted to reason through the problem, Claude Code resolved the key technical hurdles.

While there were still style issues to address, overall the process was quite fast. (It should be noted that there was minimal business logic and complexity in these demo applications.)

Developer #2: Taking a Different Path with AI-Driven Compatibility

The next two developers took surprising and distinctly different routes. Developer #2 handed the strategy completely over to Claude Code, which recommended creating a compatibility library rather than rewriting the entire codebase. At first, this seemed like a misstep—but it turned out to offer unexpected benefits, such as preserving existing user interfaces, documentation and test frameworks. While the legacy code was left intact, this approach showcased real potential for scaling efficiently across multiple legacy systems.

This was by far the more challenging approach with Claude Code. While it made the suggestion, I don’t think it fully realized what it was getting into. Documentation was created in both .md files, useful for LLM context, and in Doxygen-style format. The Doxygen-style documentation is essential for older, more complex applications as it forces the LLM to digest the actual purpose of the code, which helps in analyzing cases where it might be incorrect. This became crucial during the porting phase, where accurately translating the intent of older design patterns to new platforms and languages was key.

The goal was to keep the existing Motif code functional while integrating Qt 6 under the hood, using a newly created Qt 6-oriented Motif library. This approach posed significant challenges, as it required maintaining compatibility with minimal modification to the original code. There were numerous namespaces created to allow this mixing of old and new code, and verifying that they worked properly was no small feat. This slowed down the process considerably, as the developer manually reviewed more code than he would have with a direct Qt 6 port to ensure he understood what was being generated.

Going through each widget one by one, the developer built tests for each one, noting patterns like how callbacks should be converted into Qt signals and slots. This process was far from automatic because the developer didn’t want the LLM to get too far ahead with potentially flawed ideas, or use too much context without condensing it. There were instances, like the XMBillboard widget and others, where it struggled.

Developer #2 was not able to create a complete compatibility library within the allocated two weeks. However, he did get far enough with sample programs to validate this is indeed a very viable approach with AI. 

Developer #3: Navigating Sensitive Client Code with AI-Generated Tools

Dealing with sensitive client-owned code, developer #3 chose not to directly refactor with AI. Instead, he opted for a more general-purpose solution. He guided Claude Code to build a specialized automated conversion tool, capable of handling source transformations, build files, JavaScript updates, and dependency migrations.

There were challenges in getting Claude Code to fully meet the documentation requirements. It preferred JSON-style documentation rather than something that was truly human readable. Moreover, this process was quite time consuming for the human and the LLM, thus requiring a significantly high number of tokens to complete.

Like Developer #2, developer #3 was not able to fully complete the task within the given time period. The conversion tools that Claude Code created were functional, but in almost all cases, the code they generated required programmer changes by hand to actually get them working.

Key Insights from AI-Assisted Code Modernization

Three developers, one AI tool, and one shared goal led to entirely different—and equally valuable—solutions. All three got 80-90% of the functionality very quickly, yet all three struggled to get to the finish line before the two weeks were up.

So what’s the takeaway? While AI can write excellent code, the heart of engineering still lies in determining the goal and designing the process. Looking ahead, we may soon treat source code in much the same way we treat object files today, shifting our focus even more toward defining clear goals and robust processes. AI will certainly enhance our coding capabilities—but engineering judgment and strategic planning will always remain indispensable.

Peter Winston is the founder and CEO of custom software development firm Integrated Computer Solutions, which specializes in product development for complex use cases and regulated markets, from medical devices to automotive and industrial IoT.

More from Peter

OSZAR »