Install the "counterfact-repl" agent skill from https://github.com/counterfact/api-simulator/tree/main/skills/counterfact-repl into .claude/skills/counterfact-repl/ in this project. Copy the whole folder (SKILL.md and every file beside it), keep the folder name "counterfact-repl", then confirm the skill loads.
Claude Code copies the folder itself, the same result as the manual copy. Check what it changed before you commit it.
Type this inside Codex. $skill-installer <name> installs a curated skill from openai/skills. The installer writes to $CODEX_HOME/skills (default ~/.codex/skills). Restart Codex if the skill does not show up.
skills CLI
$ npx skills add counterfact/api-simulator --skill counterfact-repl -a codex
Project install goes to .agents/skills/; add -g for ~/.codex/skills/.
Install the "counterfact-repl" agent skill from https://github.com/counterfact/api-simulator/tree/main/skills/counterfact-repl into .agents/skills/counterfact-repl/ in this project. Copy the whole folder (SKILL.md and every file beside it), keep the folder name "counterfact-repl", then confirm the skill loads.
Codex copies the folder itself, the same result as the manual copy. Check what it changed before you commit it.
skills CLI
$ npx skills add counterfact/api-simulator --skill counterfact-repl -a cursor
Project install goes to .agents/skills/; add -g for ~/.cursor/skills/.
Install the "counterfact-repl" agent skill from https://github.com/counterfact/api-simulator/tree/main/skills/counterfact-repl into .cursor/skills/counterfact-repl/ in this project. Copy the whole folder (SKILL.md and every file beside it), keep the folder name "counterfact-repl", then confirm the skill loads.
Cursor copies the folder itself, the same result as the manual copy. Check what it changed before you commit it.
--scope user (default) or --scope workspace; --path is the subfolder of the repo that holds the skill; --consent skips the security confirmation prompt.
skills CLI
$ npx skills add counterfact/api-simulator --skill counterfact-repl -a gemini-cli
Project install goes to .agents/skills/; add -g for ~/.gemini/skills/.
Install the "counterfact-repl" agent skill from https://github.com/counterfact/api-simulator/tree/main/skills/counterfact-repl into .gemini/skills/counterfact-repl/ in this project. Copy the whole folder (SKILL.md and every file beside it), keep the folder name "counterfact-repl", then confirm the skill loads.
Gemini CLI copies the folder itself, the same result as the manual copy. Check what it changed before you commit it.
Installs for Copilot at project scope by default; add --scope user for a personal install. Preview a skill first with gh skill preview. Needs GitHub CLI 2.90.0 or later (public preview).
skills CLI
$ npx skills add counterfact/api-simulator --skill counterfact-repl -a github-copilot
Project install goes to .agents/skills/; add -g for ~/.copilot/skills/.
Install the "counterfact-repl" agent skill from https://github.com/counterfact/api-simulator/tree/main/skills/counterfact-repl into .github/skills/counterfact-repl/ in this project. Copy the whole folder (SKILL.md and every file beside it), keep the folder name "counterfact-repl", then confirm the skill loads.
GitHub Copilot copies the folder itself, the same result as the manual copy. Check what it changed before you commit it.
skills CLI
$ npx skills add counterfact/api-simulator --skill counterfact-repl -a opencode
OpenCode documents no install command of its own. Project install goes to .agents/skills/; add -g for ~/.config/opencode/skills/.
Install the "counterfact-repl" agent skill from https://github.com/counterfact/api-simulator/tree/main/skills/counterfact-repl into .opencode/skills/counterfact-repl/ in this project. Copy the whole folder (SKILL.md and every file beside it), keep the folder name "counterfact-repl", then confirm the skill loads.
OpenCode copies the folder itself, the same result as the manual copy. Check what it changed before you commit it.
Facts
Skill name
counterfact-repl
GitHub stars
170
Token cost
~3.2k tokens
SKILL.md length
906 words
Files
2
Skills in repo
12
Repo updated
First seen
Licence
MIT
At a glance
Interact with Counterfact mock API server programmatically. An agent skill from counterfact/api-simulator.
Works in 5 steps: Check for health endpoint (most reliable) → Look for package.json → Check for routes directory → …
The user mentions counterfact
SKILL.md covers Purpose, What is Counterfact?, When to Use This Skill and Detecting Counterfact, plus 5 more sections
Counterfact Repl is an agent skill from counterfact/api-simulator. Interact with Counterfact mock API server programmatically. Inspect and modify context state, configure proxy settings, test endpoints, and control mock behavior. Use when the user mentions "counterfact", "mock server", "REPL", testing APIs, or working with OpenAPI mocks.
Its SKILL.md is about 3.2k tokens, which your agent loads only when the skill is triggered. The skill folder holds 1 other file (for example `examples.md`).
It sits in Backend & APIs, covering OpenAPI specifications. It works with OpenAPI, TypeScript and JavaScript. The repository describes itself as: Turn an OpenAPI spec into a local API in one command. Build and test your frontend with custom responses, shared state, and simulated failures, without waiting for the backend. The licence is MIT.
When your agent uses it
The user mentions counterfact
Working with OpenAPI mocks
Example prompts
“counterfact”
“mock server”
“/counterfact-repl”
Requirements
Node.js
A credential in COUNTERFACT_ADMIN_API_TOKEN
Workflow steps
5 steps, taken from the first numbered list in SKILL.md.
1Check for health endpoint (most reliable)
2Look for package.json
3Check for routes directory
4Check for OpenAPI spec
5Try alternate ports
What it can do on your machine
Read from SKILL.md and the folder at commit 0508aef. It shows what the files ask for, not the result of running them.
Tool permissions
Pre-approves nothing: there is no allowed-tools line, so your agent's usual permission prompts apply.
From allowed-tools in the SKILL.md frontmatter.
Runs code
No scripts in the folder and no shell commands in SKILL.md (its code samples are http, json, javascript and typescript).
From the folder's file list and the shell code blocks in SKILL.md.
Network
Hosts in commands or code, which the agent is likely to contact:
api.production.com
Also links to:
counterfact.dev
github.com
From URLs in SKILL.md, links to its own repository left out.
Credentials
Names these keys or tokens, usually read from environment variables:
COUNTERFACT_ADMIN_API_TOKEN
From names ending in _API_KEY, _TOKEN, _SECRET, _KEY or _PASSWORD in SKILL.md.
Context cost
Counterfact Repl loads about 3.2k tokens when it runs. Until then it costs about 72 tokens; SKILL.md has 906 words of instructions outside code blocks.
Always· name and description, kept in context so the agent knows when to use it
~72
When it runs· the whole SKILL.md, loaded when a task matches
~3.2k
Estimates: characters ÷ 4, the usual rule of thumb; real counts depend on the model's tokenizer. Scripts and assets cost tokens only if the agent reads them.
Safety
Auto-check passed
The automated check found no risky patterns in SKILL.md.
Automated static check — not a guarantee. Review scripts before installing. It scans the text of SKILL.md for risky patterns (piping downloads into a shell, reading credential files, hidden Unicode, destructive commands); files beside SKILL.md are not scanned.
Download SKILL.mdSave it as .claude/skills/counterfact-repl/SKILL.md (or your agent's skills folder). This skill also uses 1 other file; get the full folder from GitHub.
name
counterfact-repl
description
Interact with Counterfact mock API server programmatically. Inspect and modify context state, configure proxy settings, test endpoints, and control mock behavior. Use when the user mentions "counterfact", "mock server", "REPL", testing APIs, or working with OpenAPI mocks.
This skill enables AI agents to interact with a running Counterfact mock server through its Admin API. Counterfact provides programmable API mocks based on OpenAPI specifications, with a REPL for runtime manipulation. This skill exposes those capabilities programmatically via HTTP endpoints.
What is Counterfact?
Counterfact is a contract-driven mock API server that:
Generates mock endpoints from OpenAPI specifications
Provides a JavaScript REPL for runtime state manipulation
Allows programmable behavior (not just static responses)
Supports context objects for storing mock state
Enables proxy mode to route requests to real APIs selectively
The REPL lets developers manipulate mock state in real-time using JavaScript. This skill exposes the same capabilities via HTTP API.
When to Use This Skill
Invoke this skill when the user:
Mentions "counterfact", "mock server", "REPL", or "OpenAPI"
Wants to test or develop against a mock API
Needs to inspect or modify mock server state
Wants to configure proxy vs. mock routing
Needs to simulate API failures or edge cases
Says things like:
"Add data to the mock"
"Change the mock state"
"Make the API return an error"
"Proxy this endpoint to the real server"
"What data is in the mock store?"
"Simulate a service failure"
Detecting Counterfact
To determine if Counterfact is running, check in this order:
Check for health endpoint (most reliable):
http
GET http://localhost:3100/_counterfact/api/health
If successful, Counterfact is running on port 3100.
Look for package.json:
Check if counterfact is in dependencies or devDependencies
Use when: Discovering available endpoints, understanding API structure.
Common Usage Patterns
Pattern 1: Inspect Current State
User request: "What pets are in the store?"
Agent workflow:
1. GET /_counterfact/api/health
→ Confirm server running
2. GET /_counterfact/api/contexts/pets
→ Retrieve pets array
3. Present formatted list to user
Example response:
Currently in the pet store:
- ID 1: Fido
- ID 2: Whiskers
Pattern 2: Add Test Data
User request: "Add a new pet named Rex with ID 3"
Agent workflow:
1. GET /_counterfact/api/contexts/pets
→ Get current pets
2. Append new pet to array
3. POST /_counterfact/api/contexts/pets
Body: { "pets": [...existingPets, newPet] }
→ Update context
4. Verify by GETting /pets endpoint
→ Confirm change visible in API
Pattern 3: Simulate Failure
User request: "Make the user service unavailable"
Agent workflow:
1. POST /_counterfact/api/contexts/users
Body: { "serviceAvailable": false }
→ Set failure flag
2. Explain that route handlers should check this flag
3. Optionally: Test GET /users to verify error
Note: The route handler must be coded to check context.serviceAvailable. The skill sets the flag, but behavior depends on route implementation.
Show full SKILL.md (365 more words)Show less
Pattern 4: Switch to Proxy Mode
User request: "Route /orders to the real API"
Agent workflow:
1. GET /_counterfact/api/config/proxy
→ Check current proxy settings
2. PATCH /_counterfact/api/config/proxy
Body: {
"proxyUrl": "https://api.production.com",
"proxyPaths": [["/orders", true]]
}
→ Enable proxy for /orders
3. Confirm that /orders now hits real server
Pattern 5: Batch Data Setup
User request: "Set up test data: 3 users and 5 products"
Agent workflow:
1. Create users array with test data
2. POST /_counterfact/api/contexts/users
Body: { "users": [...testUsers] }
3. Create products array with test data
4. POST /_counterfact/api/contexts/products
Body: { "products": [...testProducts] }
5. Confirm setup complete
Error Handling
Server Not Running
If health check fails:
❌ Error: Counterfact server not running
Suggestion: Start the server with: npx counterfact openapi.yaml
Context Not Found
If context doesn't exist:
GET /_counterfact/api/contexts/nonexistent
→ Returns: { "path": "/nonexistent", "context": {...} }
Note: Contexts are hierarchical. If /api/users doesn't exist, it returns parent context.
Invalid JSON
If request body is malformed:
← 400 Bad Request
{ "success": false, "error": "Request body must be a valid JSON object" }
Server Error
If internal error occurs:
← 500 Internal Server Error
{
"success": false,
"error": "Error message",
"stack": "..." // Only in development
}
Then GET /_counterfact/api/contexts/api/users/123 returns the /api/users context (closest parent).
Smart Diffing
Context updates use smart diffing:
javascript
// Old context: { users: [...], count: 5 }
POST { users: [...newUsers] }
// Result: { users: [...newUsers], count: 5 }
// count is preserved
Testing Proxied Requests
After setting proxy:
1. PATCH /_counterfact/api/config/proxy
Body: { "proxyPaths": [["/users", true]] }
2. Make request to http://localhost:3100/users
→ This now proxies to real server
3. Check response headers for proxy evidence
Limitations
In-memory state: Changes reset on server restart
No TypeScript validation: Context can accept any JSON object
No authentication: Admin API is unauthenticated (local development tool)
No versioning: API is v1, may evolve
Context discovery: Must know or discover paths, no automatic schema
Security Considerations
⚠️ Warning: The Admin API provides full control over mock server state.
Recommendations:
Only run Counterfact in development/testing environments
Do not expose the Admin API to untrusted networks
Configure a bearer token when exposing the Admin API beyond local development
Be cautious with context updates from untrusted sources
Current access controls:
By default, the Admin API only listens on the loopback interface (localhost)
You can require a bearer token for all Admin API requests:
Counterfact Repl next to the 5 skills that share the most tags, products or categories with it. Stars are the repository's; “used in” counts other GitHub owners with a copy.
Counterfact Repl compared with similar skills
Skill
Stars
Used in
Tokens
Auto-check
Licence
Repo updated
Counterfact Repl this skillcounterfact/api-simulator
Cross-references C Web API controllers/DTOs against their TypeScript/JavaScript consumers (React, Angular, Vue, Svelte, Node.js, or hand-written/auto-generated HTTP clients like Fetch, Axios, NSwag)…
Turns an OpenAPI or Swagger spec into an MCP server with the mcp-use TypeScript SDK, mapping each operation to a tool, wiring auth, testing and deploying.
Keep contributor changes aligned with repository test patterns, diagnostics, black-box test boundaries, release/versioning workflow, documentation requirements, and compatibility.
Interact with Counterfact mock API server programmatically. An agent skill from counterfact/api-simulator. Counterfact Repl is an agent skill from counterfact/api-simulator. Interact with Counterfact mock API server programmatically.
When should I use Counterfact Repl?
Counterfact Repl fits situations like: the user mentions counterfact; working with OpenAPI mocks.
How do I install Counterfact Repl in Claude Code?
Run `npx skills add counterfact/api-simulator --skill counterfact-repl -a claude-code`. Or copy the skill folder (skills/counterfact-repl in counterfact/api-simulator) into .claude/skills/counterfact-repl in your project. Claude Code loads it when a task matches its description.
How do I install Counterfact Repl in Codex?
Run `npx skills add counterfact/api-simulator --skill counterfact-repl -a codex`. Or copy the skill folder (skills/counterfact-repl in counterfact/api-simulator) into .agents/skills/counterfact-repl in your project. Codex loads it when a task matches its description.
Can I use Counterfact Repl in Cursor, Gemini CLI or GitHub Copilot?
Cursor, Gemini CLI, GitHub Copilot and OpenCode also load SKILL.md folders. With the skills CLI, run `npx skills add counterfact/api-simulator --skill counterfact-repl -a cursor` (or -a gemini-cli, github-copilot or opencode for the others). To copy it by hand, put the folder in .cursor/skills/counterfact-repl, .gemini/skills/counterfact-repl, .github/skills/counterfact-repl and .opencode/skills/counterfact-repl in your project.
What does Counterfact Repl need to run?
Going by SKILL.md and its folder, Counterfact Repl needs credentials named COUNTERFACT_ADMIN_API_TOKEN. Our summary lists: Node.js; A credential in COUNTERFACT_ADMIN_API_TOKEN.
Does Counterfact Repl access the network?
SKILL.md names 3 domains. In commands or code: api.production.com; the agent is likely to contact it when it follows the instructions. As links in the text: counterfact.dev and github.com. This is read from the text; nothing was executed.
Is Counterfact Repl safe to install?
Our automated static check of SKILL.md found no risky patterns, such as piping downloads into a shell, reading credential files or hidden Unicode. It is not a guarantee. Review the folder before installing.
What licence does Counterfact Repl use?
Counterfact Repl is published under the MIT licence (the repository's licence). It allows redistribution, so the full SKILL.md is shown on this page.
How many tokens does Counterfact Repl use?
About 3.2k tokens (SKILL.md is roughly 13k characters). Agents keep only the skill's name and description in context until a task matches; then they load SKILL.md in full.
What are the alternatives to Counterfact Repl?
Skills that share tags, products or a category with Counterfact Repl: API Breaking Change Detector (github/awesome-copilot, 40k stars), OpenAPI to MCP Server (mcp-use/mcp-use, 11k stars), Api2cli (alexknowshtml/api2cli, 455 stars) and Project (samchon/nestia, 2.2k stars). The comparison table on this page puts their stars, adoption, token cost, safety result and licence side by side.
Who maintains Counterfact Repl?
counterfact (a GitHub organization) maintains it in counterfact/api-simulator, which has 170 GitHub stars. The repository holds 12 skills in this directory. The repository was last updated on October 9, 2026.
Source: counterfact/api-simulator on GitHub. Facts on this page come from the repository at the commit we read; the author's words are quoted as theirs.