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 |
templates/duplicate-governance-template.md
View on GitHub# Duplicate Governance Template
Fill this in before turning on new matching or duplicate rules, and keep it with the metadata. Every row maps to something that ends up in `matchingRules/<Object>.matchingRule-meta.xml` or `duplicateRules/<Object>.<Name>.duplicateRule-meta.xml`, or to a person. Rows are pre-filled with a worked Contact example — replace the values, keep the shape.
---
## Scope
| Property | Value | Where it lands |
|----------|-------|----------------|
| Object | Contact | The matching-rule file name and the duplicate rule's `<Object>.` prefix |
| Object supported by Duplicate Management? | Yes — confirm with `SELECT SobjectType FROM DuplicateRule` in the target org | If no, this template does not apply; use a unique external id plus a before-save flow |
| Business owner | VP Sales Operations | Signs off on Block vs Alert |
| Data steward | Sales Ops analyst, named individual not a team | Works the `DuplicateRecordSet` queue |
| Main duplicate source | Mixed — web-to-lead conversion and a nightly CRM sync | Decides whether the control belongs in the rule or upstream in the integration key |
| Records the rule should ignore | Archived and test-account Contacts | `duplicateRuleFilter` |
## Matching Strategy
One row per `matchingRuleItems` entry. `matchingMethod` must come from the documented enum: `Exact`, `FirstName`, `LastName`, `CompanyName`, `Phone`, `City`, `Street`, `Zip`, `Title`.
| Field (`fieldName`) | `matchingMethod` | `blankValueBehavior` | Confidence | Notes |
|-----------------|------------|------------|------------|------|
| `Email` | `Exact` | `NullNotAllowed` | High | Business email; `NullNotAllowed` is the default and stops emailless records matching each other |
| `FirstName` | `FirstName` | `NullNotAllowed` | Medium | Fuzzy; handles Bob / Robert style variation |
| `LastName` | `LastName` | `NullNotAllowed` | Medium | Fuzzy; only meaningful combined with another field |
| `Phone` | `Phone` | `NullNotAllowed` | Low | Normalise punctuation in a before-save flow first — duplicate rules run after before-save automation |
**`booleanFilter`:** `1 OR (2 AND 3)` — email alone, or first plus last name together. Leaving `booleanFilter` off ANDs every item, which is a different rule.
**Rule status:** deploy as `Active`; verify with `SELECT DeveloperName, RuleStatus FROM MatchingRule WHERE SobjectType = 'Contact'` because activation is asynchronous and can land on `ActivationFailed`.
## Rule Behavior
| Operation | `actionOn*` | `operationsOn*` | Rationale |
|-----------|----------|-----------|-----------|
| Create | `Block` | (not set — operations only apply to `Allow`) | Confidence on exact email is high enough that a new duplicate is never wanted |
| Edit | `Allow` | `Alert`, `Report` | An edit that collides is usually a legitimate correction; warn and record it |
| Integration / Import | `Allow` on the integration's own rule, or the same rule with the integration scoped out via `duplicateRuleFilter` | `Report` | A Block rule halts the save before after-triggers, assignment rules and workflow — see `references/gotchas.md` |
**`alertText`:** "A Contact with this email already exists. Update the existing record instead." Legal on this rule only because `actionOnUpdate` is `Allow`; a rule that blocks both operations must omit `alertText` or the deploy fails validation.
**`securityOption`:** `BypassSharingRules`. Under `EnforceSharingRules` a duplicate the running user cannot see is saved with no message at all.
**Apex bypass:** the nightly sync sets `dml.DuplicateRuleHeader.allowSave = true` and `runAsCurrentUser = true`. This works only against `Allow` + `Alert` rules and only on Apex DML paths, never the UI.
## Survivorship and Merge Rules
Merge mechanics — which field values and child records the platform keeps — belong to `data/record-merge-implications`. This section records the policy, not the behaviour.
| Item | Decision |
|------|----------|
| Master record selection | Oldest `CreatedDate` with a non-blank `AccountId`; ties broken by most recent `LastActivityDate` |
| Field-level survivorship | Email and Phone: most recently modified non-blank value. Owner: from the master. Description: master's value, losing record appended to a note |
| Related record handling | Confirm Opportunity and Case counts before and after; see `data/record-merge-implications` |
| Exception path | Any merge crossing two Account hierarchies goes to the business owner, not the steward |
| Volume threshold | Above roughly a few thousand pairs this stops being a merge queue and becomes a project — hand off to `data/large-scale-deduplication` |
## Metrics
Baseline these before go-live so tuning has a comparison. All four come from `DuplicateRecordSet` and `DuplicateRecordItem`, which the `Report` operation populates.
| Metric | Source | Baseline | Target |
|---|---|---|---|
| Duplicate sets created per week | `SELECT COUNT() FROM DuplicateRecordSet WHERE CreatedDate = LAST_N_DAYS:7` | measure for two weeks before activating | trending down |
| Merges completed per week | Steward log or `DuplicateRecordSet` deletions | 0 at go-live | at least the weekly set-creation rate, or the queue grows |
| False positives sampled | Steward reviews 20 sets per month and records the verdict | n/a | under 10% of sampled sets |
| Recurrent duplicate source | Group `DuplicateRecordItem.RecordId` records by `CreatedById` and `Contact.LeadSource` | n/a | one named system or process, fixed upstream |
Steward reporting on `DuplicateRecordSet` and `DuplicateRecordItem` needs read and write access granted by an admin; reporting on `DuplicateRule` or `MatchingRule` additionally needs View Setup and Configuration.
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: 323k | 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 |