Keeping One Source Of Truth

riekelt/principal-engineer/plugins/principal-engineer/skills/keeping-one-source-of-truth

作者 riekelte67b7af9ac74无许可证5 个星标收录于 2026年10月8日更新于 2026年10月8日仓库3周前更新

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.

AI 生成的概览

为代码与数据确立“一事一源”原则,涵盖派生、合并重复项与冲突处理。

功能
这是一个仅含说明的技能,主张系统中每个事实只应存在于一个地方,其他部分都从那里读取。它给出规则:新增数据前先找到既有归属者,读取时派生而非存储副本,在工作中顺带合并重复项,并标明产物是生成还是手工编辑。它还要求用类型化词汇代替重复的自由字符串,并说明当两个来源已经不一致时该如何处理,包括暴露矛盾并收敛为单一来源。
适用场景
适用于新增可能出现在两处的数据、配置、状态、常量、类枚举字符串或缓存时,或两个来源已经不一致时。它针对的是复制某个值感觉比引用它更快的时刻,以及代码硬编码了文件已知内容的场景。
运行要求
无需脚本或工具,仅为说明性内容。它把 principal-engineering 技能列为必备背景,并提到 handling-failures 以及已安装情况下的 technical-writing 技能。

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.

来源与署名

来源:riekelt/principal-engineer位于plugins/principal-engineer/skills/keeping-one-source-of-truth提交e67b7af

许可证: 无许可证

内容归原作者所有。SourceWeft 从公开仓库中收录这些内容。

举报或申请下架

Keeping One Source Of Truth · plugins/principal-engineer/skills/keeping-one-source-of-truth 智能体技能 | SourceWeft