Ssot enforcer

From cohen-liel/agent-skills · View interactive version

Ssot enforcer is an AI agent skill from the GitHub repository cohen-liel/agent-skills. Single-source-of-truth refactoring and review workflow. Use when encountering duplicated logic, scattered constants/configuration, parallel implementations, repeated calculations, local policy decisions, model/tool routing outside central registries, or user requests mentioning SSOT, centralize, ded

How to use this skill

Skill file

SSOT Enforcer

Use this skill to keep behavior centralized. The goal is to remove parallel sources of truth without creating unnecessary abstraction.

Red Flags — Stop If You Catch Yourself Thinking

| Thought | Reality |

|---|---|

| "I'll just hardcode the timeout / URL / model ID here too" | If it has an owner (config/registry), import it. A second copy will drift. |

| "I'll copy this regex/parser into the new component" | Export the parser from one place; two copies diverge silently. |

| "These two blocks look the same, I'll merge them" | Same shape is not the same responsibility. Merge only if they must change together. |

| "I'll add one local branch just for this case" | Local policy branches are how a registry rots. Put the decision in the owner. |

| "It's quicker to recompute it in the UI" | The UI may format a value; it must not re-derive the business rule. |

| "I'll wrap the call site with a fallback default" | A fallback at the call site is a second source of truth for that default. Centralize it. |

Relationship To Root Cause First

If duplication is discovered while debugging a concrete failure, first use root-cause-first to prove the failure mechanism. When the proven cause is scattered or duplicated truth, use this skill to consolidate ownership, then return to root-cause-first for regression verification against the original symptom.

Core Rule

One responsibility should have one owner:

If code needs a value, decision, calculation, route, permission, timeout, cost, model choice, parser rule, or state transition that already has an owner, call the owner. Do not duplicate the rule locally.

When Not To Use

Do not use this skill for:

Required Workflow

  1. Scan for duplicate responsibility before editing.
  1. Identify the current or missing source of truth.
  1. Decide whether to unify.
  1. Move behavior to the owner.
  1. Protect the contract.
  1. Check for drift after the patch.

Worked Example

Duplication (what to avoid). The free-shipping threshold lives in two places:

// checkout.js (server)
if (cart.total >= 50) order.shipping = 0;

// CartBanner.jsx (UI)
const remaining = 50 - cartTotal; // "Add $X for free shipping"

Marketing changes the threshold to 75. Someone updates the server and forgets the banner — now the banner promises free shipping that checkout does not give. One policy, two sources of truth, one production bug.

Consolidated. Give the policy one owner; let the UI adapt the value for display but not re-decide it.

// pricing.js — the owner
export const FREE_SHIPPING_THRESHOLD = 75;
export const qualifiesForFreeShipping = (total) => total >= FREE_SHIPPING_THRESHOLD;

// checkout.js
if (qualifiesForFreeShipping(cart.total)) order.shipping = 0;

// CartBanner.jsx
const remaining = Math.max(0, FREE_SHIPPING_THRESHOLD - cartTotal);

Counter-example — do NOT unify. These look identical today but answer different questions:

validateProductName(s)  // catalog rule: 1-100 chars
validateChatMessage(s)  // chat rule:    1-100 chars

They share a shape, not a responsibility. Product names may later allow 200 chars; chat may add emoji rules. Merging them couples two unrelated contracts, and the next requirement forces an awkward split. Keep them separate — the match is a coincidence, not a shared owner.

Verification. Grep for the old literal (50 and the duplicated >= check) and confirm only pricing.js owns the threshold.

Anti-Patterns To Block

Acceptable Local Logic

Local code may:

Final Answer Shape

When this skill affects the work, include:

Use this skill with your AI agent: Open on Skill Issue to copy, download, or add to your library. Works with Claude, ChatGPT, Gemini, Cursor, Windsurf and more.