How To De-Slop A Codebase Ruined By AI (with one skill)

The video discusses how AI-generated code accelerates software entropy, leading to disorganized codebases, and presents the “improve codebase architecture” skill as a method to restore maintainability by deepening modules, enhancing locality, and leveraging seams and adapters. It emphasizes that improving such codebases requires active human judgment in collaboration with AI tools to strategically refactor and test code, rather than relying on full automation.

The video addresses the growing problem of software entropy accelerated by AI-generated code, which often leads to codebases becoming increasingly disorganized and difficult to maintain. The presenter explains that every change made without considering the entire codebase can introduce small inconsistencies that accumulate over time, resulting in a “ball of mud” that is hard to reverse. While previous discussions focused on preventing this decay through the concept of deep modules, this video shifts focus to curing an already deteriorated codebase using fundamental software principles and a specialized skill called “improve codebase architecture.”

Central to the discussion is the concept of modules, which are units of functionality within an application, such as authentication or logging components. Each module has an interface—the set of methods and documentation that callers use—and an implementation, which is the underlying code. The video distinguishes between deep modules, which hide complex implementation behind a simple interface, and shallow modules, which expose complex interfaces with little underlying functionality. Deep modules are preferred because they promote locality, meaning related changes and fixes are concentrated in one place, and provide leverage, allowing users to access significant functionality through a minimal interface.

The presenter introduces additional architectural concepts such as seams and adapters. Seams are the boundaries where modules interact, and they are crucial for testing and maintaining code quality. Adapters satisfy the interfaces at these seams, enabling flexibility such as substituting a real clock with a fake clock during testing. These concepts help maintain a clean architecture that supports easier testing and modification. The goal of improving a codebase is to increase module depth, locality, and leverage, which collectively enhance maintainability and testability.

The video then demonstrates the practical application of the improve codebase architecture skill on a real React-based project. The skill analyzes the codebase to identify opportunities for deepening modules and improving locality. It highlights areas where parallel implementations exist without a single seam, suggesting refactoring to unify these into a single module. The process involves interactive sessions with the AI, where the developer provides feedback and makes strategic decisions, emphasizing that this approach requires active human judgment rather than being fully automated.

In conclusion, the presenter stresses that improving a legacy or AI-affected codebase is not a fully automated task but a collaborative effort between the developer and AI tools. Running the improve codebase architecture skill regularly can uncover many opportunities to deepen modules and enhance code quality. This approach also facilitates better testing, which is essential for safely evolving legacy codebases. The video encourages viewers to explore these skills further through linked resources and highlights the importance of strategic oversight in managing codebase health in an era of rapidly evolving AI-generated software.