PromptsHub
Used by 5,000+ developers & creators
Back to Developers
Developersrefactoringtechnical-debtmigration

Legacy Code Modernizer

Refactors outdated legacy code into modern, secure, and idiomatic patterns.

Use Case

Use this prompt when onboarding onto an old codebase or migrating codebases (e.g., ES5 to ES6+, or Python 2 to Python 3).
AI Prompt
Act as a Software Architect specializing in technical debt reduction. Refactor the following legacy code into its modern, highly idiomatic equivalent. Ensure it strictly adheres to the latest language standards, maintains backwards compatibility, utilizes modern exception handling, and includes clean type annotations. Legacy Code: [insert legacy code here].

How to Use

  1. 1Select the outdated function or module that needs updating.
  2. 2Insert the old code into the prompt template.
  3. 3Review the modernization choices and run standard unit tests on the output.

Example Output

Modernized Code Solution: The old ES5 prototype syntax has been successfully refactored into modern ES6 classes, including private class fields and async await syntax instead of legacy callbacks.