I recommend reading this article for an example of how to do it right; it seems the trick is to resurrect Test-Driven-Development (TDD) and use test-results to provide a tight feedback loop for AI-code-generation so they can correct issues sooner rather than later.