Vibe Coding Rescue: Fixing AI-Generated Technical Debt

3 min read Original article ↗

In the words of Yogi Berra “you can observe a lot by just watching” and the more I looked, the more I saw. The first thing that dawned on me was the staggering lack of consistency as I tried to apply patterns that were working in one area to fix a bug in another area. Cursorrules files can be used to improve consistency, and my friend had not created one of those. Does using cursorrules go against the spirit of vibe coding? Does aiming for code consistency? 

The second thing I started to notice was regarding state management – it was a mess. It made me realise all the different ways you can access state in a react application – via an API, via props, via hooks, fetched from an API, as part of the route, and so on. Once again there was no consistent approach – values were read from props that were never set that could have been gotten from the route. The nature of the app was very simple – state was a simple hierarchy being edited by a single user, and yet it still seemed like a big stumbling block. 

The third thing I started to notice was bits of back-end functionality that didn’t work, but weren’t on my friend’s list of bugs. After discussing a few of these with him it became apparent that these were never features he’d asked for, but hallucinated features that had gone un-noticed because they were failing silently. Like a vestigial appendix in the code-base these could (and certainly should) have been removed, but teasing out what was “real” and not working, and what was just noise would take time. 

As these issues began to mount the final epiphany I had was that (for me) it was hard to fix a system like this because my mindset was now different to fixing issues in a “normal” project. In a normal project I often push through issues by trying to think about the state of mind of the previous person working on the code – you see something in there and even though it might not be right you can see what they were trying to do. Things, even buggy or misguided things, exist for a reason. Here, there was no “they” – more and more it felt like just a lot of random code that had been welded together. I was amazed that it worked at all, and suspected and subsequently confirmed with my friend that there had been a lot of back-and-forth prompting that would have gone something like this: 

 
user: I’m getting the following error when I do X 
agent: I see there’s an issue with the DoX method, let me fix that. 

user: I’m still seeing an error when I do X, it says..
agent: I apologize for the error. I see now there is another issue with the DoX method. Let me fix that.