I found this tip for coding with LLMs that seems to work well. Instead of asking them to generate code right away, follow these steps:
1. Ask it if it understood the requirements and ask it to propose a solution, but don’t code it yet.
2. Ask it to reflect on propose solution, is there a better way of handling it? Propose a better way but don’t code it yet.
3. (Optional) ask it to reflect again on the updated proposal to see if this is really the best way to do it, if not, propose changes and ask it to explain why those changes are better.
4. Finally ask it to code the solution.
9 times out of 10 it produces way better results.