Find Duplicate Ownership
Overview
Audit the codebase for multiply-owned rules instead of blindly grepping normalize.
Classify each case as real SSOT drift, local dedupe cleanup, legitimate boundary work, or legitimate domain constraint.
Workflow
Define the audit target before searching.
Narrow by feature, contract, package, service, or file slice when possible.
Good targets: session state, persistence contracts, runtime geometry, provider options, path helpers, JSON canonicalization.
Build a taxonomy first.
Use these buckets:
architecture / SSOT bug: same business rule owned in more than one layer
local dedupe cleanup: same helper semantics copied nearby
legitimate boundary adapter: wire, vendor, or untrusted input transformation with one clear owner
legitimate domain constraint: runtime clamp, math, security, or path logic that cannot be removed architecturally
Search for ownership smells, not words.
Look for:
- validation, defaults, or clamps duplicated across frontend and backend
- generated bindings or shared type aliases hiding the real contract owner
- runtime mutators calling boundary repair or coercion
- persisted shape differing from runtime shape and requiring glue
- query, store, or cache logic re-owning domain policy
- two helpers with the same semantics but different names
- thin wrapper functions that hide a second path
- copied deterministic serializers or hash inputs
- local component, hook, or service helper clones instead of one domain owner
Separate true duplicates from valid boundaries.
Do not flag these by default:
- pure UI formatting or presentation transforms
- provider or protocol adapters with one clear boundary owner
- security or path canonicalization with one clear security owner
- runtime-only clamp or math logic with one clear runtime owner
For each finding, name the winning owner.
Always answer:
- what exact rule is multiply owned
- who owns it today
- who should own it
- what gets deleted in a hard cut
- whether anything remains as real boundary adapter code
Heuristics
- Be suspicious when frontend and backend both shape or repair the same contract.
- Be suspicious when trusted runtime state is "normalized" after every mutation.
- Be suspicious when query glue, cache glue, or store glue maps between two supposedly canonical state shapes.
- Be suspicious when multiple languages or services define the same min, max, enum, or default constants independently.
- Be suspicious when a helper exists in a domain library and again in a hook, component, controller, or service.
Subagent Use
Only use subagents when the user explicitly asks for them or asks for parallel exploration.
Reusable read-only agent definitions live in this skill's agents/ directory:
ownership-taxonomy-mapper.toml
Use first for broad slice mapping and taxonomy.
duplicate-ownership-explorer.toml
Use one per independent slice: persistence, runtime state, contracts, helpers, adapters.
ssot-judge.toml
Use after explorers when you need one strict verdict on winning owner and hard-cut cleanup.
Recommended fan-out:
- 1 taxonomy mapper
- 2 to 5 explorers for disjoint slices
- 1 SSOT judge to merge and challenge findings
Tell subagents:
- stay read-only
- cite files and symbols
- do not propose compatibility shims
- distinguish duplicate ownership from legitimate boundary work
- return winner owner plus delete or keep plan
Output Contract
For each finding, return:
- severity
- rule or contract being multiply owned
- competing owners
- why it is a duplicate-owner bug or why it is legitimate boundary work
- exact files or symbols
- recommended single owner
- hard-cut cleanup:
- classification:
- architecture / SSOT bug
- local dedupe cleanup
- legitimate boundary adapter
- legitimate domain constraint
Order findings by severity, then finish with a prioritized backlog by impact versus effort.
Prompting
Use prompt patterns from references/audit-prompts.md.
Guardrails
- Do not reduce the audit to
rg normalize.
- Do not flag every adapter or clamp as bad architecture.
- Do not recommend wrappers, fallbacks, shims, or dual paths.
- Prefer deleting the losing owner, not introducing a mediator.
- If ownership is ambiguous because the diff is mixed or the contract is unclear, say so explicitly.
1---
2name: find-duplicate-ownership
3description: Find duplicate ownership, hidden second sources of truth, and contract drift in layered codebases. Use when reviewing normalization, validation, defaulting, canonicalization, persistence mapping, runtime-vs-durable state, duplicated helpers, query or cache ownership, or any "who owns this rule?" architecture question. Especially useful for SSOT audits across frontend, backend, shared core, and adapter layers, and when the user explicitly asks for duplicate-ownership exploration with subagents.
4metadata:
5 source: https://skillmd.com/skills/gabrielmoreira/find-duplicate-ownership
6---
7
8# Find Duplicate Ownership
9
10## Overview
11
12Audit the codebase for multiply-owned rules instead of blindly grepping `normalize`.
13Classify each case as real SSOT drift, local dedupe cleanup, legitimate boundary work, or legitimate domain constraint.
14
15## Workflow
16
171. Define the audit target before searching.
18 Narrow by feature, contract, package, service, or file slice when possible.
19 Good targets: session state, persistence contracts, runtime geometry, provider options, path helpers, JSON canonicalization.
20
212. Build a taxonomy first.
22 Use these buckets:
23 - `architecture / SSOT bug`: same business rule owned in more than one layer
24 - `local dedupe cleanup`: same helper semantics copied nearby
25 - `legitimate boundary adapter`: wire, vendor, or untrusted input transformation with one clear owner
26 - `legitimate domain constraint`: runtime clamp, math, security, or path logic that cannot be removed architecturally
27
283. Search for ownership smells, not words.
29 Look for:
30 - validation, defaults, or clamps duplicated across frontend and backend
31 - generated bindings or shared type aliases hiding the real contract owner
32 - runtime mutators calling boundary repair or coercion
33 - persisted shape differing from runtime shape and requiring glue
34 - query, store, or cache logic re-owning domain policy
35 - two helpers with the same semantics but different names
36 - thin wrapper functions that hide a second path
37 - copied deterministic serializers or hash inputs
38 - local component, hook, or service helper clones instead of one domain owner
39
404. Separate true duplicates from valid boundaries.
41 Do not flag these by default:
42 - pure UI formatting or presentation transforms
43 - provider or protocol adapters with one clear boundary owner
44 - security or path canonicalization with one clear security owner
45 - runtime-only clamp or math logic with one clear runtime owner
46
475. For each finding, name the winning owner.
48 Always answer:
49 - what exact rule is multiply owned
50 - who owns it today
51 - who should own it
52 - what gets deleted in a hard cut
53 - whether anything remains as real boundary adapter code
54
55## Heuristics
56
57- Be suspicious when frontend and backend both shape or repair the same contract.
58- Be suspicious when trusted runtime state is "normalized" after every mutation.
59- Be suspicious when query glue, cache glue, or store glue maps between two supposedly canonical state shapes.
60- Be suspicious when multiple languages or services define the same min, max, enum, or default constants independently.
61- Be suspicious when a helper exists in a domain library and again in a hook, component, controller, or service.
62
63## Subagent Use
64
65Only use subagents when the user explicitly asks for them or asks for parallel exploration.
66
67Reusable read-only agent definitions live in this skill's `agents/` directory:
68
69- `ownership-taxonomy-mapper.toml`
70 Use first for broad slice mapping and taxonomy.
71- `duplicate-ownership-explorer.toml`
72 Use one per independent slice: persistence, runtime state, contracts, helpers, adapters.
73- `ssot-judge.toml`
74 Use after explorers when you need one strict verdict on winning owner and hard-cut cleanup.
75
76Recommended fan-out:
77
78- 1 taxonomy mapper
79- 2 to 5 explorers for disjoint slices
80- 1 SSOT judge to merge and challenge findings
81
82Tell subagents:
83
84- stay read-only
85- cite files and symbols
86- do not propose compatibility shims
87- distinguish duplicate ownership from legitimate boundary work
88- return winner owner plus delete or keep plan
89
90## Output Contract
91
92For each finding, return:
93
941. severity
952. rule or contract being multiply owned
963. competing owners
974. why it is a duplicate-owner bug or why it is legitimate boundary work
985. exact files or symbols
996. recommended single owner
1007. hard-cut cleanup:
101 - delete
102 - keep
103 - rename
1048. classification:
105 - architecture / SSOT bug
106 - local dedupe cleanup
107 - legitimate boundary adapter
108 - legitimate domain constraint
109
110Order findings by severity, then finish with a prioritized backlog by impact versus effort.
111
112## Prompting
113
114Use prompt patterns from [references/audit-prompts.md](references/audit-prompts.md).
115
116## Guardrails
117
118- Do not reduce the audit to `rg normalize`.
119- Do not flag every adapter or clamp as bad architecture.
120- Do not recommend wrappers, fallbacks, shims, or dual paths.
121- Prefer deleting the losing owner, not introducing a mediator.
122- If ownership is ambiguous because the diff is mixed or the contract is unclear, say so explicitly.