api-mock

Serve fake API responses from a YAML definition file with Faker.js data and configurable latency. Use when you need to develop a frontend without a backend, test error states, simulate slow APIs, or do contract-first API development. Triggers include "mock API", "fake backend", "stub API", "YAML mock server", "frontend without backend", "simulate API", "API contract testing".

7 stars

Best use case

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

Serve fake API responses from a YAML definition file with Faker.js data and configurable latency. Use when you need to develop a frontend without a backend, test error states, simulate slow APIs, or do contract-first API development. Triggers include "mock API", "fake backend", "stub API", "YAML mock server", "frontend without backend", "simulate API", "API contract testing".

Teams using api-mock 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/api-mock/SKILL.md --create-dirs "https://raw.githubusercontent.com/heldernoid/agentic-build-templates/main/projects/developer-tools/api-mock-server/skills/api-mock/SKILL.md"

Manual Installation

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

How api-mock Compares

Feature / Agentapi-mockStandard Approach
Platform SupportNot specifiedLimited / Varies
Context Awareness High Baseline
Installation ComplexityUnknownN/A

Frequently Asked Questions

What does this skill do?

Serve fake API responses from a YAML definition file with Faker.js data and configurable latency. Use when you need to develop a frontend without a backend, test error states, simulate slow APIs, or do contract-first API development. Triggers include "mock API", "fake backend", "stub API", "YAML mock server", "frontend without backend", "simulate API", "API contract testing".

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

# api-mock

Serve realistic fake API responses from a YAML file. Hot reloads on file change. Web dashboard included.

## When to use

- Frontend development without a backend
- Testing error states and edge cases (404, 500, payment declined)
- Contract-first API development (define the API shape, build against it)
- Demos that need realistic data
- CI/CD tests that need a predictable API

## Installation

```bash
npm install -g @your-org/api-mock-server
```

## Quick Start

```bash
# Create api-mock.yaml
cat > api-mock.yaml << 'EOF'
endpoints:
  - method: GET
    path: /api/users
    status: 200
    body:
      users:
        - id: "{{faker.string.uuid}}"
          name: "{{faker.person.fullName}}"
          email: "{{faker.internet.email}}"
EOF

# Start the server
api-mock start
# Server: http://127.0.0.1:3100
# Dashboard: http://127.0.0.1:3101
```

## YAML Schema

```yaml
endpoints:
  - method: GET              # HTTP method
    path: /api/users/:id     # Path (Express-style params)
    status: 200              # Response status code
    latency: 50              # Delay in ms (default: 0)
    headers:
      Content-Type: application/json
    body:
      id: "{{params.id}}"
      name: "{{faker.person.fullName}}"
    scenarios:
      - name: not-found
        status: 404
        body:
          error: "Not found"
```

## Faker Templates

| Template | Example output |
|---|---|
| `{{faker.string.uuid}}` | `550e8400-e29b-41d4-a716-...` |
| `{{faker.person.fullName}}` | `Alice Johnson` |
| `{{faker.internet.email}}` | `alice@example.com` |
| `{{faker.date.recent}}` | `2025-01-10T14:33:00.000Z` |
| `{{faker.commerce.price}}` | `49.99` |
| `{{faker.number.int min=1 max=100}}` | `42` |
| `{{params.id}}` | URL param value |
| `{{body.fieldName}}` | Request body field |
| `{{query.page}}` | Query string value |

## Scenario Activation

```bash
# Persistent (via dashboard or API)
curl -X POST http://127.0.0.1:3101/api/scenarios/GET%20%2Fapi%2Fusers%2F%3Aid \
  -H 'Content-Type: application/json' \
  -d '{"scenario": "not-found"}'

# Per-request (does not persist)
curl http://127.0.0.1:3100/api/users/42?__scenario=not-found
```

## CLI Reference

| Command | Description |
|---|---|
| `api-mock start [file]` | Start mock server (default: api-mock.yaml) |
| `api-mock start --port 3200` | Override mock server port |
| `api-mock start --dashboard 3201` | Override dashboard port |
| `api-mock start --latency 100` | Add global latency to all responses |
| `api-mock validate [file]` | Validate YAML without starting server |
| `api-mock --help` | Show help |
| `api-mock --version` | Show version |

## Environment Variables

| Variable | Description | Default |
|---|---|---|
| `MOCK_PORT` | Mock server port | `3100` |
| `MOCK_DASHBOARD_PORT` | Dashboard port | `3101` |
| `MOCK_CONFIG` | Path to YAML config | `api-mock.yaml` |
| `MOCK_LATENCY` | Global latency in ms | `0` |
| `MOCK_LOG_RETENTION` | Request log retention days | `3` |
| `MOCK_ALLOW_REMOTE` | Allow remote connections (0 or 1) | `0` |

## Troubleshooting

### "config file not found"

Create `api-mock.yaml` in the current directory, or pass the path: `api-mock start path/to/config.yaml`.

### Template rendered as literal string

Check that template syntax uses double curly braces: `{{faker.string.uuid}}`. Single braces or backtick-style won't be recognized.

### Endpoint returns 404 with "no mock defined"

The path doesn't match any defined endpoint. Check the method and path pattern in your YAML. Use `:param` for dynamic segments.

Related Skills

Skill: Uptime Monitoring

7
from heldernoid/agentic-build-templates

## Overview

Skill: Status Page

7
from heldernoid/agentic-build-templates

## Overview

Skill: unit-conversion

7
from heldernoid/agentic-build-templates

## Overview

Skill: recipe-scaler

7
from heldernoid/agentic-build-templates

## Overview

reading-list

7
from heldernoid/agentic-build-templates

Operate the reading-list API to save, manage, tag, search, and export articles.

email-digest

7
from heldernoid/agentic-build-templates

Configure, test, and troubleshoot the reading-list daily email digest delivered via nodemailer.

websocket-realtime

7
from heldernoid/agentic-build-templates

Use the WebSocket connection in poll-builder to receive live vote updates. Use when you need to stream real-time poll results, monitor a poll for new votes, or build a live dashboard. Triggers include "live results", "real-time updates", "stream votes", "watch poll", or "WebSocket".

poll-builder

7
from heldernoid/agentic-build-templates

Self-hosted poll creation tool with real-time results. Use when you need to create a poll, check vote counts, close a poll, export results, or get the shareable link for a poll. Triggers include "create poll", "vote", "poll results", "survey", "collect votes", "share poll", or any task involving polling or voting.

Skill: personal-finance

7
from heldernoid/agentic-build-templates

## Overview

Skill: csv-import

7
from heldernoid/agentic-build-templates

## Overview

Skill: Syntax Highlighting

7
from heldernoid/agentic-build-templates

## Purpose

Skill: Pastebin Core

7
from heldernoid/agentic-build-templates

## Purpose