
Distill
Requirements are expressed as scenarios.
A scenario represents the system's behavior from the user's perspective and follows the Given-When-Then structure to create a testable specification.
The specification is written as executable tests, which are automated and run continuously. These tests cover a full range of scenarios, from happy paths to error cases.
Success Scenario(s)
Focus on a single command!
For the ChangeMenu command to succeed, you need to specify the required preconditions/events. In this case RestaurantCreated / Exists is a precondition.
RestaurantCreated / Exists might not be the only precondition. For example, "The menu must be in a modifiable state (e.g., not locked due to an active promotion or regulations)"

Deno.test(function changeRestaurantMenuDeciderTest() {
const changeRestaurantMenuCommand: RestaurantCommand = restaurantCommandSchema
.parse(
JSON.parse(changeRestaurantMenuCommandJson),
);
const restaurantCreatedEvent: RestaurantEvent = restaurantEventSchema
.parse(
JSON.parse(restaurantCreatedEventJson),
);
const restaurantMenuChangedEvent: RestaurantEvent = restaurantEventSchema
.parse(
JSON.parse(restaurantMenuChangedEventJson),
);
DeciderSpecification.for(restaurantDecider)
.given([restaurantCreatedEvent])
.when(changeRestaurantMenuCommand)
.then([restaurantMenuChangedEvent]);
});
Deno.test(function changeRestaurantMenuDeciderTest() {
const changeRestaurantMenuCommand: RestaurantCommand = restaurantCommandSchema
.parse(
JSON.parse(changeRestaurantMenuCommandJson),
);
const restaurantMenuNotChangedEvent: RestaurantEvent = restaurantEventSchema
.parse(
JSON.parse(restaurantMenuNotChangedEventJson),
);
DeciderSpecification.for(restaurantDecider)
.given([])
.when(changeRestaurantMenuCommand)
.then([restaurantMenuNotChangedEvent]);
});Error Scenario(s)
Focus on a single command!
Define all the possible reasons why ChangeMenu command can fail. In this case RestaurantCreated / Exists is missing as a precondition.
RestaurantCreated / Exists might not be the only missing precondition. For example, "The menu must be in a modifiable state (e.g., not locked due to an active promotion or regulations)"
Bring structure to AI coding
AI coding often feels like a blur of prompts and patches. But what if we could apply the same mature engineering practices/spec-driven development?
Imagine pairing these practices with tools like Kiro, where AI agents plug into MCP servers and APIs. Instead of ad-hoc coding, you guide the flow with specs.
This is spec-driven AI development: complexity tamed, structure preserved.

Libraries (Kotlin | Rust | TypeScript)
f{model} in Kotlin
Lightweight Kotlin library enabling functional and reactive domain modeling patterns
f(&model) in Rust
Lightweight Rust library enabling functional and safe domain modeling patterns
f(model) in TypeScript
Lightweight TypeScript library enabling functional and algebraic domain modeling patterns
Demo Applications
| Language | Source Code |
|---|---|
| Kotlin (Spring) | |
| Kotlin (Ktor) | |
| TypeScript | |
| Rust (Actix-Web Server) | |
| Rust (PostgreSQL Extension) |