Skip to content
Agentmart
Submit a tool

http-api-mock-forge

Stand up deterministic HTTP API mocks for tests and local dev using MSW, Nock, or Prism — request matching, stateful handlers, and contract fidelity.

Skill by anton-abyzov

IndexedMIT
Write a review

Install

Works with Claude Code, Claude apps, Codex, Cursor, Gemini CLI, GitHub Copilot, VS Code, OpenCode, Goose, Windsurf. Read the repository before you give any tool access to your data.

npx agentmarket install skill/anton-abyzov-http-api-mock-forge

Asks which of your tools to add it to (Claude Code, Codex, Cursor, VS Code, Windsurf, Gemini CLI, Claude Desktop) and shows the change first. See https://agentmart.dev/cli.

Get the weekly diff

The weekly diff: one email a week with new agent tools, notable updates and grade changes, plus security alerts for tools you follow. Double opt-in, one-click unsubscribe.

We use your email only for this newsletter. Privacy

About

Stand up deterministic HTTP API mocks for tests and local dev using MSW, Nock, or Prism — request matching, stateful handlers, and contract fidelity.

Use cases: documents, backend

No reviews yet. Installed it? Reviews come from verified installers only. How reviews work

Permissions

What this skill can do and what it asks for, from its SKILL.md. Checked Oct 25, 2026.

Tools
No tools found
Secrets
None asked for
Install scripts
None found

Network hosts it talks to 1

  • codeload.github.com · found in install command

Files it touches

  • ~/.claude/skills/http-api-mock-forge

What's inside

Skill name
http-api-mock-forge
Description
Stand up deterministic HTTP API mocks for tests and local dev using MSW, Nock, or Prism — request matching, stateful handlers, and contract fidelity.
License
MIT
Instructions
91 lines in SKILL.md · view on GitHub

Files (1)

  • SKILL.md

SKILL.md (first lines)

# http-api-mock-forge

Replace real upstream HTTP calls with deterministic mocks so tests are fast,
offline, and repeatable — without losing contract fidelity.

## Pick the right tool

| Tool          | Best for                                  | Layer it intercepts        |
|---------------|-------------------------------------------|----------------------------|
| **MSW**       | browser + node app code, shared handlers  | `fetch`/XHR via service worker / node interceptor |
| **Nock**      | node-only, low-level HTTP assertions      | node `http`/`https` module |
| **Prism**     | mock straight from an OpenAPI spec         | standalone HTTP server     |
| **WireMock**  | language-agnostic, JVM-friendly services  | standalone HTTP server     |

Rule of thumb: if you have an OpenAPI document, generate the mock from it
(Prism/WireMock) so the mock can never drift from the contract. Otherwise use
MSW for app-level tests.

## MSW handler example

```ts
import { http, HttpResponse } from 'msw';
import { setupServer } from 'msw/node';

const server = setupServer(
  http.get('https://api.acme.example/v1/users/:id', ({ params }) => {
    if (params.id === '404') {
      return new HttpResponse(null, { status: 404 });
    }
    return HttpResponse.json({ id: params.id, name: 'Ada' });
  }),

  http.post('https://api.acme.example/v1/users', async ({ request }) => {
    const body = await request.json();
    if (!body.name) {
      return HttpResponse.json({ error: 'name required' }, { status: 422 });
    }
    return HttpResponse.json({ id: 'usr_001', ...body }, { status: 201 });
  }),
);

beforeAll(() => server.listen({ onUnhandledRequest: 'error' }));
afterEach(() => server.resetHandlers());
afterAll(() => server.close());
```

Setting `onUnhandledRequest: 'error'` is key: it fails the test the moment code
hits an un-mocked endpoint, catching accidental real network calls.

## Stateful mocks

For flows like "create then fetch", keep state inside the handler closure and
reset it per test:

```ts
let store = new Map();
afterEach(() => { store = new Map(); });

http.post('/v1/items', async ({ request }) => {
  const item = { id: `itm_${store.size + 1}`, ...(await request.json()) };
  store.set(item.id, item);
  return HttpResponse.json(item, { status: 201 });
});
http.get('/v1/items/:id', ({ params }) =>
  store.has(params.id)
    ? HttpResponse.json(store.get(params.id))
    : new HttpResponse(null, { status: 404 }));
```

## Fidelity checklist

- Match **method + path + query + relevant headers**, not just the path.
- Mirror real **status codes and error bodies**, including 4xx/5xx, so error
  handling is actually exercised.
- Reproduce **pagination, rate-limit headers, and latency** where the code
  depends on them (use a small delay helper for timeouts/retries).
- Keep fixtures close to real payloads; trim only irrelevant fields.

## Anti-patterns

- Mocking your own code instead of the network boundary — mock at the HTTP edge.
- Over-broad matchers (`*`) that hide real request bugs.
- Letting mocks drift from the contract. Regenerate from OpenAPI when the spec
  changes, or add a contract test that runs against the real sandbox in CI.

## Agent guidance

- Default to MSW for app tests; Prism when an OpenAPI spec exists.
- Always assert on the request the code sent, not only on the response.
- Fail on unhandled requests so silent real calls cannot slip through.

From anton-abyzov/vskill-test-public-skills-826, MIT.

More from anton-abyzov/vskill-test-public-skills-826

Signals

Stars
0
Forks
0
Open issues
0
Last commit (this folder)
Jun 10, 2026 (4 months ago)

From GitHub (fetched Oct 24, 2026).

Details

License
MIT
First seen
Oct 24, 2026
Last checked
Oct 24, 2026

More from anton-abyzov

Cite this page

http-api-mock-forge skill. Agent Mart. https://agentmart.dev/skills/anton-abyzov-http-api-mock-forge (last updated 2026-10-24)