logoalt Hacker News

AI usage generates a fragile codebase

231 points • by plun9 • today at 10:25 AM • 281 comments • view on HN

Comments

basilgohar • today at 6:48 PM

I think looking at AI usage for code and development from an engineering perspective is going to be an exercise in frustration. I'm a software engineer for 20+ years and I've pivoted to using AI for my code 100%. I find it invaluable about the only way to stay relevant and run a business nowadays. Happy for anyone to disagree with me, because I don't want to be right for the first time in my life.

That said, my experience tells me that enterprise and business coding has rarely ever been about stable or robust codebases. We engineers and a fraction of competent engineering managers and a vanishing small number of directors fought against business interests to ensure quality was priority when it came to code, but it was always an uphill battle and we were oftentimes disciplined for spending too much time on quality and design.

A timed cadence of release is anathema to quality code because you can't timebox it.

So, AI is just the extension of that. Do I try to ensure my agents design code I would consider to be good? Yes, absolutely! But I've fully outsourced it and I find it's also fully capable of fixing it's own mistakes. I've gone far beyond anything I individually or even with a team was ever capable of with AI assistance, so I believe I just have to apply my experience and skills into management and architecture rather than actual lines of code.

Time only will tell how this plays out.

Wallaahu aʿlam.

➕ show 1 reply
happy_dog1 • today at 7:43 PM

Pure speculation here, but this is a thought that occurs to me. I've often seen furniture used as an analogy for how quickly an automated process can displace craftpersons, but I think it might actually in one sense be an analogy for how craft can continue to survive and thrive even post-automation. Sure, Ikea sells a LOT more furniture than Ethan Allen; but Ethan Allen's handcrafted furniture is much higher quality and sells at a premium price.

Consumers benefit all round. Those who can afford to do so can buy the high quality handcrafted product; the majority who can't get cheap access to decent-quality furniture.

This is pure speculation but I wonder whether software will gradually evolve in this way with the availability of AI. For many basic tasks, consumers will be able to basically write their own software using some AI tool; it may not be high quality but at least it will be cheap and fast to produce and it will greatly reduce the barrier to access for the average computer user to do what they want to do on their machine. Meanwhile, a much smaller niche market for high-quality tools that have been at least partly handcrafted by experts to fill some special need where performance or a quality experience are crucial will continue to thrive. Either way, in this scenario, I would imagine the importance and prominence of SaaS will slowly decline.

monjerry • today at 6:20 PM

Code quality is not an issue.....until it is. Everyone will be happy if things seem to be working and moving fast, it's only until you start seeing symptoms like not being able to change things without breaking existing features or even seeing an increase in tokens burned for reading complex code bases that you will start caring about code quality (which i imagine now people will just have AI try to fix it's own mess).

➕ show 1 reply
peterbell_nyc • today at 7:08 PM

I'm not sure that "AI generates..." articles are going to age well.

My immediate question would be what kind of adversarial reviews and deterministic gates did the author write to capture the dimensions of maintainability (lack of DRY, cyclomatic complexity, unclear naming, poorly architected flows, etc) that they cared about.

Don't get me wrong. When I was speeding along at 200 PRs a day (personal projects - I would not have inflicted them on others) I pretty quickly slopped together a big ball of mud, but as I'm re-generating my estate (a) the models are a little better but (b) I'm adding a lot more rigor around verification (correctness, performance, security, operational costs and maintainability). It's not an easy problem to solve, but it feels to me like an engineering endeavor, not speculative rocket science.

I fully understand that many AI generated code bases do indeed suffer from more incidents and less maintainability, but I think it's important to distinguish between what is common and what is possible as the fix for one is improving the rigor of your verification whereas the fix for the other would be either accepting crappy code or giving up on LLMs.

shermantanktop • today at 7:49 PM

Easy way to start: ask AI to make the codebase more robust. Modern models are quite good at finding areas of fragility.

So many of these complaints suggest that people are accepting that the first attempt by a model is the best it can possibly do. Yes, it takes effort to guide and correct the model's output, but not that much effort.

You may not want that to be your job, which I understand. And AI isn't great at everything, and has gaps, etc. But if you are going to give AI a fair shot, don't hamstring it by using it poorly and then claiming your bad results are representative.

KylerAce • today at 7:52 PM

