cleanup-lead-owners
About
This skill removes former employees from HubSpot and reassigns their orphaned CRM records to active owners. It identifies non-employee users and handles the redistribution of associated contacts, companies, and deals. Use it alongside the assign-unowned-contacts skill for complete ownership cleanup.
Quick Install
Claude Code
Recommendednpx skills add TomGranot/hubspot-admin-skills -a claude-code/plugin add https://github.com/TomGranot/hubspot-admin-skillsgit clone https://github.com/TomGranot/hubspot-admin-skills.git ~/.claude/skills/cleanup-lead-ownersCopy and paste this command in Claude Code to install this skill
Documentation
Cleanup Lead Owners
Remove departed employees from HubSpot and reassign their CRM records. Orphaned records with no active owner fall through the cracks.
Prerequisites
- HubSpot API token in
.env - Python with
hubspot-api-clientinstalled viauv - A list of current employees (to compare against HubSpot users)
- A default owner or round-robin assignment rule for orphaned records
Step-by-Step Instructions
Stage 1: Before — Identify Non-Employee Owners
from hubspot import HubSpot
api_client = HubSpot(access_token=os.getenv("HUBSPOT_API_TOKEN"))
# Get all owners including deactivated
active_owners = api_client.crm.owners.owners_api.get_page(limit=100)
deactivated_owners = api_client.crm.owners.owners_api.get_page(
limit=100, archived=True
)
Cross-reference with your current employee list. Flag:
- Deactivated HubSpot users who still own records
- Active HubSpot users who are no longer employees
- Contractors or vendors who should not own records
For each flagged owner, count how many contacts, companies, and deals they own.
Stage 2: Execute — Reassign and Deactivate
-
Reassign records owned by non-employees:
- Use the batch update API to reassign contacts to the appropriate active owner
- Apply round-robin or territory-based rules if no specific owner is obvious
- Reassign companies and deals associated with the same contacts
-
Deactivate users who are no longer employees (requires Super Admin in HubSpot Settings > Users & Teams).
-
Run
/assign-unowned-contactsafter reassignment to catch any records that ended up without an owner.
Stage 3: After — Verify
- Search for contacts where
hubspot_owner_idmatches any deactivated owner ID — count should be zero. - Confirm all reassigned contacts have an active owner.
- Check that no workflows broke due to owner changes (some workflows may filter by specific owners).
Stage 4: Rollback
- Owner reassignments can be reversed by batch-updating the
hubspot_owner_idback to the original value. - Keep a log of original owner assignments before making changes.
- Deactivated users can be reactivated in HubSpot Settings if needed.
Tips
- Run this whenever an employee leaves the company — do not wait for quarterly cleanup.
- Set up an offboarding checklist that includes HubSpot record reassignment.
- Pairs with
/assign-unowned-contactsfor comprehensive ownership hygiene.
GitHub Repository
Related Skills
content-collections
MetaThis skill provides a production-tested setup for Content Collections, a TypeScript-first tool that transforms Markdown/MDX files into type-safe data collections with Zod validation. Use it when building blogs, documentation sites, or content-heavy Vite + React applications to ensure type safety and automatic content validation. It covers everything from Vite plugin configuration and MDX compilation to deployment optimization and schema validation.
polymarket
MetaThis skill enables developers to build applications with the Polymarket prediction markets platform, including API integration for trading and market data. It also provides real-time data streaming via WebSocket to monitor live trades and market activity. Use it for implementing trading strategies or creating tools that process live market updates.
creating-opencode-plugins
MetaThis skill helps developers create OpenCode plugins that hook into 25+ event types like commands, files, and LSP operations. It provides the plugin structure, event API specifications, and implementation patterns for JavaScript/TypeScript modules. Use it when you need to intercept, monitor, or extend the OpenCode AI assistant's lifecycle with custom event-driven logic.
sglang
MetaSGLang is a high-performance LLM serving framework that specializes in fast, structured generation for JSON, regex, and agentic workflows using its RadixAttention prefix caching. It delivers significantly faster inference, especially for tasks with repeated prefixes, making it ideal for complex, structured outputs and multi-turn conversations. Choose SGLang over alternatives like vLLM when you need constrained decoding or are building applications with extensive prefix sharing.
