Fix Lifecycle Stages logo

Fix Lifecycle Stages

Community
TomGranot
fix-lifecycle-stages

Ensure all contacts and companies have appropriate lifecycle stages. Backfills missing stages via API, fixes records stuck at disallowed stages, and creates prevention workflows to stop future gaps.

Overview

PublisherTomGranot
Repositoryhubspot-admin-skills
Skill namefix-lifecycle-stages
Stars
79
Forks
18
Bundled files
3
LicenseMIT
Links
  • Markdown instructions

    A SKILL.md file the model loads on demand, so it only costs tokens when a request actually matches.

  • Works with any LLM

    AI skills are plain Markdown, not provider-specific code, so this works with GPT, Claude, Gemini, Grok, or a local model.

  • 3 bundled files

    Scripts, templates, and references the model can read while it works. Files are read-only and never executed.

  • Open source

    Published by TomGranot on GitHub. Read the source before you install it.

Installation

Install the Fix Lifecycle Stages AI skill in TypingMind to use it with any LLM, or drop it into another agent that reads SKILL.md.

1

Install in TypingMind

TypingMind installs a skill straight from its GitHub folder — it reads SKILL.md, bundles the resource files, and stores the result locally.

  1. Open the app and go to Plugins → Skills.
  2. Choose "Install from GitHub".
  3. Paste the skill folder URL below and confirm.
    https://github.com/TomGranot/hubspot-admin-skills/tree/main/skills/fix-lifecycle-stages
  4. Enable the skill in any chat where you want it available.
Plugins → Skills → Add skill → From GitHub URL, then paste the folder URL and press Continue.
2

Install in another agent

Any agent that reads the Agent Skills format can use this skill — copy the folder into that agent's skills directory.

Claude Code — .claude/skills
git clone --depth 1 https://github.com/TomGranot/hubspot-admin-skills.git /tmp/hubspot-admin-skills
mkdir -p .claude/skills
cp -r /tmp/hubspot-admin-skills/skills/fix-lifecycle-stages .claude/skills/fix-lifecycle-stages
Restart Claude Code after copying so it picks up the new skill.

Use it in TypingMind

Enable Fix Lifecycle Stages in any TypingMind chat and the model takes it from there. Its name and description sit in the system prompt, and the moment a request matches, the model loads the full instructions itself — you never invoke it by hand, and it costs no tokens until it is actually used.

The model loads Fix Lifecycle Stages on its own as soon as a request matches it.

Works with any AI model

AI skills are plain Markdown instructions rather than provider-specific code, so Fix Lifecycle Stages is not tied to the model it was written for. Install it once in TypingMind and use it with GPT-5, Claude, Gemini, Grok, DeepSeek, Mistral, Llama, or a local model you run yourself — all on your own API keys.

  • Loaded only when it is needed

    The system prompt carries just the name and description. The instructions are fetched on the first matching request, so an idle skill costs nothing.

  • Switch models mid-chat

    Because the skill is instructions rather than code, changing model does not break it — the next model reads the same SKILL.md.

Skill instructions

This is the SKILL.md content the model loads. Read it before installing — a skill is instructions your model will follow.

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)
  • A HubSpot service key (HUBSPOT_ACCESS_TOKEN in .env; an existing legacy private app token also works) with contact and company read/write scopes
  • Python 3.10+ with uv
  • 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)

Scripts

Script paths are relative to this skill's directory. Run them from your project directory so .env, data/, and reports/ resolve there: prefix each path with wherever this skill is installed (skills/fix-lifecycle-stages/ in a clone of the repo).

StageScriptRun with
Beforescripts/before.pyuv run scripts/before.py
Executescripts/execute.pyuv run scripts/execute.py
Afterscripts/after.pyuv run scripts/after.py

before.py audits missing and per-stage counts for contacts and companies. execute.py performs the clear-then-set fixes (review its configuration block for the disallowed-stage mapping before running). after.py verifies coverage.

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:

  1. FIRST clear the lifecycle stage (set to blank/empty)
  2. 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.

python
url = f"{BASE}/crm/v3/objects/contacts/{contact_id}"

# WRONG — silently fails if current stage is "later" than target
requests.patch(url, headers=HEADERS,
               json={"properties": {"lifecyclestage": "lead"}})

# CORRECT — clear first, then set (two separate calls)
requests.patch(url, headers=HEADERS,
               json={"properties": {"lifecyclestage": ""}})
requests.patch(url, headers=HEADERS,
               json={"properties": {"lifecyclestage": "lead"}})

Plan

  1. Audit missing and disallowed lifecycle stages (before state)
  2. Define which stages are "disallowed" for your business and map them to correct stages
  3. Fix contacts with disallowed stages (clear + re-set)
  4. Set missing stages to appropriate defaults based on associated company context
  5. Create prevention workflows for contacts and companies
  6. Verify 100% coverage (after state)

Before

Audit Script

Run uv run scripts/before.py. The core queries it runs:

python
def count(object_type, filters):
    resp = requests.post(f"{BASE}/crm/v3/objects/{object_type}/search",
                         headers=HEADERS,
                         json={"filterGroups": [{"filters": filters}], "limit": 1})
    resp.raise_for_status()
    return resp.json()["total"]

missing = count("contacts", [
    {"propertyName": "lifecyclestage", "operator": "NOT_HAS_PROPERTY"}])
print(f"Contacts missing lifecycle stage: {missing}")

stages = ["subscriber", "lead", "marketingqualifiedlead", "salesqualifiedlead",
          "opportunity", "customer", "evangelist", "other"]
