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.

Done with Claude Code· Advanced

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.