Vibe Coding vs Harness

Harness is the term that recently emerged to refer to the shell around an AI model that serves to drive it. The goal of a harness is to increase the chances of getting the generation right, and the way it works is by implementing a self-correcting loop that drives the model and evaluates its generation. In essence, it tells the model what to do, checks that the result is correct, and iterates until the result is as expected.

A first layer of harness is built into the agents. That explains why, at least in my experience, Claude works better than Copilot even though both may use the same Anthropic model in the same version: the harness inside them is different.

The second layer of harness is provided by the user. It consists of prompt engineering, skills, tests, guardrails, and configuration files that explain to the agent what to do and how to do it. It’s supposed to be more rigid than the default harness and to focus on what’s important for the engineer. It’s pointless to specify “make it compile” in the prompt because that’s an obvious criterion in the first layer. Instead, it’s useful to add explicit examples that can be used for validation.

The second layer of harness is what makes the difference between “vibe coding” and proper engineering. Vibe coders typically prompt the agent without adding their own guidelines (“make no mistakes” is obviously a useless waste of tokens). Vibe coding is therefore a shoot-and-pray approach that relies entirely on the agent to define what good looks like and lets the model wander left and right without a fixed direction.

What more savvy engineers do is use a more complex setup that includes multiple levels of configuration: a core “generic” configuration and a per-project configuration, each containing instructions that specify every aspect the model must consider, from coding conventions to the architecture. Plus, of course, a good engineer specifies what the acceptance criteria are.

I saw tutorials suggesting a stratified approach that, quite frankly, I consider overwhelming. So far my fairly simple solution seems to work pretty well:

  • Claude.md/Agent.md at project level.
  • Thematic md files in ./docs to describe individual aspects of the application.
  • Acceptance tests to validate the result, including metrics with gates to automatically approve a change, automatically iterate, or ask for confirmation. For example, I ignore a performance drift of 1%, and I ask to retry if the drift is between 1% and 3%, to take into account the noise on my machine. Only above 3% do I check more carefully.

I suppose that my acceptance tests are the single most effective tool in my setup.

For a PDF library I’m developing, the measure of success is based on comparing how Chromium and my library transform the same HTML into a PDF. The test I wrote compares the renderings pixel by pixel and estimates how different they are. I also added a correction factor to ignore empty space (otherwise even a very wrong rendering would still be 90% accurate).

In figure: red/blue pixels mean that only my library or Chromium rendered something in that position, gray means that both rendered something in that position (=this is good!)

The similarity metrics, together with the performance metrics, became the harness for the AI. It immediately identified quick wins and increased the score, but the metrics also put pressure on keeping memory and CPU usage under control.

Very often an iteration partially failed because adding a feature made the processing slower, but I could always detect the issue and act on it.

In figure: sometimes it’s hard to distinguish between an error of 1px and a bigger one.

Since iText is one of the most popular Java libraries for PDF, I initially used it as a benchmark for quality. Having used it for many years, I know how good it is, and I didn’t expect to hit its limits so soon, but it happened. The diagram shows the inversion of similarity when I changed the goal from being very close to iText to being very close to Chromium.

After weeks of work, I now have a product that is almost ready for launch and renders complex pages pretty well, with better results than similar products.

After reaching at least 99% on my original benchmarks, I built a new one, which is now the next challenge. While iText renders it with several errors (it seems to ignore many style elements), my library gets closer and closer to the “golden” quality of Chromium.

Working this way took me a fraction of the time I would have needed to code everything by hand. The PDF and CSS specs are very complex, hard to follow, and tedious, and it would have been nearly impossible to be competitive. Thanks to AI and my approach, I progressed very quickly and had almost zero regressions.

Tags: AI
audit pixel