for stage in stages:
    n = count("contacts", [
        {"propertyName": "lifecyclestage", "operator": "EQ", "value": stage}])
    if n:
        print(f"  {stage}: {n}")

print(f"Companies missing lifecycle stage: "
      f"{count('companies', [{'propertyName': 'lifecyclestage', 'operator': 'NOT_HAS_PROPERTY'}])}")

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":

python
# 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:

  1. Contacts at Customer companies -> set to "Customer"
  2. Contacts at Opportunity companies -> set to "Opportunity"
  3. All remaining contacts -> set to "Lead"
python
# 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:

  1. Create a list: Lifecycle stage is unknown AND Associated company lifecycle stage is Customer -> bulk edit to "Customer"
  2. Create a list: Lifecycle stage is unknown AND Associated company lifecycle stage is Opportunity -> bulk edit to "Opportunity"
  3. Remaining contacts in the "no lifecycle stage" list -> bulk edit to "Lead"

Step 3: Fix Companies Without Lifecycle Stage

  1. Check companies with associated deals:
    • Companies with closed-won deals -> set to "Customer"
    • Companies with open deals -> set to "Opportunity"
  2. 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:

python
# 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:

  1. Go to Automation > Workflows > Create workflow
  2. Select Contact-based > Blank workflow
  3. Name: AUTO-FIX: Set Default Lifecycle Stage (Lead)
  4. Enrollment trigger: Contact property > Lifecycle stage > is unknown
  5. Enable re-enrollment
  6. Action: Set contact property > Lifecycle stage > Lead
  7. Activate and enroll existing contacts

Company prevention workflow:

  1. Create another workflow: Company-based > Blank workflow
  2. Name: AUTO-FIX: Set Default Company Lifecycle Stage (Lead)
  3. Enrollment trigger: Company property > Lifecycle stage > is unknown
  4. Enable re-enrollment
  5. Action: Set company property > Lifecycle stage > Lead
  6. Activate and enroll existing companies

Optional: Disallowed stage correction workflows:

If contacts keep getting set to disallowed stages (e.g., by imports or integrations):

  1. Create a workflow: Trigger = Lifecycle stage changed to "Subscriber" (or other disallowed value)
  2. Action 1: Clear lifecycle stage (set to blank)
  3. Action 2: Set lifecycle stage to "Lead"

This prevents disallowed stages from recurring.

After

Re-run the audit: uv run scripts/after.py. Both missing-stage counts (contacts and companies) should be 0.

Verification checklist:

  1. 0 contacts with missing lifecycle stage
  2. 0 companies with missing lifecycle stage
  3. 0 contacts at disallowed stages (Subscriber, Other, Evangelist, or whatever you defined)
  4. Spot-check contacts from Customer sub-list -> their lifecycle stage is "Customer"
  5. Spot-check contacts from Opportunity sub-list -> their lifecycle stage is "Opportunity"
  6. 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.
  7. Funnel reports now show all records with no "unknown" bucket

Rollback

  • The execute script's CSV audit trail records every record it changed with the original stage value. To undo, batch-update those IDs back to their previous stage (remember: moving backward requires the same clear-then-set pattern).
  • Turn off the prevention workflows to stop automatic stage assignment.

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.

Bundled files

The model reads these on demand while the skill is loaded. They are exposed as readable files and are never executed.

Frequently asked questions

What does the Fix Lifecycle Stages AI skill do?

Ensure all contacts and companies have appropriate lifecycle stages. Backfills missing stages via API, fixes records stuck at disallowed stages, and creates prevention workflows to stop future gaps.

Why use Fix Lifecycle Stages on TypingMind?

Because you install it once and use it with any model. Fix Lifecycle Stages is plain Markdown rather than provider-specific code, so the same skill runs on GPT-5, Claude, Gemini, Grok, or a local model — and you can switch model mid-chat without it breaking. TypingMind runs on your own API keys, so you pay providers directly instead of a per-seat subscription, and your skills and chats stay in your own storage.

How do I install Fix Lifecycle Stages in TypingMind?

Open Plugins → Skills → Install from GitHub in TypingMind and paste https://github.com/TomGranot/hubspot-admin-skills/tree/main/skills/fix-lifecycle-stages. TypingMind reads its SKILL.md and bundles its files and installs it as a skill you can enable per chat.

Which AI models can use Fix Lifecycle Stages?

Any model you connect in TypingMind. AI skills are plain Markdown instructions rather than provider-specific code, so GPT, Claude, Gemini, Grok, and local models can all load this skill when a request matches it.

How many AI models can I use with Fix Lifecycle Stages?

As many as you like. As long as a model supports skills, you can use Fix Lifecycle Stages with it — GPT, Claude, Gemini, Grok, DeepSeek, Mistral, Llama and more — all on TypingMind with your own API keys.

Is the Fix Lifecycle Stages AI skill free?

Yes. It is published on GitHub by TomGranot under the MIT license. You only pay your own AI provider for the tokens you use.

What are AI skills?

An AI skill is a reusable instruction bundle that teaches an AI model how to do one specific task. It follows the open Agent Skills format: a SKILL.md file with a name and description, plus any scripts, templates or reference files the model may need. The model reads the instructions only when your request matches the skill, so an installed skill costs nothing until it is used.

How are AI skills different from plugins or MCP servers?

A plugin or MCP server gives a model new tools to call — code that runs somewhere and returns a result. An AI skill gives the model knowledge and process instead: how to approach a task, which steps to follow, what good output looks like. Skills are plain Markdown, so they need no server, no API key and no runtime, and they work with any model.

View all

Set up your own AI workspace now

Get notified about new features and future giveaways by subscribing to our newsletter 👇