7 ms·
Something I've been trying recently for non-throwaway code is extensive refactoring, without typing any code myself but by closely directing the coding agent.
by simonw 5mo ago
Something I've been trying recently for non-throwaway code is extensive refactoring, without typing any code myself but by closely directing the coding agent.
Prompts like "move the code relating to SQL query analysis into a new file", "look for opportunities to use pytest parametrize to remove duplication in that test", "rename method X to Y".
Early indications are that this is helping a lot with the problem where it's easy to churn out thousands of lines of code and not really have it stick in my head, even if I review every line of it.
Reviewing code and actively refactoring it is less tedious and more mentally engaging than reviewing code without changes.
If this was a human collaborator I'd be worried that I'm just creating busywork for them, but I don't care about busywork for LLMs!
The goal is to produce code that I understand and that I can remember just well enough that I get an updated mental model to help me productively make future decisions about the codebase.
- j_bum 5mo agoInteresting idea. It’s almost like a buffer space would be useful for code. I’ve been using tuicr for agent code reviews and have been enjoying that. I think I’ll try your idea as part of my workflow.
- docheinestages 5mo agoI think the best approach is active code review as the agent does small batches. Or letting it come up with a solution, testing if it passes or fails the desired outcome, then creating a separate fresh project and asking it to rewrite in small parts, and have it explain to you what and why it's doing to achieve each part.
- lanstin 5mo agoYeah my main current work repo I have five clones of it (de1.main, de2.main etc) each with an agent in a tmux session. The main priority change I will have up in my emacs gui with editing the files and reading and so on, but the side ideas that used to just get a line in the ideas or todo section of daily.org now sometimes get a claude working on it. As POC at the least.
- thfuran 5mo ago>Prompts like "move the code relating to SQL query analysis into a new file", "look for opportunities to use pytest parametrize to remove duplication in that test", "rename method X to Y". There’s a lot of overlap there with the sorts of things traditional automated refactoring tools can do approximately instantly, locally, and for free.
- mattacular 5mo agoWhat are some traditional automated refactoring tools that can do stuff like those tasks from the example?
- iLoveOncall 5mo agoLiterally any IDE or decent text editor?
- foobarbecue 5mo agoVSCode "rename symbol" is a basic example. Jetbrains products have way more and it's pretty great: https://www.jetbrains.com/help/idea/refactoring-source-code.html https://www.jetbrains.com/help/idea/refactoring-source-code....
- swatcoder 5mo ago??? Mature workflows for those kinds of tasks have been mostly ubiquitous across professional-grade engineering tools like those from JetBrains or Visual Studio itself for longee than many people here have even been working in the trade. It's clearly not the case for simonw, but much of what many people task AI tools to do foe them are only a novelty for the "VS Code"-type users who stubbornly refused to explore more professional-grade paid tools in the past. Yet for many tasks, those mature paid tools provided reliable and efficient features that make the AI approach look like an expensive, slow, and dangerously nondeterministic regression.
- simonw 5mo agoOh I'd definitely classify myself as a "'VS Code'-type users who stubbornly refused to explore more professional-grade paid tools in the past." I've never liked the larger IDEs - VS Code only won me over because it was indistinguishable from a lighter text editor at first, and the IDE tools then emerged slowly as I used it.