mocking-apis

Generate mock API servers for testing and development with realistic response data. Use when creating mock APIs for development and testing. Trigger with phrases like "create mock API", "generate API mock", or "setup mock server".

25 stars

Best use case

mocking-apis is best used when you need a repeatable AI agent workflow instead of a one-off prompt.

Generate mock API servers for testing and development with realistic response data. Use when creating mock APIs for development and testing. Trigger with phrases like "create mock API", "generate API mock", or "setup mock server".

Teams using mocking-apis should expect a more consistent output, faster repeated execution, less prompt rewriting.

When to use this skill

  • You want a reusable workflow that can be run more than once with consistent structure.

When not to use this skill

  • You only need a quick one-off answer and do not need a reusable workflow.
  • You cannot install or maintain the underlying files, dependencies, or repository context.

Installation

Claude Code / Cursor / Codex

$curl -o ~/.claude/skills/mocking-apis/SKILL.md --create-dirs "https://raw.githubusercontent.com/ComeOnOliver/skillshub/main/skills/jeremylongshore/claude-code-plugins-plus-skills/mocking-apis/SKILL.md"

Manual Installation

  1. Download SKILL.md from GitHub
  2. Place it in .claude/skills/mocking-apis/SKILL.md inside your project
  3. Restart your AI agent — it will auto-discover the skill

How mocking-apis Compares

Feature / Agentmocking-apisStandard Approach
Platform SupportNot specifiedLimited / Varies
Context Awareness High Baseline
Installation ComplexityUnknownN/A

Frequently Asked Questions

What does this skill do?

Generate mock API servers for testing and development with realistic response data. Use when creating mock APIs for development and testing. Trigger with phrases like "create mock API", "generate API mock", or "setup mock server".

Where can I find the source code?

You can find the source code on GitHub using the link provided at the top of the page.

SKILL.md Source

# Mocking APIs

## Overview

Generate mock API servers from OpenAPI specifications that return realistic, schema-compliant response data for development and testing. Support dynamic response generation with Faker.js data, configurable latency simulation, stateful CRUD behavior, and request recording for contract testing validation.

## Prerequisites

- OpenAPI 3.0+ specification file with response schema definitions
- Mock server runtime: Prism (Stoplight), json-server, MSW (Mock Service Worker), or WireMock
- Faker.js or equivalent for realistic test data generation
- Docker for containerized mock server deployment (optional but recommended)
- Frontend or consumer application needing API stubs for parallel development

## Instructions

1. Read the OpenAPI specification using Read and extract all endpoint definitions, response schemas, and example values to build the mock response inventory.
2. Generate response fixtures for each endpoint using schema-aware data generation: realistic names (Faker), valid emails, properly formatted dates, and relational IDs that reference other mock entities.
3. Configure the mock server to match requests by method, path pattern, query parameters, and request body content type, returning the appropriate fixture.
4. Add stateful behavior for CRUD operations: POST creates a record in memory, GET returns it, PUT updates it, DELETE removes it -- enabling realistic integration testing flows.
5. Implement configurable response delays (50-500ms per endpoint) to simulate real-world latency and test client timeout handling.
6. Add error scenario mocking: configure specific request patterns to return 400, 401, 404, 429, or 500 responses for testing error handling paths.
7. Enable request recording that captures all incoming requests with timestamps and headers for later replay in contract tests.
8. Create a startup script that launches the mock server on a configurable port with hot-reload when fixture files change.

See `${CLAUDE_SKILL_DIR}/references/implementation.md` for the full implementation guide.

## Output

- `${CLAUDE_SKILL_DIR}/mocks/server.js` - Mock server entry point with route registration
- `${CLAUDE_SKILL_DIR}/mocks/fixtures/` - Per-endpoint response fixture JSON files
- `${CLAUDE_SKILL_DIR}/mocks/generators/` - Dynamic response generators using Faker.js
- `${CLAUDE_SKILL_DIR}/mocks/scenarios/` - Error scenario configurations (4xx, 5xx responses)
- `${CLAUDE_SKILL_DIR}/mocks/state.js` - In-memory state store for CRUD behavior
- `${CLAUDE_SKILL_DIR}/mocks/recordings/` - Captured request logs for contract testing
- `${CLAUDE_SKILL_DIR}/docker-compose.mock.yml` - Docker configuration for mock server

## Error Handling

| Error | Cause | Solution |
|-------|-------|----------|
| Schema mismatch | Mock response does not match updated OpenAPI spec | Run spec-to-fixture sync on spec change; add CI check comparing fixture schemas |
| Missing endpoint | Consumer requests path not defined in OpenAPI spec | Return 501 with message listing available endpoints; log unknown path for spec update |
| Stale fixtures | Mock data becomes unrealistic after API schema evolution | Regenerate fixtures from latest spec; use generators over static fixtures for evolving APIs |
| Port conflict | Mock server port already in use by another dev service | Make port configurable via environment variable; default to spec-defined server URL port |
| State leak between tests | Stateful mock retains data from previous test run | Reset in-memory state before each test suite; expose `POST /mock/reset` admin endpoint |

