5/29/2026 at 1:01:38 PM
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.
by simonw
5/29/2026 at 1:12:24 PM
>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.
by thfuran
5/29/2026 at 1:45:53 PM
Yea, when I read about people using AI with prompts like that, my first thought is, "Wow, that's like copy/paste, but instead of Ctrl-C/Ctrl-V, it's round-tripping to a server and using GPUs to do it." What's next? "Claude, rename the function doFoo() to performBar()"?by ryandrake
5/29/2026 at 5:43:50 PM
Sometimes when I'm in the CLI and don't have a code editor open, I do this. Yes, it's lazy. But I also trust the model to check and update related things (tests, etc., while applying some judgement).It's not unlike some managers who tell their teams to do something trivially easy that they could have done themselves.
(I'm not saying this is ideal and I'm not defending my laziness. It's just the current state of things.)
by jannyfer
5/29/2026 at 4:44:40 PM
Yes, it's copy pasting but it's tedious and it adds up fast.Even the doFoo to performBar is tedious because you need to catch all instances and your find/replace script strategy might have unintended victims.
In this case indeed, it's just much more convenient.
by RealityVoid
5/29/2026 at 6:06:38 PM
The languages I use the IDE literally does this for you, perfectly, deterministically.And instantly, certainly when compared to AI.
by mattmanser
5/29/2026 at 9:37:51 PM
That doesn't update documentation or comments referring to the function. I prefer search-and-replace.by Kiro
5/29/2026 at 10:42:26 PM
Sure it does. IntelliJ will do that just fine.by thfuran
5/30/2026 at 6:55:25 AM
Sounds like it doesn't catch everything and they recommend search-and-replace. From their docs: "For example, if you want to replace a variable name with a new name for a large project, use the Replace in path instead of the Rename refactoring since your variable can appear in the config files as well."by Kiro
5/29/2026 at 7:32:17 PM
If IDE can do it, a custom tool can do it to. IntelliJ even have a built in MCP server ready to help any agent with such tasks.by miroljub
5/29/2026 at 6:32:14 PM
Which languages, just out of interest?by simonw
5/29/2026 at 7:08:59 PM
That should be most? Unless you do very weird stuff like using strings in JS to call functions, or reflection in C# and similar very special cases, any IDE can handle that.by Semaphor
5/29/2026 at 7:54:00 PM
Kotlin, Java, Python, C#, Typescript. Anything that has a trustworthy and consistent pointer between code.Ruby would be the one exception I’ve worked on in my head, and for they language, ctrl+f *usually* (but not always) finds the rest.
Ruby is particularly magical with being able to evaluate methods from dynamic strings into running, production code[0]; but otherwise, languages and capable IDEs, like IntelliJ and Visual Studio just support that. I don’t happen to use VS Code, but I assume it has basic refactor, too.
[0] Devise. https://github.com/heartcombo/devise/blob/main/lib/devise/co...
by t-writescode
5/29/2026 at 7:24:44 PM
Java has very good refactor support. I use jdt.ls which is eclipse based, but I've heard intellij is even better. I've wished for similar refactor actions in other langs.by rustyminnow
5/29/2026 at 8:56:24 PM
Yeah, VSCode will rename functions and vars perfectly, using the language semantics. It'll handle changing imports in python if you change file names.Like you said, it's basically instant.
by habinero
5/29/2026 at 4:55:48 PM
don't LSPs and IDE's help with that?by fridder
5/29/2026 at 6:20:28 PM
I'm right there with you - prefer classic, deterministic tools wherever possible - but there's a limit. E.g. it's easy to rename a single getter from classic enterprise java `Foo getFoo() {..}` to a modern style `Foo foo() {..}` ... but to rename dozens of getters/setters across hundreds of classes is still tedious.Even harder would be to update your setters from `void setFoo(Foo f) { this.foo = f; }` to fluent-style `Parent foo(Foo f) { this.foo = f; return this; }` - I'd be surprised if there's an LSP action for that at all. (I'd love to be proven wrong though)
by rustyminnow
5/29/2026 at 9:15:13 PM
Not sure about LSP, but IntelliJ has had a "structural search and replace" feature for many years, and it can easily handle changes like the one in your second paragraph. It's conceptually like a regex search, but it matches language-specific AST subtrees instead of character sequences.by teraflop
5/29/2026 at 11:03:41 PM
I've found that for super large but simple refactors, codex and Claude struggle and will just quietly stop doing what you asked it if it's a long running task.I actually had better luck asking codex to write temporary sed scripts based on the requirements then apply them.
by yonaguska
5/29/2026 at 7:14:58 PM
Perhaps, but do they handle all the other aspects of refactoring, too?by christoff12
5/29/2026 at 8:58:47 PM
Yes, LSPs can supply a variety of refactoring commands (rename, extract to, inline, etc.) that the LSP server can implement directly, deterministically, locally.by deathanatos
5/29/2026 at 1:55:16 PM
Here's the loop for a successful small refactor (anything beyond a rename that could be handled entirely by an IDE):1. Find the code you want to change
2. Run the tests to confirm that test coverage is good for the starting point
3. Track down everywhere else that might call or interact with that code
4. Update the tests (red/green TDD)
5. Alter the code
6. Update the things that call the code
7. Run the tests again
8. Apply linters/formatters
9. Address any feedback from linters
10. Check to see if any documentation needs updating and do that
11. Land a commit with a descriptive commit message
I can get all of that done with a coding agent with a single sentence prompt - especially if it's already in a session where it knows that I do "red/green TDD".
... and then I can work on something else while the agent is churning through those steps.
by simonw
5/29/2026 at 2:15:31 PM
My point is that all these steps can be done very quickly by even a junior developer who knows emacs or their IDE, in a codebase with existing lint/format/test automation, without even taking their hands off the keyboard. You're already in your IDE, you can probably do it just as fast there. I don't see the cost/benefit of spending tokens and hitting a server for this kind of work.I guess the difference may be in people's mode of AI working: Do you primarily develop in your IDE or a bunch of terminals running vim, and occasionally fire up claude to do more complex things? Or do you primarily develop in a long-lasting claude terminal, and occasionally tab over to the IDE to watch/codereview? In other words: What dev tool is on your primary monitor and what's on your secondary monitor? It's getting hard for developers in one camp to discuss coding and see eye-to-eye with developers from the other camp.
by ryandrake
5/29/2026 at 2:24:02 PM
Those 11 steps would probably take me 15 minutes.There are a lot of small refactorings that I wouldn't consider to be worth 15 minutes of my time, so I wouldn't do them.
Outsourcing those to an agent means I don't have to make that tradeoff, which means I can get better quality code.
But yes, for a lot of my work I'm now a Claude Code / Codex first developer. I run Zed so I can navigate the code and occasionally make small edits.
by simonw
5/29/2026 at 4:33:01 PM
When you make the change on an IDE, you:1 - Find the code
4 - Move the code
10 - Change the documentation
You don't do the other steps because it's deterministic and always correct.
by marcosdumay
5/29/2026 at 4:40:36 PM
Presumably you're talking about statically typed languages? I mainly work in Python and JavaScript.I don't trust any refactors until I've seen the test suite pass.
(OK, sure, "rename method" might be OK, but most of my refactors and design changes are more interesting than that.)
by simonw
5/29/2026 at 8:13:54 PM
Shift-F6 (rename refactor) is my goto, and what I miss most in a code editor (maybe LSPs support that today for most languages).It also takes away the mental tax burden of thinking up good names for things when writing out code quickly on the first pass.
Works very well with PHP (in PHPStorm), and I'd expect somewhat similar reliability in PyCharm on a Python project with some type annotations (or maybe even with none?).
With the advent of LSPs and treesitter parser approach I wished to see higher level refactorings possible by now, but innertia in tooling space died down as most focus switched to LLMs.
by mhitza
5/30/2026 at 3:12:10 PM
The point of good names is not just readability but also to sharpen your cognitive model of the solution. That moment when you realize you don’t know what to name a thing is a valuable prompt to deepen your thinking a bit.And I sometimes prefer searching for the method names and changing them one by one (find-grip-dired followed by query replace) just to see where all the code is being used, if anything looks bad, if there is some opportunity for code reduction, etc. not that I don’t also prompt Claude to rename things, or better yet make sure all the SQL commands log enough etc.
by lanstin
5/29/2026 at 10:02:00 PM
Use the Python type hints. You don't need to be specific, they help a lot even when you have some 'anys' inside composed types.Anyway, Python tools are usually capable of refactoring any code that isn't reflective or self-rewriting. There are places for those two, but those are very few and the AI won't have any idea how to work at those places either.
JavaScript is a problem.
by marcosdumay
5/29/2026 at 8:37:05 PM
100% agreedby steine65
5/29/2026 at 3:55:27 PM
I develop with a very custom neovim using only the keyboard. Over the years I've become really fast. And yet I'm doing it less and less myself and ask the LLM even small things. In my case the switch happened naturally as I moved to local AI and fully integrated the coding harness into my tmux + neovim workflow. Neovim becomes more of a project and file explorer, together with lazygit to diff review the changes.by regexorcist
5/30/2026 at 6:55:42 AM
Yes, and ideally in this case LLM would be translating your intent into a series of invocations of specific APIs or scripts to do the transformations, and correcting for unexpected failures or realizations.Because it's often not just Ctrl-C/Ctrl-V. It's Ctrl+C/Ctrl+V, except today paste is Shift+Insert, and in the other project it's usually C-y, and you actually need to check one more place for full list of things to copy, and then you discover one case needs a minor transformation, ...
LLMs can handle such annoying details intelligently.
> What's next? "Claude, rename the function doFoo() to performBar()"?
Yes. Such prompt can be issued in many equivalent ways, and works across environments, contexts and tool stacks. I can issue it from the phone, in form of "also doFoo -> perform... reame", and it will work even on Lisp code inside Word documents it accesses through Google Drive.
by TeMPOraL
5/30/2026 at 8:53:55 AM
For one function, yes. I used Copilot to do massive refactoring on my project recently - switch to a new JSON library, completely switch web frameworks, etc. The stuff I needed to do but was putting off forever.And even with small things, it's just toil. You can start a small update and then realize with all the back and forth of edit/test/edit/test that you've been stuck in the OODA loop for 40 minutes you will never get back.
by renegade-otter
5/29/2026 at 9:02:22 PM
It is indeed. At individual level thinking folks like yourself can think and do better of course. But all these AI companies are now heavily leaning on enterprises. And there I see function renaming via AI, or extracting column from excel sheet is not rhetorical but normal day to day task.by geodel
5/29/2026 at 9:29:00 PM
> What's next? "Claude, rename the function doFoo() to performBar()"?As an engineer: of course not, keyboards are more efficient.
Also as an engineer: of course, “tea, Earl Grey, hot”, or what are we even working for?
by bonesss
5/30/2026 at 3:15:40 PM
My son bought a Japanese water heater to keep a liter of water at just below boiling at all times. For my 4 pm Ceylon tea break, milk no sugar, I refuse to use the prefab water; preferring to stick with my routine of boiling the water, to a rolling boil, adding it to the tea bag in the cup, and letting it steep. One doesn’t take tea to maximize efficiency but to pause and plan, or just let go the reins on attention and see what happens.My son loves the always ready hot water.
by lanstin
5/30/2026 at 11:39:21 AM
"Pft, you use an entire IDE inside an electron web browser eating 16GB of memory to rename a function instead of a simple regex? What a waste"by vitally3643
5/31/2026 at 7:05:27 AM
Firstly, yes, software bloat is a waste.Secondly, no, it's not even comparable with AI basically delaying electricity decarbonization on entire continent-sized countries, requiring entire coal-fired power stations and stealing all the ram and storage of the planet to build specific and short-lived hardware that will last few years and will be thrown away very fast.
by jraph
5/29/2026 at 1:52:40 PM
Sure, and sometimes the coding agent will even use one of those refactoring tools on my behalf.Getting them to run ast-grep is really fun, especially when it saves me from having to memorize that syntax myself.
by simonw
5/29/2026 at 1:19:49 PM
What are some traditional automated refactoring tools that can do stuff like those tasks from the example?by mattacular
5/29/2026 at 1:36:16 PM
???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.
by swatcoder
5/29/2026 at 1:56:50 PM
Oh 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.
by simonw
5/29/2026 at 4:48:37 PM
I used JetBrains IDEs for years. The refactoring tooling was fancy find-replace as far as I recall? Pretty cool in 2015, though.by duggan
5/31/2026 at 7:50:13 AM
It goes deeper than this, you have features like rename function / change method signature that will update your whole code base and even suggest applying such changes to related(-looking) functions.by jraph
5/29/2026 at 6:26:53 PM
https://www.jetbrains.com/help/idea/refactoring-source-code....This has a list, but some of them that I've used extensively:
- Rename anything, can also do smart renames that apply patterns, deal with capitalization differences, pluralization, etc
- Move function, constant to a different file
- Change function signature, including adding, removing, reordering, and renaming arguments
- Turn a chunk of code into a constant, variable, or function, including replacing other similar patterns or calculations with the new constant/variable/function
- Inline any of the above.
- Replace a class with an interface, have the class implement the interface... same with field accesses
- Move functions up/down the type hierarchy
I'm sure there's others. This has all been there for at least a decade.
by rendaw
5/29/2026 at 1:23:30 PM
VSCode "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....by foobarbecue
5/29/2026 at 1:40:03 PM
Eclipse IDE since like 2001by hack1312
5/29/2026 at 1:23:03 PM
Literally any IDE or decent text editor?by iLoveOncall
5/29/2026 at 1:24:43 PM
Yeah I do find myself leaning back into those tools. For awhile I’d just prompt to rename something. But when it’s my own tokens I’m paying for, I prefer the fast and free option :)by cautiouscat
5/30/2026 at 12:35:15 AM
Traditional automated refactoring tools cannot read multiple functions and, in one go, determine what subsets of all of those functions relate philosphically to the SQL queries (not just the actual queries themselves) and pull those out into a new coherent interface in a new file.by quietbritishjim
5/29/2026 at 9:43:27 PM
> traditional automated refactoring toolsany recommendations?
by NooneAtAll3
5/29/2026 at 10:45:17 PM
Whatever the most popular IDE is for any given language, probably.by thfuran
5/29/2026 at 1:37:38 PM
You just went too far. Go back to the subscription.by keybored
5/30/2026 at 10:28:38 AM
which tools?by sharts
5/29/2026 at 1:11:23 PM
I 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.by docheinestages
5/30/2026 at 3:19:57 PM
Yeah 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.by lanstin
5/29/2026 at 1:05:32 PM
Interesting 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.
by j_bum