# Refactoring prompts

> 3 bides on refactoring, each with the result it produced.

- [Explain inherited legacy code before you have to change it](https://promptabide.com/bides/explain-legacy-code-before-changing-it) — Developers who inherited code with no docs and no original author, and have a concrete change to make soon.
- [Write characterization tests for untested code before a refactor](https://promptabide.com/bides/characterization-tests-for-untested-code) — Developers inheriting untested functions who need a safety net before refactoring or fixing them.
- [Refactor legacy code behind a characterization test gate](https://promptabide.com/bides/refactor-with-tests-gate-for-coding-agents) — Developers asking an agent to clean up tangled code where any behavior change, even an improvement, would be a bug.

---

Canonical HTML: https://promptabide.com/topics/refactoring
Agent guide: https://promptabide.com/llms.txt · https://promptabide.com/agent-instructions.md
Sitemap: https://promptabide.com/sitemap.xml
