EasyFileMagic logo
Open a tool
All AI prompts
Coding & Dev

Refactor messy code with reasoning

Cleaner version with a diff-style rationale.

The prompt

Refactor the code below for readability and correctness. Requirements: keep the public API identical, no new dependencies, add types where missing. Output:
1. The refactored code in one block.
2. A bulleted 'what changed and why' section.
3. Any bugs you fixed along the way.

```
[PASTE CODE]
```

Paste it into ChatGPT, Claude, Gemini or Midjourney and replace anything in [SQUARE BRACKETS] with your own details.