Modernize legacy scientific code with verified rebuilds
Use Claude Code to map an old codebase, rewrite it safely, and compare old and new results against test inputs before accepting changes.
- What they did
- Stephen Turner describes Claude Code’s code modernization plugin for scientific software. It starts by reading the project structure, tracing dependencies, and turning behavior into testable rules with source references. A person reviews the plan before the agent changes code, then the plugin reconstructs the program and checks the original and rewritten versions on the same inputs with fixed floating-point tolerances. It can also seed edge cases and intentional faults to see whether the tests fail as expected.
- How it went
- The write-up is about the workflow, not a personal rewrite Turner completed. It highlights the plugin’s verdicts — PROVEN, PARTLY PROVEN, or NOT PROVEN — and points to other examples, including RustQC, which reduced one run from 15 hours to 15 minutes.
- Tips
- This approach is useful when correctness matters more than reading every line of code. There is also an assessment-only mode that skips the rebuild, which may fit an inherited codebase where the original developer is no longer available.
Try it yourself with Claude Code
Review the legacy code in [folder path], which is written in [old language], and help me modernize it to [target language]. First, inspect the codebase, identify dependencies, and create testable behavior checks from the current implementation using [sample inputs or reference data]. Then draft a step-by-step rewrite plan and stop for my approval before you change any files. After approval, rebuild the code module by module, run both versions on the same inputs, and compare results using [tolerance] for any numeric differences. Add a few edge cases and at least one deliberate faulty change to confirm the tests catch regressions. Before you delete, overwrite, or submit anything irreversible, ask me to confirm. Finish with a short report listing matches, mismatches, and anything that still needs review.
Fill in the [brackets]. Agents can make mistakes, so review anything before it is sent, paid or deleted.
Get 3 agent uses like this every morning
With the day's top AI news. Free, and one click to unsubscribe.
Related agent uses
Investigate why a service is getting killed
Run a read-only SSH check to find the cause of a process death and rank fixes by risk.
Test a GUI app with headless scripted input
A developer used one agent to build an image editor and another to exercise it through headless mouse and keyboard scripts.
Split a big spec across parallel AI workers
A developer used one lead agent to break a large spec into independent modules and push them through sub-agents and workers in parallel.
Run a shared coding session with separate Claude Code agents
Let a group divide one feature across individual Claude Code instances, each with its own fresh context and review step.
Review your app’s user flow with computer use
Claude Code was used on Windows to inspect an app for usability problems, but the Windows setup sounded patchy.
Build branch-isolated workspaces for coding agents
A developer used Cursor to create a macOS Electron app that keeps each coding agent in its own branch-specific workspace with a separate local IP.