counterfact

Modify routes, contexts, and scenarios in Counterfact API simulations.

169|19|Updated Apr 8, 2022
One-click install
npx skills add https://github.com/counterfact/api-simulator --skill counterfact
Or copy as Structured Prompt for Agent
Please help me install this Agent Skill.
Skill: counterfact
Source: https://github.com/counterfact/api-simulator/tree/main/skills/counterfact
Command: npx skills add https://github.com/counterfact/api-simulator --skill counterfact

SYSTEM DOCUMENTATION & REQUIREMENTS

What problem does it solve?

Helps developers quickly understand how Counterfact is structured and how a generated API simulation is organized, reducing misconfigurations and edit mistakes.

Core Features & Use Cases

  • Generates route handlers and types from an OpenAPI/Swagger spec to produce a working mock API.
  • Live server with hot reload and a built-in REPL to control behavior at runtime.
  • Shared runtime state across routes and scenarios, with state mutations stored in context files.

Quick Start

Start a local Counterfact project from an OpenAPI spec and open the REPL to inspect and control API behavior.

Frequently Asked Questions about counterfact

High-intent search queries and answers about installing and using this skill.

FAQPage Schema
How do I safely edit routes and scenarios in a generated API simulation?

To safely edit API simulation routes and scenarios, use a tool that automates exploration and modification of Counterfact-generated structures. It applies changes across routing definitions, contexts, and runtime state to reduce misconfigurations.

What is the best way to manage shared state across API mock routes?

Managing shared state across API mock routes involves storing state mutations in context files. This approach maintains consistent runtime behavior across different routes and scenarios within your generated simulation project.

How do I control OpenAPI mock behavior at runtime without restarting the server?

You can control OpenAPI mock behavior at runtime without restarting by using a built-in REPL. It allows you to inspect and dynamically adjust the API simulation while the live server runs with hot reload enabled.

Do I need an OpenAPI specification to generate route handlers for a mock API?

Yes, you need a working OpenAPI specification to generate route handlers and types. The specification drives the creation of a working mock API and its corresponding project structure.

Can I use Node.js to run an OpenAPI-driven simulation with hot reload?

Yes, you can run an OpenAPI-driven simulation in a Node.js environment. Execution requires a generated project structure with routes, scenarios, and context files to enable the live server with hot reload.

Why are my API simulation state mutations not persisting across scenarios?

API simulation state mutations must be stored in _.context.ts files to persist correctly. If mutations are not properly applied to these context files, shared runtime state across routes and scenarios will not remain consistent.