The best code I've written with an LLM has been where I architect it, I guide the LLM through the scaffolding and initial proofs of different components, and then I guide it through adding features. Along the way it makes mistakes and I guide it through fixing them. Then when it is slow, I profile and guide it through optimizations. So in the end, it's code that I know very, very well. I could have written it but it…
I had a very complex piece of logic, with many many many moving parts. So I implemented many paths of that logic by hand, every one with their own specifics. Every path took something like 200-400 lines of code.
When this was done and correct. It was difficult to see the moving parts through the forest. Some code was similar but still a bit different, and hard to think about and spread in many places.
I put everything into an Llm and asked about isolation, architecture and refactoring.
And it actually gave me pretty good abstractions and a good architecture. It didn't include every possible path, but was easy enough to be continued by hand.
It's not that I would not have tought about it. But it was easier that way, and probably my handcrafted solution would be very similar (+headache).
Of course, I reviewed it extensively, and reimplemented every missing path and corrected the ones that were buggy now by hand.
For the experiment, I played with agents to fill the missing parts, it was a disaster :)