Refer to `${CLAUDE_SKILL_DIR}/references/errors.md` for comprehensive error patterns.

## Examples

**Frontend parallel development**: Launch a Prism mock server from the OpenAPI spec so frontend developers can build against realistic API responses while backend implementation is in progress.

**Integration test isolation**: Use MSW (Mock Service Worker) to intercept HTTP requests in Node.js test suites, returning fixture responses without network calls, with per-test response customization.

**Contract testing**: Record all requests to the mock server during frontend E2E tests, then replay them against the real backend to verify the mock accurately represents actual API behavior.

See `${CLAUDE_SKILL_DIR}/references/examples.md` for additional examples.

## Resources

- Prism (Stoplight): https://stoplight.io/open-source/prism
- Mock Service Worker (MSW): https://mswjs.io/
- WireMock: https://wiremock.org/
- Faker.js for realistic data generation: https://fakerjs.dev/

Related Skills

versioning-apis

25
from ComeOnOliver/skillshub

Implement API versioning with backward compatibility, deprecation notices, and migration paths. Use when managing API versions and backward compatibility. Trigger with phrases like "version the API", "manage API versions", or "handle API versioning".

throttling-apis

25
from ComeOnOliver/skillshub

Implement API throttling policies to protect backend services from overload. Use when controlling API request rates. Trigger with phrases like "throttle API", "control request rate", or "add throttling".

rate-limiting-apis

25
from ComeOnOliver/skillshub

Implement sophisticated rate limiting with sliding windows, token buckets, and quotas. Use when protecting APIs from excessive requests. Trigger with phrases like "add rate limiting", "limit API requests", or "implement rate limits".

monitoring-apis

25
from ComeOnOliver/skillshub

Build real-time API monitoring dashboards with metrics, alerts, and health checks. Use when tracking API health and performance metrics. Trigger with phrases like "monitor the API", "add API metrics", or "setup API monitoring".

migrating-apis

25
from ComeOnOliver/skillshub

Implement API migrations between versions, platforms, or frameworks with minimal downtime. Use when upgrading APIs between versions. Trigger with phrases like "migrate the API", "upgrade API version", or "migrate to new API".

load-testing-apis

25
from ComeOnOliver/skillshub

Execute comprehensive load and stress testing to validate API performance and scalability. Use when validating API performance under load. Trigger with phrases like "load test the API", "stress test API", or "benchmark API performance".

generating-rest-apis

25
from ComeOnOliver/skillshub

Generate complete REST API implementations from OpenAPI specifications or database schemas. Use when generating RESTful API implementations. Trigger with phrases like "generate REST API", "create RESTful API", or "build REST endpoints".

fuzzing-apis

25
from ComeOnOliver/skillshub

This skill enables Claude to perform automated fuzz testing on APIs to discover vulnerabilities, crashes, and unexpected behavior. It leverages malformed inputs, boundary values, and random payloads to generate comprehensive fuzz test suites. Use this skill when you need to identify potential SQL injection, XSS, command injection vulnerabilities, input validation failures, and edge cases in APIs. Trigger this skill by requesting fuzz testing, vulnerability scanning, or security analysis of an API. The skill is invoked using the `/fuzz-api` command.

tRPC — End-to-End Type-Safe APIs

25
from ComeOnOliver/skillshub

You are an expert in tRPC, the framework for building type-safe APIs without schemas or code generation. You help developers create full-stack TypeScript applications where the server defines procedures and the client calls them with full type inference — no REST routes, no GraphQL schemas, no OpenAPI specs, just TypeScript functions that are type-safe from database to UI.

eodhd-apis-automation

25
from ComeOnOliver/skillshub

Automate Eodhd Apis tasks via Rube MCP (Composio). Always search tools first for current schemas.

designing-apis

25
from ComeOnOliver/skillshub

Designs REST and GraphQL APIs including endpoints, error handling, versioning, and documentation. Use when creating new APIs, designing endpoints, reviewing API contracts, or when asked about REST, GraphQL, or API patterns.

update-swiftui-apis

25
from ComeOnOliver/skillshub

Scan Apple's SwiftUI documentation for deprecated APIs and update the SwiftUI Expert Skill with modern replacements. Use when asked to "update latest APIs", "refresh deprecated SwiftUI APIs", "check for new SwiftUI deprecations", "scan for API changes", or after a new iOS/Xcode release. Requires the Sosumi MCP to be available.