When to rewrite it
Almost never. Here's the almost.
The urge to start again is strong, especially with a vibe-coded project you've lost the thread on. It's usually the wrong call, and the reasoning behind that is worth understanding before you spend three weeks finding out.
Why rewrites disappoint
The existing code contains every bug fix, edge case and awkward workaround you accumulated. Most of them are undocumented and look like mess. A rewrite discards all of them, and you rediscover each one in production.
Meanwhile you have two codebases: the old one still running and needing fixes, and the new one not yet working. Progress on both is slower than progress on one.
And the new version will accumulate its own mess. The problem was rarely the code — it was the absence of a clear model of what the thing does.
Legitimate reasons
The stack is genuinely dead. Unsupported runtime, unpatched security holes, a framework nobody maintains.
The data model is wrong in a way you can't migrate around. Rare, but real. This is the one that genuinely justifies starting over.
It's small. A three-hundred-line project isn't a rewrite, it's an afternoon. The arguments against rewrites are about scale.
You're rewriting to learn, deliberately, with no deadline.
Do this first
Before deciding, spend a day reading it and writing down what it does. Very often the feeling of "this is unsalvageable" is really "I don't remember how this works", and the cure is a map rather than a rewrite.
I'm considering rewriting this. Here's the code: <paste or describe> What's driving it: <the honest reason> Push back on me: - Is the problem the code, or my understanding of the code? - What specifically would a rewrite fix that a refactor wouldn't? - What's in here that I'd lose and have to rediscover — edge cases, fixes, workarounds? - If I refactored the worst part instead, which part, and how long? Then give me your honest recommendation, including "rewrite it" if that's genuinely right.
If you do it, do it in slices
Never big-bang. Move one piece at a time, with both versions running, so you have something working at every stage. It's slower to start and much faster to finish.
"I want to rewrite it" and "I don't understand it any more" feel identical from the inside. Read it for a day before deciding which one you're experiencing.