ThinkWithPrompt by SynotticThinkWithPrompt

Refactor code to be cleaner and easier to maintain

Improves structure, naming, and design without changing behavior.

Software DevelopmentRTFStandardCodingWritePlanFill-in Template

The prompt

Refactor this code without changing its behavior. Language: [LANGUAGE] Code: [PASTE] Goals: [readability / testability / remove duplication / split a large function / remove dead code / apply a pattern] Constraints: [public API must not change, performance limits, style guide] Process: 1. List the code smells you see, by priority. 2. Propose a refactoring plan in small, safe steps. 3. Show the refactored code. 4. Explain each change and why behavior is preserved. 5. List tests I should run (or write) to confirm nothing broke. If any part needs a behavior change to fix a bug, flag it separately — don't silently change it.

Highlighted [brackets] are blanks to replace with your own details.

Fill in the blanks and use this promptMore Software Development prompts

What to fill in

  • LANGUAGE
  • PASTE
  • public API must not change, performance limits, style guide

How this prompt is built

This prompt follows the RTF structure (Role, Task, Format). RTF tells the model who to be, what to do and what shape the answer should take. It is the quickest structure that still gives noticeably better results than a bare request.

Related prompts

Find more prompts like this