Has anyone found a good way to make AIs generate useful tests and/or longer horizon changes like a skill or asking for antagonistic review subagents? These are the main issues behind AI code besides the unavoidable "you don't know what you didn't write as well as what you did"

yodsanklai • today at 12:11 PM

I don't think this matters anymore. Software is becoming a black box and agents make it works, as long as you can provide some reasonable spec of what you want to do, and a bit of supervising and directions.

Right now, they're not great at following good software engineering principles. They do the job, with verbose code, lots of duplication, abstraction leaks, useless unit tests and so on.

Is it an issue? you could think that in the long term it'll be, that AI won't be able to handle the complexity it introduced, but I'm not really worried about it. Most software isn't that big, and agents are getting better by the day. And if you really care about design, it's not too hard to instruct your agent to follow your standards.

I wish it wasn't the case and that I could justify my experience and expertise for a few more years, but the facts are there.

➕ show 10 replies
hackersnooze1 • today at 5:56 PM

Code quality is no longer a concern to almost anyone since about 6 months ago. Software is a black box now, get used to it

➕ show 14 replies
jasode • today at 12:07 PM

I don't disagree with the article but it may give some readers the impression that pre-AI hand-written code wasn't fragile.

Here's the famous commentary about Oracle RDBMS codebase of 25 million lines: https://news.ycombinator.com/item?id=18442941

Every big company codebase with millions of lines devolves into a similar state. The small codebase starts with clean conceptual integrity. It then inevitably decays into incomprehensible spaghetti code as more people are added to it. Various reasons for it including the later devs caring less about the code than the initial team of devs, deadlines, avoiding refactoring because of fear about breaking things, etc.

If you don't want AI to create fragile code, you have to apply the same quality gates that would have been applied to pre-AI hand-written code to keep everything clean. Most companies don't do that.

➕ show 1 reply
a34729t • today at 6:03 PM

One of the things AI reduces is curious engineers futzing around in the codebase, which is a great way to find dead code, suboptimal structures, etc. With AI that's all gone.

➕ show 4 replies
user43928 • today at 11:41 AM

After 7 months and a 500k LOC codebase I can say that in my experience the fragility is inconsequential.

Disclaimer: I have no SaaS platform, it's a mobile app.

In my experience maintenance does not suffer long term with codebase size, if anything it became easier with model advances.

Most people talking about suboptimal implementation, fragility, and maintenance burden seem to theorize and extrapolate with no actual experience in implementing a large project with AI.

I can't blame them, I see the same in my day job, but the results after 500h+ on a separate project show that the concerns do not manifest in practice.

➕ show 13 replies
luckystarr • today at 7:12 PM

I sympathise with the author, but the problem is not that the agents do that, the problem is that they haven't been told explicitly what to do and what not to do.

I had to define the ideal test in my project and from then on the agents wrote exactly the tests that were needed.

And this doesn't stop at tests, but extends to all aspects of the codebase. How should code be structured, what not to do, how should the process go, tests before code or not, etc.

Over a year I arrived at a setup where I only once every few weeks have to change how an agent should do something specific. My last change was regarding how it should decide on naming buttons when creating new features. There is now a standard, a list of preferred content for specific situations and a rule on how to decide (incl. some leeway).

When told nothing, I feel the agents take it as "its fine any way, may as well be lazy".

beastman82 • today at 11:44 AM

Try using a statically typed language, refined types, and functional programming. Your tests become limited to things that are hard or impossible to assert with the type system.

My code has never been stronger.

➕ show 8 replies
abalgir • today at 3:09 PM

Vibe coding taught me the hard way. These principles confirmed it: AI made it easier to create software. It didn't make production easy.

1 - Done does not mean DONE. 2 - The code gets over-engineered, and you will not know about it. Unless you have a large team reviewing the AI's work. Which defeats the whole purpose. 3 - AI reviewing the code can over-review. It chases unrealistic edge cases and kills your project. 4 - Maintainability is not native to AI. It builds code nobody can maintain later.

I built a machine around the agents that takes care of these issues, and I can safely say that vibe coding made me a better builder of solutions (not a better coder).

cagz • today at 7:05 PM

I understand the concern fully. I believe this is mainly because software development is currently in transition.

