[{"data":1,"prerenderedAt":-1},["ShallowReactive",2],{"skill:01M73ACHHT82VDK8C7F6T0Z7J8":3,"skill-same:01M73ACHHT82VDK8C7F6T0Z7J8":50},{"skillNo":4,"name":5,"nameZh":6,"description":7,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":6,"repositoryNo":12,"starsCount":13,"licenseSpdxId":14,"licenseFileUrl":6,"sourceHtmlUrl":15,"categories":16,"keywords":17,"publishedAt":18,"linkOnly":19,"markdownContent":20,"markdownBody":21,"frontMatter":22,"refName":28,"commitSha":29,"skillDirectory":30,"forksCount":31,"repositoryHtmlUrl":32,"repositoryHomepageUrl":6,"ownerHtmlUrl":33,"ownerBlogUrl":34,"ownerDescription":6,"updatedAt":35,"install":36,"resources":49},"01M73ACHHT82VDK8C7F6T0Z7J8","merge-duplicate-companies",null,"Identify duplicate company records by domain and name, export audit CSVs for review, and guide merging. API for discovery, third-party tools or manual UI for merging (HubSpot has no bulk merge API).","roohe\u002Fagentic-super-skills","roohe","https:\u002F\u002Favatars.githubusercontent.com\u002Fu\u002F99054084?v=4","01M734WCDFP6RZVT5CNM00QR26","01M734WCE4BD0T4NZS5PCV9V5F",10,"MIT","https:\u002F\u002Fgithub.com\u002Froohe\u002Fagentic-super-skills\u002Fblob\u002Fmaster\u002Fskills_library\u002Fmerge-duplicate-companies\u002FSKILL.md",[],[],"2026-11-11 15:11:14",false,"---\nname: merge-duplicate-companies\ndescription: >\n  Identify duplicate company records by domain and name, export audit\n  CSVs for review, and guide merging. API for discovery, third-party\n  tools or manual UI for merging (HubSpot has no bulk merge API).\nlicense: MIT\nmetadata:\n  author: tomgranot\n  version: \"1.0\"\n  category: database-hygiene\n---\n\n# Merge Duplicate Companies\n\n## Purpose\n\nDuplicate company records fragment contacts, deals, and engagement history across multiple records for the same real-world company. This leads to inaccurate reporting, broken associations, sales confusion, and workflow failures. This skill identifies duplicates by domain and by name, exports prioritized audit CSVs, and guides the user through merging.\n\n## Prerequisites\n\n- A HubSpot private app access token with `crm.objects.companies.read` scope\n- Python 3.10+ with `uv` for package management\n- A `.env` file containing `HUBSPOT_ACCESS_TOKEN`\n- Super Admin permissions for merging in the HubSpot UI\n\n## Key Constraint\n\n**HubSpot has no bulk merge API.** Merging must happen one pair at a time through the HubSpot UI or via third-party tools. The API is used for discovery, analysis, and audit trail generation.\n\n**HubSpot's built-in Duplicates tool is NOT available on all plan tiers.** Check whether the account has access to Settings > Data Management > Duplicates before relying on it.\n\n## Execution Pattern\n\nThis skill follows a 4-stage execution pattern: **Plan -> Before State -> Execute -> After State**.\n\n### Stage 1: Plan\n\nBefore writing any code, confirm with the user:\n\n1. **Confirm intentional duplicates**: Ask whether separate records for regional offices of the same company are intentional. If so, exclude those from merging.\n2. **Merging is irreversible.** Once two company records are merged, they cannot be un-merged. The surviving record inherits all associations, but property values from the deleted record may be lost if both have the same property filled in.\n3. **Prioritization strategy**: Recommend merging Customer-stage companies first, then Opportunity-stage, then everything else.\n4. **Time estimate**: This is the most time-consuming process. Budget 2-4 hours for critical duplicates, 8-12 hours total for full cleanup.\n\n### Stage 2: Before State\n\nFetch all companies, identify duplicate groups by domain and name, and export audit CSVs.\n\n```python\n\"\"\"\nBefore State: Identify duplicate companies by domain and by name.\nCreates CSV audit logs for review before merging.\n\"\"\"\nimport os\nimport csv\nimport time\nimport requests\nfrom collections import defaultdict\nfrom dotenv import load_dotenv\n\nload_dotenv()\n\nTOKEN = os.environ[\"HUBSPOT_ACCESS_TOKEN\"]\nBASE = \"https:\u002F\u002Fapi.hubapi.com\"\nheaders = {\n    \"Authorization\": f\"Bearer {TOKEN}\",\n    \"Content-Type\": \"application\u002Fjson\",\n}\n\n# --- Step 1: Fetch all companies ---\nprint(\"Fetching all companies...\")\n\nall_companies = []\nafter = None\n\nwhile True:\n    params = {\n        \"limit\": 100,\n        \"properties\": \"name,domain,lifecyclestage,num_associated_contacts,\"\n                       \"num_associated_deals,hubspot_owner_id,createdate\",\n    }\n    if after:\n        params[\"after\"] = after\n\n    resp = requests.get(\n        f\"{BASE}\u002Fcrm\u002Fv3\u002Fobjects\u002Fcompanies\",\n        headers=headers, params=params,\n    )\n    if resp.status_code != 200:\n        print(f\"Stopped at {len(all_companies)} (status {resp.status_code})\")\n        break\n\n    data = resp.json()\n    for company in data.get(\"results\", []):\n        props = company.get(\"properties\", {})\n        all_companies.append({\n            \"id\": company[\"id\"],\n            \"name\": (props.get(\"name\") or \"\").strip(),\n            \"domain\": (props.get(\"domain\") or \"\").strip().lower(),\n            \"lifecycle_stage\": props.get(\"lifecyclestage\", \"\"),\n            \"associated_contacts\": props.get(\"num_associated_contacts\", \"0\"),\n            \"associated_deals\": props.get(\"num_associated_deals\", \"0\"),\n            \"owner_id\": props.get(\"hubspot_owner_id\", \"\"),\n            \"createdate\": props.get(\"createdate\", \"\"),\n        })\n\n    paging = data.get(\"paging\", {})\n    after = paging.get(\"next\", {}).get(\"after\")\n    if not after:\n        break\n    time.sleep(0.05)\n\nprint(f\"Total companies fetched: {len(all_companies)}\")\n\n# --- Step 2: Find duplicates by domain ---\nprint(\"\\nAnalyzing duplicates by domain...\")\n\ndomain_groups = defaultdict(list)\nfor c in all_companies:\n    if c[\"domain\"]:\n        domain_groups[c[\"domain\"]].append(c)\n\ndup_domain_groups = {d: cs for d, cs in domain_groups.items() if len(cs) > 1}\ndup_domain_records = sum(len(cs) for cs in dup_domain_groups.values())\n\nprint(f\"Unique domains with duplicates: {len(dup_domain_groups)}\")\nprint(f\"Total records in duplicate domain groups: {dup_domain_records}\")\n\n# Top offenders\nsorted_domains = sorted(dup_domain_groups.items(), key=lambda x: len(x[1]), reverse=True)\nprint(\"\\nTop duplicate domains:\")\nfor domain, companies in sorted_domains[:15]:\n    print(f\"  {domain}: {len(companies)} records\")\n\n# --- Step 3: Find duplicates by name ---\nprint(\"\\nAnalyzing duplicates by name...\")\n\nname_groups = defaultdict(list)\nfor c in all_companies:\n    if c[\"name\"]:\n        name_groups[c[\"name\"].lower()].append(c)\n\ndup_name_groups = {n: cs for n, cs in name_groups.items() if len(cs) > 1}\ndup_name_records = sum(len(cs) for cs in dup_name_groups.values())\n\nprint(f\"Unique names with duplicates: {len(dup_name_groups)}\")\nprint(f\"Total records in duplicate name groups: {dup_name_records}\")\n\nsorted_names = sorted(dup_name_groups.items(), key=lambda x: len(x[1]), reverse=True)\nprint(\"\\nTop duplicate names:\")\nfor name_lower, companies in sorted_names[:15]:\n    print(f\"  {companies[0]['name']}: {len(companies)} records\")\n\n# --- Step 4: Save CSV audit logs ---\nos.makedirs(\"data\u002Faudit-logs\", exist_ok=True)\n\n# Domain duplicates CSV\ndomain_csv = \"data\u002Faudit-logs\u002Fduplicate-companies-by-domain.csv\"\nwith open(domain_csv, \"w\", newline=\"\") as f:\n    writer = csv.DictWriter(f, fieldnames=[\n        \"domain\", \"duplicate_count\", \"id\", \"name\", \"lifecycle_stage\",\n        \"associated_contacts\", \"associated_deals\", \"owner_id\", \"createdate\",\n    ])\n    writer.writeheader()\n    for domain, companies in sorted_domains:\n        for c in companies:\n            writer.writerow({\n                \"domain\": domain,\n                \"duplicate_count\": len(companies),\n                **{k: c[k] for k in [\n                    \"id\", \"name\", \"lifecycle_stage\", \"associated_contacts\",\n                    \"associated_deals\", \"owner_id\", \"createdate\",\n                ]},\n            })\n\nprint(f\"\\nDomain duplicates CSV: {domain_csv}\")\n\n# Name duplicates CSV\nname_csv = \"data\u002Faudit-logs\u002Fduplicate-companies-by-name.csv\"\nwith open(name_csv, \"w\", newline=\"\") as f:\n    writer = csv.DictWriter(f, fieldnames=[\n        \"duplicate_name\", \"duplicate_count\", \"id\", \"name\", \"domain\",\n        \"lifecycle_stage\", \"associated_contacts\", \"associated_deals\",\n        \"owner_id\", \"createdate\",\n    ])\n    writer.writeheader()\n    for name_lower, companies in sorted_names:\n        for c in companies:\n            writer.writerow({\n                \"duplicate_name\": name_lower,\n                \"duplicate_count\": len(companies),\n                **{k: c[k] for k in [\n                    \"id\", \"name\", \"domain\", \"lifecycle_stage\",\n                    \"associated_contacts\", \"associated_deals\",\n                    \"owner_id\", \"createdate\",\n                ]},\n            })\n\nprint(f\"Name duplicates CSV: {name_csv}\")\n```\n\n**Present findings to the user.** Key data points:\n- Total duplicate domain groups and affected records\n- Total duplicate name groups and affected records\n- Top offenders by domain and name\n- CSVs for manual review\n\n### Stage 3: Execute\n\nThis stage is primarily manual. Guide the user through the merging process.\n\n**Option A: HubSpot Built-In Duplicates Tool (if available)**\n\n1. Navigate to **Settings > Data Management > Duplicates > Companies**\n2. HubSpot shows suggested duplicate pairs ranked by confidence\n3. For each pair, click **Review** to see side-by-side comparison\n4. Select the \"primary\" (surviving) record based on:\n   - More associated contacts\n   - More associated deals\n   - More recent activity\n   - Has a company owner\n   - More complete property data\n5. Click **Merge**\n6. Process ~50 pairs at a time; HubSpot loads the next batch automatically\n\n**Prioritization order:**\n1. Customer-stage company duplicates (highest value data)\n2. Opportunity-stage company duplicates\n3. Everything else (Leads, Subscribers)\n\n**Option B: Manual search-and-merge for top offenders**\n\nFor companies with many duplicates (4+ records):\n\n1. Search for the company by name in **Contacts > Companies**\n2. Identify the \"winner\" record (most associations, deals, activity)\n3. Open the winner record > **Actions** > **Merge**\n4. Search for the duplicate > select it > choose property values > **Merge**\n5. Repeat until only one record remains\n\n**Option C: Third-party deduplication tools**\n\nFor large-scale merging, recommend:\n- **Dedupely** (dedupely.com) -- HubSpot-native integration, bulk merge\n- **Insycle** (insycle.com) -- Data management platform with dedup\n- **Koalify** (koalify.com) -- HubSpot duplicate management\n\nThese tools can automate bulk merges that would take hours manually.\n\n**Prevention: Configure auto-association after merging**\n\n```\nSettings > Data Management > Companies (or Settings > Objects > Companies)\nEnable: \"Create and associate companies with contacts\"\nSet unique identifier: Company domain name\n```\n\nThis prevents future duplicates by using domain-based matching instead of name-based.\n\n### Stage 4: After State\n\nRe-run the Before State analysis and compare duplicate counts.\n\n```python\n\"\"\"\nAfter State: Verify duplicate reduction.\n\"\"\"\n# Re-fetch all companies and re-run duplicate analysis\n# Compare:\n#   - Number of duplicate domain groups (should decrease)\n#   - Number of duplicate name groups (should decrease)\n#   - Top offenders (should be resolved)\n\n# Also verify merged records:\n# For each known duplicate that was merged, search for the company\n# and confirm only one record exists with all expected associations.\n```\n\n**Manual verification:**\n1. Search for top offenders by name (should show only 1 record each)\n2. Open merged records and verify contacts and deals from both originals appear\n3. Check Settings > Data Management > Duplicates -- count should be significantly lower\n\n## Safety Mechanisms\n\n| Mechanism | Detail |\n|-----------|--------|\n| **CSV audit trail** | Complete export of all companies with duplicate group annotations before any merging. |\n| **Prioritized approach** | Customer and Opportunity companies merged first to protect highest-value data. |\n| **Review before merge** | CSVs enable team review before any irreversible merges happen. |\n| **Confirmation prompt** | Present duplicate analysis to the user and wait for explicit confirmation before instructing merges. |\n| **No auto-merge** | This skill never merges automatically. All merges require manual human decision. |\n\n## Technical Gotchas\n\n1. **HubSpot has no bulk merge API.** There is no programmatic way to merge companies. All merges happen through the UI or third-party tools.\n\n2. **Merging is irreversible.** Once merged, records cannot be split apart. When in doubt, skip a pair and revisit later.\n\n3. **Property conflicts**: When both records have a value for the same property, HubSpot keeps the value from the \"primary\" record. Review important properties (phone, address, industry) before confirming.\n\n4. **Companies endpoint uses GET, not POST\u002Fsearch.** To list all companies, use `GET \u002Fcrm\u002Fv3\u002Fobjects\u002Fcompanies` with pagination, not the Search API. The Search API works too but is slower for full exports.\n\n5. **Domain normalization**: Always lowercase and strip whitespace from domains before grouping. `Example.com` and `example.com` are the same company.\n\n6. **Name-based duplicates have higher false-positive rates.** \"State University\" might match multiple genuinely different institutions. Domain-based duplicates are more reliable.\n\n7. **Contact reassociation**: After merging, verify that contacts from both original records appear under the surviving record. HubSpot should handle this automatically, but spot-check.\n\n8. **The Duplicates tool is plan-tier dependent.** Not all HubSpot plans include it. Check availability before instructing the user to navigate there.\n\n## Package Setup\n\n```bash\nuv init hubspot-cleanup\ncd hubspot-cleanup\nuv add requests python-dotenv\n```\n\nCreate a `.env` file:\n```\nHUBSPOT_ACCESS_TOKEN=pat-na1-xxxxxxxx\n```\n","# Merge Duplicate Companies\n\n## Purpose\n\nDuplicate company records fragment contacts, deals, and engagement history across multiple records for the same real-world company. This leads to inaccurate reporting, broken associations, sales confusion, and workflow failures. This skill identifies duplicates by domain and by name, exports prioritized audit CSVs, and guides the user through merging.\n\n## Prerequisites\n\n- A HubSpot private app access token with `crm.objects.companies.read` scope\n- Python 3.10+ with `uv` for package management\n- A `.env` file containing `HUBSPOT_ACCESS_TOKEN`\n- Super Admin permissions for merging in the HubSpot UI\n\n## Key Constraint\n\n**HubSpot has no bulk merge API.** Merging must happen one pair at a time through the HubSpot UI or via third-party tools. The API is used for discovery, analysis, and audit trail generation.\n\n**HubSpot's built-in Duplicates tool is NOT available on all plan tiers.** Check whether the account has access to Settings > Data Management > Duplicates before relying on it.\n\n## Execution Pattern\n\nThis skill follows a 4-stage execution pattern: **Plan -> Before State -> Execute -> After State**.\n\n### Stage 1: Plan\n\nBefore writing any code, confirm with the user:\n\n1. **Confirm intentional duplicates**: Ask whether separate records for regional offices of the same company are intentional. If so, exclude those from merging.\n2. **Merging is irreversible.** Once two company records are merged, they cannot be un-merged. The surviving record inherits all associations, but property values from the deleted record may be lost if both have the same property filled in.\n3. **Prioritization strategy**: Recommend merging Customer-stage companies first, then Opportunity-stage, then everything else.\n4. **Time estimate**: This is the most time-consuming process. Budget 2-4 hours for critical duplicates, 8-12 hours total for full cleanup.\n\n### Stage 2: Before State\n\nFetch all companies, identify duplicate groups by domain and name, and export audit CSVs.\n\n```python\n\"\"\"\nBefore State: Identify duplicate companies by domain and by name.\nCreates CSV audit logs for review before merging.\n\"\"\"\nimport os\nimport csv\nimport time\nimport requests\nfrom collections import defaultdict\nfrom dotenv import load_dotenv\n\nload_dotenv()\n\nTOKEN = os.environ[\"HUBSPOT_ACCESS_TOKEN\"]\nBASE = \"https:\u002F\u002Fapi.hubapi.com\"\nheaders = {\n    \"Authorization\": f\"Bearer {TOKEN}\",\n    \"Content-Type\": \"application\u002Fjson\",\n}\n\n# --- Step 1: Fetch all companies ---\nprint(\"Fetching all companies...\")\n\nall_companies = []\nafter = None\n\nwhile True:\n    params = {\n        \"limit\": 100,\n        \"properties\": \"name,domain,lifecyclestage,num_associated_contacts,\"\n                       \"num_associated_deals,hubspot_owner_id,createdate\",\n    }\n    if after:\n        params[\"after\"] = after\n\n    resp = requests.get(\n        f\"{BASE}\u002Fcrm\u002Fv3\u002Fobjects\u002Fcompanies\",\n        headers=headers, params=params,\n    )\n    if resp.status_code != 200:\n        print(f\"Stopped at {len(all_companies)} (status {resp.status_code})\")\n        break\n\n    data = resp.json()\n    for company in data.get(\"results\", []):\n        props = company.get(\"properties\", {})\n        all_companies.append({\n            \"id\": company[\"id\"],\n            \"name\": (props.get(\"name\") or \"\").strip(),\n            \"domain\": (props.get(\"domain\") or \"\").strip().lower(),\n            \"lifecycle_stage\": props.get(\"lifecyclestage\", \"\"),\n            \"associated_contacts\": props.get(\"num_associated_contacts\", \"0\"),\n            \"associated_deals\": props.get(\"num_associated_deals\", \"0\"),\n            \"owner_id\": props.get(\"hubspot_owner_id\", \"\"),\n            \"createdate\": props.get(\"createdate\", \"\"),\n        })\n\n    paging = data.get(\"paging\", {})\n    after = paging.get(\"next\", {}).get(\"after\")\n    if not after:\n        break\n    time.sleep(0.05)\n\nprint(f\"Total companies fetched: {len(all_companies)}\")\n\n# --- Step 2: Find duplicates by domain ---\nprint(\"\\nAnalyzing duplicates by domain...\")\n\ndomain_groups = defaultdict(list)\nfor c in all_companies:\n    if c[\"domain\"]:\n        domain_groups[c[\"domain\"]].append(c)\n\ndup_domain_groups = {d: cs for d, cs in domain_groups.items() if len(cs) > 1}\ndup_domain_records = sum(len(cs) for cs in dup_domain_groups.values())\n\nprint(f\"Unique domains with duplicates: {len(dup_domain_groups)}\")\nprint(f\"Total records in duplicate domain groups: {dup_domain_records}\")\n\n# Top offenders\nsorted_domains = sorted(dup_domain_groups.items(), key=lambda x: len(x[1]), reverse=True)\nprint(\"\\nTop duplicate domains:\")\nfor domain, companies in sorted_domains[:15]:\n    print(f\"  {domain}: {len(companies)} records\")\n\n# --- Step 3: Find duplicates by name ---\nprint(\"\\nAnalyzing duplicates by name...\")\n\nname_groups = defaultdict(list)\nfor c in all_companies:\n    if c[\"name\"]:\n        name_groups[c[\"name\"].lower()].append(c)\n\ndup_name_groups = {n: cs for n, cs in name_groups.items() if len(cs) > 1}\ndup_name_records = sum(len(cs) for cs in dup_name_groups.values())\n\nprint(f\"Unique names with duplicates: {len(dup_name_groups)}\")\nprint(f\"Total records in duplicate name groups: {dup_name_records}\")\n\nsorted_names = sorted(dup_name_groups.items(), key=lambda x: len(x[1]), reverse=True)\nprint(\"\\nTop duplicate names:\")\nfor name_lower, companies in sorted_names[:15]:\n    print(f\"  {companies[0]['name']}: {len(companies)} records\")\n\n# --- Step 4: Save CSV audit logs ---\nos.makedirs(\"data\u002Faudit-logs\", exist_ok=True)\n\n# Domain duplicates CSV\ndomain_csv = \"data\u002Faudit-logs\u002Fduplicate-companies-by-domain.csv\"\nwith open(domain_csv, \"w\", newline=\"\") as f:\n    writer = csv.DictWriter(f, fieldnames=[\n        \"domain\", \"duplicate_count\", \"id\", \"name\", \"lifecycle_stage\",\n        \"associated_contacts\", \"associated_deals\", \"owner_id\", \"createdate\",\n    ])\n    writer.writeheader()\n    for domain, companies in sorted_domains:\n        for c in companies:\n            writer.writerow({\n                \"domain\": domain,\n                \"duplicate_count\": len(companies),\n                **{k: c[k] for k in [\n                    \"id\", \"name\", \"lifecycle_stage\", \"associated_contacts\",\n                    \"associated_deals\", \"owner_id\", \"createdate\",\n                ]},\n            })\n\nprint(f\"\\nDomain duplicates CSV: {domain_csv}\")\n\n# Name duplicates CSV\nname_csv = \"data\u002Faudit-logs\u002Fduplicate-companies-by-name.csv\"\nwith open(name_csv, \"w\", newline=\"\") as f:\n    writer = csv.DictWriter(f, fieldnames=[\n        \"duplicate_name\", \"duplicate_count\", \"id\", \"name\", \"domain\",\n        \"lifecycle_stage\", \"associated_contacts\", \"associated_deals\",\n        \"owner_id\", \"createdate\",\n    ])\n    writer.writeheader()\n    for name_lower, companies in sorted_names:\n        for c in companies:\n            writer.writerow({\n                \"duplicate_name\": name_lower,\n                \"duplicate_count\": len(companies),\n                **{k: c[k] for k in [\n                    \"id\", \"name\", \"domain\", \"lifecycle_stage\",\n                    \"associated_contacts\", \"associated_deals\",\n                    \"owner_id\", \"createdate\",\n                ]},\n            })\n\nprint(f\"Name duplicates CSV: {name_csv}\")\n```\n\n**Present findings to the user.** Key data points:\n- Total duplicate domain groups and affected records\n- Total duplicate name groups and affected records\n- Top offenders by domain and name\n- CSVs for manual review\n\n### Stage 3: Execute\n\nThis stage is primarily manual. Guide the user through the merging process.\n\n**Option A: HubSpot Built-In Duplicates Tool (if available)**\n\n1. Navigate to **Settings > Data Management > Duplicates > Companies**\n2. HubSpot shows suggested duplicate pairs ranked by confidence\n3. For each pair, click **Review** to see side-by-side comparison\n4. Select the \"primary\" (surviving) record based on:\n   - More associated contacts\n   - More associated deals\n   - More recent activity\n   - Has a company owner\n   - More complete property data\n5. Click **Merge**\n6. Process ~50 pairs at a time; HubSpot loads the next batch automatically\n\n**Prioritization order:**\n1. Customer-stage company duplicates (highest value data)\n2. Opportunity-stage company duplicates\n3. Everything else (Leads, Subscribers)\n\n**Option B: Manual search-and-merge for top offenders**\n\nFor companies with many duplicates (4+ records):\n\n1. Search for the company by name in **Contacts > Companies**\n2. Identify the \"winner\" record (most associations, deals, activity)\n3. Open the winner record > **Actions** > **Merge**\n4. Search for the duplicate > select it > choose property values > **Merge**\n5. Repeat until only one record remains\n\n**Option C: Third-party deduplication tools**\n\nFor large-scale merging, recommend:\n- **Dedupely** (dedupely.com) -- HubSpot-native integration, bulk merge\n- **Insycle** (insycle.com) -- Data management platform with dedup\n- **Koalify** (koalify.com) -- HubSpot duplicate management\n\nThese tools can automate bulk merges that would take hours manually.\n\n**Prevention: Configure auto-association after merging**\n\n```\nSettings > Data Management > Companies (or Settings > Objects > Companies)\nEnable: \"Create and associate companies with contacts\"\nSet unique identifier: Company domain name\n```\n\nThis prevents future duplicates by using domain-based matching instead of name-based.\n\n### Stage 4: After State\n\nRe-run the Before State analysis and compare duplicate counts.\n\n```python\n\"\"\"\nAfter State: Verify duplicate reduction.\n\"\"\"\n# Re-fetch all companies and re-run duplicate analysis\n# Compare:\n#   - Number of duplicate domain groups (should decrease)\n#   - Number of duplicate name groups (should decrease)\n#   - Top offenders (should be resolved)\n\n# Also verify merged records:\n# For each known duplicate that was merged, search for the company\n# and confirm only one record exists with all expected associations.\n```\n\n**Manual verification:**\n1. Search for top offenders by name (should show only 1 record each)\n2. Open merged records and verify contacts and deals from both originals appear\n3. Check Settings > Data Management > Duplicates -- count should be significantly lower\n\n## Safety Mechanisms\n\n| Mechanism | Detail |\n|-----------|--------|\n| **CSV audit trail** | Complete export of all companies with duplicate group annotations before any merging. |\n| **Prioritized approach** | Customer and Opportunity companies merged first to protect highest-value data. |\n| **Review before merge** | CSVs enable team review before any irreversible merges happen. |\n| **Confirmation prompt** | Present duplicate analysis to the user and wait for explicit confirmation before instructing merges. |\n| **No auto-merge** | This skill never merges automatically. All merges require manual human decision. |\n\n## Technical Gotchas\n\n1. **HubSpot has no bulk merge API.** There is no programmatic way to merge companies. All merges happen through the UI or third-party tools.\n\n2. **Merging is irreversible.** Once merged, records cannot be split apart. When in doubt, skip a pair and revisit later.\n\n3. **Property conflicts**: When both records have a value for the same property, HubSpot keeps the value from the \"primary\" record. Review important properties (phone, address, industry) before confirming.\n\n4. **Companies endpoint uses GET, not POST\u002Fsearch.** To list all companies, use `GET \u002Fcrm\u002Fv3\u002Fobjects\u002Fcompanies` with pagination, not the Search API. The Search API works too but is slower for full exports.\n\n5. **Domain normalization**: Always lowercase and strip whitespace from domains before grouping. `Example.com` and `example.com` are the same company.\n\n6. **Name-based duplicates have higher false-positive rates.** \"State University\" might match multiple genuinely different institutions. Domain-based duplicates are more reliable.\n\n7. **Contact reassociation**: After merging, verify that contacts from both original records appear under the surviving record. HubSpot should handle this automatically, but spot-check.\n\n8. **The Duplicates tool is plan-tier dependent.** Not all HubSpot plans include it. Check availability before instructing the user to navigate there.\n\n## Package Setup\n\n```bash\nuv init hubspot-cleanup\ncd hubspot-cleanup\nuv add requests python-dotenv\n```\n\nCreate a `.env` file:\n```\nHUBSPOT_ACCESS_TOKEN=pat-na1-xxxxxxxx\n```\n",{"name":5,"license":14,"metadata":23,"description":27},{"author":24,"version":25,"category":26},"tomgranot","1.0","database-hygiene","Identify duplicate company records by domain and name, export audit CSVs for review, and guide merging. API for discovery, third-party tools or manual UI for merging (HubSpot has no bulk merge API).\n","master","f483e54f3ad5f202a77d45f2e57f8d970b71195f","skills_library\u002Fmerge-duplicate-companies",2,"https:\u002F\u002Fgithub.com\u002Froohe\u002Fagentic-super-skills","https:\u002F\u002Fgithub.com\u002Froohe","yoou.link","2026-05-19 15:56:07",{"source":8,"skillName":5,"commands":37,"prompt":47,"zipAvailable":48},[38,41,44],{"tool":39,"command":40},"npx","npx skills add roohe\u002Fagentic-super-skills --skill merge-duplicate-companies",{"tool":42,"command":43},"bunx","bunx skills add roohe\u002Fagentic-super-skills --skill merge-duplicate-companies",{"tool":45,"command":46},"pnpm","pnpm dlx skills add roohe\u002Fagentic-super-skills --skill merge-duplicate-companies","安装技能，技能地址：https:\u002F\u002Fgithub.com\u002Froohe\u002Fagentic-super-skills\u002Fblob\u002Fmaster\u002Fskills_library\u002Fmerge-duplicate-companies\u002FSKILL.md",true,[],[51,58,65,72,79,86],{"skillNo":52,"name":53,"nameZh":6,"description":54,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":6,"repositoryNo":12,"starsCount":13,"licenseSpdxId":14,"licenseFileUrl":6,"sourceHtmlUrl":55,"categories":56,"keywords":57,"publishedAt":18},"01M73D865CZME2FCMKA4PQM348","zarr-python","Chunked N-D arrays for cloud storage. Compressed arrays, parallel I\u002FO, S3\u002FGCS integration, NumPy\u002FDask\u002FXarray compatible, for large-scale scientific computing pipelines.","https:\u002F\u002Fgithub.com\u002Froohe\u002Fagentic-super-skills\u002Fblob\u002Fmaster\u002Fskills_library\u002Fzarr-python\u002FSKILL.md",[],[],{"skillNo":59,"name":60,"nameZh":6,"description":61,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":6,"repositoryNo":12,"starsCount":13,"licenseSpdxId":14,"licenseFileUrl":6,"sourceHtmlUrl":62,"categories":63,"keywords":64,"publishedAt":18},"01M73D7Z64J4ABWZJD7P44XBBF","youtube-downloader","Download and process YouTube content for research. Use when: downloading competitor videos for analysis; extracting audio for podcasts; getting transcripts for content repurposing; archiving webinars; research content curation","https:\u002F\u002Fgithub.com\u002Froohe\u002Fagentic-super-skills\u002Fblob\u002Fmaster\u002Fskills_library\u002Fyoutube-downloader\u002FSKILL.md",[],[],{"skillNo":66,"name":67,"nameZh":6,"description":68,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":6,"repositoryNo":12,"starsCount":13,"licenseSpdxId":14,"licenseFileUrl":6,"sourceHtmlUrl":69,"categories":70,"keywords":71,"publishedAt":18},"01M73D7K8778TGZV3GJFR3703D","yc-pitch-deck","Create a compelling startup pitch deck that follows the structure proven to raise billions from top investors. Master the YC and Sequoia formats that get founders funded. Use when: **Fundraising** to create investor pitch decks; **YC application** to structure your narrative; **Demo Day prep** to craft your 2-minute pitch; **Angel investors** to communicate your opportunity; **Partnership pitches** to structure compelling asks","https:\u002F\u002Fgithub.com\u002Froohe\u002Fagentic-super-skills\u002Fblob\u002Fmaster\u002Fskills_library\u002Fyc-pitch-deck\u002FSKILL.md",[],[],{"skillNo":73,"name":74,"nameZh":6,"description":75,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":6,"repositoryNo":12,"starsCount":13,"licenseSpdxId":14,"licenseFileUrl":6,"sourceHtmlUrl":76,"categories":77,"keywords":78,"publishedAt":18},"01M73D70KJSE0E8Z28YMNNRT04","x-twitter-scraper","Use when the user needs X (Twitter) data or confirmation-gated X actions through Xquik: tweet search, user lookup, follower extraction, media download, monitoring, webhooks, MCP, SDKs, posting, likes, DMs, and profile updates. Requires a Xquik API key. Never ask for X login material.","https:\u002F\u002Fgithub.com\u002Froohe\u002Fagentic-super-skills\u002Fblob\u002Fmaster\u002Fskills_library\u002Fx-twitter-scraper\u002FSKILL.md",[],[],{"skillNo":80,"name":81,"nameZh":6,"description":82,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":6,"repositoryNo":12,"starsCount":13,"licenseSpdxId":14,"licenseFileUrl":6,"sourceHtmlUrl":83,"categories":84,"keywords":85,"publishedAt":18},"01M73D6ED01GV077R7K4NZNFZJ","write-vignette","Create R package vignettes using R Markdown or Quarto. Covers vignette setup, YAML configuration, code chunk options, building and testing, and CRAN requirements for vignettes. Use when adding a Getting Started tutorial, documenting complex workflows spanning multiple functions, creating domain-specific guides, or when CRAN submission requires user-facing documentation beyond function help pages.","https:\u002F\u002Fgithub.com\u002Froohe\u002Fagentic-super-skills\u002Fblob\u002Fmaster\u002Fskills_library\u002Fwrite-vignette\u002FSKILL.md",[],[],{"skillNo":87,"name":88,"nameZh":6,"description":89,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":6,"repositoryNo":12,"starsCount":13,"licenseSpdxId":14,"licenseFileUrl":6,"sourceHtmlUrl":90,"categories":91,"keywords":92,"publishedAt":18},"01M73D69YJR0BK3NFHE0CYG3EF","write-validation-documentation","Write IQ\u002FOQ\u002FPQ validation documentation for computerized systems in regulated environments. Covers protocols, reports, test scripts, deviation handling, and approval workflows. Use when validating R or other software for regulated use, preparing for a regulatory audit, documenting qualification of computing environments, or creating and updating validation protocols and reports for new or re-qualified systems.","https:\u002F\u002Fgithub.com\u002Froohe\u002Fagentic-super-skills\u002Fblob\u002Fmaster\u002Fskills_library\u002Fwrite-validation-documentation\u002FSKILL.md",[],[]]