How do you prevent a new project starting from scratch
with the same employees from ending up with the exact
same tech as before?
You can't. I mean legally you can. But the court case to fully flesh this out are impossibly long. So safe to just not. The _former employee_ part is so damning that is just doesn't work.
If you have separate employees you _can_, if you avoid patents. Look up clean room implementation.
If you have separate employees you _can_, if you avoid patents. Look up clean room implementation.