A Two-Step AI Workflow for Legacy Code Modernization

A Reddit post on r/ClaudeAI argues against simply asking AI to 'refactor' legacy spaghetti code, noting that AI tends to preserve flawed existing structures. Instead, it proposes a two-step 'reverse engineering' workflow that leverages LLM reasoning more effectively.
The Problem with Direct Refactoring
When you paste old code into an AI agent with a request like 'Please refactor this and make it clean,' the result is often just a polished version of the same bad architecture. The AI is biased by the code you provide—it tries to preserve your structure, variable names, and logic flow, even if they were flawed from the beginning.
The Two-Step 'Reverse Engineering' Process
Step 1: Extract the Intent (The 'What')
Don't ask the AI to fix the code. Instead, ask it to ignore the code structure and extract the business logic. Specifically, have it write a high-level Business Requirement Document (BRD) based on the file. This yields the pure logic without the technical debt.
Step 2: The 'Clean Slate' Build (The 'How')
Take that fresh BRD and feed it into a 'Master Architect' prompt. Now, the AI isn't fixing old mistakes; it's building a solution from scratch using modern best practices. This approach also facilitates technology migration (e.g., from legacy Java to modern Node.js) because the intermediate BRD layer is technology-agnostic.
The post mentions that the specific 'Master Architect' prompt used for Step 2 is provided in the first comment of the Reddit thread.
📖 Read the full source: r/ClaudeAI
👀 See Also

How to disable Claude Code's verb spinner feature
Claude Code includes a default verb spinner that displays whimsical gerunds like 'Seasoning' and 'Crafting' during processing. You can disable it by editing the settings.json file with a blank space in the spinnerVerbs array.

Using Light-Context Cron Jobs for Daily OpenClaw Tips
A user shares their setup of a daily cron job that posts OpenClaw tips to a Nextcloud Talk channel, highlighting the --light-context flag to reduce bootstrap overhead for isolated tasks.

Claude Isn't Bad at Coding — Your Context Setup Is
After months of using Claude, one developer argues failures stem from how you structure context, not the model itself. Key improvements: separate instructions from logic, cut context noise, and use stable patterns.

Token Waste in Claude Code: A User's Self-Audit Shows Behavioral Fixes Beat Model Switching
One user measured token usage in Claude Code and found that /clear between tasks, planning before editing, and banning re-reads of edited files saved more tokens than switching models. Practical discipline beats wrappers.