r/softwaredevelopment • u/Maoaii_ • 26d ago
Issues with navigating a complex AI-generated codebase
Hello! :)
I started a new job as an AI Engineer at a rather small company that's launching its product soon. Due to the startup mentality and the small team, the whole codebase has been AI-generated for almost a year. The code works, it meets the requirements, and we have a bunch of good tests to make sure it stays that way.
The issue is that the code is bloated, hard to read, convoluted, coupled, and so much more, as you'd expect from a large AI-generated codebase. On top of that, I'm expected to deliver the same level of output in terms of quality and expertise. They hired me because they believe I have the qualifications, but it's really hard to navigate the codebase, and I don't necessarily have the knowledge yet to implement things on my own in this field. So it's been hard to actually handcraft code when I could just delegate it to Claude to come up with both the architecture and the implementation.
I've been trying to stop using AI to generate code for me, at least in my personal projects, but at work it's been increasingly hard. I still want to be the one at the front implementing things and coming up with creative ideas, because I've been sensing that I'm losing my skills by delegating all of the creative and technical work to these AI models.
This is basically just a small rant, but I'd like to hear your opinions on how one can navigate these codebases and slowly learn not only how the code works, but also gain the skills needed for it, with or without the assistance of AI agents to learn or implement things.
17
u/LongDistRid3r 22d ago
Oh you poor poor soul. My condolences.
Thought: all software has bugs. Software generating software containing bugs. So you have buggy software building buggy software.
4
u/Capable-Wrap-3349 21d ago
You can’t fix the whole thing all at once, but maybe you can try starting to get it under control little bits at a time?
E.g. define the architecture you want and then write future code adhering to that architecture, refactoring existing code to this pattern only as your new code touches it. Also, maybe start putting slop code behind wrappers/interfaces to separate the maintainable code from the slop (i.e. board it up, and start slowly cleaning it bit by bit).
You’ll never be able to clean it all and it’s a moving target, but you will feel better starting to take control back in little islands of the codebase, and otherwise like-minded developers will gravitate towards your clean islands.
A few different authors I’ve read (e.g. pragmatic programmer, Kent beck, Martin fowler) say to refactor/design continuously, and I think this is a good approach. Clean a little as you go, and don’t try bite off more than you can chew in one go.
4
u/jeff77k 21d ago
You have what we use to call technical debt. Now you have to think about all the trade-offs that go along with dealing with it. Engineers usually want to address it sooner rather than later, and stakeholders never want to address it unless it positively affects the bottom line.
Good luck to you!
3
u/AnnualReview2383 21d ago
You're expected to deliver the same quality code. Fortunately for you, it sounds like their quality is already pretty low.
3
u/Apprehensive-Fan8999 21d ago
You are doing it wrong! What you need to do is spawn agents to create the code, then span more agents to review the code, then spawn more agents to fix the code! Have you not read the answer of every AI booster; ever?!?
<\sarcasm>
You can't read it all. So focus on the key parts. Where is the reused code? That matters a lot more than than the one off leaf nodes. A bug in a leaf likely affects only a single execution path. A bug in core reused code affects the whole application. So find those points, focus on it as best as you can, and branch out only if you are able.
Don't be afraid to ask AI to help you find the key parts. AI is great at pattern matching, and core reused code is a ton of patterns for it to match on.
3
u/PhantomThiefJoker 20d ago
Rip good luck, it will take longer to untangle the codebase than if it was properly written by someone who knows what they're doing from the start
2
u/OGxPePe 21d ago
Pray and hope for the best
1
u/rollingSleepyPanda 21d ago
Sounds like my previous job.
Emphasis on previous.
1
u/baubleglue 21d ago
You may ask AI to refactor the code.
1
u/cyb3rstrik3 21d ago
Ask the AI, but also when working with unfamiliar codebases start with the unit tests, if they are none start adding them and refactor as you.
1
u/Cautious_Chicken_604 20d ago
>The issue is that the code is bloated, hard to read, convoluted, coupled, and so much more, as you'd expect from a large AI-generated codebase
12 years ago when I started my first software job this was my exact experience. It was almost my exact experience at every company I worked at. All codebases were 1 ~ 2 million lines of code. Some better than others, but every single one of them matching this exact description, minus the AI.
1
u/Cultural-Money-9633 20d ago
Oh nooo, dearest you job have
Have you considered asking an llm to build your feature and validate it?
1
u/Grouchy-Friend4235 20d ago
Run.
1
u/theJacofalltrades 20d ago
if you really want to learn a lot of people take bootcamps like with bootdev and they seem to improve their understanding based on what they say
1
u/Ok_Part_459 9d ago
sounds like my current job , I have to deal with huge codebase written in a languages Im not familiar with ( entry level job ) ship features , startup want me just to understand the requiremeents and use claude , I can describe my current job as "VIBECODER" more of "SWE" , it's OK , I feel this is just an opportunity to learn this new lang on my own and try to at least understand some of the code being shipped , else my current 9-5 will be talking with claude and trying to understand what's this machine is doing
1
u/NaeilaDjeloul76 2d ago
dont let the model do the architecture part. sketch out the interfaces, data structures, and function signatures yourself, then let the generator fill in the boilerplate inside those strict boundaries so you stay in control of the design
0
u/zerovian 22d ago
skills applied by subagents are your friend. do your best to create skills that enforce best practices at the code review level. create an orchestrator agent that triggers a bunch of lesser read only agents that have focus areas. I have a similar project. its about a million lines of code and tests.. all AI written.... a large tewrite from c.. but that highly cohesive duplicate codebase can be improved with engineering practices that enforce good behaviour. but it takes an active choice. read all the code. let the llm write the code. then use a really good strict set of code review rules and anti patterns written as skills to surface problems. and then make the llm fix its mess.
software dev has changed and will continue to change... and rapidly. we are at the front edge of the ai wave. ride it. get good. or fall off the board is my viewpoint. this requires changes to your engineering skills and practies... and you get to invent those. be mindful. good luck
-5
u/Minimum_Hour519 22d ago
asks claude code to analyze and refacotr it. why are yu still reading code???
-4
u/kincaidDev 22d ago
I've fully embraced AI development and treat what I do now as managing and combining outcomes.
I'm delegating task to agents, but I feel like for me it allows me to be more creative and to think more. I can spend a lot of time thinking and planning and still getting a ton of work done because after my ideas/plans are out of my head, I can just delegate it to an agent and move on to thinking and planning the next thing.
Managing all the outcomes and planning out how to combine the outcomes feels pretty creative to me.
I built this system to work this way, you may enjoy it because it turns what could be a dull process into something you'll feel more involved with + makes a lot of mundane task easier and more efficient
https://github.com/Obedience-Corp/festival
0
u/[deleted] 21d ago
[deleted] — view deleted comment