{"success":true,"name":"design-the-api-contract-before-writing-any-endpoint-code","description":"About to build or change an API and no agreed contract exists yet","category":"ai-brimind","path":"ai-brimind/design-the-api-contract-before-writing-any-endpoint-code/SKILL.md","file":"SKILL.md","content":"---\nname: design-the-api-contract-before-writing-any-endpoint-code\ndescription: \"About to build or change an API and no agreed contract exists yet\"\n---\n\n# Design the API Contract Before Writing Any Endpoint Code\n\n## When to use\nYou are starting a new API, a new endpoint, or a breaking change, and the request/response shape, status codes, and error format are not written down and agreed on yet.\n\n## Example request\nFrontend guesses field names while backend is still coding → both sides drift apart; a written contract (OpenAPI/spec) is the shared source of truth. — Endpoint returns different error shapes in different failure cases → clients must special-case everything; a single error envelope is the missing agreement. — A field gets renamed and mobile apps break in production → nobody versioned the contract; API versioning is the mechanism. — Two teams build 'the same' endpoint twice with different shapes → no one owns the contract; contract-first design assigns ownership.\n\n## Instructions\nAct as an API architect who refuses to write endpoint code before the contract is written down. Before coding: 1) Write the contract first — for each endpoint list method, path, request body shape, response body shape, status codes, and one shared error format. 2) Name the consumers: who will call this (web, mobile, another service, third party)? Each consumer is a reason the contract must be stable. 3) Check for an existing standard before inventing one: REST conventions, an existing OpenAPI spec in the repo, the team's current error envelope, existing pagination style. Reuse it — a new endpoint must look like the old ones. 4) Decide the versioning and breaking-change rule now: how will you change this later without breaking clients? 5) If any consumer or shape is unknown, ask or investigate — do not guess field names. Only start coding once the contract is confirmed, and explain how each implementation choice serves the agreed contract, not just what was convenient to code.\n\n## Metadata\n- role: developer\n- level: tactical\n- places: vibeCoding\n- origin: ai.brimind.pro skill #882\n","linked_files":[],"origin":"ai.brimind.pro","owner_id":null,"source":"router"}