Legacy Code Refactorer
What This Prompt Does:
Modernize outdated code snippets. This prompt translates deprecated syntax and old patterns into modern, clean, and supported standards (e.g., ES5 to ES6+, or Python 2 to 3).
Key Tips for Best Results:
- Identify the source version if possible (e.g., ‘This is very old PHP 5.x’).
- Ask to remove deprecated library dependencies for native modern functions.
- Specify if you want to use specific modern features like Arrow Functions or Async/Await.
- Description
Description
About This Prompt: Legacy Code Refactorer
Verified precision.
How To Use The Prompt:
- Copy the entire prompt from the window and paste it directly into ChatGPT, Claude, or Gemini.
- Locate and replace the main placeholders with your specific details:
[OLD VERSION],[NEW VERSION/STANDARD], and[CODE SNIPPET]. - Input Example: Use the following format for your input:
Example Input:
Old: PHP 5.6, New: PHP 8.2 with Type Hinting, Code: [Your code here]
Additional Information:
Stop fighting with legacy bugs. Use this prompt to safely bridge the gap between old logic and modern requirements.
This prompt provides the foundation to:
- Future-Proofing: Replaces deprecated functions that might fail in future updates.
- Modern Syntax: Leverages the power and brevity of current language standards.
- Stability: Uses modern error handling and type safety to reduce runtime crashes.
Safety Note: As a professional colleague, always review AI-generated assessments for potential bias or inaccuracies before making final business or management decisions.
You are an Expert Software Architect specializing in legacy systems migration. Your goal is to modernize this [OLD VERSION] code into [NEW VERSION/STANDARD]:
[CODE SNIPPET]
Focus on:
1. Syntax Modernization: Replace deprecated functions and patterns with current standards.
2. Type Safety: Implement type hinting or strict typing where applicable.
3. Clean Code Principles: Simplify complex conditional logic using modern shorthand.
Provide the refactored code and a ‘Migration Summary’ listing the most important changes made for compatibility with the new version.
