{"success":true,"name":"treat-every-external-call-as-something-that-will-fail","description":"Calling an external service, API, or resource as if it always answers","category":"ai-brimind","path":"ai-brimind/treat-every-external-call-as-something-that-will-fail/SKILL.md","file":"SKILL.md","content":"---\nname: treat-every-external-call-as-something-that-will-fail\ndescription: \"Calling an external service, API, or resource as if it always answers\"\n---\n\n# Treat Every External Call as Something That WILL Fail\n\n## When to use\nYour code depends on something outside itself (network call, external API, file, third-party service) and has no plan for that thing failing or being slow.\n\n## Example request\nCalling an API with no failure handling → the provider has a bad day and your whole feature dies with a cryptic crash; the network is not reliable. Assuming the response arrives instantly → sometimes it takes 20 seconds and the app hangs; slowness is a failure mode too. Trusting the response shape → the provider changed a field name and everything downstream broke; validate at the boundary. Retrying blindly forever → the failing service gets hammered harder; failure handling is a designed behavior, not a reflex.\n\n## Instructions\nAdopt the mindset of a sailor who respects the sea: the calm days are borrowed, not promised. Whenever your code calls anything outside itself: (1) List this call's failure modes like a checklist: it never answers, it answers slowly, it answers with an error, it answers successfully but with unexpected content. All four WILL happen eventually. (2) Decide deliberately, for each, what your code does: fail loudly with a clear message? use a sensible fallback? retry a limited number of times? Whichever you choose, choose it — the one wrong answer is 'didn't think about it.' (3) Validate what comes back before using it — arriving successfully and being what you expected are two different things; check the shape at the boundary. (4) Decide what the USER experiences when it fails: an honest error and a retry option beat an infinite spinner or a silent nothing. If you don't know how a dependency fails in practice, that's worth one question or one test with the network unplugged. Only ship once each external call has a confirmed, intentional answer to 'and what if this fails?' — and be able to state that answer per call.\n\n## Metadata\n- role: developer\n- level: tactical\n- places: vibeCoding\n- origin: ai.brimind.pro skill #289\n","linked_files":[],"origin":"ai.brimind.pro","owner_id":null,"source":"router"}