# API Mocking Engineer

> Evaluates and operates advanced mock server tools: Mountebank imposter protocol, Hoverfly simulation, and service virtualization for microservice test environments. Use when working with mountebank, hoverfly or when the user mentions mountebank, hoverfly.

- Skill: `opknock/api-mocking-engineer` (Agent Skill)
- Install (CLI): `npx get-skill add opknock/api-mocking-engineer`
- Raw SKILL.md: https://api.skillmd.com/api/skills/opknock/api-mocking-engineer/raw
- Safety review: pending
- Works with: Claude Code, Claude.ai, OpenAI Codex
- Category: Integrations & APIs
- License: MIT
- Author: OpKnock (https://skillmd.com/u/opknock)
- Updated: 2026-11-23
- Page: https://skillmd.com/skills/opknock/api-mocking-engineer

---


Evaluates and operates advanced mock server tools: Mountebank imposter protocol, Hoverfly simulation, and service virtualization for microservice test environments.

## Agentic Workflow: Read -> Reason -> Act (api-mocking-engineer)

You are **api-mocking-engineer** (testing) — a sub-agent that **Reads, Reasons, and Acts** via `allowed-tools`.

### 1. Read — testing context for `api-mocking-engineer`
- Domain: Evaluates and operates advanced mock server tools: Mountebank imposter protocol, Hoverfly simulation, and service virtualization for microservice test environments.
- **mountebank**: Create protocol-level mock services (imposters) with Mountebank — `npm install -g mountebank`
- **hoverfly**: Simulate and record APIs with Hoverfly in capture mode — `docker run --name hoverfly -p 8888:8888 -p 8500:8500 spectolabs/hoverfly:latest`
- Check `knowledge` and `prerequisites: prism, wiremock, msw, openapi`

### 2. Reason — think for `api-mocking-engineer`
- For `mountebank`: Create protocol-level mock services (imposters) with Mountebank — decide which checks to run
- For `hoverfly`: Simulate and record APIs with Hoverfly in capture mode — decide which checks to run
- Evaluate trust/policy: `kdesk trust` + `kdesk doctor` patterns for your inputs

### 3. Act — execute with `api-mocking-engineer` tools
- Tools: `Glob`, `Grep`, `Read`, `Bash`, `Mb` (see frontmatter `tools`/`allowed-tools`)
- Use `safe_path` for any write; record evidence (paths, checksums)
- Fingerprint: `api-mocking-engineer:0194d797`

# API Mocking Engineer

Service virtualization with Mountebank and Hoverfly.

## What This Skill Does
- Creates protocol-level mocks (HTTP, TCP, SMTP) with Mountebank
- Captures and replays traffic with Hoverfly
- Supports stateful and conditional mock responses

## When to Use
- Virtualizing downstream services for integration testing
- Simulating email/SMS providers over SMTP
- Replaying recorded traffic in CI environments

## Real Commands

```bash
mb start --port 2525
curl -s -X POST http://localhost:2525/imposters -H 'Content-Type: application/json' \
  -d '{"port":4545,"protocol":"http","stubs":[{"responses":[{"is":{"statusCode":200,"body":"ok"}}]}]}'
curl -s http://localhost:4545/anything
```

## Mountebank Predicates
- Deep equality: { deepEqual: { path: '/a' } }
- Contains: { contains: { body: 'error' } }
- JSONPath: { jsonpath: { selector: '$..status' } }
- Proxy: forward unmatched requests to a real target

## Testing
- Verify imposter state via the admin API
- Record traffic with Hoverfly, export simulations, replay offline

## Best Practices
- Use JSONPath predicates over brittle body matching
- Export simulations to files for CI reproducibility
- Prefer imposter scopes that mirror production topology

## Capabilities

### mountebank
Create protocol-level mock services (imposters) with Mountebank

**Parameters:**
- `protocol` (string): http, https, tcp, or smtp imposter protocol
- `port` (integer): Port for the mock service
- `stubs` (array): Predicates and responses defining mock behavior

**Commands:**
- `npm install -g mountebank`
- `mb start --port 2525`
- `curl -s -X POST http://localhost:2525/imposters -H 'Content-Type: application/json' -d '{"port":4545,"protocol":"http","stubs":[{"responses":[{"is":{"statusCode":200,"body":"ok"}}]}]}'`
- `curl -s http://localhost:4545/anything`
- `curl -s http://localhost:2525/imposters | jq '.imposters | length'`

**Examples:**
- mb start --port 2525 runs the Mountebank control plane
- POST /imposters with protocol http creates a mock on port 4545
- GET /imposters lists active mock services

### hoverfly
Simulate and record APIs with Hoverfly in capture mode

**Commands:**
- `docker run --name hoverfly -p 8888:8888 -p 8500:8500 spectolabs/hoverfly:latest`
- `curl -s -X PUT http://localhost:8888/api/v2/hoverfly/mode -d '{"mode":"capture"}' -H 'Content-Type: application/json'`
- `curl -s http://localhost:8500/api/v2/hoverfly/state`
- `curl -s -X PUT http://localhost:8888/api/v2/hoverfly/mode -d '{"mode":"simulate"}' -H 'Content-Type: application/json'`

**Examples:**
- -cli --help
- -api --help

## References
- [Mountebank API Docs](http://www.mbtest.org/docs/api/overview)
- [Hoverfly Docs](https://docs.hoverfly.io/en/latest/)

