PromptKit
← All prompts
PromptBuild · CodingPro

Refactor a legacy function to modern patterns

Old code that still works isn't necessarily code worth leaving alone — it's code that's gotten harder to touch safely with each year it's avoided.

Use it for
Anyone with an old function written in outdated patterns who wants it modernized without changing its behavior.

A function written years ago in an older style — callbacks instead of async/await, a deprecated API, patterns the rest of the codebase has since moved past — keeps working, which is exactly why it never gets updated until it becomes a genuine liability to touch. This prompt modernizes it to current patterns while explicitly preserving behavior, rather than a rewrite that quietly changes what the function actually does.

When not to use this

If the function is about to be deleted or replaced entirely, there's no point modernizing it first — this is for legacy code that's staying and needs to become safer to maintain.

Pro

The full prompt text is part of PromptKit Pro.

Unlock with Pro

Did this work?

The refactored version behaves identically to the original but uses current language features and patterns, with every behavior change called out explicitly if any were unavoidable.

Tested on claude-opus-5. Evidence status is draft; it moves to battle-tested only on recorded runs, never by hand.

Consense — Big decision? Compare and combine multiple LLM responses.