riekelt/principal-engineer已通过检查
SKILL DETAIL
keeping-one-source-of-truth
riekelt/principal-engineer/keeping-one-source-of-truth
该技能编码了代码和数据的一事实一来源原则:每个事实只存在于一个地方,系统的其他部分都从那里读取。它优先于便利性:第二个副本是未来的矛盾,而漂移的副本总是那个没人记得存在的副本。当两个地方可以持有相同的真相时,它们最终会不一致,系统看起来健康却提供错误数据。 该原则包括:在添加数据之前,找到谁已经拥有它并扩展该所有者;派生而不是存储,如果平台或现有源可以在读取时回答,则在那里读取;吸收你遇到的重复项;缺失条目应大声失败;标记生成与手工编辑,绝不编辑生成输出;词汇表是类型化的,而不是字符串化的;当两个来源不一致时,说出来。边界包括:缓存和读模型是合法的派生副本,只要它们的派生是自动的且陈旧性有界且可观察;测试夹具可以有目的地冻结现实副本;文档遵循相同规则。
安装量 · 321查看来源
Installation
npx skills add https://github.com/riekelt/principal-engineer --skill keeping-one-source-of-truth
技能文件
SKILL.md
最近同步 · 2026年10月21日
SKILL.md›
---
name: keeping-one-source-of-truth
description: "Use when adding data, config, state, constants, an enum-like string, a cache, or anything that could exist in two places - or when two sources already disagree. Encodes the one-fact-one-source doctrine for code and data: derive rather than store, extend the owner, absorb duplicates. Use at the moment copying a value feels faster than referencing it."
---
# 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.
## The doctrine
1. **Before adding data, find who already owns it.** Extend that owner; do not start a rival.
2. **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.
3. **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.
4. **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.
5. **Mark generated versus hand-edited, and never edit generated output.** Every artifact states which it is.
6. **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.
7. **When two sources disagree, say so.** Surfacing the contradiction is the first fix. The full fix determines which value is live, collapses to one source, and deletes the loser. Never silently follow either one; that 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-writing` skill 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-v2` beside `thing` instead of editing in place.
- 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.