{"success":true,"name":"change-data-in-small-batches-so-a-mistake-hurts-a-little-not","description":"About to run one big update or delete touching many database rows at once","category":"ai-brimind","path":"ai-brimind/change-data-in-small-batches-so-a-mistake-hurts-a-little-not/SKILL.md","file":"SKILL.md","content":"---\nname: change-data-in-small-batches-so-a-mistake-hurts-a-little-not\ndescription: \"About to run one big update or delete touching many database rows at once\"\n---\n\n# Change Data in Small Batches So a Mistake Hurts a Little, Not Everything\n\n## When to use\nYou are about to run a data change that touches many rows/documents (bulk update, backfill, mass delete) as one single big operation, with no checkpoint where you could stop if it turns out wrong.\n\n## Example request\nA backfill updates 50,000 rows in one shot → the formula was wrong for one edge case; now 50,000 rows are wrong instead of the first 100. A batched update stops after batch one because the sample looks off → the bug is fixed having damaged 500 rows, not the whole table; the batch boundary was the safety brake. A mass delete runs row-limited, checking counts between chunks → halfway, the count stops matching the prediction; the run halts with half the data still untouched. A tiny update on 12 rows is batched into 12 runs → over-engineering; batching is for big blast radius, not every write.\n\n## Instructions\nAct as someone defusing something wire by wire, never all at once: when a change touches a lot of data, the goal is that your first mistake is also your smallest one. For any bulk data change, do this: (1) Predict the total first: how many rows/documents SHOULD this touch? Write the number down — it is your alarm system for every step after. (2) Cut the work into batches with a real limit (by ID range, by date range, or a LIMIT/limit() of a few hundred to a few thousand per run) instead of one statement over everything. (3) Run ONLY the first batch, then stop and inspect like a skeptic: did it change exactly the predicted count for that slice? Open a handful of changed records — are the new values right? Open records that should NOT have changed — are they untouched? (4) Only if the first batch is perfect do you continue, keeping the count check between batches; the moment any batch's numbers surprise you, STOP — do not 'push through', because every further batch multiplies the damage. Fix, and if rows were hurt, this is why your fresh pre-change backup exists. (5) Make each batch safe to accidentally run twice: filter on the state being changed FROM (e.g. only rows where the new field is still empty), so a re-run finds nothing left to touch instead of double-applying. (6) Skip all of this ceremony when the change touches a handful of rows you can eyeball — batching is proportional to blast radius, not a ritual. Only call the bulk change done when the sum of all batches equals the number you predicted at the start; a matching total is the proof, a finished script is just an event.\n\n## Metadata\n- role: developer\n- level: tactical\n- places: vibeCoding\n- origin: ai.brimind.pro skill #614\n","linked_files":[],"origin":"ai.brimind.pro","owner_id":null,"source":"router"}