One thing I’ve noticed is that AI agents are much better at writing code than changing code. One approach that sometimes works for me is to write a spec and then have AI build it, and then iterate by updating the spec to clarify everything that wasn’t what I wanted, deleting all of the code, and having a new AI agent try again. Or if you’re happy with some files and not others, delete everything you’re not happy with and keep the pieces you are happy with.
You can save some loop time by making your prompts much more detailed, and using plan mode to check if your prompts have the amount of context you think they do. If I actually care about the output of a coding session, my prompts get huge, covering what I’m trying to do, why, what I’m not trying to do, hard constraints, relevant code to read, how I want particularly tricky pieces done, high-level design, everything I can possibly think of that might go wrong, and so on. Spending 10 minutes just brain dumping can save you a lot of time later.
My CLAUDE.md also has a bunch of standard things (always use strict typing, which libraries and linters I prefer, DRY advice that agents sometimes follow, etc.).
Even then, you probably won’t get 100% perfect code, but it should at least be in a state where improving it is easier than writing it from scratch (or for me, easier than finding the motivation to write code from scratch).
One thing I’ve noticed is that AI agents are much better at writing code than changing code. One approach that sometimes works for me is to write a spec and then have AI build it, and then iterate by updating the spec to clarify everything that wasn’t what I wanted, deleting all of the code, and having a new AI agent try again. Or if you’re happy with some files and not others, delete everything you’re not happy with and keep the pieces you are happy with.
You can save some loop time by making your prompts much more detailed, and using plan mode to check if your prompts have the amount of context you think they do. If I actually care about the output of a coding session, my prompts get huge, covering what I’m trying to do, why, what I’m not trying to do, hard constraints, relevant code to read, how I want particularly tricky pieces done, high-level design, everything I can possibly think of that might go wrong, and so on. Spending 10 minutes just brain dumping can save you a lot of time later.
My CLAUDE.md also has a bunch of standard things (always use strict typing, which libraries and linters I prefer, DRY advice that agents sometimes follow, etc.).
Even then, you probably won’t get 100% perfect code, but it should at least be in a state where improving it is easier than writing it from scratch (or for me, easier than finding the motivation to write code from scratch).