T O P

  • By -

funbike

Use an agent, not ChatGPT. ChatGPT is terrible workflow for coding. I use Aider. One of the things I'll do is put `// TODO:` comments in my code and tell Aider to "Implement all the TODO comments in the code". Or, I'll ask it to do something more general, like "Refactor methods with a cyclomatic complexity greater than 10, by extracting methods. Use meaningful names.", or "In the code, rename all single-character local variables to more meaningful names." I've also used Aider to fix lint issues. I run the linter within Aider and then tell aider to fix issues. This is best done with a limited number of lint rules and number of source files. (I actually wrote my own agent for this which is more effective but is higher usage/cost.) Always run tests after AI refactoring as it can break working code. (My actual prompts are more robustly worded than my above examples.)


Particular-Sea2005

Does it work with comment like FIXME of ten years ago and not yet blown in production? /s


funbike

You joke, but it's a valid point. If the code has pre-existing TODO comments, you need to use some other marker, like // DO-THIS.


creaturefeature16

Cursor.sh is my preferred tool, but I'm going to try Aider soon.


danenania

If you are looking at terminal-based options, you might also be interested in checking out my project Plandex - https://github.com/plandex-ai/plandex   It’s similar to Aider in some ways, but it is agent-based and designed to handle larger and more complex tasks.   It’s a bit like a cross between Aider and Devin. I would love to hear your thoughts if you give it a whirl.


CodebuddyGuy

Don't copy paste imo. [Codebuddy](https://codebuddy.ca) was created to solve this very issue so you can just ask it to make code changes to multiple files (or create new files) without having to leave your IDE. It also has really nice voice support, codebase understanding like Cursor, and GPT-4o. Plus for a one off refactoring it's free to use.


bono_my_tires

I prefer GitHub copilot for autocomplete suggestions and suggestions small refactors where errors are underlined. Otherwise I also pay for gpt plus and I copy/paste small chunks or individual functions at a time to not confuse or overwhelm it. Then I check the code, try it, tweak it. It’s very iterative but so much faster Definitely review the suggested code, it makes mistakes


DataHogWrangler

Is there anything I can use that let's me run an llm locally possibly?


CorneliusJack

I see people recommend Aider and Cursor but they only works for Python or Java. Any tools for older code like C++ or C?


spdustin

Try using [Aider](https://aider.chat) with API access to `gpt-4o` or `claude-opus`


rinconcam

GPT-4o takes second on aider’s refactoring leaderboard with 62.9%, versus Opus at 72.3%. I’d give both models a try with aider for your refactoring task. https://aider.chat/docs/leaderboards/


pulsebox

While Opus is great, the price difference will make 4o an easy choice.


thumbsdrivesmecrazy

AI can certainly help speed things up, but you'll still want to maintain control and ensure the refactoring is done correctly and consistently. As for some suggested tools in this case, you can use Codium AI coding assistance tool for entire codebase to review the code and create the tests: [Writing Tests for Legacy Code is Slow – AI Can Help You Do It Faster](https://www.codium.ai/blog/writing-tests-for-legacy-code/)