Legacy Code Modernization
Modernize legacy JavaScript/TypeScript code to current best practices
Modernize this legacy code to use current best practices: ``` [PASTE_LEGACY_CODE] ``` **Current:** [WHAT_IT_USES — e.g., "class components, jQuery, callbacks, var"] **Target:** [MODERN_PATTERNS — e.g., "React hooks, native fetch, async/await, const/let"] Modernize step by step: 1. **Syntax upgrades** — var → const/let, callbacks → async/await, etc. 2. **Pattern updates** — class components → hooks, imperative → declarative 3. **API modernization** — jQuery → native DOM/React, XMLHttpRequest → fetch 4. **Type safety** — add TypeScript types where applicable 5. **Remove polyfills** — identify code that's no longer needed in modern browsers For each change: - Show the before and after - Explain why the modern approach is better (not just "it's newer") - Flag any behavioral differences to watch for Provide the complete modernized file, followed by a migration checklist to verify nothing broke.
How to Use This Prompt
- 1Copy the prompt template above
- 2Paste into Claude, ChatGPT, or Cursor
- 3Replace [bracketed placeholders] with your specific project details
- 4Iterate on the AI output to refine and customize the results
Part of 2 Collections
Debug Like a Pro
9 promptsSystematic debugging prompts that help you find root causes faster — from memory leaks to race conditions to performance bottlenecks.
View collection →Clean Code Rescue
8 promptsRefactoring prompts to turn messy codebases into maintainable ones — extract services, simplify conditionals, modernize legacy patterns.
View collection →More Refactoring Prompts
Related refactoring templates from the vault
Switch Statement to Strategy Pattern
Use this prompt to switch statement to strategy pattern with AI assistance
Code Smell Detector and Fixer
Identify code smells in existing code and get refactored versions
Code Review Prompt
Get a thorough code review with actionable feedback
Nested Conditionals Flattener
Use this prompt to nested conditionals flattener with AI assistance
You Might Also Like
Prompts from other categories that share similar tags
Strangler Fig Migration Strategy
Use this prompt to strangler fig migration strategy with AI assistance
TypeScript Type Wizard
Get help with complex TypeScript types, generics, and utility types
API Error Response Standard
Define a consistent error response format across all API endpoints
Code Documentation with JSDoc
Add comprehensive JSDoc documentation to existing code
Keep Exploring the Vault