This file is byte-identical to the first copy the registry indexed, one of 8 indexed copies. Same content hash, so the same checks give both the same grade.
data-integrity from globalmpc/backendskills is an agent skill: a SKILL.md folder an AI agent loads when a task calls for it.
Rules for code that writes to the database where two requests, retries or jobs can run at once. Use for anything that changes money, stock, balances, counters or statuses, creates rows that must be unique, or calls a payment provider, email or other outside service. Applies in endpoints, webhooks and background jobs.
Collected from public GitHub. Every version is saved exactly as it was and never changes. Install it at an exact version with the mdr tool, and every file is checked before it reaches your agent. The main file is checked against the SHA-256 fingerprint recorded here, and the others against the fingerprints GitHub keeps for its source commit. The automatic checks below grade the latest version, and the same checks always give the same file the same grade.
What the file says
# Data integrity
Examples are TypeScript with `pg`. The rules apply to any stack. Assume every write can run twice at the
same time: two clicks, a client retry, two servers picking up the same job.
## 1. Read-then-write is one conditional statement, or one transaction with a lock
Why: two requests at once both read "1 seat left", both book it. Counts go negative and money gets created.
```ts
// Bad: check and write are separate; a concurrent request slips in between
const { rows: [e] } = await pool.query("select seats_left from events where id = $1", [id]);
if (e.seats_left < seats) return sendError(res, 409, "sold_out", "Not enough seats");
await pool.query("update events set seats_left = seats_left - $1 where id = $2", [seats, id]);
// Good: the check is part of the write
const { rowCount } = await client.query(
"update events set seats_left = seats_left - $1 where id = $2 and seats_left >= $1", [seats, id]);
if (rowCount === 0) throw new HttpError(409, "sold_out", "Not enough seats");
```
When several rows must change together (every line of a booking, both accounts in a payment), do it in one
…
The line at the top of this page pins the label git:20261105.6131a31, which is what most people want. This one pins the sha256 fingerprint of the contents instead, so it survives a label being moved. Either way the exact version is written to mdr.lock, and mdr install downloads and checks those contents again, so it installs them exactly or stops with an error.
GET https://markdownregistry.com/api/v1/artifacts/art_dj5khshpbvribonb
GET https://markdownregistry.com/api/v1/resolve?ref=globalmpc/backendskills/data-integrity
GET https://markdownregistry.com/api/v1/blob/dc3cf0ab531b421d93acd85441ddabc7f513e44dda34ce0b848c419099763e20
Your AI assistant does the legwork. You hear about the deals worth your word. Hand yours the standing instructions at modelranch.com and it joins the network that reads files like this one.
globalmpc/backendskills · bench/results/2026-11-04/checkout-with-1-20261104164959-6498/skills/api-endpoint/SKILL.md · Rules for HTTP API endpoints. Use when adding or changing any endpoint (route, request or response shape, status…
globalmpc/backendskills · bench/results/2026-11-04/checkout-with-1-20261104164959-6498/skills/data-integrity/SKILL.md · Rules for code that writes to the database where two requests, retries or jobs can run at once. Use for anything that…
globalmpc/backendskills · bench/results/2026-11-04/checkout-with-1-20261104164959-6498/skills/db-migration/SKILL.md · Rules for database schema changes. Use for any new table, column, index, constraint, enum or trigger, any data…
globalmpc/backendskills · bench/results/2026-11-04/checkout-with-1-20261104173809-28998/skills/api-endpoint/SKILL.md · Rules for HTTP API endpoints. Use when adding or changing any endpoint (route, request or response shape, status…
globalmpc/backendskills · bench/results/2026-11-04/checkout-with-1-20261104173809-28998/skills/data-integrity/SKILL.md · Rules for code that writes to the database where two requests, retries or jobs can run at once. Use for anything that…
globalmpc/backendskills · bench/results/2026-11-04/checkout-with-1-20261104173809-28998/skills/db-migration/SKILL.md · Rules for database schema changes. Use for any new table, column, index, constraint, enum or trigger, any data…
globalmpc/backendskills · bench/results/2026-11-04/checkout-with-1-20261105081443-28376/skills/api-endpoint/SKILL.md · Rules for HTTP API endpoints. Use when adding or changing any endpoint (route, request or response shape, status…
globalmpc/backendskills · bench/results/2026-11-04/checkout-with-1-20261105081443-28376/skills/db-migration/SKILL.md · Rules for database schema changes. Use for any new table, column, index, constraint, enum or trigger, any data…
globalmpc/backendskills · bench/results/2026-11-04/checkout-with-2-20261104164959-23336/skills/api-endpoint/SKILL.md · Rules for HTTP API endpoints. Use when adding or changing any endpoint (route, request or response shape, status…
globalmpc/backendskills · bench/results/2026-11-04/checkout-with-2-20261104164959-23336/skills/data-integrity/SKILL.md · Rules for code that writes to the database where two requests, retries or jobs can run at once. Use for anything that…
globalmpc/backendskills · bench/results/2026-11-04/checkout-with-2-20261104164959-23336/skills/db-migration/SKILL.md · Rules for database schema changes. Use for any new table, column, index, constraint, enum or trigger, any data…
globalmpc/backendskills · bench/results/2026-11-04/checkout-with-2-20261104173809-13068/skills/api-endpoint/SKILL.md · Rules for HTTP API endpoints. Use when adding or changing any endpoint (route, request or response shape, status…
nahid-sparktales/agent-dispatcher · skills/database/data-integrity/SKILL.md · Keep data correct over time — write the invariants down, push each one to the lowest layer that can enforce it, cover…
globalmpc/backendskills · bench/results/2026-11-04/checkout-with-2-20261105081443-12446/skills/data-integrity/SKILL.md · Rules for code that writes to the database where two requests, retries or jobs can run at once. Use for anything that…
globalmpc/backendskills · bench/results/2026-11-04/checkout-with-1-20261104173809-28998/skills/data-integrity/SKILL.md · Rules for code that writes to the database where two requests, retries or jobs can run at once. Use for anything that…
globalmpc/backendskills · bench/results/2026-11-04/checkout-with-3-20261104173809-29907/skills/data-integrity/SKILL.md · Rules for code that writes to the database where two requests, retries or jobs can run at once. Use for anything that…
globalmpc/backendskills · bench/results/2026-11-04/checkout-with-2-20261104173809-13068/skills/data-integrity/SKILL.md · Rules for code that writes to the database where two requests, retries or jobs can run at once. Use for anything that…
globalmpc/backendskills · bench/results/2026-11-04/checkout-with-3-20261104164959-7407/skills/data-integrity/SKILL.md · Rules for code that writes to the database where two requests, retries or jobs can run at once. Use for anything that…
globalmpc/backendskills · bench/results/2026-11-04/checkout-with-1-20261104164959-6498/skills/data-integrity/SKILL.md · Rules for code that writes to the database where two requests, retries or jobs can run at once. Use for anything that…
globalmpc/backendskills · bench/results/2026-11-04/checkout-with-2-20261104164959-23336/skills/data-integrity/SKILL.md · Rules for code that writes to the database where two requests, retries or jobs can run at once. Use for anything that…