Hacker Newsnew | past | comments | ask | show | jobs | submitlogin

>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.

 help



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()"?

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.)


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.


The languages I use the IDE literally does this for you, perfectly, deterministically.

And instantly, certainly when compared to AI.


Which languages, just out of interest?

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...


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.

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.

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.

don't LSPs and IDE's help with that?

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)


Perhaps, but do they handle all the other aspects of refactoring, too?

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.


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.


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.


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.


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.)


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.

What are some traditional automated refactoring tools that can do stuff like those tasks from the example?

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.


???

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.


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.


I used JetBrains IDEs for years. The refactoring tooling was fancy find-replace as far as I recall? Pretty cool in 2015, though.

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....

Eclipse IDE since like 2001

Literally any IDE or decent text editor?

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.


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 :)

You just went too far. Go back to the subscription.



Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: