One fact one source
Skill goodday6709-sudo/one-fact-one-source-skill/skills/one-fact-one-source
Use when a coding task may create, change, audit, or consolidate multiple implementations of the same business fact across functions, constants, statuses, permissions, amounts, schemas, contracts, derived caches, or repositories.From its SKILL.md
npx -y skills add goodday6709-sudo/one-fact-one-source-skill --skill one-fact-one-sourceAssembled from the repository path, not quoted from the project. Check it against their README if it does not work.
2 things to look at
- 24 days oldThe repository was created 24 days ago. New is not bad, but a brand new repository carrying a familiar-sounding name is the shape a typosquat arrives in, and there has been no time for anyone else to find a problem with it.
- 1 stars1 stars. Stars are a popularity signal and not a quality one, but at this level it is likely that nobody has read this closely except its author, and you would be relying on your own review.
SKILL.md
5.4 KB, ~1.0k tokens by cl100k_base, as published. Nobody here has run it
One Fact, One Source
Core Rule
Keep exactly one canonical function, constant, type, schema, contract, or authoritative output for each business fact.
Allow consumers to present or transport the result differently. Do not let them reimplement the underlying status, amount, permission, classification, or business decision.
This rule covers business facts only. Pure layout helpers and helpers without business meaning are out of scope.
Do not merge code merely because it looks similar. Merge only when the business meaning, inputs, boundaries, and ownership are the same. Preserve and document intentional differences.
Scope of Effort
Match the process weight to the task:
- Audit only: run Discover and produce the Before Editing record. Report definitions, consumers, conflicts, and the recommended canonical source when the evidence is sufficient. Do not modify files or continue into consolidation.
- Small change (touches one existing business fact, no consolidation intended): run a targeted semantic search across business terms, names and aliases, status literals, magic values, equivalent conditions, schemas, contracts, and call sites. Reuse the canonical source without adding a parallel implementation. Skip repo-wide counting, clone scans, and the full consolidation report unless the search reveals conflicting or duplicated definitions.
- Consolidation or refactor (merging duplicates, extracting a canonical source, cross-repo work): run Discover and Before Editing here, then read
CONSOLIDATION.mdfor the While Editing and Validate steps. - If a small change reveals duplicated definitions of the fact, report the duplication instead of silently expanding scope. Consolidate only when the task authorizes it.
Example
Illustrative example: three consumers independently decide whether an order qualifies for free shipping.
// cart.js, checkout.js, and api/order.js
const freeShipping = subtotal >= 1000
Consolidate the rule into one canonical function:
// domain/shipping.js
const FREE_SHIPPING_MINIMUM = 1000
export const qualifiesForFreeShipping = (subtotal) =>
subtotal >= FREE_SHIPPING_MINIMUM
All consumers call qualifiesForFreeShipping(). UI labels, fee presentation, and API response shapes may differ, but consumers must not re-derive the eligibility rule.
Do not merge two date + N days functions merely because their code is similar. A payment due date and a contract end date are different business facts when their meanings, ownership, or boundaries differ.
Discover
Use layered discovery:
- Use
rgto find names, synonyms, constants, status values, magic values, inline conditions, types, schemas, and cross-repo copies. - Search consumer boundaries, including imports, exports, re-exports, direct calls, string dispatch, configuration, rules, endpoint names, generated code, and cross-language contracts. Record the methods used, scope covered, and known blind spots.
- When available and supported for the project language, use
jscpdto find identical or near-identical code andast-grepto find structurally equivalent code. Fall back torgand manual inspection when they are unavailable or unsupported. - Inspect every candidate semantically. Tool matches are evidence of duplication, not proof that two implementations represent the same business fact.
Before Editing
For code involving business facts:
- Record the business fact, canonical name and file, duplicate definitions, consumers found through the recorded search coverage, known blind spots, implementation differences, expected behavior, test baseline, planned removals, public or persisted identifiers, required compatibility names, and authorized behavior or identifier changes.
- Count the definitions, consumers, old names, and detected clone clusters before editing so the result can be compared after consolidation.
- If existing implementations disagree, stop and report the differences. Do not guess which behavior is correct.
- If no canonical source exists, place it in the lowest stable shared layer that owns the business meaning.
- Separate business meaning from presentation, transport, caching, and platform adapters.
- Identify every known mirror repository or generated artifact and verify that it is readable. Record inaccessible mirrors before editing.
Consolidating
Read CONSOLIDATION.md before making consolidation edits. It carries the While Editing and Validate steps: git baseline and commit-authorization rules, compatibility aliases, breaking identifier changes, drift checks, and the final report contents.
Completion Gate
Do not claim completion merely because a shared helper exists.
Require all of the following:
- one canonical implementation;
- consumers found through the recorded search coverage migrated, with known blind spots disclosed;
- obsolete definitions removed and retained compatibility aliases delegating to the canonical source;
- intentional differences preserved and documented;
- available tests and builds passing, with missing test infrastructure reported;
- old-name and drift checks executed for accessible scope, with inaccessible mirrors reported; guards extended where infrastructure exists, or recommended in the report.
What ships with it: 2 files
3.9 KB alongside SKILL.md
agents/
- openai.yaml301 B
- CONSOLIDATION.md3.6 KB