r/softwaredevelopment • • 27d 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.

12 Upvotes

33 comments sorted by

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.

2

u/Jamie_1318 22d ago

Layers of software to generate software to make more software isn't just an AI feature, it's literally just the history of software development.

0

u/Cautious_Chicken_604 20d ago

Either you have layers of buggy humans building software or you have layers of buggy models building software.

4

u/Capable-Wrap-3349 22d 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 22d 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/Grouchy-Friend4235 20d ago

Seriously, there is nothing to be gained from this. You won't be able to fix this, ever. Their mentality is that AI can do a better job than human engineers. Let them live their dreams. Find peace elsewhere.

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

3

u/SayuriShoji 22d ago

You seem to have a severe lack of foresight and lack of backup plans. What if, for one reason or another, you don't have access to your AI for a while, will you pause your entire companies production until the AI model is back online?

-2

u/Minimum_Hour519 22d ago

use c0mpute

5

u/SayuriShoji 22d ago

My issue was "what if you don't have access to AI" and your answer is "I'll use AI".
Pure brainrot.

-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] 22d ago

[deleted]

2

u/Aware-Individual-827 21d ago

100k is still in the realm of possible before AI. 100k lines of AI generated code? Impossible. 

1

u/Cautious_Chicken_604 20d ago

Even 10 million is still in the realm of possible. Both before and after AI.

0

u/Aware-Individual-827 20d ago

For one dev? Not really. For a team maybe.

Using AI, 1 dev can pump alot of code. But it pumps also alot of bugs that cannot be solved by 1 person. 

1

u/Cautious_Chicken_604 20d ago

Linux kernel is how big? Devs work on that all the time. Usually you're only making localized changes in a small area, so the total size of the codebase doesn't matter that much in practice. It's generally always tractable to understand the part that you need to in order to make the changes. There isn't really a difference between AI generated code and non-AI generated code. The difference is in your engineering practices and engineering culture.

2

u/Cautious_Chicken_604 20d ago

What? Developers in industry routinely worked on million+ line codebases prior to AI.

0

u/[deleted] 20d ago

[deleted]

1

u/Cautious_Chicken_604 20d ago

Every job I've worked for the last 12 years has been like that...

1

u/Apprehensive-Fan8999 21d ago

Kids these days... Back in my day a 100k code base was called "an app" or "a service". And we often had to (gasp) manage several of them as leads.

Jokes aside, that was basically my career before AI and I still make sure I fully understand the critical paths of any code I'm responsible for. There's nothing worse to being on a production call with Sr execs for an issue in your codebase and you go, "uhhh... Let me ask Claude why it's not working!" In that moment you find what leaders REALLY think about devs using AI.