new-contact-hygiene-workflow — скилл для Claude Code
Создаёт в HubSpot воркфлоу, который при появлении контакта ставит стадию жизненного цикла и подтягивает компанию с отраслью.
npx skills add TomGranot/hubspot-admin-skills --skill new-contact-hygiene-workflow -a claude-codeЧто делает new-contact-hygiene-workflow
Скилл собирает воркфлоу «HYGIENE: Default Lifecycle Stage for New Contacts»: триггер — известная дата создания контакта, действие — выставить стадию «Lead», повторное зачисление включено. Скрипты scripts/before.py, scripts/execute.py и scripts/after.py запускаются через uv run. Воркфлоу создаётся выключенным, чтобы вы сначала посмотрели его в интерфейсе.
Создание идёт через v4 Automation API, а он помечен как beta. Скрипты обращаются к пути /automation/v4/flows без версии. Действия «копировать из связанного объекта» и ветку с уведомлением администратора в API не описать: их добавляют руками в UI. Если создание через скрипт начнёт падать, остаётся ручная сборка в интерфейсе — она описана в скилле целиком.
Понадобится тариф HubSpot Marketing Professional или Enterprise, сервисный ключ с областью automation в .env как HUBSPOT_ACCESS_TOKEN и Python 3.10+ с uv. Копирование названия компании и отрасли имеет смысл только после того, как для существующих контактов уже отработали /enrich-company-name и /enrich-industry.
Какие задачи решает
- создать воркфлоу для новых контактов через API, а не мышкой
- проставить стадию жизненного цикла до того, как контакт тронет человек
- подтянуть название компании и отрасль из связанной компании
- проверить коллизии имён воркфлоу перед созданием
- оставить ветку с уведомлением админа, когда компания так и не привязалась
Примеры запросов агенту
- Запусти
uv run scripts/before.pyи покажи, какие воркфлоу уже есть в портале - Создай воркфлоу для новых контактов через
uv run scripts/execute.pyи оставь его выключенным - Добавь в воркфлоу копирование названия компании из связанной компании
Как установить new-contact-hygiene-workflow
1Через Skills CLI (Vercel)
npx skills add TomGranot/hubspot-admin-skills --skill new-contact-hygiene-workflow -a claude-code2Вручную: положить файлы
~/.claude/skills/new-contact-hygiene-workflow/SKILL.mdПапка скилла целиком; для одного проекта — .claude/skills/new-contact-hygiene-workflow/
1Через Skills CLI (Vercel)
npx skills add TomGranot/hubspot-admin-skills --skill new-contact-hygiene-workflow -a codex2Вручную: положить файлы
.agents/skills/new-contact-hygiene-workflow/SKILL.mdДля всех проектов — ~/.agents/skills/
1Через Skills CLI (Vercel)
npx skills add TomGranot/hubspot-admin-skills --skill new-contact-hygiene-workflow -a cursor2Вручную: положить файлы
.cursor/skills/new-contact-hygiene-workflow/SKILL.mdCursor читает и .agents/skills/, и .claude/skills/
1GitHub CLI
gh skill install TomGranot/hubspot-admin-skills new-contact-hygiene-workflow2Вручную: положить файлы
.github/skills/new-contact-hygiene-workflow/SKILL.md1Через Skills CLI (Vercel)
npx skills add TomGranot/hubspot-admin-skills --skill new-contact-hygiene-workflow -a gemini-cli2Командой платформы
gemini skills install https://github.com/TomGranot/hubspot-admin-skills --path skills/new-contact-hygiene-workflowВручную: положить файлы
.devin/skills/new-contact-hygiene-workflow/SKILL.mdСтарый путь .windsurf/skills/ тоже читается
Через Skills CLI (Vercel)
npx skills add TomGranot/hubspot-admin-skills --skill new-contact-hygiene-workflow -a opencodeClaude.ai
Упакуйте папку в zip и загрузите в Settings → Capabilities → Skills
По шагам, с командами для каждой платформы: Как установить скилл в Claude Code: пять способов
Вопросы о new-contact-hygiene-workflow
Как установить new-contact-hygiene-workflow в Claude Code?
Выполните npx skills add TomGranot/hubspot-admin-skills --skill new-contact-hygiene-workflow -a claude-code. Файл скилла появится по пути ~/.claude/skills/new-contact-hygiene-workflow/SKILL.md.
Что делает new-contact-hygiene-workflow?
Создаёт в HubSpot воркфлоу, который зачисляет каждый новый контакт, выставляет стадию «Lead» и служит заготовкой для копирования данных компании. Копирование из связанного объекта и уведомление администратора добавляются в интерфейсе.
Что нужно для работы скилла?
Тариф HubSpot Marketing Professional или Enterprise, сервисный ключ с областью automation в .env и Python 3.10+ с uv. Создание воркфлоу идёт через beta-версию v4 Automation API, поэтому результат сначала проверяют в UI.
Исходный текст
SKILL.md · MIT
---
name: new-contact-hygiene-workflow
description: "Build a HubSpot workflow that auto-enriches and stages new contacts upon creation. Sets lifecycle stage via the v4 Automation API, copies company name and industry from the associated company (UI step), and branches on completeness."
license: MIT
metadata:
author: tomgranot
version: "1.1"
category: automation-workflows
---
# New Contact Hygiene Workflow
Build a workflow that automatically enriches every new contact at creation time. This ensures contacts enter the database with a lifecycle stage, company name, and industry before any human touches them.
## What Is and Isn't Scriptable
**API status:** HubSpot documents the Workflows API as **beta** and subject to change. Its current reference is the date-based beta path `/automation/v4/2027-03-beta/flows`; this skill's scripts still call the unversioned `/automation/v4/flows` path, which v4's end of support on March 30, 2027 also covers. Creating workflows disabled and reviewing them in the UI is what makes a beta API acceptable here. If a script's create call starts failing, the manual UI build below is the fallback.
The v4 Automation API creates workflows programmatically, including "is unknown" enrollment conditions via `LIST_BASED` filter criteria. Two pieces of this particular design still belong in the UI:
1. **Copy from associated object** actions (copy company name/industry from the associated company) have no documented v4 action fields. Add them in the UI during review — or build the action once in the UI, `GET /automation/v4/flows/{flowId}`, and extend the script with the exact field shapes your portal returns.
2. **The notification branch** (alert admin when a contact still has no company after the delay) depends on portal-specific recipients.
So the split is: the script creates the default-lifecycle-stage workflow via API; the enrichment copy actions and the notification branch are added in the UI. If you already run `/enrich-company-name` and `/enrich-industry`, their dedicated workflows cover the copy actions and this skill's API-created workflow completes the intake picture.
## Prerequisites
- HubSpot Marketing Professional or Enterprise plan
- A HubSpot service key (`HUBSPOT_ACCESS_TOKEN` in `.env`; an existing legacy private app token also works) with the `automation` scope (for the API path)
- Python 3.10+ with [`uv`](https://github.com/astral-sh/uv)
- Workflow creation permissions in HubSpot
- Company association enrichment completed (run `/enrich-company-name` and `/enrich-industry` first for existing contacts)
## 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/new-contact-hygiene-workflow/` in a clone of the repo).
| Stage | Script | Run with |
|-------|--------|----------|
| Before | [`scripts/before.py`](./scripts/before.py) | `uv run scripts/before.py` |
| Execute | [`scripts/execute.py`](./scripts/execute.py) | `uv run scripts/execute.py` |
| After | [`scripts/after.py`](./scripts/after.py) | `uv run scripts/after.py` |
`execute.py` creates one workflow — "HYGIENE: Default Lifecycle Stage for New Contacts" (enrollment: create date known AND lifecycle stage unknown; action: set stage to Lead; re-enrollment on) — **disabled, for review before enabling**. Extend it in the UI with the copy actions and notification branch per the design below.
## Building the Workflow: Two Options
**Option A (primary):** run the scripts, then extend the created workflow in the UI with the copy-from-associated-company actions, the delay, and the no-company notification branch (Stage 3, steps 3-6).
**Option B:** build the whole workflow manually in the UI (all of Stage 3).
**Alternatives:** HubSpot Breeze AI provides minimal value for this workflow — it creates event-based (OR) triggers, and cannot create "is unknown" conditions, copy-from-association actions, or re-enrollment rules. The Claude Chrome extension can drive the workflow builder UI directly and handles those cases. Both are secondary options.
## Workflow Design
```
TRIGGER: Contact create date is known
(fires for every new contact)
│
▼
┌─────────────────────────┐
│ Set lifecycle stage │
│ = "Lead" (if empty) │
└────────────┬────────────┘
│
▼
┌─────────────────────────┐
│ Copy company name from │
│ associated company │
└────────────┬────────────┘
│
▼
┌─────────────────────────┐
│ Copy industry from │
│ associated company │
└────────────┬────────────┘
│
▼
┌─────────────────────────┐
│ Delay: short wait │
│ (3-10 min, rec: 5) │
└────────────┬────────────┘
│
▼
┌─────────────────────────┐
│ IF/THEN BRANCH: │
│ Company name is unknown? │
├──────────┬──────────────┘
│ YES │ NO
│ │
▼ ▼
Retry Continue
copy (enriched)
+ notify
admin
```
## Step-by-Step Build Instructions
### Stage 1: Plan
1. Confirm the default stage for new contacts (Lead, unless your funnel differs).
2. Decide who receives the "no company association" notification.
### Stage 2: Before
1. Confirm company enrichment processes have run for existing data.
2. Run `uv run scripts/before.py` to inventory workflows and check name collisions.
### Stage 3: Execute
**Option A:** run `uv run scripts/execute.py`, then open the created workflow in the UI and continue from step 3 below (copy actions, delay, branch). **Option B:** open HubSpot > Automation > Workflows > Create workflow, select "Contact-based", start from scratch, and follow all steps.
1. **Set enrollment trigger:**
- Property: "Create date" > "is known"
- This enrolls every new contact automatically.
2. **Add action: Set property value**
- Property: "Lifecycle stage"
- Value: "Lead"
- Condition: Only if lifecycle stage is unknown (use an if/then branch before this step, or rely on HubSpot's "only if empty" option if available in your plan).
3. **Add action: Copy property**
- Source: Associated company > "Company name"
- Target: Contact > "Company" property
4. **Add action: Copy property**
- Source: Associated company > "Industry"
- Target: Contact > "Industry" property
5. **Add delay: a short delay (3-10 minutes, recommended: 5)**
- Purpose: Allow time for company associations to sync (especially for form submissions or integrations that create contacts before associating them). Adjust the duration based on how quickly your integrations typically create associations.
6. **Add if/then branch:**
- Condition: Contact "Company" property is unknown
- YES branch: Add internal notification to CRM admin — "New contact {firstname} {lastname} ({email}) has no company association after enrichment attempt."
- NO branch: No further action needed (contact is enriched).
7. **Review settings:**
- Re-enrollment: OFF (each contact should only go through this once)
- Unenrollment: None needed
- Time zone: Not applicable (no time-based actions beyond delay)
8. **Turn on the workflow.**
### Stage 4: After
0. Run `uv run scripts/after.py` (API path) to confirm the workflow exists and report enabled state.
1. Create a test contact manually. Confirm:
- Lifecycle stage is set to "Lead"
- Company name copied from associated company
- Industry copied from associated company
2. Create a test contact with no company association. Confirm:
- Admin notification fires after the configured delay
3. Check workflow history for any errors in the first 24 hours.
## Rollback
1. Turn off the workflow in HubSpot > Automation > Workflows.
2. Contacts already enriched retain their values — no destructive changes to undo.
3. If lifecycle stages were set incorrectly, use the Search API to find contacts created after the workflow activation date and reset as needed.
## Edge Cases
- **Contacts created via import:** These fire the trigger. If imports include company name/industry, the copy action will overwrite with the associated company's values. Consider excluding imported contacts via a list filter.
- **Contacts without company associations:** The copy action silently fails. The branch handles notification.
- **Multiple associated companies:** HubSpot copies from the primary associated company only.
© tomgranot · MIT · TomGranot/hubspot-admin-skills