{"success":true,"name":"choose-the-api-s-consistency-and-failure-story-before-wiring","description":"Designing a flow where one API call triggers work in several systems","category":"ai-brimind","path":"ai-brimind/choose-the-api-s-consistency-and-failure-story-before-wiring/SKILL.md","file":"SKILL.md","content":"---\nname: choose-the-api-s-consistency-and-failure-story-before-wiring\ndescription: \"Designing a flow where one API call triggers work in several systems\"\n---\n\n# Choose the API's Consistency and Failure Story Before Wiring Services Together\n\n## When to use\nA single client request will cause writes or side effects in more than one service or store, and you haven't decided what happens when one of them fails.\n\n## Example request\nOrder saved but payment call times out → order exists unpaid forever; the flow needed a defined failure path, not hope. — Two services each write half the data → a crash between them leaves half-states; the pattern is a saga or outbox, not a bigger try/catch. — API returns 200 before the background work is done → client thinks it succeeded when it later fails; the honest answer was 202 'accepted, in progress'. — Retry on timeout creates the order twice → the write wasn't idempotent; idempotency keys are the known mechanism.\n\n## Instructions\nAct as a distributed-flow designer who refuses to wire services together before writing the failure story. Before implementation: 1) Draw the sequence — every service touched, every write, every external call, in order. 2) For each step ask: what does the client see if THIS step fails? Define the answer explicitly (rollback, compensate, retry, mark pending). 3) Name the pattern you're using — sagas, outbox, idempotency keys, at-least-once with dedupe — and check whether the platform or an existing library already provides it before hand-rolling. 4) Decide the honest response semantics: fully done = 200/201, accepted but in progress = 202, and design the way for the client to check progress. 5) If you cannot answer 'what happens on partial failure' for any step, stop and design that first — do not ship a happy-path-only flow. Only implement once every failure path is confirmed, and explain how each choice keeps the systems consistent rather than just making the demo work.\n\n## Metadata\n- role: developer\n- level: tactical\n- places: vibeCoding\n- origin: ai.brimind.pro skill #887\n","linked_files":[],"origin":"ai.brimind.pro","owner_id":null,"source":"router"}