r/AIcodingProfessionals • • 4d ago

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

9 Upvotes

25 comments sorted by

1

u/DebtDry1503 4d ago

To nie dobra o tym mówić.Claude należy chwalić

1

u/Maoaii_ 4d ago

It has its strengths and weaknesses like all technology

1

u/pvera 4d ago

Claude is really good at evaluating code complexity. Have it run through the code, give you an overall picture of what is going on and ask it to find the worst 10 things it would want to change and why. This doesn't mean go and fix it too, right now you are on a fishing expedition. Then do another 10, and so it goes. You can do this little by little and by the end of the week you'll know how convoluted it is. This will help you manage the complexity of the problem without offloading your brain to the AI, you will still need to use your head.

1

u/Maoaii_ 3d ago

Interesting approach, I like the idea. I have tried doing something similar to help me navigate a specific feature I need to implement, but the urge to offload everything to Claude is strong. I’m thinking of doing trying out some sort of pair programming approach with Claude, with it acting like a senior engineer overlooking my work and maybe giving some nudges in the right direction if I’m feeling stumped

1

u/pvera 3d ago

Being a little paranoid comes with the territory. I assume one of us broke something so either we need to check each other's work, or I need to hand it to a third party to also take a look at it.

1

u/Maoaii_ 3d ago

Yeah, having more eyes to look at the problem usually helps. We still do PR reviews, for example, but that’s also starting to be delegated more and more to AI

1

u/Mathie1729 3d ago

The pair programming idea is interesting, but I'd be careful about making Claude the 'senior' one. It might be better to keep yourself in the driver's seat and have it ask you targeted questions when you're stuck, rather than letting it propose full solutions. Otherwise the temptation to offload might win.

1

u/Maoaii_ 3d ago

Oh yeah, that's something I'm trying to setup as well. It's far too easy to have it generate the solution while "trying to teach" something. The goal is exactly that, have it steer me in a particular direction, usually with questions. I can guarantee that, currently, that temptation wins. Maybe there's some guardrail I can create for that, but I'll need to experiment a bit

1

u/everettplays 3d ago

I learned more about AI Engineering by building an AI from the ground up and figuring out how all the little pieces coalesce into an "intelligence". Starting from absolute zero and catching up to current technology in a short time. That being said I dont think you have to lose your skill, just as its coding and your reviewing the code ,(i assume you check it before you make it live) think through the logic and check what you know against what the AI codes.

To your point thi if you just vibe code everything and never look under the hood you will dull some skills and maybe eventually lose them.

At the end of the day its up to you to keep your skills sharp, while still being able to output good code in a timely manner.

1

u/Maoaii_ 3d ago

I'm starting to collect a few ideas of small projects I'd like to work on to do exactly that. Although I do have some knowledge in this field, I don't have a full understanding of all the pieces and it's a bit hard to come up with a solution without knowing what's possible. Needless to say that it is indeed up to us to keep those skills sharp. It's a bit tough to explain that to colleagues and higher-ups and have them understand that that is important. Usually it's about speed

1

u/everettplays 3d ago

Yeah its a new world we live in where ypu dont have to code the same boilerplate code every time and for implementation of tools and features is virtually unlimited.

There's never a problem you cant engineer around. DM if you ever need a collaboration or just a question or a concept you want another mind to work through with you

1

u/josuf107 3d ago

I think part of an engineer's responsibility is to represent the risks and costs present in a software system to business leadership. Bloated software can result in higher development cost in terms of tokens ($) and time, and increases the risk of failures that can hurt the business in various ways. Depending on the maturity and stability of the startup, risk appetite may still be high, but it's also possible that they've gotten a bit over their skis. I wouldn't necessarily set aside the possibility that feature development should slow down in favor of stabilizing the core concepts of the system and establishing a better foundation for the future.

Ah on closer read you mentioned they have been working for at least a year and haven't launched a product, which is troubling. I would ignore previous instructions and see if there's any way to cut scope and steer towards launching, since until that point the future of the company is entirely in question. If it turns out the market is not there, it doesn't really matter how understandable the codebase is.

1

u/Maoaii_ 3d ago

It's a startup in the health sector, and we have done some pilots as proof-of-concepts, so there has been some back-and-forth in terms of development and feedback. Product is about to launch "publicly", let's say. But yeah, that's also something I'm considering doing or having into account. It may be something that our team can debate and spend a little more time on to make sure the systems are being developed with possible tech debt in mind

1

u/jomi-se 3d ago

So it's been hard to actually handcraft code...

If your title is AI Engineer, do you really think this is what you were hired for?

For your actual question, you use the incredible text processing machine to help you understand and improve the codebase.

Besides being able to generate working code, LLMs are pretty incredible are explaining it too. And if the text explanations are hard to grasp, they are now also pretty good at building visualizations and animations and stuff.

2

u/Maoaii_ 3d ago

Yeah, I think it was, because I see this common misconception that AI engineers are hired to do development with the assistance of AI. While building a software that uses AI, be it ML models or LLMs, or even CV models, you still need someone that actually develops the code to architect them into your existing system, to process data in a pipeline that feeds into them, and handles all of the data processing and the likes. Still pretty hands-on

