Devil's advocate: perhaps you are holding a hammer complaining about rivets. If you used AI to interact with the code instead, you wouldn't have to wade through the mess and might have gotten what you needed fairly easily, except you're using the wrong tool for the job
Bad code is bad code, doesn't matter how it was generated.