PromptAI
Appearance
Coding

Refactor, but prove nothing broke

Refactoring without tests is gambling. This makes the model show its safety reasoning.

Refactor this code for readability and maintainability WITHOUT changing its behavior.

```
[PASTE CODE]
```

Rules:
1. List the specific smells you're fixing (and the ones you're deliberately leaving alone)
2. Show the refactored code
3. Prove behavior is unchanged: walk the same 3 inputs through the old and new versions step by step
4. If anything in the original is ambiguous, say so — don't silently pick an interpretation.
Open in ChatGPT Claude

Works with Claude · ChatGPT · Gemini — replace the [bracketed] parts with your own details, keep the structure.

Want a new tested prompt every week? The PromptAI briefing delivers the AI story that matters, the paper everyone's citing and a prompt worth stealing — subscribe free →

More prompts like this