{"success":true,"name":"classify-the-api-failure-before-touching-client-or-server-co","description":"An API call is failing or returning wrong data and the cause is unclear","category":"ai-brimind","path":"ai-brimind/classify-the-api-failure-before-touching-client-or-server-co/SKILL.md","file":"SKILL.md","content":"---\nname: classify-the-api-failure-before-touching-client-or-server-co\ndescription: \"An API call is failing or returning wrong data and the cause is unclear\"\n---\n\n# Classify the API Failure Before Touching Client or Server Code\n\n## When to use\nA request between client and server is broken (error, wrong data, timeout), and you are about to edit code before knowing which layer actually failed.\n\n## Example request\nFrontend shows 'undefined' → the server actually returned 200 with a different field name; the bug is a contract mismatch, not a UI bug. — Call works in Postman but fails in the app → headers or auth token differ; the gap is in how the request is built, not the server. — Random 500s under load → server logs show a timeout to the database; the API is only the messenger, root cause is downstream. — CORS error in the browser console → the server response is fine but missing headers; it's a browser policy, not broken logic.\n\n## Instructions\nAct as a request detective who never edits code before locating the failing layer. Steps: 1) Capture the real request and real response — exact URL, method, headers, body, status code (use network tab, logs, or curl). Do not trust what the code 'should' send. 2) Classify the failure: 4xx means the client sent something wrong, 5xx means the server broke, network/CORS/timeout means the layer between them. Say the classification out loud before proceeding. 3) Compare against the contract: does the actual response match what the client code expects (field names, nesting, types)? A mismatch is a contract bug, not a logic bug. 4) State your hypothesis in one sentence ('the client omits the auth header on retry') and verify it with one targeted test before writing any fix. 5) If you cannot reproduce the failing request, investigate more or ask for the exact payload — do not guess. Only fix once the failing layer is confirmed, and explain why the fix addresses that layer's root cause rather than hiding the symptom on another layer.\n\n## Metadata\n- role: developer\n- level: tactical\n- places: vibeCoding\n- origin: ai.brimind.pro skill #883\n","linked_files":[],"origin":"ai.brimind.pro","owner_id":null,"source":"router"}