There was a time when all tables were made by hand. Carpentry was often seen as an art form. Every table was unique and carried something special from its creator. Then the industrialisation came; factories started making tables. The first ones had issues, but over time, they started producing high-quality tables at high volume. Today, "hand-made " still has a special place in our hearts, but it is usually seen as a niche/luxury product. When a company wants to buy tables or desks for an office, they rarely go to a carpenter to get them made.

I am sure master carpenters found (and still find) factory-made tables inferior, and perhaps they are, if we are looking for a special human touch. Unfortunately, the free economy demands cheaper, factory-made tables, so they are very popular.

Software development is just in the middle of this transition, and it is painful. It will get better soon, but the bitter taste will linger. There will definitely be niche development tasks where we ask master developers to get the job done manually. Software for flight control systems comes to mind, where every low-level instruction matters.

What do we do now? Given that the trend and demand are obvious, we can focus our efforts on making the factories better. If I may reference a couple of points from the post:

AI makes shallow tests:

The opportunity here is improving test-writing skills (AI skills) to ensure tests written have enough depth.

AI writes overly complex code

I found that TDD helps greatly here. Write failing tests first, then write the minimum amount of code to make them pass.

For me, these are how we can make the factory better. I don't think the two organisations mentioned that expect code to be developed 80 or 100%, respectively, would mind developers spending some of their time improving the team's shared skills library.

Perhaps it helps to see this not as "stopping writing code", but as "going one more level up in the abstraction hierarchy". It's similar to going from assembly to higher-level languages, although I appreciate it is not a perfect analogy.

➕ show 1 reply
simonw • today at 6:53 PM

The most interesting engineering challenge of 2026 onwards is how to use AI coding tools to create a more robust codebase, avoiding the default which is a lean towards fragility.

stevefan1999 • today at 11:33 AM

This is absolutely right because AI lacks Fingerspitzengefühl: https://architecturenotes.co/p/the-cost-of-ai-in-code-goodby...

➕ show 2 replies
damowangcy • today at 7:44 PM

Some comments claim that "models are getting better over time" misses the point.

What does "better" even mean? Better at following instructions, or better at fixing everything on their own? If it's the latter, it's not progress, it's the model's behavior matching your preference.

Coding itself is deterministic, but code quality and the product aren't. A better model per se might solve the former, but there's no single better solution for code quality or product because it requires judgment per case, and that judgment depends on context that is unwritten or lives in people's heads.

Code quality matters. A coding agent is faster than a human at pattern matching, but a bad codebase is going to slow it down or, worse, point it in the wrong direction.

So a better model won't be enough. We need better processes.

➕ show 1 reply
fauigerzigerk • today at 12:17 PM

I think shallow tests is the the most important issue on this list. AI works well if there's a good feedback loop. Without very good test cases and/or some kind of formal specification, the feedback loop is a haphazard, unrepeatable mess and code quality will inevitably decline.

➕ show 1 reply
vorticalbox • today at 6:57 PM

The test one I have seen too, one way I have had some luck with is to get an agent to write a plan, then another agent to plan the tests for that plan.

For this agent it is told to think of it as a graph and each “if” or function call, import etc as a new node.

They generate pretty detailed graphs this way. Seems to really help them with the “depth” issue.

NegativeLatency • today at 7:14 PM

On the other hand I've fixed some really amazingly hard technical debt issues with AI that have made my codebases less fragile, also written up end to end test pipelines, automated QA etc.

mgdev • today at 6:28 PM

So do bad developers. So do very junior developers. So do PMs when they think they can start slinging code.

You still need systems in place to ensure quality.

That in turn requires you describe what 'quality' means to you.

Then you need to design your AI-driven token factory in a way where it converges on something resembling that definition.

Otherwise, yeah. You're gonna have a bad time, until the models get significantly better.

But if you can figure that out, you can build some INCREDIBLE software. (Just look at Rex!)

exabrial • today at 7:22 PM

No. The lack of a good architecture and design blueprints do. This is literally the exact same problem before AI.

armanckeser • today at 12:24 PM

A fragile codebase *today. What happens when the new generation models come out? Taking on debt today to move faster makes a lot more sense because the "interest rates", if you will, make the math such that new AI models can pay the debt their predecessor left. Bad tests were harmful because I had to hand fix them which meant spent time, today it just means 5 seconds for the AI model.

