Comment by seanmcdirmid
7 hours ago
Why do you orchestrate the AI manually? You could write a BUILD file that just does it in a loop a few times, or I guess if you lack build system interaction, write a python script?
> If it knows how to make the code more readable and / or better for performance by me simply asking "can you make this more readable and performant?" then it should be able to provide this result from the beginning.
This is the wrong way to think about AI (at least with our current tech). If you give AI a general task, it won't focus its attention at any of these aspects in particular. But, after you create the code, if you use separate readability and optimization feedback loops where you specifically ask it to work on those aspects of the code, it will do a much better job.
People who feel like AI should just do the right thing already without further prompting or attention focus are just going to be frustrated.
> Btw, this isn't about code formatting or linting. It's about how the logic is written.
Yes, but you still aren't focusing the AI's attention on the problem. You can also write a guide that it puts into context for things you notice that it consistently does wrong. But I would make it a separate pass, get the code to be correct first, and then go through readability refactors (while keeping the code still passing its tests).
> Why do you orchestrate the AI manually?
I have zero trust in any of these tools and usually I use them for 1 off tasks that fit well with the model of copy / pasting small chunks of code.
> But, after you create the code, if you use separate readability and optimization feedback loops where you specifically ask it to work on those aspects of the code, it will do a much better job.
I think that's where I was going with the need to re-prompt. Why not provide the result after 5 internal rounds of readability / optimization loops as the default? I can't think of times where I wouldn't want the "better" version first.
Make (or whatever successor you are using, I'm sure no one actually uses nmake anymore) is pretty reliable in filling in templates that feed into prompts. And AI is pretty efficient at writing make files, lowering the effort/payoff payoff threshold.
> I think that's where I was going with the need to re-prompt. Why not provide the result after 5 internal rounds of readability / optimization loops as the default? I can't think of times where I wouldn't want the "better" version first.
I don't think this would work very well right now. I find that the AI is good at writing code, or maybe optimizing code, or maybe making the code more readable (that isn't one I do often, but optimization all the time), but if I ask it to do it all at once it does a worse job. But I guess you could imagine a wrapper around LLM calls (ClaudeCode) that does multiple rounds of prompting, starting with code, then improving the code somewhat after the code "works". I kind of like that it doesn't do this though, since I'm often repairing code and don't want the diff to be too great. Maybe a readability pass when the code is first written and then a readability pass sometimes afterwards when it isn't in flux (to keep source repository change diffs down?).