AI Coding Sweet Spots

It's no secret that I, along with many other seasoned software engineers, dislike the unbridled "vibe" approach to coding with AI. I have, however, found it immensely useful in several cases. Here are a two:

Fixing small issues in open source projects

While a recent study among AI users on open source projects found that it does not actually make them faster, on the whole, those findings are extremely context-dependent. Here's an example from my own experience: An extension to my code editor of choice (VS Code, currently) was lacking a feature that I really wanted. In the past, I would have filed a feature request with the tool's maintainer and hoped for the best. But today, I just downloaded the code, asked Claude Code to implement the feature, tested it (obviously!) and submitted the changes for the maintainer to review.

AI, in this case, rapidly sped up the part where you slowly familiarize yourself with an existing codebase to find the place(s) where a change must be made. Given that I have no intention to become a permanent maintainer of that tool, that upfront time investment would be prohibitive if it weren't for AI.

Understanding and Improving Legacy Code

This is an area I'm pretty excited about. The world is replete with legacy code (and one can argue that vibe coding is only going to add to that pile). First, a definition. Legacy code isn't code that's old. Instead, according to the guy who wrote the book on legacy code (Working Effectively with Legacy Code by Michael Feathers):

Legacy code is code without tests

Simple as that. Why is that? Without tests, you can't safely change or extend the code, and you lack a true documentation of the code's intent. And that's when you're in a case of "well, this works for now but we better don't touch it because Bob wrote this five years ago and has since left the company and we don't know how it works".

In that book, Feathers describes strategies for slowly turning legacy code into well-tested code. These steps are somewhat mechanical and deterministic but not quite as straightforward as automated refactorings. That makes them excellent for AI coding agents:

  • AI can scan a large codebase and figure out dependencies that span many files. If you ask the right questions, it'll do the tedious "look in this file, find a function being used, so go look for the file where that function is defined, find another rabbit hole to go down" etc etc

  • AI can write, or at least suggest useful tests. Once you have tests, you can move on to more aggressive refactorings and code improvements

  • The existing code and its behaviour are a narrow source of truth that keeps the AI honest: If all you do is add a test, that new test must pass. If all you do is a structural change (aka refactoring), the existing tests must pass.

I'd be curious to see how far one could push autonomous agents to overhaul a legacy codebase; there are probably too many idiosyncrasies in each case to allow for a fully automated one-click solution. Still, it's a great chance where the costs of continuing to tolerate a legacy codebase might finally be larger than the costs of tackling them (and all without a full from-scratch rewrite!)

This was a longer and more technical post than usual, but I wanted to provide some positive counterweight to my bashing of vibe coding. The tools are what they are, and it's up to us to use them to good effect.

Previous
Previous

LLM Recommendations

Next
Next

Fast Fashion, Fast Software