Prompt Library 💻 Coding & Dev Technical Debt & Legacy Code Refactor
GPT-4o 💻 Coding & Dev Intermediate

Technical Debt & Legacy Code Refactor

Analyzes older code blocks to identify inefficiencies, security vulnerabilities, and modernization opportunities.
👁 8 views ⎘ 0 copies ♥ 0 likes

The Prompt

"I am providing a legacy code snippet in [Language, e.g., 'PHP 7.4' or 'ES5 JavaScript'] below:

[Insert Code Snippet]

Your task is to refactor this for a [Target Version, e.g., 'Node.js 22' or 'Python 3.12'] environment.

Requirements:

Improve Readability: Use modern syntax (e.g., 'Async/Await' instead of 'Callbacks').

Improve Efficiency: Optimize any nested loops or redundant O(n) operations.

Security Check: Identify and fix any vulnerabilities (e.g., 'SQL Injection' or 'XSS').

Documentation: Add JSDoc or Type Hinting to the functions.
Explain the 'Why' behind each major change you made."

📝 Fill in the blanks

Replace these placeholders with your own content:

[Language, e.g., 'PHP 7.4' or 'ES5 JavaScript']
[Insert Code Snippet]
[Target Version, e.g., 'Node.js 22' or 'Python 3.12']

How to use this prompt

1
Copy the prompt

Click "Copy Prompt" above to copy the full prompt text to your clipboard.

2
Replace the placeholders

Swap out anything in [BRACKETS] with your specific details.

3
Paste into GPT-4o

Open your preferred AI assistant and paste the prompt to get started.