The place where I consistently see AI/LLMS/Agents/language-widgets-with-tools fail at making decent code (and more often configuration) is infrastructure.
The number of times it has spit out a python program where a much simpler bash script would do, is too many to count.
I have a pet theory that if you don't know what you really want, and aren't skilled enough to understand what you got, infra code is THE WORST.
Anecdote: I wanted a simple change to an ansible playbook today. GPT-6-Astra/codex came up with the most convoluted, brittle solution possible the first time, even though it was extending and already clear, idiomatic playbook. It took some amount of offensive and critical prompting to get it to use ansible's built in modules and tooling to do the same job - and do so with nearly 80% less configuration and like 1000% more human readability.
Some part of me harbours a sneaking suspicion that the "throw everything at it" ethos is by design, not as a defensive measure against crappy code, but as a way to ensure there's so much code and it's so convoluted orgs and operators (or developers) are stuck/addicted.
It's still a force multiplier - but it's by no means driverless, especially for existing/already-running infra.
I work as a (depressed lol) sysadmin apprentice in a small MSP company (I live in Europe) and boy do I got a story about Ansible playbooks: We made an offer to one of our clients to automate the deployment of software to their computers (this is a client with around 150-200 employees, depending on whether you count only the "core" employees or also security and maintenance staff). Before we made and implemented this offer using Ansible, they did not have any sort of Software Deployment tool whatsoever, everything got installed fully manually.
(they also used to have local admin rights on all of their client computers until one employee got phished and literally gave away their personal ID card via a webcam)
In any case, guess who got to implement all the relevant playbooks for installing software and what tool they used for it? Our company literally handed the job to an intern who had no IT background whatsoever. I say this not to be mean, he was legitimately just at our company because a government program required him to do an internship.
He used Deepseek (our company does not believe in purchasing LLM subscriptions, at least not for us normal employees) to write literally all of the playbooks for any kind of software that mattered to our clients.
Now, as I said before, I am only an apprentice, and I am certainly not a good programmer by any means, but I read through parts of the Ansible documentation and had worked with it before, and I understood enough to at least be able to roughly judge whether a playbook made sense or was just way too complicated and convoluted.
I had to help this intern out multiple times, because he hadn't yet understood that, in order to write a functioning playbook, you first had to somewhat understand how to deploy a piece of software on a single test machine using CMD or Powershell syntax with an according .exe or .msi.
He simply prompted, pasted the playbook and then reprompted with the error codes from the failed playbook until it somehow worked or until I had to help him out.
This took place in December or November of last year and the playbooks are mostly still pretty shitty if I am being honest.
I did take away an important lesson from this "episode", though: LLMs can be very usefuly for writing code, or in this case, Ansible playbooks, but only if you have a somewhat decent and basic grasp of how software installation works via CMD/powershell and if you took the time to read through and learn about at least the basic Ansible concepts.
Since I am only an apprentice (on paper and in terms of my knowledge and how I get paid, not in terms of how much I am expected to earn for the company), I have painfully experienced how important it is to possess a certain level of understanding about the infra-related code and scripts that you would like LLMs to write for you, because otherwise it very quickly spirals out of control and starts throwing everything at the problem, just as you described.