fix-lifecycle-stages
关于
This skill automatically fixes missing or incorrect lifecycle stages for contacts and companies via API backfilling and correction. It also creates prevention workflows to maintain data integrity for future records. Use it to ensure reliable pipeline reporting and proper segmentation in your CRM.
快速安装
Claude Code
推荐npx 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/fix-lifecycle-stages在 Claude Code 中复制并粘贴此命令以安装该技能
技能文档
Fix Lifecycle Stages
Ensure every contact and company has an appropriate lifecycle stage. This includes backfilling missing stages, correcting disallowed stage values, and creating prevention workflows that automatically assign stages to new records.
Why This Matters
Records without a lifecycle stage are invisible in pipeline reports, excluded from stage-based workflows, and cannot be properly segmented. Even a small percentage of missing lifecycle stages corrupts funnel reporting and makes pipeline analytics unreliable. Lifecycle stage data is also a prerequisite for lead scoring models and lifecycle progression workflows.
Prerequisites
- Phase 1 hygiene processes completed (invalid/deleted contacts removed first)
- Access to Contacts and Companies with bulk edit permissions
- Access to Automation > Workflows
- Understanding of HubSpot's lifecycle stage progression rules (see Critical Concept below)
Critical Concept: Forward-Only Lifecycle Progression
HubSpot has forward-only lifecycle progression by default. The built-in order is:
Subscriber > Lead > MQL > SQL > Opportunity > Customer > Evangelist
To move a record from a later stage (e.g., "Other", "Evangelist") to an earlier one (e.g., "Lead"), you must:
- FIRST clear the lifecycle stage (set to blank/empty)
- THEN set the new value
A direct set to an earlier stage will be silently rejected — no error, no warning, the value simply does not change. This is the single most common gotcha when fixing lifecycle stages.
# WRONG — silently fails if current stage is "later" than target
api_client.crm.contacts.basic_api.update(
contact_id=contact_id,
simple_public_object_input={"properties": {"lifecyclestage": "lead"}}
)
# CORRECT — clear first, then set
api_client.crm.contacts.basic_api.update(
contact_id=contact_id,
simple_public_object_input={"properties": {"lifecyclestage": ""}}
)
api_client.crm.contacts.basic_api.update(
contact_id=contact_id,
simple_public_object_input={"properties": {"lifecyclestage": "lead"}}
)
Plan
- Audit missing and disallowed lifecycle stages (before state)
- Define which stages are "disallowed" for your business and map them to correct stages
- Fix contacts with disallowed stages (clear + re-set)
- Set missing stages to appropriate defaults based on associated company context
- Create prevention workflows for contacts and companies
- Verify 100% coverage (after state)
Before State
Audit Script
import os
from hubspot import HubSpot
from dotenv import load_dotenv
load_dotenv()
api_client = HubSpot(access_token=os.getenv("HUBSPOT_API_TOKEN"))
# Count contacts with no lifecycle stage
result = api_client.crm.contacts.search_api.do_search(
public_object_search_request={
"filterGroups": [{
"filters": [{
"propertyName": "lifecyclestage",
"operator": "NOT_HAS_PROPERTY"
}]
}],
"limit": 0
}
)
print(f"Contacts missing lifecycle stage: {result.total}")
# Count contacts at each stage
stages = ["subscriber", "lead", "marketingqualifiedlead", "salesqualifiedlead",
"opportunity", "customer", "evangelist", "other"]
for stage in stages:
result = api_client.crm.contacts.search_api.do_search(
public_object_search_request={
"filterGroups": [{
"filters": [{
"propertyName": "lifecyclestage",
"operator": "EQ",
"value": stage
}]
}],
"limit": 0
}
)
if result.total > 0:
print(f" {stage}: {result.total}")
# Repeat for companies
result = api_client.crm.companies.search_api.do_search(
public_object_search_request={
"filterGroups": [{
"filters": [{
"propertyName": "lifecyclestage",
"operator": "NOT_HAS_PROPERTY"
}]
}],
"limit": 0
}
)
print(f"\nCompanies missing lifecycle stage: {result.total}")
Define Disallowed Stages
Decide which lifecycle stage values should not exist in your database. The table below shows common examples -- your disallowed stages and their correct mappings will depend on how your organization uses the CRM. Review your own stage distribution and decide what makes sense for your business:
| Example Disallowed Stage | Common Reason | Example Correct Stage |
|---|---|---|
| (empty/blank) | Invisible to reports | Lead (default) |
| Subscriber | Often misapplied when not used for newsletter-only contacts | Lead |
| Other | Meaningless catch-all | Lead |
| Evangelist | Rarely used correctly in most organizations | Customer (if actual customer) or Lead |
These are starting-point examples only. Your mapping will differ based on your sales process, integrations, and how stages are currently used. Define your specific mapping before executing.
Execute
Step 1: Fix Contacts at Disallowed Stages
For contacts at "Subscriber", "Other", or "Evangelist" that should be moved to "Lead":
# Pattern: Clear then set (required for backward movement)
DISALLOWED_TO_LEAD = ["subscriber", "other", "evangelist"]
for stage in DISALLOWED_TO_LEAD:
# Search for contacts at this stage
# Paginate through all results
# For each batch:
# 1. Clear lifecycle stage (set to "")
# 2. Set lifecycle stage to "lead"
# Use batch API for efficiency (100 per call)
pass
Important: The clear-then-set must happen as two separate API calls. You cannot clear and set in one call.
Step 2: Set Missing Contact Stages with Context
Do not set all missing contacts to "Lead" blindly. Check their associated company context:
- Contacts at Customer companies -> set to "Customer"
- Contacts at Opportunity companies -> set to "Opportunity"
- All remaining contacts -> set to "Lead"
# Pattern for context-aware assignment:
# 1. Search for contacts with no lifecycle stage
# 2. For each, get their primary associated company
# 3. Check the company's lifecycle stage
# 4. Set the contact's stage to match (or "lead" as default)
Manual approach via lists:
- Create a list: Lifecycle stage is unknown AND Associated company lifecycle stage is Customer -> bulk edit to "Customer"
- Create a list: Lifecycle stage is unknown AND Associated company lifecycle stage is Opportunity -> bulk edit to "Opportunity"
- Remaining contacts in the "no lifecycle stage" list -> bulk edit to "Lead"
Step 3: Fix Companies Without Lifecycle Stage
- Check companies with associated deals:
- Companies with closed-won deals -> set to "Customer"
- Companies with open deals -> set to "Opportunity"
- All remaining companies without a stage -> set to "Lead"
Step 4: Fix Stuck Records
Some records may fail to update due to the forward-only progression rule. Run a "fix stuck" script:
# Pattern: Find records that should be at a stage but are not
# For each:
# 1. Read current lifecycle stage
# 2. If current stage is "later" than target, clear first
# 3. Set the target stage
Step 5: Create Prevention Workflows
Contact prevention workflow:
- Go to Automation > Workflows > Create workflow
- Select Contact-based > Blank workflow
- Name:
AUTO-FIX: Set Default Lifecycle Stage (Lead) - Enrollment trigger: Contact property > Lifecycle stage > is unknown
- Enable re-enrollment
- Action: Set contact property > Lifecycle stage > Lead
- Activate and enroll existing contacts
Company prevention workflow:
- Create another workflow: Company-based > Blank workflow
- Name:
AUTO-FIX: Set Default Company Lifecycle Stage (Lead) - Enrollment trigger: Company property > Lifecycle stage > is unknown
- Enable re-enrollment
- Action: Set company property > Lifecycle stage > Lead
- Activate and enroll existing companies
Optional: Disallowed stage correction workflows:
If contacts keep getting set to disallowed stages (e.g., by imports or integrations):
- Create a workflow: Trigger = Lifecycle stage changed to "Subscriber" (or other disallowed value)
- Action 1: Clear lifecycle stage (set to blank)
- Action 2: Set lifecycle stage to "Lead"
This prevents disallowed stages from recurring.
After State
# Re-run the before-state audit
result = api_client.crm.contacts.search_api.do_search(
public_object_search_request={
"filterGroups": [{
"filters": [{
"propertyName": "lifecyclestage",
"operator": "NOT_HAS_PROPERTY"
}]
}],
"limit": 0
}
)
print(f"Contacts missing lifecycle stage: {result.total} (should be 0)")
result = api_client.crm.companies.search_api.do_search(
public_object_search_request={
"filterGroups": [{
"filters": [{
"propertyName": "lifecyclestage",
"operator": "NOT_HAS_PROPERTY"
}]
}],
"limit": 0
}
)
print(f"Companies missing lifecycle stage: {result.total} (should be 0)")
Verification checklist:
- 0 contacts with missing lifecycle stage
- 0 companies with missing lifecycle stage
- 0 contacts at disallowed stages (Subscriber, Other, Evangelist, or whatever you defined)
- Spot-check contacts from Customer sub-list -> their lifecycle stage is "Customer"
- Spot-check contacts from Opportunity sub-list -> their lifecycle stage is "Opportunity"
- Test the prevention workflow: create a test contact with no lifecycle stage, wait a few minutes, confirm it gets set to "Lead". Delete the test contact.
- Funnel reports now show all records with no "unknown" bucket
Key Technical Learnings
- Forward-only progression is the biggest gotcha. Direct API updates to an "earlier" stage are silently rejected. You MUST clear first, then set. This applies to both API and workflow actions.
- "Lead" is the safest default. It is early in the progression and will not block forward movement from workflows or deal progression. "Subscriber" is NOT a good default unless you know the contacts subscribed to a newsletter.
- Context-aware assignment matters. Setting a contact at a Customer company to "Lead" instead of "Customer" degrades data quality. Take the time to check associated company context.
- Prevention is more important than cleanup. The prevention workflows ensure the problem never recurs. Without them, new records from imports, integrations, or manual entry will immediately re-create the gap.
- Lifecycle stage and deals interact. HubSpot can automatically advance lifecycle stage when deals are created or won. Your prevention workflows will not interfere because they only trigger when lifecycle stage is unknown.
- Batch edit limitations. The UI may time out on very large bulk edits. Process one page at a time, or use the API approach for large volumes.
- The sub-list approach is important. Do not skip context-aware assignment and set everyone to "Lead". Contacts associated with Customer or Opportunity companies deserve the correct stage.
GitHub 仓库
相关推荐技能
content-collections
元Content Collections 是一个 TypeScript 优先的构建工具,可将本地 Markdown/MDX 文件转换为类型安全的数据集合。它专为构建博客、文档站和内容密集型 Vite+React 应用而设计,提供基于 Zod 的自动模式验证。该工具涵盖从 Vite 插件配置、MDX 编译到生产环境部署的完整工作流。
polymarket
元这个Claude Skill为开发者提供完整的Polymarket预测市场开发支持,涵盖API调用、交易执行和市场数据分析。关键特性包括实时WebSocket数据流,可监控实时交易、订单和市场动态。开发者可用它构建预测市场应用、实施交易策略并集成实时市场预测功能。
creating-opencode-plugins
元该Skill帮助开发者创建OpenCode插件,用于接入命令、文件、LSP等25+种事件。它提供了插件结构、事件API规范和JavaScript/TypeScript实现模式,适合需要拦截操作、扩展功能或自定义事件处理的场景。开发者可通过它快速构建响应式模块来增强OpenCode AI助手的能力。
sglang
元SGLang是一个专为LLM设计的高性能推理框架,特别适用于需要结构化输出的场景。它通过RadixAttention前缀缓存技术,在处理JSON、正则表达式、工具调用等具有重复前缀的复杂工作流时,能实现极速生成。如果你正在构建智能体或多轮对话系统,并追求远超vLLM的推理性能,SGLang是理想选择。
