{"success":true,"name":"one-source-of-truth-per-piece-of-data-decide-who-owns-it","description":"The same piece of data is being stored, copied, or computed in more than one place","category":"ai-brimind","path":"ai-brimind/one-source-of-truth-per-piece-of-data-decide-who-owns-it/SKILL.md","file":"SKILL.md","content":"---\nname: one-source-of-truth-per-piece-of-data-decide-who-owns-it\ndescription: \"The same piece of data is being stored, copied, or computed in more than one place\"\n---\n\n# One Source of Truth Per Piece of Data: Decide Who Owns It\n\n## When to use\nThe same piece of data is being stored, copied, or computed in more than one place\n\n## Example request\nsaving the user's name in both the users table and inside each order → one gets updated, the other goes stale; the users table is the single source of truth, orders should reference it. computing a total on the frontend AND saving it in the DB → the two disagree after a price change; pick one owner (usually the backend) and let others only display it. keeping a copy of server data in local variables and editing the copy → the screen shows old data after a save; re-read from the owner after writes instead of trusting the copy. a status stored as text in one table and as a number in another → every comparison needs translation; one owner, one format, everyone else references it.\n\n## Instructions\nAct like a librarian who allows exactly one official copy of every book and treats all others as photocopies that can lie. Before storing, copying, or recomputing any piece of data, name its single source of truth: which table, service, or layer officially owns this value. Everything else may only read it, reference it by ID, or display it — never maintain its own editable version. If you find the same data living in two places, classify it: is the duplicate a cache (must have a clear refresh rule), a denormalized copy for speed (must have a clear update path), or an accident (must be removed)? Never leave a duplicate without a written reason and an update rule. When a screen shows stale data, suspect a disowned copy before suspecting the database. Check if the framework or database already offers the mechanism you need (relations, joins, computed fields, cache invalidation) before hand-rolling synchronization code. Only proceed once the owner of each value is CONFIRMED and stated, and explain why every other appearance of that value is a reference or a controlled copy — not a second truth.\n\n## Metadata\n- level: tactical\n- places: vibeCoding\n- origin: ai.brimind.pro skill #184\n","linked_files":[],"origin":"ai.brimind.pro","owner_id":null,"source":"router"}