♻️

Legacy Code Modernization

Modernize legacy JavaScript/TypeScript code to current best practices

prompt template
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

  1. 1Copy the prompt template above
  2. 2Paste into Claude, ChatGPT, or Cursor
  3. 3Replace [bracketed placeholders] with your specific project details
  4. 4Iterate on the AI output to refine and customize the results