Slopification of Codebase
How pure AI generation can lead to a slopified codebase and how to avoid it

Recently, I have been working on a projects, where the proliferation of AI generated code has led to … how to put it … interesting codebase.
It is not a secret that AI tools are getting better and better at generating code, but it is also not a secret that they are not perfect and they can generate code that is not up to the standards of the project.
However, the problem goes deeper. If you go yolo with AI generation, without any human oversight, you can get to the point that not even the largest model will be able to understand the codebase.
You can argue that you will spend more tokens on solving the issue and yes, that is one of the solutions, but really?
If it is prototype, proof of concept or pet project, which you will only use for yourself, go yolo. You can stop reading this article, because it is not for you.
But do not do that in a project, that you will share with other people, that you will maintain for a long time, that you will use in production. Make yourself a favor and do not let the slopification of codebase happen to you.
Why slopification happens?
Code Smells
AI is really good at reading the code, understanding it and patching it.
However, if you have only one wrong pattern in your codebase, it can lead to a snowball effect, where the model will start to generate more and more code that is not up to the standards of the project, because it will learn from the existing codebase.
Poor code design tastes well, because it enables you to get things done faster, but it is a trap. It is like eating junk food, it tastes good, but it is not good for you in the long run.
AI is doing the same thing, if it sees the simple way out, it will take it, because it is the path of least resistance. Why it would bother to write clean code, when it can write dirty code and get the same result?
Context Rot
Context windows of the models are getting bigger and bigger, however, they are not infinite. Moreover, the more context it uses, the poorer the results will get.
If you get to the point, where your codebase is so big and so messy, there are multiple scenarios that can happen:
- The model will not be able to understand the codebase, because it will not be able to fit it into the context window.
- The model will try to fix your issue, but by fixing it, it will make it even worse, because it will not understand whole scope of the issue
- The context will stop being relevant, because the model will start to forget important information, which can lead to even more issues.
Lack of Human Oversight
Models are great, but they are not perfect.
I use them on daily basis, my colleagues use them on daily basis, but we our oversight.
Human in the loop is still necessary, because you can catch the issues before they become a problem. You can guide the model, you can give it feedback, you can make sure that the codebase is not getting slopified.
I change the code composition, its intent, its design, rename things couple of time, iterate on solution. Not because, I do not thing the model is good, but I want to make the code up to my taste and standards. I want to make the code to look as it would be my code.
Till, it is off, it is not my code, it is the model’s code. I want to make it my code, because I want to be able to understand it, maintain it, improve it in the future. It has to click in my head, so I can work with it.
It is more work, it will burn more tokens, but it is worth it, because I keep my mental model of the codebase. I know how it works and I am able to make changes to it even without AI.
If the code is average, it is not good enough. It has to be good, because I will be solving the issues in the future. I do not want to beg model to solve my issues.
What you can do?
You have limited mental capacity to do reviews, so use it wisely. There are couple of ways to do that:
- give feedback to the model and iterate on the solution while you are working on it
- use review agent to review the results with fresh context
- use linters and git hooks - do not have mercy on the model
- use tests to verify behavior
- use code formatting tools to keep the codebase consistent
- you can use AI tools for merge request reviews
Conclusion
AI tools are great and they improved my productivity a lot, but they are not perfect and they can lead to a slopified codebase if you are not careful.
Check your codebase, check your code changes before merging them. If you understand them and you would be able to do changes in the codebase, you are good. Otherwise, go back to the drawing board and iterate. sa
Socials
Thanks for reading this article!
For more content like this, follow me here or on X or LinkedIn.