➕ show 1 reply
soon_to_be_sb • today at 11:29 AM

Every once in a while something comes up that proves beyond a doubt that 99% of human beings on planet earth cannot think for themselves. And most sensible things that human beings do, they do by following the herd or "instructions".

➕ show 2 replies
mydreamof • today at 6:30 PM

I don't agree with arictle. For example regarding test cases, I find that it creates better tests that most ppl and it is not lazy (lazy people didn't write tests). Also it can write more tests than me, I can just give it the cases

retrac98 • today at 11:51 AM

My experience has been sort of the opposite. In the past 6 months I don’t think I’ve introduced a single production bug through my work, which is unheard of (for me, at least).

LLM code is verbose, and often quite inflexible, but that rigidity and verbosity tends to come from the AI being very thorough about ensuring the code does exactly what’s expected, and it seems to leave much less room for error as a result. It acts as a really good forcing function for specificity on requirements, and for thinking through "what if" scenarios.

➕ show 2 replies
amelius • today at 11:45 AM

We just need new Software Engineering books that explain how to build software in the AI age.

➕ show 1 reply
CharlieDigital • today at 11:27 AM

it doesn't have to.

AI is great at following patterns and loves to write tests. Start with good patterns that most teams would not have the discipline to write by hand and it is possible to get very robust code.

➕ show 1 reply
keeda • today at 6:44 PM

I can agree with the premise, but not all the details. Like, I’ve never seen a shallow test, even with models from 2 years ago. On the contrary they often think of edge cases I have missed, and sometimes go overboard in what they test for. I also have not seen them use inappropriate APIs for effects, like JS instead of hover. Maybe this is an artifact of different models? EG I’ve never used open source models for serious coding. (Interestingly, until a couple weeks ago I’d never paid for AI, all this was on free tiers; so these were not frontier models either.)

From my experience, the biggest problem is overcomplicated, over-paranoid and redundant code, especially for large code changes, like a whole feature built end-to-end by agents. If I step back, it’s like code written in a large company where dozens of engineers are writing code but no one engineer can have all the context or the code base in their heads. Which describes agents pretty well, really.

And so you get tons of near-duplicate abstractions, and dozens of guards for conditions that would never happen (but they don’t know that, and they won’t voluntarily stipulate reasonable invariants), and Rube Goldberg contraptions to fetch some data or use some abstraction when there is a convenient alternative a few source files away. In fact I see the opposite of DRY that TFA observes.

But this is also the reason why developers lack understanding… it’s just too painful to review that code. Especially if you get mountains of it, because every line of code that surprises you entails a lengthy back-and-forth with the agent, and it usually has a good reason for it, just that it doesn’t matter. And so Im not surprised that most engineers just blind ship it.

And this compounds in a big company because the next PRs that agents pile on are influenced by these changes, and so they have to handle extra edge cases, and deal with competing or conflicting abstractions, and follow similar patterns because they simply don’t know better.

On the other hand, I can also see how this won’t matter for anything but critical infrastructure code. As I said, this looks like code at any other big company and none of them have collapsed because, in addition to the always under-appreciated customer indifference, they rely on other built in processes (like customer service and security pen testers, say) to deal with the inevitable issues. And these processes are also eminently outsourceable to AI.

I do think these issues can be prevented by more sophisticated usage of agents (like adversarial review by other models) and tooling, but people are still figuring that out.

_ink_ • today at 11:44 AM

The question is, is it really a problem when letting agents rewrite everything better costs not that much.

➕ show 1 reply
Nekorosu • today at 12:25 PM

The article seems to repeatedly confuse product quality with code quality, as if they're interchangeable. They're not, and that confusion pretty much undermines the entire argument.

➕ show 1 reply
hintymad • today at 7:10 PM

> AI writes overly complex ccode

Not just complex code. AI tends to add new code. After all, AI predicts what code to write, so it happily spew out all kinds of code that do not make sense but definitely look like belonging to the code base.

I suspect that sooner or later we will run into some outage that AI can't fix because there's just so many inter-dependencies that fixing an issue turns into an infinite game of Whac-A-Mole. The question is, is such scenario going to happen in a frontier lab first or in a random company. If it's the latter, at least we can blame that the company didn't use AI well.

