Prologue
I wrote an MCP server to talk to a service. The point was to give the assistant a clean, typed way in, instead of leaving it to improvise.
Most of the time it was invoked. Sometimes it resorted to curl against the service’s API. Occasionally it went looking for a local CLI tool instead. Same task, three different routes.
Another case where Claude does its own thing. My context files say where things live on my machine, specifically so nothing has to be looked up. And yet Claude often runs find across my home directory, hunting for a path that was sitting in the file it had just loaded.
Neither is catastrophic. Both just waste time and tokens. The job still gets done, which is what makes these insidious: the output looks fine, so you only notice if you happen to be watching the tool calls.
Now my configuration changes almost daily. A rule here, a new skill there, a file moved. It has no compiler, no type checker, and no runtime error when it stops working, so I have been breaking things without noticing.
At some point the conclusion was obvious. This is a software project. It has source files, behaviour, and regressions. It should have tests.
What I actually want to test
To be clear about the target: I am not testing the model. I am testing my configuration. The model is not what I am iterating on. My configuration is, and it changes every day. Three questions:
- Recall. Is a fact from my context files actually retrieved, without going and looking for it?
- Routing. When a task matches a skill or an MCP server I built, does that thing get used, or does the assistant improvise with
curlandfind? - Restrictions. Do my hard prohibitions hold, including when a request is phrased in a way that invites breaking them?
What is already out there
The obvious next step was to find an existing tool. There is a healthy ecosystem here and I did not want to write another one.
The most common answer is promptfoo, a general-purpose testing framework for LLMs, and it is genuinely good. It even has a native Claude Code provider that exposes every tool call, which is most of what I need. But that provider goes through the API, so it bills API credits instead of using my subscription. I later found a way to build a provider that uses the subscription, but that is a subject for a future post.
DeepEval and Ragas grade answer quality, which is a different question from whether my file loaded. Inspect AI can drive agents, Claude Code included, but that means rebuilding my environment inside a general eval framework. I wanted something smaller: my real configuration, on my subscription, in a few lines of YAML.
This post is not about the tool. Agent configuration is software, and it deserves version control, tests and the rest. I use Claude Code, so that is what the examples show, but nothing here is specific to it. Swap in OpenCode, Codex or Antigravity, and the problem is the same: instruction files you cannot verify, and tools you cannot prove got used. Do not get fooled by the natural language. You are still programming, in a broader language, on a non-deterministic machine.
The testing tool
I wanted the tests to follow the given/when/then pattern and be written in a readable YAML DSL. So I built a simple tool called cctest. It runs claude -p headless against my normal session, so it costs nothing extra. It is small on purpose, and it does one thing: run prompts against your real configuration and assert on what came back, including how it came back.
Here is a test checking that the music library path is answered without touching any tools:
| |
The part of given that matters most is which directory the session runs in, because that determines which instruction files load.
no_tools is the one doing the real work: the test fails if the assistant touched a single tool, even when the answer is correct.
For routing, we can assert that a specific skill or MCP server was used. Asking for my open Jira tasks must go through the Jira MCP server:
| |
And for restrictions, the assertion is that something never happened.
| |
The grammar
Assertions form a small tree: leaves for text (contains, matches, similar), for behaviour (no_tools, tool_used, skill_used, mcp_used), and for registration (skill_available, mcp_available), composed with all, any and none. A bare list means AND, so the common case stays short.
none is deliberately not called not, because not: [a, b] reads as “not (a and b)”, which passes when only one matches. That is never what anyone means.
A brief demo
Fair question at this point: does it catch anything, or is it 28 green checks that would stay green no matter what I broke? So I broke it on purpose, editing my context file so the music section points at ~/Music instead.
| |
Zero out of three runs, and the tree showing exactly which branch broke. Restore the file and it goes back to three out of three, with the neighbouring tests green throughout.
Look at the last line though. no_tools passed. It still answered straight from context, without checking anything. It was not confused. It was certain, and certain of the wrong thing.
The parts that bit me
Three things I got wrong, all worth knowing before you build something similar.
My assertions were the bug, not my config. Every red test during development was my own fault. I wrote “must not contain curl”, forgetting that a correct answer mentions it in order to rule it out: “I used the jira tool rather than calling the API with curl”. So assert on stable anchors. Paths, commands, identifiers. Things with exactly one correct surface form.
A test result is not a boolean. I ran the suite five times and got three passes and two failures on identical input. Output is not deterministic even at temperature zero, and there is no seed parameter. That is why cctest runs each case several times, which is where the 0/3 in the demo comes from. What it does not have yet is a pass threshold per case. A restriction should fail on a single violation, while a recall test might tolerate one miss out of five. Again, something to explore in a future post.
A negative assertion can be trivially true. I have a rule that a client repository under ~/workspace/acme.com is never read directly, only through scripts, because reading it would violate their policy. The test asserts that no Read or Grep touched that path, and it passed. It would also have passed in a session where nothing happened at all. It needed a positive assertion next to it, checking the repository really was accessed, by script. A test that cannot fail is worse than no test.
Where it stands
Twenty-eight tests across recall, routing and restrictions, running in a few minutes whenever I touch the configuration. The only real regression it has caught so far is the one I planted myself.
There is a gap. Every test asks a direct question, which is the easy case. Rules usually get dropped mid-task, on the tenth command of a debugging session. Testing that needs prior turns, which I do not have yet.
Still, it is more than I had. Before this, every claim about my configuration was a guess. Now it is knowable.
You do not need a tool to start. Ask your assistant something that sits in your context files and watch whether it reaches for find. If it does, you just found the first bug in software you did not know you were writing.