{"success":true,"name":"mock-the-api-behind-the-contract-so-frontend-work-isn-t-bloc","description":"Frontend needs an API that isn't built, stable, or reachable yet","category":"ai-brimind","path":"ai-brimind/mock-the-api-behind-the-contract-so-frontend-work-isn-t-bloc/SKILL.md","file":"SKILL.md","content":"---\nname: mock-the-api-behind-the-contract-so-frontend-work-isn-t-bloc\ndescription: \"Frontend needs an API that isn't built, stable, or reachable yet\"\n---\n\n# Mock the API Behind the Contract So Frontend Work Isn't Blocked\n\n## When to use\nYou are building UI against an endpoint that doesn't exist yet or is unreliable in dev, and the plan is to hardcode fake data inside components.\n\n## Example request\nFake data hardcoded in the component → shipping requires surgery to remove it, and one path always gets forgotten; mocking at the network/client layer keeps components real. — Mock returns only perfect data → the first real error state was never designed; mocks must include failure and empty cases. — Mock shape invented from memory → the real API differs and integration day becomes rewrite day; mocks must be generated from or checked against the agreed contract. — Everyone mocks differently per branch → demo behavior is random; one shared mock setup is the reusable mechanism.\n\n## Instructions\nAct as a contract-driven frontend developer who mocks the network, never the components. When the API isn't ready: 1) Get or write the contract first — the agreed request/response shapes are what you mock; a mock without a contract is fiction that guarantees integration pain. 2) Mock at the boundary using an existing mechanism (a request-interception library, the API client layer's injection point, or a small mock server) — check what the project already uses; component code must stay identical between mock and real. 3) Mock the whole truth, not just success: include error responses, empty lists, slow responses, and edge shapes — these are exactly the states the UI must handle and the ones hardcoded happy-path data hides. 4) Make switching explicit and shared: one config flag flips mock/real for everyone, and mocks live in the repo so the team demos the same behavior. 5) When the real endpoint lands, verify the mock matched (run the same flows against real) and retire or sync it — a drifted mock is worse than none. Only build on mocks once they're confirmed contract-faithful and failure-inclusive, and explain how the setup makes integration a switch-flip rather than a rewrite.\n\n## Metadata\n- role: developer\n- level: tactical\n- places: vibeCoding\n- origin: ai.brimind.pro skill #915\n","linked_files":[],"origin":"ai.brimind.pro","owner_id":null,"source":"router"}