{"success":true,"name":"check-the-affected-row-count-after-every-sql-write","description":"Just ran a SQL INSERT, UPDATE, or DELETE from code.","category":"ai-brimind","path":"ai-brimind/check-the-affected-row-count-after-every-sql-write/SKILL.md","file":"SKILL.md","content":"---\nname: check-the-affected-row-count-after-every-sql-write\ndescription: \"Just ran a SQL INSERT, UPDATE, or DELETE from code.\"\n---\n\n# Check the Affected Row Count After Every SQL Write\n\n## When to use\nProject uses SQL, and your code executes a write statement and moves on without reading how many rows it changed.\n\n## Example request\nUPDATE 'succeeded' but changed 0 rows → the WHERE matched nothing and the bug hid for weeks; no error is not the same as success. DELETE affected 500 rows instead of 1 → the count was right there in the driver's response; nobody read it. INSERT in a retry loop → duplicates piled up silently; the row count would have shown it. ORM save() returns → whether it actually wrote is in the result object; the return value carries the truth.\n\n## Instructions\nAct like an accountant who reconciles every transaction. After every INSERT, UPDATE, or DELETE in code: read the affected-row count your driver or ORM returns, and compare it to what the logic expects — updating one user should affect exactly 1 row, so treat 0 or 2+ as an error condition, not a shrug. State the expected count before running the write, then verify. Where the expectation is strict, enforce it in code (raise or log when it mismatches). If a count surprises you, stop and find out why before continuing. Only consider the write done when the actual count matches the stated expectation, and log enough to prove it later.\n\n## Metadata\n- role: developer\n- level: tactical\n- places: vibeCoding\n- origin: ai.brimind.pro skill #1036\n","linked_files":[],"origin":"ai.brimind.pro","owner_id":null,"source":"router"}