{"success":true,"name":"define-the-contract-between-frontend-backend-and-db-before-b","description":"About to build a feature spanning frontend, backend, and database without agreed contracts","category":"ai-brimind","path":"ai-brimind/define-the-contract-between-frontend-backend-and-db-before-b/SKILL.md","file":"SKILL.md","content":"---\nname: define-the-contract-between-frontend-backend-and-db-before-b\ndescription: \"About to build a feature spanning frontend, backend, and database without agreed contracts\"\n---\n\n# Define the Contract Between Frontend, Backend, and DB Before Building Either Side\n\n## When to use\nAbout to build a feature spanning frontend, backend, and database without agreed contracts\n\n## Example request\nFrontend built expecting user.name, backend returns user.fullName → integration day becomes renaming day; the concept is contract-first (agree the JSON before coding either side). Backend returns errors as plain strings sometimes, objects other times → the frontend can't handle failures uniformly; the concept is one standard error shape for the whole API. Frontend paginates with page/limit, backend implemented offset/count → both work alone, neither works together; the concept is agreeing the query conventions once. Endpoint returns the entire user with password hash included → the contract never said what to EXCLUDE; the concept is response shaping (send only what the screen needs).\n\n## Instructions\nAct as a systems architect whose law is: layers meet at contracts, and contracts are written before either side is coded. When a feature spans frontend, backend, and database, produce the contract first (a short block in the feature's .md): (1) ENDPOINTS — each route with method, path, and purpose (POST /api/bookings — create a booking); (2) REQUEST — the exact payload shape with types and which fields are required; (3) RESPONSE — the exact success shape (only the fields the client actually needs — never dump raw DB documents with internal fields), plus status codes; (4) ERRORS — ONE standard error format for the entire API ({ error: { code, message } } or the project's existing standard), used by every endpoint with meaningful codes (400 validation, 401 auth, 404 missing, 409 conflict, 500 unexpected) so the frontend handles all failures with one pattern; (5) CONVENTIONS — decide once, project-wide: naming style (camelCase vs snake_case), date format (ISO strings), pagination style, and reuse the project's existing choices rather than inventing new ones per feature. With the contract written, the two sides can be built in parallel and even tested against it independently (frontend against mock responses, backend against example requests). Any change to the contract during building is announced and updated in the doc, never done silently on one side. Integration stops being a merge of two guesses and becomes two implementations of one agreement — that is why it works on the first connection.\n\n## Metadata\n- level: tactical\n- places: vibeCoding\n- origin: ai.brimind.pro skill #174\n","linked_files":[],"origin":"ai.brimind.pro","owner_id":null,"source":"router"}