Audience: engineers using or evaluating AI coding tools, so they can explain it to the VP for a PowerPoint
Experts at anything are reliably poor at teaching novices what they know. Colloqueally stated, the expert's deep understanding of a problem space limits how much they can understand about a newcomer's perspective. Experts cannot easily determine where a novice is not "getting it" (Chaiklin, 2003).
Let's anthropomorphize! Everyone's doing it! Imagine a technology, the "LLM", or "AI", going forward with the skills of a novice and the confidence of a mediocre white man. Then, in a long session, our budding little artificial tech bro builds up the context it needs to "collaborate" more effectively. To act "expert-like." To be that mediocre white AI. Where do you put the safety gates? You know, the gates your parents put in front of the basement stairs to prevent you from tumbling down them?
(Photo: These are skulls in the Sedlac Ossuary in the Czech Republic, and guardrails around AI code generation are essential for avoiding an AI Plague. And the bone skull church memorials they historically manifest.)
If you are using AI to write code, you're going to need some safety gates so that little baby artificial bro doesn't throw your hard work down the stairs. Test-first programming, sometimes called "test driven development" is one such safety gate I've used in every Aveloxis release. Oh, and there have been 119 since my last post. Over the next few weeks I'll use this space to tell you more about how I built a series of gates, playpens, and dog parks to wrangle AI, or as I call it now, "Little Artificial Tech Bro Intelligence", or "LATBI".
Nearly every instruction I gave Claude Code during the five days that produced the first release of Aveloxis carried the same bounding text:
I need you to implement the following features in Aveloxis, one at a time. For each feature:
- Write comprehensive Go tests first,
- Run
go test ./...to confirm they fail,- Implement the feature across all necessary files,
- Run tests again and iterate until all pass,
- Move to the next feature.
Test Driven Development (TDD)
Test-driven development is usually sold on correctness. Write the test first, and you can't write code that passes a test you invented afterward to match it. If you misunderstood the requirements, then either your code or your test will be wrong. Either way, the test fails. In this way it is the most elementary form of reflection for a software engineer.
Each test in a TDD regine will create a constraint under incomplete context. TDD is most valuable when the person writing the code cannot hold the whole system in their head. Imagine a new hire, a contractor, or someone returning to a codebase after months or years. The test is an executable specification that survives the gap between what you meant when you wrote the test, and what you understood when you wrote the code.
Step 2 in my TDD prompt, "run the tests and confirm they fail", goes part, but not all of the way toward good process. We can write crap tests that don't cover our intentions, and fail. Then get crap code to pass them. So, it's not process for processes sake that matters. Systematically and thoughtfully defining the necessary functionality and performance criteria, and manifesting that in a test is what's important.
If you want tests that hold your AI use inside your safety gates, you have to have somebody who understands the problem space on your team. Or, that needs to be you; but I think in the Aveloxis example, I'm a bit of a unicorn. Few people have three decades in software engineering and computing research to combine with over a decade of expertise in open source software health metrics.
The Rules and The Skills
Here's a snippet from my development workflow section in CLAUDE.md:
Pre-push adversarial pass (v0.27.145): before pushing a batch, the NEW diff gets one fresh-context adversarial review against
docs/contributing/review-lenses.md(the lenses distilled from the PR #184 retrospective, summary/23; L11–L13 added after PR #191). Findings are verified against code, then fixed or declined-with-reason — the cycle is review→fix→push. The fix for a finding is itself new code: it gets the same pass (lens L10).
"L10" is "lens 10" from the review lenses document. So, TDD, yes, but one also has to be clear about the overall process and how the AI gets through it.
So, the documented review lenses are here: https://github.com/aveloxis/aveloxis/blob/main/docs/contributing/review-lenses.md and to that, and TDD, I add invariants to the CLAUDE.md, and maintain a set of reinforcing skills under the .claude/ directory in my project. These rules cover all of the critical, software engineering pitfalls I became familiar with while spending a decade buildint the CHAOSS project's core software, Augur. There are rule documents for:
- Architecture
- Database Migrations
- GraphQL
- Pitfalls
- Scheduling
- Testing
- REST API Development
Each of these particular areas happen to be rife with paradox, enigma, and rare data that will break them. I don't publish these for a number of reasons, but the fact that it's a documentation of everything I learned building CHAOSS Software for 10 years is central. I gotta eat.
Two things about it are worth generalizing.
First, it encodes invariants, not tasks. "Everything that errors should be logged" is not a feature request. It's a property that every subsequent piece of code has to satisfy. Task-shaped instructions produce task-shaped code. Invariant-shaped instructions produce a system.
Second, it grew by accretion at the moment of decision. Every time I decided something — a naming convention, a schema choice, a policy about GitLab gaps — it went in the file immediately. Not at the end of the day. Immediately.
I did that because I don't trust AI to have a recollection of our last conversation. Heck, I don't trust myself to remember!
The constraint runs both directions
In April I quoted Phil Agre and argued that what I was working with isn't "artificial intelligence" in the inherited sense — that it's closer to a systematic implementation of patterns, and that once it recognizes your pattern of problem-solving it starts constraining your actions the way grammar constrains speech. Imperfectly, but deliberately.
Months later, I think that's the truest thing in the post, and I buried it three-quarters of the way down.
The short version
If you're taking one of these tools for a serious run:
Keep a rules file, write invariants rather than tasks, and update it the moment you decide something. Make the model confirm failure before it implements. Expect the tool to shape how you write, and notice when it does. And put your review effort on the specification rather than the implementation, because the implementation is going to be a faithful rendering of whatever you asked for, including the parts you got wrong.
And for the good of the commonwealth, write your tests first. How else will you know if the AI got where you wanted it to?
References
Chaiklin, S. (2003). The zone of proximal development in Vygotsky’s analysis of learning and instruction. Vygotsky’s Educational Theory in Cultural Context, 1(2), 39–64.
aveloxis