
Why we write Executable Specs before any agent writes code
Everyone who works with coding agents has learned to plan first. You switch on plan mode, or write a plan.md or spec.md, agree it with the agent, and then let it build. It’s a good habit, and much better than prompt and pray.
But look at what a plan or spec file is. It’s prose, written for a model to read. The model reads it once, interprets it, and acts. Then the file goes stale while the code moves on. Nothing checks that it was complete. Nothing checks that it didn’t contradict itself. And nothing checks, a month later, that the code still does what it said.
Making the file more detailed doesn’t change that. Split it into many files, stories and tasks, and it’s still prose. Nothing can check it for gaps or contradictions, or reliably generate contracts and tests from it.
A plan or spec file is a message to a model. An Executable Spec is a contract the machine checks.
The gap, in one line of a spec file
Suppose a plan or spec.md says: “Users can mark a task as done.”
That reads as complete, but it leaves questions open. What happens if the task is already done? Can a done task be reopened? Who is allowed to do it? The file doesn’t say, so the agent decides, silently, and differently each time you ask.
An Executable Spec doesn’t let you leave those questions open. The same behaviour is written as typed data.
“Typed” needs a word of explanation. In a spec file, “priority” is just a word. In a typed specification, priority is declared as a whole number of zero or more, and a task ID is declared as a task ID, not just any text. “Typed” means the machine knows what kind of thing each piece is, so it can tell when something doesn’t fit.
So the one line in the spec file becomes:
- An entity with a lifecycle. A Task moves from Open to Done. There is no arrow back, so reopening is illegal by absence. Nobody has to remember to forbid it.
- A command with every outcome declared. CompleteTask either completes the task or is refused because the task is already done. Commands are the only way state changes, and each one must declare its refusals, not just its happy path.
- An actor. The spec says who may issue CompleteTask.
- Invariants. An invariant is a rule that must be true at all times, whatever happens: “a priority is never negative”, “lives never drop below zero”. Every action that changes the system has to leave the rule still true.
What the machine does with it
Because an Executable Spec is typed data, not prose, the toolchain can do things a plan or spec file never can.
It checks the spec itself. The toolchain’s commands all start with ess, short for Executable System Specifications. ess specify validate reports every problem in one run. An unresolved name can’t even be represented. If the spec doesn’t say enough about something to test it, that thing is refused, not omitted, and the tool tells you why. Completeness and consistency become things you can check, not things you hope for.
It generates the contracts. From one spec, ess generate produces OpenAPI and AsyncAPI documents, JSON Schema, and human-readable documentation and diagrams. The documentation is a projection of the spec, so it can’t drift from it.
It generates the tests. ess verify conform derives one test scenario per obligation: every declared outcome, every lifecycle move, every move that must not be allowed, every invariant. In the task example, that includes a test that completing an already-done task is refused, and one that a done task can’t be reopened. The spec becomes the oracle the implementation must answer to.
It refuses to let the test suite quietly shrink. As the documentation puts it, a suite holding fewer checks than the spec requires “is the one failure a passing run cannot show.” So the toolchain reports what it couldn’t generate, rather than silently skipping it.
It tracks drift. Every generated artifact carries the specification version and a digest of the exact part of the model it came from. When the spec changes, you can see which contracts and tests are out of date.
It keeps design separate from deployment. The same spec can compile to a modular monolith or to separate services without changing the domain model.
Spec file versus Executable Spec
| plan.md, spec.md, plan mode | Executable Spec | |
|---|---|---|
| Written for | A model to read | A machine to check |
| Form | Prose | Typed, validated data |
| Gaps and contradictions | Invisible until the code shows them | Reported by validation; untestable parts are refused |
| Edge cases and refusals | Decided by the agent, silently | Declared as outcomes, or the spec isn’t valid |
| Tests | Written separately, if at all | Generated: one scenario per obligation |
| After the session | Goes stale | Stays the source of truth; generated artifacts are versioned and checked for drift |
Where the agents come in
An Executable Spec deliberately does not generate behaviour. It generates the structure, the slots where the behaviour plugs in, and the obligations that behaviour must meet. Writing the behaviour is the agent’s job, or a person’s, and the generated tests decide whether they got it right.
That’s the division of labour in what we call Safe Agentic Coding. Human intent is turned into a specification first. The specification is checked for completeness and consistency, and turned into contracts and tests. Only then do agents write code, and every change is checked against those contracts. In the words of our principles, the model “may reason inside each step” but “should not silently own rules.”
Agents are good at writing code. They shouldn’t be the ones deciding, unseen, what the system is allowed to do.
An aside: a game, for fun
For a bit of fun with the team, Timo Friedl wrote a Pac-Man-style arcade game, REAPER.EXE, as an Executable Spec. It’s a good illustration of how much one spec can reliably be the source for. From the same spec came:
- Renderings: documentation and contracts for the game’s rules.
- A generated test suite that holds the game core to the spec.
- The move set of an AI player. Timo trained an AI to play the game, and its possible moves are exactly the commands the spec lets a player issue. A test checks that the two match.
What the spec deliberately leaves out (time, geometry, randomness and arithmetic) stays in the game engine. That’s the same split you’d make in any business system. The rules are the contract; the timing and the maths are implementation.
[GIF: reaper-policy-v2.gif]
Try it
Executable Specs, their documentation and a getting-started guide are on beyond10x.
To get involved in using agentic AI safely in your teams, join one of our early access programmes (EAPs).

