Don’t use chatGPT, for one…
Second, use an IDE like windsurf
Third, you should highlight code or mention files you want adjusted, then explicitly write what actions you want it to take. Your prompt is the most important part. Also, reject code and tell it that it fucked up, and try again