How do you clean up a messy vibe coded prototype without breaking what already works?

Getting a working prototype up in an afternoon with AI is easy now but by the end of the day you usually end up with a giant 800 line file full of duplicate logic and weird workarounds

Whenever I ask the agent to refactor a working file into smaller modules it almost always breaks some subtle edge case that was already working fine

Do you refactor bit by bit with tests around each piece or just leave ugly working code alone until you actually need to touch it?

34 views

Add a comment

Replies

Best

first i get it to write down what the file does today, weird edge cases too. then every split gets checked against that list

The report carried a confident number nobody had actually measured. It took a day to find out it was just a placeholder the agent faked. It looked completely functional. Before cleaning up prototype logic, outputs have to tie back to raw data, not hardcoded hallucinations.

My experience -- be sure to get all the backend requirements clarified first, like the databases you need and how they will relate to one another, and what security levels you need to ensure data remains safe. Focus on outlining these before going straight to front-end design.