Agent skill · Backend & API

api-mock

Generate API mocks and stub servers from OpenAPI specs or code analysis

majiayu000github.com/majiayu000GitHub ↗
claude-codeMIT
Install
npx skills add majiayu000/claude-skill-registry --skill api-mock --agent claude-code

Same command for any agent — swap --agent for codex, cursor, copilot.

Facts
Files in the skill folder: 2
SKILL.md size: 33 KB
Bundled scripts: none
Path: skills/api/api-mock/SKILL.md
Open the folder on GitHub →
Where it comes from
Stars: 534
Language: HTML

Weekly change comes from our own snapshots, not the repository page — it measures attention, not adoption.

Review
written from the skill's own SKILL.md · Aug 5, 2026

What it does

Generates API mock servers and stub services for testing and development based on OpenAPI specifications or code analysis. It supports multiple mock tools (json-server, MSW, Prism, WireMock) and drives generation through a multi-phase workflow that detects specs, selects a mock tool, and generates server stubs.

How it works

  • Phase 1: Detect API Specifications
    • Scans for OpenAPI/Swagger files (openapi.yaml/yaml, openapi.json, swagger.yaml/json).
    • If none found, checks for GraphQL schemas (schema.graphql or *.graphql).
    • If still none, analyzes code to infer REST APIs (express, flask, fastapi, go), otherwise marks as custom.
    • Outputs SPEC_TYPE and SPEC_PATH.
  • Phase 2: Choose Mock Server Tool
    • If the user provides a tool, selects that tool.
    • Otherwise, recommends a tool based on SPEC_TYPE (e.g., Prism for OpenAPI, json-server/MSW for REST/custom, GraphQL mock for GraphQL) and presents options for manual selection.
  • Phase 3: Generate Mock Server
    • Creates a mocks directory and calls a specific generator based on the chosen tool:
      • prism: ensures Prism is installed, validates the OpenAPI spec, creates mocks/start-prism.sh, optionally updates package.json with a mock script, and prints start commands.
      • msw: installs MSW, creates mocks/handlers and setup files for Node and browser, plus test integration stubs.
      • json-server: configures a simple REST mock path (details described in code).
      • wiremock: prepares a WireMock-based mock server (details described in code).

When to use it

  • Use when you need reproducible API mocks from OpenAPI specs or code-analyzed REST APIs.
  • Suitable for teams relying on automated mock generation with templated approaches and caching strategies to reduce token/compute usage.

What it can touch

  • Tools: "json-server", "MSW" (through MSW setup), "Prism" (prism-cli), and "WireMock" (via generator).
  • It interacts with the file system to create mocks/, start-prism.sh, and potentially package.json scripts.

Caveats

  • Relies on external tools installation (Prism, MSW) and may modify package.json if present.
  • Validates OpenAPI specs and may prompt to continue if validation errors exist.
  • Behavior depends on detected SPEC_TYPE and user/tool choices.
From the SKILL.md

# API Mock Server Generator I'll help you generate API mock servers and stub services for testing and development, based on OpenAPI specifications or code analysis. **Mock Server Tools:** - **json-server**: Simple REST API mocking - **MSW (Mock Service Worker)**: Browser and Node.js request interception - **Prism**: OpenAPI-based mock server - **WireMock**: Advanced API simulation ## Token Optimization This skill uses mock generation-specific patterns to minimize token usage: ### 1. API Spec Detection Caching (600 token savings) **Pattern:** Cache API specification locations and structure - Store spec analysis in `.api-mock-cache` (1 hour TTL) - Cache: spec location, endpoints, schemas, examples - Read cached spec on subsequent runs (50 tokens vs 650 tokens fresh) - Invalidate on spec file changes - **Savings:** 92% on repeat mock generations ### 2. OpenAPI Spec Parsing via Bash (1,800 token savings) **Pattern:** Use yq/jq for OpenAPI parsing instead of LLM - Extract endpoints: `yq '.paths | keys'` (200 tokens) - Extract schemas: `yq '.components.schemas'` (200 tokens) - No Task agents for spec parsing - **Savings:** 90% vs LLM-based OpenAPI analysis ### 3. Template-Based Mock Gene

What's inside
Steps it walks through
  1. Token Optimization
  2. 1. API Spec Detection Caching (600 token savings)
  3. 2. OpenAPI Spec Parsing via Bash (1,800 token savings)
  4. 3. Template-Based Mock Generation (2,500 token savings)
  5. 4. Example-Based Response Generation (1,000 token savings)
  6. 5. Sample-Based Endpoint Analysis (700 token savings)
  7. 6. Cached Mock Tool Setup (400 token savings)
  8. 7. Grep-Based Existing Mock Detection (500 token savings)
  9. 8. Early Exit for Existing Mocks (90% savings)
  10. Real-World Token Usage Distribution
  11. Phase 1: Detect API Specifications
  12. Phase 2: Choose Mock Server Tool
  13. Phase 3: Generate Mock Server
  14. Phase 4: Generate Realistic Mock Data
Ships with 1 file
  • metadata.json
Commands it runs
Detect API specifications and existing APIs
echo "=== Detecting API Specifications ==="
echo ""
local spec_found=false
echo "Searching for OpenAPI/Swagger specifications..."
if [ -n "$openapi_files" ]; then
echo "✓ OpenAPI/Swagger specifications found:"
echo "$openapi_files" | sed 's/^/  /'
fi
if [ -z "$openapi_files" ]; then
More from claude-skill-registry
All skills →
About this skill
What does the api-mock skill do?

Generate API mocks and stub servers from OpenAPI specs or code analysis

How do I install it?

Run `npx skills add majiayu000/claude-skill-registry --skill api-mock --agent claude-code` — it drops the skill into your project so the agent can pick it up. Swap the --agent value for codex, cursor or copilot if you use one of those.

Where does this skill come from?

From majiayu000/claude-skill-registry, a repository with 534 stars. We read it straight from the repository tree rather than a submitted listing, so what you see here is what is actually published.

Is a popular skill a good skill?

Not necessarily. Stars measure attention, not adoption — a repository can trend for a week and be abandoned. That is why we show the weekly change from our own snapshots next to the total, instead of a single flattering number.

Keep going