Two passes through the same checkout refactor
A checkout function has become difficult to read. It collects item prices, applies a discount, adds delivery, and prepares a receipt. You want to make it easier to maintain without changing what customers pay. This is a useful, contained task for trying Claude Opus 5.5 and Claude Sonnet 5.5 on the same refactor.
A refactor changes the structure of code while preserving its behavior. That distinction matters when working with an AI assistant. A shorter function is not automatically an improvement if it rounds a total differently or changes when delivery becomes free. The goal is code that is easier to understand and still follows the existing rules.
You do not need to choose a permanent favorite before starting. Give each model the same small task, inspect the results, and use what you can verify.
Start with a shared baseline. Save the current code in version control, which records changes and lets you return to an earlier state. Create a separate working branch or copy for each attempt. Both should begin with identical files. If the second model receives the first model’s changes, you are evaluating a review process rather than two independent attempts.
Before asking for edits, identify the behavior that must survive. For this checkout example, that might mean applying discounts before delivery, keeping money as whole cents, and preserving the receipt’s existing fields. Use the actual rules in your code, even if some look unusual. A refactor is a poor moment to silently redesign them.
Write a few checks around those rules. Include an ordinary order, an empty basket, a discounted order, and an order at the free-delivery threshold. If the project already has tests, run them before making changes. A failing baseline makes later results harder to interpret.
Give both models the same instructions. A practical request could read: “Refactor the checkout calculation into small, clearly named functions. Preserve all current behavior and the public function signature. Keep monetary values in whole cents. Avoid adding dependencies. Explain any assumptions and list the tests you ran.”
Also provide the relevant code, its tests, and any project instructions. The public function signature is the way other code calls the function: its name, inputs, and expected output. Preserving it reduces the chance that a local cleanup breaks another part of the application.
Vana API can provide access to both models through one service. It offers an OpenAI-compatible endpoint and also supports the Anthropic Messages and Gemini native protocols. For a comparison like this, keep your coding tool, project context, and available permissions consistent, and change only the selected model where practical.
Read the changes before judging the explanation. An assistant can describe a tidy solution while overlooking an edge case. Review the actual patch, which shows the lines it added and removed. Ask whether the new function names reveal the business rules, whether the changes stay within the requested scope, and whether another developer could follow the calculation.
- Run the same tests against both attempts.
- Check that discounts, rounding, and delivery thresholds still behave as expected.
- Look for unrelated edits, new dependencies, or altered receipt fields.
- Record the usage cost and the time you spent reviewing and correcting each result.
Passing tests provide evidence, but they cover only the cases they exercise. If an extracted helper changes the order of operations, inspect that change directly. If you discover a missing edge case, add a check and run it against both attempts.
There is no need to assume that one model will always produce the better refactor. For this task, the useful result is the patch that preserves behavior, communicates intent, and needs the least repair. A larger rewrite may create more review work than a modest extraction of two well-named helpers.
If you want to try this workflow, create a Vana API account and start with one small function. Usage is billed per real token with no monthly fee, so record the cost alongside the outcome. Keep the original code available until you have reviewed the chosen patch and confirmed that the checkout still follows its rules.