Deterministic vibe coding for APIs.
Turn your OpenAPI specification into a running system you can control with JavaScript.
Start a mock server in one command.
Starts a mock API server and opens an interactive REPL.
Your API contract defines the structure.
Your code defines the behavior.
What you get
- Contract-driven mock server generated from OpenAPI.
- JavaScript REPL for interrogating and changing server state.
- Programmable simulations, not static canned responses.
- Deterministic resets on restart, with optional persistence.
- Fast feedback loops for frontend and integration work.
APIs are contracts
Your OpenAPI specification already describes the system.
Endpoints. Requests. Responses. Schemas. Error conditions.
But most tools treat the spec as documentation.
Counterfact treats it as the source of truth.
From that contract, Counterfact generates a working mock server and strongly typed interfaces that enforce the API structure automatically. Change the spec and the system updates immediately. You don't even have to restart the server.
No handwritten types. No drift between the contract and the implementation. No surprises during integration.
Your API specification stops being documentation. It becomes executable.
Contract-driven mock servers
Counterfact generates a mock API server directly from your OpenAPI specification.
At the same time, it exposes a JavaScript REPL that lets you inspect and manipulate the system through a programmable context object.
Your API contract defines the structure.
Your code defines the behavior.
Program the behavior, not the responses
Most mock servers return static responses. Counterfact lets you program how the system behaves.
The built-in REPL exposes a context object representing
the state of the mock server. You can interrogate it, modify it, and
change how the system responds with ordinary JavaScript.
Change data directly
The server updates immediately. No restart required.
Simulate system conditions
Now requests to that endpoint return a 500 error. You decide how the system behaves.
Because the REPL exposes a programmable context object, you can simulate almost anything.
- modify data
- trigger edge cases
- simulate outages
- test failure modes
- prototype new API behavior
Restart Counterfact and the system returns to a known state. If you want persistence, you can implement it using TypeScript.
Deterministic when you need repeatability.
Programmable when you need realism.
Example
A simple OpenAPI specification for a pet store.
Start Counterfact
Call the API
Modify the system in the REPL
Response updates instantly
Your OpenAPI contract defines the structure.
The REPL lets you control the behavior.
Designed for predictable systems
Modern development moves quickly. Teams prototype APIs, generate code with AI, and integrate services earlier than ever before. But speed only works if systems remain predictable.
Counterfact is built around a simple idea:
The API contract defines the structure.
Developers control the behavior.
The OpenAPI specification describes the system. The REPL exposes a programmable context object that lets you simulate whatever behavior you need using ordinary JavaScript or TypeScript. This keeps the system deterministic, flexible, and easy to reason about.
Restart the server and the system returns to a known state. When you need persistence, you can implement it. When you need realism, you can program it.
Deterministic resets. Programmable behavior.
Get started
Start a mock server in one command.
Explore the REPL. Modify the system state. Prototype APIs faster.
Built by Patrick McElhaney
Software engineer and architect focused on developer tooling and system design.
I enjoy building tools that make complex systems easier to understand, explore, and build. Counterfact is one of those tools.
Open to work
I'm currently open to new opportunities building developer tools, platform infrastructure, and high-leverage engineering systems.
If you're hiring or would like to connect, you can find me here: