Keeping score
My big brother Mikael talked a lot about measuring code quality. I mostly nodded. He worked at Ericsson and this was his job. I didn’t think too much of it, until now.
Now agents write most of my code. And it works fine, until it doesn’t. The trouble is one don’t know when that happens, and it is hard to catch it when it does. I tried some experiments, but learned that experiments on open source code are pretty misleading. Most open source is probably already part of the models, so they just know the code by instinct. Hmm.
I recently watched Adam Tornhill’s talk AI-Friendly Code from GOTO Copenhagen. The idea that stuck with me is that code that is hard for a human to work in is hard for the agent too. Tangled code makes the agent slower and sloppier, and then it writes more tangled code. So how about letting the agent see a score?
So I whipped up aihealth, a CodeScene-style health estimate from 1 to 10, built from a handful of explainable smells like Brain Method, Deep Nesting and Bumpy Road. The part I care about is the delta. Did this change make things better or worse:
aihealth delta --format markdown
It exits with 1 when health degraded and lists the new smells with path:line and a hint, so a Claude Code hook can just hand it back to the agent.
But frankly, a talk is not a result. So I ran a scan on every commit of six of my own repos. Three written by hand, two 100% built with agents, and beer_planner that I switched to agentic along the way.

Please be kind, I’m exposing my own code quality level here (between 8 and 9). abl_app I did for money, so I maybe made a better effort there, the others are things I made for fun. I was actually a little surprised how well beer_planner held up, that one was more or less built with least effort.
The agent repos trend worse, and end up a bit lower than my own. Some of the jumps are from adding tests or other big parts in one go. The Agents Dashboard grew to 33,000 lines and sat around 6.9 for months, and epslicer is at 6.11. Then on the dashboard I let the agents work through the aihealth findings. Two days later it was at 9.80, and a test gate has kept it there since. Me smile.
Code that just gets worse and worse must be a real threat. I believe the worse it gets, the easier it is for the models to make mistakes, just like humans. I’m not sure a score makes the code safe, but at least I can see which way it is going. All six histories are in the full report.
Mikael was right, of course, he always was.
Grab it at github.com/epatel/ai-health.