keeping-one-source-of-truth
This skill guides developers to identify and maintain a single source of truth when adding data, config, state, constants, caches, or anything that could exist in two places. It encodes the doctrine of deriving rather than storing, extending the owner, absorbing duplicates, and surfacing disagreements. Use it at the moment copying a value feels faster than referencing it. It helps prevent silent data drift, reduces debugging time caused by conflicting sources, and keeps codebases maintainable and reliable.
npx skills add https://github.com/riekelt/principal-engineer --skill keeping-one-source-of-truthBefore / After Comparison
1 组Without this skill, developers often face data inconsistency because config, enums, or constants are copied in multiple places. Debugging requires comparing each copy and finding which one is stale, often taking hours and missing hidden dependencies.
This skill eliminates duplicate copies by enforcing a single source of truth and derivation. New data is automatically routed to the right owner, inconsistency issues drop dramatically, and fixing time shrinks from hours to under half an hour, keeping the system healthy.
Keeping one source of truth
REQUIRED BACKGROUND: the principal-engineering skill.
Overview
Every fact about the system lives in exactly one place, and every other part of the system reads it from there. This outranks convenience: a second copy is a future contradiction, and the copy that drifts is always the one nobody remembers exists. When two places can hold the same truth they will eventually disagree, and the system then looks healthy while serving wrong data.
The doctrine
- Before adding data, find who already owns it. Extend that owner; do not start a rival. Finding the owner is cheaper than the incident two owners eventually cause.
- Derive rather than store. If the platform or an existing source can answer it at read time, read it there; do not copy the answer into a second source where it can go stale.
- Absorb duplicates you find on the way. When you touch code that hardcodes what a file already knows (or the reverse), fold the two together as part of the work instead of leaving a third variant behind.
- A missing entry fails loud (see
handling-failures): the single source is only authoritative if absence from it is an error, never a silent default. - Mark generated versus hand-edited, and never edit generated output. Every artifact states which it is; edits to derived files are lost work plus a divergence.
- Vocabulary is typed, not stringly. Identifiers, kinds, states, and names that code branches on are constants, enums, sealed types, or registry entries; a free string spelled twice is two sources of truth with a typo between them.
- When two sources disagree, say so. One of them is stale. Surfacing the contradiction is the first fix. The full fix determines which value is live, collapses to one source, and deletes the loser. Silently following either one launders the disagreement into whichever answer you happened to read first. On a declared critical path, a live disagreement earns a direct message to the owner, not only a tracked item; an unread ticket surfaces nothing.
Boundaries
- Caches and read models are legitimate derived copies when their derivation is automatic and their staleness is bounded and observable. The rule bans copies a person keeps in sync by hand.
- Test fixtures may freeze a copy of reality on purpose; the word fixture is the label that says so.
- Documentation follows the same rule (an index routes, never decides); the technical-writer plugin's
technical-writingskill carries that side where installed.
Common mistakes
- Copying a threshold, URL, or mapping "temporarily". Temporary copies have the same lifetime as the TODO above them.
- Creating
thing-v2besidethinginstead of editing in place. The second file is a fork of the truth, and both will receive different fixes. - A default value in code that shadows the config file's value. When someone changes the config and nothing happens, this is why.
- Two enums in two services spelling the same states. The day one gains a state, the boundary between them becomes a silent filter.
User Reviews (0)
Write a Review
No reviews yet
Statistics
User Rating
Rate this Skill