# Is the data actually right?

Recipe · Bugs, speed and data · RDBR01

Checks a PostgreSQL database from raw sources up — recomputing key figures, running cross-table sanity checks, spotting duplicate entities, and fixing only proven shared causes.

**Use it when:** Important numbers in a Postgres database must be verified before anyone relies on them.

## Steps

1. Source recomputation & cross-table checks: rebuild key figures from raw inputs and test cross-table totals (read-only)
2. Entity identity & historical meaning: check for split/merged records and retroactive rule changes (read-only)
3. Fix confirmed shared causes: apply targeted fixes plus repeatable SQL/metric checks after approval
4. Independent verification: show before/after recomputed examples and state any remaining source limits

## As one prompt

```text
Is the data actually right? Verify key PostgreSQL figures against original sources before changing anything.

Run these steps one at a time. Wait for my yes after each step. Stay read-only during Steps 1, 2, and 4 — never edit production data, schemas, or app code until I approve Step 3.

Step 1 (prove numbers and cross-check tables — read-only): Pick representative important figures and independently reconstruct them from raw sources without trusting existing calculation code. Also test cross-table totals, accounting identities, plausible ranges, and source coverage for data that passes constraints yet is analytically wrong. Bring back: independent rebuilds, failed cross-table reconciliations, affected row counts, and shared causes (file:line). Stop if the database stores only raw entries with no derived figures.

Step 2 (identity & history — read-only, run only if Step 1 points here): Check whether real-world entities (customers, companies, products) were duplicated or wrongly merged across imports, and whether today's rules rewrite past records' historical meaning. Bring back: concrete duplicate/merge examples with the matching rule (file:line), or past records whose meaning shifted.

Step 3 (targeted fix): After I approve, fix only the confirmed shared causes and add SQL or metric regression tests for them.

Step 4 (proof): Show recomputed examples that now match their sources, how many records were affected, and any source gaps stated plainly.

Start your report in plain English: what you found, what it means, and whether I need to do anything. Put files, lines and commands underneath.
```

Source: https://www.atlasscope.dev/prompts/is-the-data-actually-right-rdbr01