microsoftedging • today at 12:33 PM

I agree with most of this, but the market will solve itself[0]. I do think the last analogy diminishes the point.

> Shopping for clothes from a website always results in worse fits than shopping in person.

Knowing how one brand's clothes fit means that this isn't always true, and you just adjust depending on the brand. I don't understand what is trying to be conveyed here.

[0] https://news.ycombinator.com/item?id=50439062

rokkamokka • today at 11:25 AM

AI Without Oversight Considered Harmful :)

lf88 • today at 1:00 PM

AI in software development should be limited to security scans and maybe occasional bug-fixing. We'll have the best of all worlds: more secure code bases, happier & not unemployed developers, human understanding of what the code does, and far less money for companies that are hijacking our future by developing a god-like artificial super-intelligence.

snarfy • today at 11:39 AM

Business incentives create fragile codebases.

AI is a force multiplier in whatever you apply it to. Most software companies output binaries with new features, whether it runs locally or on a server. Binaries with new features. None of the business owners give a shit about what is in the binary. It may be extremely fragile and only work for one type of user, but if they only have one type of user nobody cares. Most software doesn't keep evolving forever and at some point gets rewritten as a 2.0 version or whatever, so the quality was never as important.

It doesn't have to be that way. You can use AI just as effectively to produce quality source code as you can slop binaries. It depends on the business priorities and what is actually important.

The caveat is if you are the one engineer on the team trying to use AI the right way to produce quality source instead of binaries as fast as possible, you might get left behind or let go since your work no longer aligns with the business.

Magicrafter13 • today at 7:31 PM

To the surprise of literally 0 people who are actually honest about the field and not suffering from AI psychosis.

CurleighBraces • today at 11:19 AM

Humans not using their own brains and relying on AI to think for them creates a fragile code base.

I say that as a frustrated slop fighter.

➕ show 3 replies
vinyl7 • today at 7:12 PM

This thread seems to be a great example of the dead internet theory.

ricardobeat • today at 11:33 AM

Imagine a junior engineer in the same position: they write shallow tests, they write overly complex code.

What do you do? You provide guidance, support and tooling so they can write better tests and code. You supervise and help them meet the standard. It is the same with AI agents (including the challenge of how to carry that knowledge around and transfer it). You are responsible.

You are also responsible for the understanding part: know what is being worked on, glance at changes, inspect the outcomes, cross-check specifications, tests, product requirements. The 'moving too quickly' idea is the other side of the same coin; it is your responsibility to keep track of things and decide what's worth intervention. The exact same thing happens in a project where you have ten developers (or 200) working together — you cannot possibly read all of the code they write.

Seeing all of these as downsides is a choice.

➕ show 4 replies
insane_dreamer • today at 5:16 PM

> 2. AI writes overly complex ccode

100% this is my experience; I frequently am telling the agent 1) "this way is simpler", or 2) "why are you doing X instead of Y, which is simpler"

fxwin • today at 11:57 AM

> Here are the four most common ways that I have seen AI generating a fragile codebase. / Four signs that you have a fragile codebase

It would be nice if the listed symptoms (which have their own issues, e.g. "AI writes overly complex code" - overly complex for who?) were backed up with numbers or at least case studies, rather than stating "this is how you can recognize that X is happening", then stating "X is happening" in the title.

IvanK_net • today at 12:38 PM

I think there is a new Moores law!

Every six months, the number of people capable of writing code better than AI is halved! :D

dreambigwrkhard • today at 11:57 AM

The market will fix itself.

If the article is correct: AI generated codebase creates incidents that are more severe and take longer to recover from, companies will dial it back after they get burned bad enough.

If it's a skill issue: Maybe some coders can push the frontier out even a lot more than others before such things happen. Then the problem is the human in front of the screen.

softwaredoug • today at 12:00 PM

AI coding requires a lot of care to observability and verification.

If you can’t measure the problem, is it really a problem? A lot of assertions about code fragility seem to merge in with bike shedding arguments about style and what one person sees as readable.

But in the end if you have 100k of slop but we can know with high levels of certainty it does what it needs to - does it matter?

taspeotis • today at 12:27 PM

Early 2025 Copilot + GPT 4o energy here.

🔗 View 15 more comments