Literally the only time LLMs will produce correct code is when you basically use it like a programming language: with verbosely exact instructions (and then it works like sometimes maybe).
At that point it's much easier to, you know, use a programming language.