📦 Fix Lifecycle Stages — 技能工具

v1.0.0

Ensure all contacts and companies have appropriate lifecycle stages. Backfills missing stages via API, fixes records stuck at disallowed stages, and creates...

0· 68·0 当前·0 累计
tomgranot 头像by @tomgranot (TomGranot)·MIT-0
下载技能包
License
MIT-0
最后更新
2026/3/27
0
安全扫描
VirusTotal
无害
查看报告
OpenClaw
可疑
high confidence
The skill's code and runtime instructions mostly match the HubSpot lifecycle-fixing purpose, but there are clear inconsistencies around required environment variables and packaging (env var name mismatch and code files present with no install spec), so you should review before installing or running it.
评估建议
This skill appears to actually do what its description says (audit and fix HubSpot lifecycle stages), but there are important inconsistencies you should address before using it: - Environment variable mismatch: the repository scripts expect a HUBSPOT_ACCESS_TOKEN (scripts) while SKILL.md examples reference HUBSPOT_API_TOKEN; the registry lists no required env vars. Confirm which env var the runtime will provide and update the skill or your environment accordingly. - Token scope and placement: t...
详细分析 ▾
用途与能力
The name/description and the scripts all target HubSpot lifecycle-stage fixes — that is coherent. However, the registry metadata declared no required environment variables or primary credential, while every script expects a HubSpot API token. This mismatch is unexpected and should be resolved (the skill cannot operate without the token).
指令范围
SKILL.md and the three scripts restrict actions to HubSpot's CRM API (search, batch update) and local CSV outputs. They read a .env file and an environment variable for the API token and write CSV audit files in the scripts directory. They do not call unknown third-party endpoints or attempt to read unrelated system files, but they do explicitly load a parent .env file which may contain other secrets — verify what will be present in that .env before running.
安装机制
There is no install spec even though the package includes three Python scripts with dependency comments. That means the skill is instruction-only but ships runnable code; there's no automatic installation of dependencies. This is a packaging inconsistency you should be aware of (you'll need to install Python and the dependencies yourself before running).
凭证需求
The scripts require a HubSpot token, but the registry lists no required env vars. Additionally, SKILL.md example code uses HUBSPOT_API_TOKEN while scripts use HUBSPOT_ACCESS_TOKEN — the env var name mismatch is a concrete inconsistency that could lead to misconfiguration or accidental token leakage. Aside from HubSpot, no other credentials are requested, and the token requirement is proportionate to the task if the token's scope is properly limited.
持久化与权限
The skill does not request elevated platform privileges, does not set always:true, and does not modify other skills or global agent settings. It runs as an on-demand script and writes only local CSV audit files.
安全有层次,运行前请审查代码。

License

MIT-0

可自由使用、修改和再分发,无需署名。

运行时依赖

无特殊依赖

版本

latestv1.0.02026/3/27

- Initial release of fix-lifecycle-stages skill. - Audits and backfills missing lifecycle stage data for contacts and companies. - Fixes records stuck at disallowed or backwards stages using correct HubSpot progression logic. - Provides API scripts and manual list-based methods for context-aware stage assignment. - Includes guidance for creating prevention workflows to stop future lifecycle stage gaps.

无害

安装命令

点击复制
官方npx clawhub@latest install fix-lifecycle-stages
镜像加速npx clawhub@latest install fix-lifecycle-stages --registry https://cn.longxiaskill.com

技能文档

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 StageCommon ReasonExample Correct Stage
(empty/blank)Invisible to reportsLead (default)
SubscriberOften misapplied when not used for newsletter-only contactsLead
OtherMeaningless catch-allLead
EvangelistRarely used correctly in most organizationsCustomer (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.
数据来源ClawHub ↗ · 中文优化:龙虾技能库