Loop/Prompt Library / Build and ship it yourself
๐ฌ AI prompt: Refactor code safely with an AI agent
This code works but it's a mess, and I'm scared to touch it.
Copy this prompt
Refactor [file/module] to [measurable goal, e.g. 'split the 600-line function into units under 80 lines']. First run the tests and record the baseline. Then make one small change at a time without changing public behavior, rerunning the same tests after each. Keep only changes that pass. Stop after 5 rounds, when the goal is met, or if a change needs my approval. Finish with the diff summary, test results, and what you tried and rejected.
How to use it
- Open Claude (or Claude Code in your project folder).
- Paste the prompt and fill in every [bracket].
- Read what it changed or wrote before you keep it.
Not medical, legal or financial advice. The AI drafts; you decide and you press send.
More prompts like this
Build an app by describing it
I want to describe an app in plain English and get something working.
An AI coding agent for your real codebase
I already have code and want an agent that edits, runs and fixes it.
Take payments (cards or crypto)
How do I get paid for the thing I built?
Turn a bug report into a tested fix
A user reported a bug and I don't know where to start.
Give your AI agent a memory that lasts
My agent forgets everything between sessions and I keep re-explaining my project.
Get a second pair of AI eyes on every code change
I'm the only one reviewing my code (or my AI's code) and things slip through.
