api-mock-templates

api-mock-templates is a command for Claude Code from thapaliyabikendra/ai-artifacts. It costs 0 tokens per session (2,412 once invoked), scanned A, original, Apache-2.0.

Ready-made examples for creating fake API responses with Mock Service Worker, a tool that lets tests and development code imitate web requests. The templates cover Node.js and React applications.

In plain words
What is it for?
Use them when building mock API handlers for development or automated tests. They help simulate response data, network delays, pagination, and HTTP errors.
Why use it?
They let you test frontend and server behavior without relying on a live API or real data. The examples include common cases such as paginated lists and not-found responses.

Command for Claude Code

Written for Claude Code: installed under .claude/.

Needs its repository: it reads a path above its own folder, which exists only inside the repository. The line is import { server } from '../mocks/server';.

Good fit Use them when building mock API handlers for development or automated tests. They help simulate response data, network delays, pagination, and HTTP errors.

Compare 6 commands from other repositories ↓
Install

Getting it into your agent

It runs from inside its repository, so the clone comes first — what it calls does not travel with the file alone.

Clone the repo
git clone --depth 1 https://github.com/thapaliyabikendra/ai-artifacts
agentmods
npx agentmods add commands/thapaliyabikendra/ai-artifacts/api-mock-templates

Made for: Claude Code.

Wrote this? Show the measurements

A badge with what this costs and how it scanned, read live from this page, so it follows the numbers instead of freezing them. Markdown for a README, HTML for a documentation site or a project page.

agentmods badge for api-mock-templates

README.md
[![agentmods](https://agentmods.dev/badge/commands/thapaliyabikendra/ai-artifacts/api-mock-templates.svg)](https://agentmods.dev/commands/thapaliyabikendra/ai-artifacts/api-mock-templates)
Your own site
<a href="https://agentmods.dev/commands/thapaliyabikendra/ai-artifacts/api-mock-templates"><img src="https://agentmods.dev/badge/commands/thapaliyabikendra/ai-artifacts/api-mock-templates.svg" alt="Measured on agentmods" height="20"></a>
Per session 0 Only the description is in the session, so the agent can decide to use it. The body loads when it is invoked.
When invoked 2,412 The whole file, excluding the scripts and references it only reads on demand.
Security scan A 0 findings. A grade says what 26 rules found in the file — not that it is safe.
Origin original No closer match found in the catalogue.
Token cost

What it costs to keep this loaded

Counted locally with the o200k_base tokenizer, which is exact for GPT models; Claude uses its own tokenizer and its counts differ. Treat this as one consistent yardstick across the catalogue rather than a bill. Prices are per million input tokens.

ModelPer sessionOnce invoked
Fable 5.1 $0.00000 $0.02412
Opus 5 $0.00000 $0.01206
Sonnet 5 $0.00000 $0.00482
Haiku 4.5 $0.00000 $0.00241

Measured 8d ago against content hash 48f2015168a3, method: parsed. Prices are Anthropic first-party input rates as of 2026-09-08, from the pricing page.

Security

Grade A, and why

api-mock-templates scanned grade A with 0 findings against 26 rules in 11 categories — prompt injection, anti-refusal, data exfiltration, privilege escalation, supply chain, agent snooping, system-prompt leakage, SSRF and excessive agency — measured 8d ago.

A static scan of the body, not an audit. Every finding is printed with the line that produced it so you can judge whether it matters here. A mod is markdown that instructs an agent; that is exactly why what it instructs is worth reading.

Nothing flagged

None of the 26 patterns this scan looks for appear in this file: no shell pipes, no recursive deletes, no credential paths, no hidden text, no instruction-override or anti-refusal phrasing, no agent-config snooping. That is not a guarantee, it is the absence of the things that are checkable.

.claude/commands/references/api-mock-templates.md · 411 lines

How it starts

The opening of the file, as written. The whole thing — 411 lines — stays where its author put it; the contents beside it link to each section on GitHub.

API Mock Templates Reference

Templates for mock server implementation using MSW (Mock Service Worker) for Node.js/React.

MSW Setup

Installation

npm install msw --save-dev

Mock Server Handler (Node.js)

// mocks/handlers.ts
import { http, HttpResponse, delay } from 'msw';

// Define API mocks
export const handlers = [
    // GET list with pagination
    http.get('/api/patients', async ({ request }) => {
        const url = new URL(request.url);
        const page = parseInt(url.searchParams.get('page') || '1');
        const pageSize = parseInt(url.searchParams.get('pageSize') || '20');

        await delay(100); // Simulate network latency

        return HttpResponse.json({
            items: generatePatients(pageSize, page),
            totalCount: 150,
            pageNumber: page,
            pageSize: pageSize,
        });
    }),

    // GET single resource
    http.get('/api/patients/:id', async ({ params }) => {
        const { id } = params;

        if (id === 'not-found') {
            return HttpResponse.json(
                { error: { code: 'NOT_FOUND', message: 'Patient not found' } },
                { status: 404 }
            );
        }

        return HttpResponse.json({
            id,
            name: 'John Doe',
            email: '[email protected]',
            status: 'Active',
        });
    }),

    // POST create resource
    http.post('/api/patients', async ({ request }) => {
        const body = await request.json();

        // Simulate validation error
        if (!body.email) {
            return HttpResponse.json(
                { error: { code: 'VALIDATION_ERROR', details: [{ field: 'email', message: 'Email is required' }] } },
                { status: 422 }
            );
        }

        return HttpResponse.json(
            { id: crypto.randomUUID(), ...body },
            { status: 201 }
        );
    }),

    // PUT update resource
    http.put('/api/patients/:id', async ({ params, request }) => {
        const { id } = params;
        const body = await request.json();

        return HttpResponse.json({ id, ...body });
    }),

    // DELETE resource
    http.delete('/api/patients/:id', async ({ params }) => {
        return new HttpResponse(null, { status: 204 });
    }),
];

Read the full file on GitHub · 411 lines

Changes

What this file has done since we first saw it

Hashed on every crawl. A supply-chain change to an agent config is a question of when, not whether, so the history is kept rather than the latest state alone.

  1. 8d ago First seen · 411 lines · 0 tokens per session scan A 48f2015168a3

Subscribe to this mod's changes

api-mock-templates is a command published in the GitHub repository thapaliyabikendra/ai-artifacts (24 stars, last pushed 5mo ago), licensed Apache-2.0. It costs nothing until one of its globs matches a file; then it loads 2,412 tokens. A static security scan graded it A with 0 findings. No closer match exists in the catalogue, so it is treated as the original; first seen 2026-08-30.