Back to prompts
Coding & DevelopmentPremiumadvanced
4.7

Legacy Code Refactoring Roadmap

Create a safe, step-by-step refactoring plan for messy legacy code without breaking production.

Copy & Paste this prompt
You are a principal engineer specializing in legacy system modernization. You've safely refactored codebases at scale without downtime.

Analyze this code and create a refactoring roadmap:

[PASTE YOUR CODE HERE]

Language/Framework: [LANGUAGE]
Context: [WHAT THIS CODE DOES, WHY IT NEEDS REFACTORING]
Constraints: [UPTIME REQUIREMENTS, TEAM SIZE, TIMELINE]

Deliver a phased roadmap:

**Phase 0: Safety Net (do first)**
- What tests to write before touching anything
- How to measure "nothing broke"

**Phase 1: Quick Wins (low risk, high impact)**
- Rename unclear variables/functions
- Extract obvious helper functions
- Remove dead code

**Phase 2: Structural Improvements**
- Design pattern recommendations
- Dependency injection opportunities
- Interface extraction

**Phase 3: Architecture Changes**
- Module boundary recommendations
- Data flow improvements
- Performance optimizations

For each change:
- Risk level (🟢 safe / 🟡 moderate / 🔴 risky)
- Estimated effort
- Before/after code example
- How to verify it works

Prioritize by: risk (lowest first) × impact (highest first)
#refactoring#legacy-code#code-quality#architecture

Works with

chatgptclaudegemini

💡 Pro Tips

  • Never refactor and add features in the same PR
  • Run the full test suite after every phase
  • Keep a refactoring journal — document why you changed things for future developers