← ClaudeAtlas

mycosingle-source-of-truth-refactoringlisted

Apply this skill whenever you encounter logic, values, or transformations duplicated across multiple files in the Myco codebase — even if the user doesn't explicitly ask for a refactor. Covers five recurring SSoT patterns: (1) extracting shared read projections to the shared read-projections module, (2) centralizing provider capabilities in the shared context-window module, (3) replacing magic strings with named constants in the shared constants module, (4) creating semantic wrapper functions in the config loader and settings-merge modules, and (5) adding path properties to service state objects (DaemonServiceState). Also covers two critical violation classes to detect during code review: parallel ownership predicates (is-this-mine? checks duplicated across files) and database query locality (direct DB calls in tool files that bypass the shared data access layer). The root discipline is: name the thing, own it in one place, let consumers reference it.
goondocks-co/myco · ★ 13 · Code & Development · score 79
Install: claude install-skill goondocks-co/myco
# Single-Source-of-Truth Refactoring The Myco codebase has a recurring architectural smell: logic, values, or transformations scattered across multiple files with no canonical owner. When two consumers independently compute or verify the same thing, they drift — silently. CI stays green while production ships divergent behavior. This skill documents five fix patterns and two violation classes discovered across six independent sessions of Myco development. **Core discipline:** Name the thing, own it in one place, let consumers reference it. ## Prerequisites - Identify the canonical home before touching code: is there already an obvious module that *should* own this value? (`the shared constants module` for named scalars, `the shared context-window module` for provider capability defaults, service state objects for related file paths, `daemon-scoping path helpers` for daemon-scoping decisions) - Grep for all existing usages before extracting so no call site is missed: ```bash grep -rn "the-pattern-or-literal" packages/ ``` - Confirm tests cover the scattered behavior before deleting any duplicate path ## Procedure A: Detecting SSoT Violations During Code Review Apply these two checks when reviewing any PR that touches shared infrastructure. The violations surface as runtime failures, not compile errors — catching them here saves production incidents. ### Check 1 — Re-computation of an already-available value Flag any function that re-derives a value already availa