PranavNagrecha/AwesomeSalesforceSkills / skills/admin/duplicate-management
duplicate-management
VerifiedUse when designing, reviewing, or troubleshooting Salesforce duplicate prevention, matching rules, duplicate rules, and merge governance. Covers cleaning up duplicates that already exist at ordinary volume: merge sequencing, survivorship, stewardship ownership. Also covers the deployable MatchingRule / DuplicateRule metadata, the Alert-vs-Block action pair, DuplicateRecordSet reporting, and the Apex DMLOptions.DuplicateRuleHeader.allowSave bypass. Triggers: 'duplicate rule', 'matching rule', 'merge strategy', 'dedupe', 'survivorship', 'D&B', 'same contact twice', 'clean up duplicate records', 'clean up duplicate accounts', 'DUPLICATES_DETECTED', 'allowSave', 'FindDuplicates'. NOT for cleanup at volume — hundreds of thousands of records, batch merge jobs, DemandTools/Cloudingo — use data/large-scale-deduplication. NOT for which field values and child records the platform keeps in a merge - use data/record-merge-implications.
| File | Kind | Size |
|---|---|---|
| SKILL.md | skill md | 21.7 KB |
| references/examples.md | markdown | 4.1 KB |
| references/gotchas.md | markdown | 11.3 KB |
| references/llm-anti-patterns.md | markdown | 7.2 KB |
| references/metadata-examples.md | markdown | 20.8 KB |
| references/well-architected.md | markdown | 3.8 KB |
| scripts/check_duplicate_rules.py | script | 17.3 KB |
| templates/duplicate-governance-template.md | markdown | 5.6 KB |
references/examples.md
View on GitHub# Examples: Duplicate Management
---
## Example: Blocking Contact Duplicates by Email
**Scenario:** Internal users create Contacts manually, and duplicate Contacts with the same business email cause confusion for sales reps.
**Decision:** Use a blocking duplicate rule on Contact with strong email-based matching.
**Why:** The confidence level is high enough that allowing save would create avoidable cleanup work.
---
## Example: Alerting on Account Name + Domain Similarity
**Scenario:** Account names vary slightly (`Acme Inc.`, `Acme Incorporated`, `Acme, Inc.`) and users sometimes add the same company twice.
**Decision:** Use a fuzzy or composite matching approach with steward review rather than hard blocking all saves.
**Why:** Business-account matching often needs human judgment, especially when subsidiaries or regional entities exist.
**The matching rule:** extends the guide's own `AccountMatchingRule` sample (`Name` compared with `CompanyName`, `BillingCity` with `City`) by adding the website as a second, stronger signal. `booleanFilter` numbers the items in document order, so this reads "fuzzy company name, confirmed by either the website or the city".
```xml
<?xml version="1.0" encoding="UTF-8"?>
<MatchingRules xmlns="http://soap.sforce.com/2006/04/metadata">
<matchingRules>
<fullName>Account_Name_And_Domain</fullName>
<label>Account: fuzzy name confirmed by domain or city</label>
<description>Catches Acme Inc. / Acme Incorporated / Acme, Inc. without matching every company in one city.</description>
<booleanFilter>1 AND (2 OR 3)</booleanFilter>
<matchingRuleItems>
<blankValueBehavior>NullNotAllowed</blankValueBehavior>
<fieldName>Name</fieldName>
<matchingMethod>CompanyName</matchingMethod>
</matchingRuleItems>
<matchingRuleItems>
<blankValueBehavior>NullNotAllowed</blankValueBehavior>
<fieldName>Website</fieldName>
<matchingMethod>Exact</matchingMethod>
</matchingRuleItems>
<matchingRuleItems>
<blankValueBehavior>NullNotAllowed</blankValueBehavior>
<fieldName>BillingCity</fieldName>
<matchingMethod>City</matchingMethod>
</matchingRuleItems>
<ruleStatus>Active</ruleStatus>
</matchingRules>
</MatchingRules>
```
`CompanyName` and `City` are fuzzy methods from the documented `matchingMethod` enum; there is no fuzzy method for a URL, so the website uses `Exact`. `NullNotAllowed` on `Website` is what stops every Account without a website matching every other one. The duplicate rule that consumes this stays on `actionOnInsert` = `Allow` with `alert` and `report`, which is the "steward review rather than hard blocking" half of the decision — see `references/metadata-examples.md` for the duplicate-rule side.
---
## Example: Merge Governance for Historical Cleanup
**Scenario:** The org already has thousands of duplicate Contacts. The business wants cleanup without losing useful values.
**Approach:**
1. define survivorship rules per field
2. assign a steward queue
3. merge in controlled batches
4. track duplicates found versus duplicates resolved
**Measuring step 4:** the `report` operation writes a `DuplicateRecordSet` per group it finds, and stewards resolve a group by merging and deleting the set. Found-versus-resolved is therefore the gap between what each rule creates and what is left standing.
```sql
-- Found: sets each rule produced over the cleanup window.
SELECT DuplicateRuleId, COUNT(Id) setsCreated
FROM DuplicateRecordSet
WHERE CreatedDate = LAST_N_DAYS:30
GROUP BY DuplicateRuleId
-- Outstanding: the steward's actual backlog, oldest first.
SELECT Id, Name, RecordCount, CreatedDate
FROM DuplicateRecordSet
ORDER BY CreatedDate ASC
LIMIT 50
```
`DuplicateRecordSet` supports `delete()`, and nothing on the platform removes a set once its duplicates are merged — so a backlog that only grows means the rule is producing work faster than the queue absorbs it, which is the signal to retune matching rather than hire another steward.
**Why this works:** It treats merges as governed remediation, not as random record deletion.
Related skills
| Skill | Stars | Updated | Works with | Status | Install |
|---|---|---|---|---|---|
| writing-skillsobra/superpowersUse when creating new skills, editing existing skills, or verifying skills work before deployment | Stars: 322k | Updated | Claude CodeCodex | Verified | Install |
| xlsxanthropics/skillsUse this skill any time a spreadsheet file is the primary input or output. This means any task where the user wants to: open, read, edit, or fix an existing .xlsx, .xlsm, .xltx, .csv, or .tsv file (e.g., adding columns, computing formulas, formatting, charting, cleaning messy data); create a new spreadsheet from scratch or from other data sources; or convert between tabular file formats. Trigger especially when the user references a spreadsheet file by name or path — even casually (like "the xlsx in my downloads") — and wants something done to it or produced from it. Also trigger for cleaning or restructuring messy tabular data files (malformed rows, misplaced headers, junk data) into proper spreadsheets. The deliverable must be a spreadsheet file. Do NOT trigger when the primary deliverable is a Word document, HTML report, standalone Python script, database pipeline, or Google Sheets API integration, even if tabular data is involved. | Stars: 198k | Updated | Claude CodeCodex | Verified | Install |
| shipping-and-launchaddyosmani/agent-skillsPrepares production launches. Use when preparing to deploy to production, or when asking what needs to be in place before shipping. Use when you need a pre-launch checklist, when setting up monitoring, when planning a staged rollout, or when you need a rollback strategy. | Stars: 119k | Updated | Claude CodeCodex | Verified | Install |
| childhoodthedotmack/claude-memBabysit a shipped release after merge, publication, or deployment. Verify published packages, production behavior, installed plugins, and late CI or user reports until the observation window is clean; use babysit for PR readiness before release. | Stars: 118k | Updated | Claude CodeCodex | Verified | Install |