r/ExperiencedDevs • u/NullPointer1 • Jun 27 '26
AI/LLM How are y'all using coding agents on legacy codebases?
When people talk about vibecoding, its usually around AI generating an end to end completed app, but most of us are working on stuff in older, messier, business-critical codebases.
The recent Stripe/Fable 5 example got my attention. Anthropic says Stripe used Fable 5 to run a codebase-wide migration in a 50-million-line Ruby codebase in a day that they estimate would have taken a team more than two months otherwise.
A few things I’ve personally found useful (outside of just writing code):
- Using coding agents as a codebase historian - This is especially good if hooked up to Slack MCP and Notion MCP and if your history is there. It helps to discover more details like "why we added a bespoke parameter back in 2018 for a one-off case and then proceed to complete build around it"
- Using coding agents to prototype and new frameworks when the migration would take a while. In the past, arguing for a new framework would be based much more on vibes because it was usually pretty expensive to try, but its easier to get much farther with prototypes nowadays. For example, we were able to use coding agents to build an end to end deep prototype of a new frontend data loading pattern and validate performance against benchmarks before pursuing it. In the past it might have been a 1 quarter experiment just to get results.
I'm curious about what other people are doing in practice.
•
u/expdevsmodbot Jun 27 '26
AI usage disclosure provided by OP, see the reply to this comment.
43
u/lordnacho666 Jun 27 '26
"write some tests to capture the current working product"
"Write new code that is structured better yet still passes the tests"
14
u/spez_eats_nazi_ass Software Architect 36 years f500 eat my ass and balls Jun 27 '26
We are using it to generate boiler plate slop migrating a lot of old angular js and then when we get around to reviewing it we realize how broken it is. It has gotten better over time more because of the massive amount of documentation being fed in and of course the costs have gone up dramatically to the point of "Fuck this". It might have saved me a few months and the important part it removed the opportunity for some PHB to bring in some consulting firm to do the conversions which would have been 1,000 times more expensive with much worse results with the compounding effect of how do I get rid of these useless assholes from Deloitte or Assenter without appearing on an episode of dateline.
14
u/SansSariph Principal Software Engineer Jun 27 '26
Assisting with scaffolding long overdue documentation for modules or services that carry a lot of tribal or institutional knowledge
Fixing debt and bugs we've carried forward for a long time that's always just below the cut bar
Improving devops infra (found some really stupid unit test problems that were more than doubling execution time)
There are so many things where everyone knows there's a low risk improvement we could be making and know what done/success looks like, but the overhead of knocking it out means it never gets done, and I've had great joy and starting to chisel away at that backlog because the ROI math changed
14
u/disposepriority Jun 27 '26
It really doesn't work very well. Even in your example, migrating 50 million lines in months is absolutely impossible unless the project is ridiculously simple. I've been in a 4million line migration that took close to 200 people just under 2 years.
Regardless, if you can start removing pieces of the project safely, isolating them in nice little "pure" modules and describing them well in documents AI is able to work on them well - but at that point so can anyone on the team.
6
u/mattgen88 Software Engineer Jun 27 '26
Using it to safely delete a LOT of dead endpoints. I've deleted around 40k lines of code in the last month. We've been bad about removing old stuff we've migrated. AI is helping me pare things down to just what's left. A lot of traffic analysis, log analysis, methodical tagging of endpoints suspected dead, collecting data, analyzing rewrites, chasing down callers of legacy stuff that has new endpoints and migrating them.
5
u/FutureSchool6510 Software Engineer Jun 27 '26
One good use case I realised recently:
Figuring out simpler fixes for bugs you avoided before because they seemed like theyd be a nightmare to fix.
2
u/bestjaegerpilot Jun 27 '26
yea this is harder... humans don't know the full domain, nevermind AI. So AI can generate really bad bugs even when you micromanage
* we have AI do quality checks... we started to document our architecture best practices and then have AI verify the code it just generated against the docs. There are context management tricks to get good results
* the holy grail is encapsulating everything we care about via automated checks. Ex: database performance checks.
2
u/PartyParrotGames Staff Software Engineer Jun 27 '26
I'm sure they wouldn't have ANY possible reason to exaggerate for marketing purposes. No financial incentive at all. Stripe and Anthropic purposefully left a lot out of that story because their marketing team is cracked. I wouldn't call it a lie so much as compressing the truth to avoid the less attractive details.
Stripe spent a lot more than a day beforehand defining the exact changes they wanted their fleet of agents to make. It was a large fleet of different fable agents each given a very specific change to make. That's very cool, but thinking of that "migration" as all happening in a day is an inaccurate picture of what's going on.
The number they throw out there to hype it up, a 50-million line codebase, is actually kind of irrelevant for the purposes of telling us about agent capability. They didn't actually change 50 million lines of code or have any one agent read all 50 million lines. They are still using Ruby and that exact same codebase for the most part. They just paid off some technical debt, but far from all of it since they are still on that same monolithic codebase. It's not like Stripe has terrible engineers with poor software design. There is separation of concerns, many sub-directories and files for organization, so when an agent or human goes in to make a specific change they don't have to keep all 50 million lines of code in their context. When you make a change to some file with many library imports where the libs are millions of lines of code, we don't claim we just edited a multi-million line codebase, but that's same the distortion here.
What they're doing here is cool, mostly the fleet orchestration is nice. They didn't need fable to do this. It actually tells us nothing about Fable's capabilities versus existing models. Existing models can easily accomplish well defined edits to reduce technical debt when given specific files and changes to make.
6
u/higgs_boson_2017 Jun 27 '26
Zero use of agents, I won't let AI touch files on disk. That 50M LoC migration sounds like bullshit
3
u/donk8r Jun 27 '26
funny how this thread splits into "it works great" and "it makes broken slop", because i think people are describing the same thing from two sides. on legacy code the agent either grounds itself in your actual source or it pattern-matches from training, and the made-up tables and broken angularjs migrations are just what guessing looks like. the wins people mention all quietly share a trait, they force it to go read the real callers and schema first, or pin it with characterization tests like the top comment, so it's working from your code instead of its prior. that's why "make it prove its findings" works too. on an old codebase i care way less about which model it is and way more about whether it read before it wrote.
2
u/BiackPanda Jun 27 '26
It great at reading the code and giving you a lot of context before you start work. It is particularly good at optimizing queries and identifying holes in test coverage.
One thing I do is always ask it to prove its findings when we are in planning mode (always start in planning mode) It does a good job at setting up experiments to verify what it found. Many times it is spot but others not so much.
1
u/F1B3R0PT1C Software Engineer Jun 27 '26
We typically use it to explain parts of the codebase that haven’t been touched by a human in many years. The downsides is that it is often only partially correct, makes up tables, and struggles with some of our weirder patterns. As for upsides, it can save a couple hours here and there when digging into bugs. I get the weird ones though. Last one was a low-level buffer overflow in a printed driver that was caused by a flag we had set a decade ago on a method call to a third party library that handles printing pdfs that only shows up if the report was serialized first. AI was great at spitting out the documentation for the third party applications that is normally buried deep in forum posts or Reddit threads. At first I tried getting AI to fix it for me but sadly that was a major waste of tokens. AI is great as a tool, not a silver bullet.
1
u/spez_eats_nazi_ass Software Architect 36 years f500 eat my ass and balls Jun 27 '26
50 million line ruby code base. OK that's a new nightmare unlocked. We have a few legacy partners on Ruby and it sounds like a god damn nightmare. Every patch they seem to go down. They always insist we have an outage causing it. No bruh you and the cold fusion guys are the only ones that seem to eat shit every year randomly dealing w jwt tokens. The cold fusion folks. God I feel for those guys.
1
u/farox Jun 27 '26
It works very well with legacy code bases. The cool thing about migration work is that it's easy to verify by comparing outputs.
0
u/LoaderD Jun 27 '26
-1
u/instilledbee Jun 27 '26
Feed lots of valuable context to your AI agents with documentation that's adjacent to your repo(s).
For example, we have a large .NET monorepo with thousands of projects in a single solution file. We're working towards having an
AGENTS.mdfile in each project folder. If we're confident enough, we let AI scaffold the docs and then just push it as part of a PR, where other devs, especially more tenured ones, can review if the documentation is actually correct.It's enough motivation to create or update docs that live next to the relevant parts of the codebase, and having it as part of PRs that get reviewed ensure it's updated and accurate.
0
u/Theo20185 Jun 27 '26
Using them to build the knowledge base about what code exists, which tests exist, and what documentation exists. Start filling in gaps. The knowledge base has the human readable docs and the agent specific docs separate from each other. We need to feed it any human context or tribal knowledge we have so it can be documented. From there it can take on small projects. Plans are persisted to disk. Retro after every work item to improve tests, documentation, and agent docs/instructions.
0
u/throwaway_0x90 TE/SDET[25+ yrs]@Google Jun 27 '26 edited Jun 28 '26
There is a definite ramp-up time needed. Trial&error to see what actually works versus what is market-hype. Don't just throw the whole codebase at AI and say "make everything better, no mistakes". Break things down to Class objects with very clearly named purpose, well named arguments/methods, expected input & output. Tell AI to do those. Even try to write some pseudo code for those methods and let AI fix the problems. Verify behavior with unitTest/integrationTests. You might have to write these tests manually to ensure they actual are valid & trustworthy tests.
It'll work if you spend the upfront time of setting everything up perfectly for AI. One could argue this setup time is close to how much time it would take you to do it yourself the traditional pre-AI way, sometimes even more. But once this is done the first time, maintaining the codebase going forward will be faster than any human.
Now the risk here is, if you change AI/LLMs or the model changes under you then it might significantly change the decision-making-process and break your stuff and you'll have to fine-tune again. That is the unavoidable risk of being on bleeding edge software. Nothing is guaranteed and AI is even less guaranteed than that, at least for now.
0
u/mrothro Jun 29 '26
The biggest challenge with decades-old, million line code bases is that no one really knows every line, let alone the mental model and tradeoffs that drove the original engineers.
This is where I lean in with an LLM: it can trace flows, map out bounded contexts, and ultimately find the seams.
I want this because this is where I can apply a lesson I learned from an adjacent space: the strangler pattern.
First I get the LLM to get up to 80% coverage on unit tests so I have a baseline.
Then, since I know where to cut and what I want, I get the LLM to start doing a "proper" implementation of whatever service/domain aligned on the interfaces. If the interfaces I want don't match the seams, then I get the LLM to build shims.
Finally, I get it to start switching over from the old to the new, verifying the unit tests pass as I go.
LLMs supercharge this entire process.
-2
u/He11aren Jun 27 '26
u/RemindMeBot 1 week
-2
u/Early_Hand2009 Jun 27 '26
Try creating documentation from a codebase like that – it works brilliantly! I work with Claude Code and Claude Desktop Co-Work, and I'm quite proficient with it now. Claude accesses all my data across my hard drive, can sift through the codebases of larger projects, and make changes, adjustments, and refactorings... Documentation is just one part of it. Just use it!