It's been my experience that the quality of code is greatly influenced by the quality of your project instructions file, and your prompt. And of course what model you're using.
I am not necessarily a proponent of AI, I just found myself being reassigned to a team that manages AI for developer use. Part of my responsibilities has been to research how to successfully and productively use the tech.