{"success":true,"name":"separate-deciding-from-doing-pure-logic-core-side-effects-at","description":"Writing logic that mixes calculations with saving, sending, or displaying","category":"ai-brimind","path":"ai-brimind/separate-deciding-from-doing-pure-logic-core-side-effects-at/SKILL.md","file":"SKILL.md","content":"---\nname: separate-deciding-from-doing-pure-logic-core-side-effects-at\ndescription: \"Writing logic that mixes calculations with saving, sending, or displaying\"\n---\n\n# Separate Deciding From Doing: Pure Logic Core, Side Effects at the Edges\n\n## When to use\nYou are writing a function that both computes a result and performs actions (writes, network calls, UI changes), or logic you cannot test without triggering real effects.\n\n## Example request\nprice calculation buried inside the save handler → can't test the math without writing to the database; mixed decision and action. validation rules spread across click handlers → same rule impossible to reuse; logic trapped in effects. a report function that computes and emails in one body → testing means sending emails; no pure core. — each mixes deciding with doing.\n\n## Instructions\nAct as an organizer who keeps the thinking room separate from the machine room. Before writing a function, split its job in two: the decision (take inputs, return an answer, touch nothing outside) and the action (save, send, show — using that answer). Write the decision as a pure function: same inputs always give the same output, no hidden reads, no effects. Keep actions in a thin outer layer that calls the pure part. If you find logic already tangled with effects, name what the pure core would be before changing anything. The test of success: can the decision be checked by calling it with plain values and looking at the return? If not, the split is not done. Only proceed once you can point at the pure part and the effect part separately, and explain why the important rules now live where they can be tested and reused without triggering anything real.\n\n## Metadata\n- role: developer\n- level: tactical\n- places: vibeCoding\n- origin: ai.brimind.pro skill #705\n","linked_files":[],"origin":"ai.brimind.pro","owner_id":null,"source":"router"}