api-mock-designer
API Mock Designer Protocol
This skill allows mobile and frontend developers to construct robust UIs without waiting for the backend to be finished. It goes beyond simple static JSON stubs to provide a truly simulated environment that mimics production chaos.
Core assumption: If a frontend only tests against static 200 OK responses, it will break immediately in production when a 503 Service Unavailable or a 4-second latency spike occurs.
1. Scenario Planning (Static)
Analyze the API spec and design scenarios that consumers must handle:
- Happy Path: Standard CRUD operations.
- Chaos / Edge Cases:
429 Too Many Requests(Testing retry logic).500/503(Testing error boundaries/toasts).- High Latency Responses (Testing loading spinners/skeleton screens).
- Partial or Empty Lists (Testing "No items found" UI states).
2. Stateful Design
A good mock server must be stateful in a single session.
- If a client sends
POST /users, the next call toGET /usersMUST include the newly created user in memory.
3. Output Generation
Required Outputs (Must write BOTH to docs/api-report/):
- Human-Readable Markdown (
docs/api-report/api-mock-report.md)
### 🧪 API Mock Server Blueprint
**Tooling Recommendation:** WireMock or MSW (Mock Service Worker)
#### 🚥 Configured Scenarios
**1. Stateful Order Flow**
- `POST /orders`: Returns `201` and saves `{ id: 123 }` to memory.
- `GET /orders/123`: Returns the saved order instead of a random stub.
**2. The Chaos Endpoint (Latency & Reliability)**
- `GET /products`:
- 80% chance: Returns `200 OK` (with 500ms - 2000ms randomized latency).
- 15% chance: Returns `503 Service Unavailable` (to test failure UI).
- 5% chance: Returns `429 Too Many Requests`.
**3. Empty State Testing**
- `GET /notifications`: Purposefully returns an empty array `[]` to ensure the frontend displays the "All caught up!" screen correctly.
- Machine-Readable JSON (
docs/api-report/api-mock-output.json)
{
"skill": "api-mock-designer",
"tooling": "MSW",
"scenarios": [
{"name": "Stateful Validation", "endpoint": "/orders", "method": "POST/GET"},
{"name": "Chaos Latency", "endpoint": "/products", "error_rate_pct": 20, "max_latency_ms": 2000},
{"name": "Empty State", "endpoint": "/notifications", "returns": []}
]
}
Guardrails
- Avoid Over-Engineering: Mock servers shouldn't recreate complex backend business logic (like computing tax). They just need to faithfully replay expected structural responses.
- Schema Validation: Ensure the mock data strictly adheres to the definitions in the
contract-first-designer's OpenAPI spec.
More from fatih-developer/fth-skills
task-decomposer
Break down large, complex, or ambiguous tasks into independent subtasks with dependency maps, execution order, and success criteria. Plan first, then execute step by step. Triggers on 'how should I do this', 'where do I start', 'plan the project', 'break it down', 'implement' or whenever a task involves multiple phases.
24context-compressor
Compress long conversation histories, large code files, research results, and documents by 70% without losing critical information. Triggers when context window fills up, when summarizing previous steps in multi-step tasks, before loading large files into context, or on 'summarize', 'compress', 'reduce context', 'save tokens'.
17multi-brain-debate
Two-round debate protocol where perspectives challenge each other before consensus. Round 1 presents independent positions, Round 2 allows counter-arguments and rebuttals. Produces battle-tested decisions for high-stakes choices.
17multi-brain-score
Confidence scoring overlay for multi-brain decisions. Each perspective rates its own confidence (1-10) with justification. Consensus uses scores as weights, flags low-confidence areas, and surfaces uncertainty explicitly.
15checkpoint-guardian
Automatic risk assessment before every critical action in agentic workflows. Detects irreversible operations (file deletion, database writes, deployments, payments), classifies risk level, and requires confirmation before proceeding. Triggers on destructive keywords like deploy, delete, send, publish, update database, process payment.
14parallel-planner
Analyze multi-step tasks to identify which steps can run in parallel, build dependency graphs, detect conflicts (write-write, read-write, resource contention), and produce optimized execution plans. Triggers on 3+ independent steps, 'speed up', 'run simultaneously', 'parallelize', 'optimize' or any task where sequential execution wastes time.
14