Automated duplicate detection and resolution for HubSpot companies sharing Salesforce Account IDs with lift-and-shift execution
From opspal-hubspotnpx claudepluginhub revpalsfdc/opspal-commercial --plugin opspal-hubspot[options]Detect and resolve duplicate HubSpot companies that share the same Salesforce Account ID using the proven lift-and-shift pattern with two-phase commit.
/hsdedup [options]
--scan - Scan for duplicates only (no resolution)--dry-run - Preview what would be resolved without making changes--confirm - Execute live resolution (requires explicit confirmation)--max=N - Limit resolution to N duplicate groups (default: all)--batch=N - Process N groups before pausing (default: 10)--scan)salesforceaccountid populated--dry-run)--confirm)Prioritization order for selecting master company:
/hsdedup --scan
Output:
๐ Scanning for duplicate companies...
Found 52 duplicate groups sharing Salesforce Account IDs:
Group 1: Trion Properties
SF Account: 0012A00002D1juIQAR
Master: 12345678901 (lead, 11 contacts, 7 deals)
Duplicate: 12345678902 (customer, 0 contacts, 0 deals)
Group 2: Invesco
SF Account: 0012A00002D1kbjQAB
Master: 23456789012 (lead, 63 contacts, 2 deals)
Duplicate: 23456789013 (salesqualifiedlead, 0 contacts, 0 deals)
...
Total: 52 duplicate groups, 52 duplicates to resolve
/hsdedup --dry-run --max=3
Output:
๐งช DRY RUN - No changes will be made
[1/3] Coastline Real Estate Advisors (HQ)
Master: 34567890123 (customer)
Duplicate: 34567890124 (lead)
Would migrate: 3 contacts, 0 deals, 0 tickets
Would delete: 34567890124
[2/3] TAM Residential
Master: 45678901234 (lead)
Duplicate: 45678901235 (customer)
Would migrate: 150 contacts, 16 deals, 0 tickets
Would delete: 45678901235
[3/3] Morgan Properties (HQ)
Master: 56789012345 (customer)
Duplicate: 56789012346 (customer)
Would migrate: 274 contacts, 1 deals, 0 tickets
Would delete: 56789012346
Summary:
Groups: 3
Contacts to migrate: 427
Deals to migrate: 17
Tickets to migrate: 0
Duplicates to delete: 3
/hsdedup --confirm --max=52 --batch=10
Output:
โ ๏ธ LIVE EXECUTION - Changes will be made
Processing 52 duplicate groups in batches of 10...
[1/52] Trion Properties
โ
Migrated 11 contacts
โ
Migrated 7 deals
โ
Deleted duplicate 12345678902
[2/52] Invesco
โ
Migrated 63 contacts
โ
Migrated 2 deals
โ
Deleted duplicate 23456789013
...
[52/52] Kildare Partners
โ
Migrated 0 contacts
โ
Migrated 0 deals
โ
Deleted duplicate 67890123456
โโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโ
๐ EXECUTION SUMMARY
โโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโ
Total processed: 52
Successful: 52
Failed: 0
Duration: 425s
Contacts migrated: 1,695
Deals migrated: 56
Tickets migrated: 0
๐พ Results saved to: instances/example-company/dedup-results-2025-10-07.json
โโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโ
instances/{portal}/duplicate-scan-{date}.json
instances/{portal}/dedup-results-{date}.json
instances/{portal}/merge-audit/{session-id}/
crm.objects.companies.readcrm.objects.companies.writecrm.objects.contacts.readcrm.objects.deals.readcrm.objects.tickets.read/hsmerge - Analyze merge strategy for specific companies/hssfdc-scrape - Scrape Salesforce sync settings/hshealth - Check portal healthdocs/SALESFORCE_SYNC_MERGE_CONSTRAINTS.md - SF sync limitationsdocs/HUBSPOT_PATTERN_LIBRARY.md - Lift-and-shift patterninstances/example-company/DUPLICATE_RESOLUTION_SUMMARY.md - Case studyUses the following scripts and modules:
scripts/lib/hubspot-merge-strategy-selector.js - Strategy selectionscripts/lib/association-migrator.js - Association migrationscripts/lib/two-phase-commit-validator.js - Data safetyscripts/lift-and-shift-company-duplicates.js - Batch executionIf issues occur:
instances/{portal}/merge-audit/--max=3 firstsalesforceaccountid populatedsalesforceaccountid