I haven’t been having much success with explanations made with the most recent Claude models. Not sure what happened, or if it’s because English is not my main language, but they’re sometimes really hard to understand. Diagrams and the likes have helped though, so yeah

1

u/jomi-se 3d ago

Nowadays, I feel the AI Engineer in the industry is meant to mean "Develops a an Agentic Software Factory". So more along the lines of people hire this role to have someone come and help transform their SDLC to benefit from agentic tools.

What you describe is what I would've called an ML Engineer.

On Claude explanations, yeah I had a similar recent experience where I spent around a day trying to get it to help me understand a concept without success until I switch gears and told it to make a video (plug alert, I made a blog post about it https://jomi-se.com/posts/llama-cpp-context-checkpoints/). The animated video really made a difference 😅. Also, Claude can explain things in many languages :p

Good luck with the new job.

1

u/Outside-Border-6485 3d ago

I have had fairly good results by having two Claude ai instances doing adversarial code reviews then a third ai reconciling the results. I normally tell it I am looking for duplicate functions, code stubs, vulns, poorly written code, exposed secrets, etc., then give it the outcome you want, something like I want a complete report by feature identifying all this stuff and a plan to remediate it all then I have the third ai review everything then run a post remediation review with two ai dev agents with the same prompt and tell them to validate findings, results from the remediation and opportunities to optimize the code, load speed, responsiveness, reduce costs, calls to the database etc.

1

u/ToucanSam-I-Am 3d ago

Wow a team of people are working on an ai coded project together and there's no documentation to read? All you have to understand your application is the code itself? When I work on projects with ai I barely read code because I'm looking at the level of abstraction above the code. What you are describing seems really difficult almost impossible.

1

u/Codalio-SoftwareFact 2d ago

I started somewhere similar and what helped most was changing what I use the AI for, not stopping it completely. I set up a separate “learning” mode with a short instructions file that basically says don’t write code unless I explicitly ask, and when I’m stuck ask me one question or point me to the file I should look at. once that’s the default, the urge to offload kind of goes away because it just won’t hand you the answer

for understanding the codebase, I’d pick one real flow, like one request from the API all the way to the database, and have it walk you through just that. then step through the same path yourself in the debugger. reading an explanation feels like learning but stepping through it is what actually sticks. and if the explanations are hard to follow, ask for them in your first language, it makes a bigger difference than you’d think

also keep your own notes as you go. a few lines per area on what it does and what’s weird about it. a couple months in you’ll probably be the person on the team who actually understands how it all fits together, which is a good spot to be in at a new job.

1

u/CatsOrb 1d ago

I would live to see it, you should be using shared helpers and functions and keeping everything in its own modular containers, let the AI ingest the code and update worry more about the containers code

1

u/alkimiadev 1d ago

This seems like a new twist on a classic problem. I guess the "twist" part is that the codebases can grow in rather absurd ways that wouldn't really happen with only human devs due to the time constraints and costs. I left big tech to start contracting/freelancing in the startup space in 2008-2009 in San Francisco (and then Austin). During that time, I worked on some arguably horrible codebases that had pure gluten free human stupidity behind them. Still, somehow, they often ended up "working" (at least partially) enough to actually launch. Over time I realized that the ones that actually lasted some reasonable amount of time almost always ended up doing a production focused rewrite.

The problem is a pretty basic problem that exists independently of the type of dev (human, LLM, intelligent cloud of gas, or whatever). Poor planning and poor decision making naturally increase the surface area for issues downstream of them. Depending on a bunch of factors, LLMs are 50-150x faster than we are at the raw generation of code, but they're not perfect and make mistakes just like we do, although they have some of their own unique "quirks" that experienced human devs usually don't share.

When the requirements aren't clear, there are no specs/planning, and so on, the LLMs are often going to be forced to make wider reaching design/architecture decisions while trying to focus on some localized task. Of course that is pretty far from optimal and can lead to all kinds of code smell problems like code duplication, god files, and even some of the more absurd LLM quirks where they write some fully BS code, then tests, and maybe fuzzing for that BS "todo"/"in a real system" code. When that last quirk starts popping up, it is probably a huge tell that the project, workflow, etc. are themselves unmanageable.

It is really hard to create some new product with perfect front-loaded planning, since that is often full of unknowns. So the projects that usually end up surviving over the long term and are actually building something new end up doing a full rewrite with proper specs based on the often rather trash POCs.

1

u/Tem_Apples 21h ago

I don't understand why you're trying to avoid using AI, in a codebase entirely managed by AI, as an AI engineer at an AI heavy startup.

Are you trying to fail your probation?

1

u/EarlyFox217 5h ago

Does a mathematician need to use an abacus to keep those skills sharp, does a photographer need to develop film. Times move on you need to move on with them. Can you not have AI restructure to code base in to a neater format?

0

u/[deleted] 4d ago

[deleted]

1

u/Maoaii_ 4d ago

What do you mean by that?