customer-retention — скилл для Claude Code: поиск оттока и задачи
Находит клиентов без контакта и с риском оттока через фильтры CRM HubSpot, затем создаёт задачи на дозвон пачкой.
npx skills add HubSpot/agent-cli-skills --skill customer-retention -a claude-codeЧто делает customer-retention
Скилл работает поверх bulk-operations: оттуда берутся JSONL-конвейер, пагинация и режим --dry-run. Сначала он ищет неактивных — например, контакты со стадией customer, у которых notes_last_contacted старше 60 дней, или те, кого вообще ни разу не касались. Отдельно проверяются подписки со статусом past_due и связи подписки с контактом.
Дальше на когорту создаются задачи. Поиск пишется в файл, jq собирает по одной задаче на контакт, hubspot objects create создаёт их одним вызовом, а hubspot associations create связывает задачи с контактами — до 100 пар за вызов API. Задача без связи не видна в интерфейсе CRM, поэтому связывание обязательно.
Схема портала у каждого своя: перед фильтрацией проверяйте свойства через hubspot properties get. Если subscriptions отдаёт 403, у токена нет области subscriptions-read — нужен токен приватного приложения с этой областью. Готового свойства со скором оттока нет, придётся завести своё.
Какие задачи решает
- найти клиентов, с которыми не связывались 60 дней
- выгрузить контакты, которых не касались ни разу
- отметить подписки с просроченным платежом
- создать задачи на дозвон целой когорте за один проход
- связать новые задачи с контактами, чтобы они были видны в CRM
Примеры запросов агенту
- найди клиентов без контакта больше 60 дней и создай задачи на звонок
- покажи подписки со статусом past_due и их контакты
- собери когорту неактивных клиентов и поставь задачи с приоритетом HIGH
Как установить customer-retention
1Через Skills CLI (Vercel)
npx skills add HubSpot/agent-cli-skills --skill customer-retention -a claude-code2Вручную: положить файлы
~/.claude/skills/customer-retention/SKILL.mdПапка скилла целиком; для одного проекта — .claude/skills/customer-retention/
1Через Skills CLI (Vercel)
npx skills add HubSpot/agent-cli-skills --skill customer-retention -a codex2Вручную: положить файлы
.agents/skills/customer-retention/SKILL.mdДля всех проектов — ~/.agents/skills/
1Через Skills CLI (Vercel)
npx skills add HubSpot/agent-cli-skills --skill customer-retention -a cursor2Вручную: положить файлы
.cursor/skills/customer-retention/SKILL.mdCursor читает и .agents/skills/, и .claude/skills/
1GitHub CLI
gh skill install HubSpot/agent-cli-skills customer-retention2Вручную: положить файлы
.github/skills/customer-retention/SKILL.md1Через Skills CLI (Vercel)
npx skills add HubSpot/agent-cli-skills --skill customer-retention -a gemini-cli2Командой платформы
gemini skills install https://github.com/HubSpot/agent-cli-skills --path customer-retentionВручную: положить файлы
.devin/skills/customer-retention/SKILL.mdСтарый путь .windsurf/skills/ тоже читается
Через Skills CLI (Vercel)
npx skills add HubSpot/agent-cli-skills --skill customer-retention -a opencodeClaude.ai
Упакуйте папку в zip и загрузите в Settings → Capabilities → Skills
По шагам, с командами для каждой платформы: Как установить скилл в Claude Code: пять способов
Вопросы о customer-retention
Как установить customer-retention в Claude?
Выполните npx skills add HubSpot/agent-cli-skills --skill customer-retention -a claude-code. Скилл появится в ~/.claude/skills/customer-retention/SKILL.md.
Что делает customer-retention?
Ищет неактивных и рискующих уйти клиентов по фильтрам HubSpot CRM и создаёт задачи на повторный контакт — по одной или сразу на всю когорту.
Что нужно для работы скилла?
Сначала прочитайте bulk-operations/SKILL.md: на его конвейере и пагинации держатся все чтения и записи. Для проверки подписок нужен токен с областью subscriptions-read.
Исходный текст
SKILL.md · Apache-2.0
---
name: customer-retention
description: Identify inactive/at-risk customers via CRM filters and create follow-up tasks at scale. Builds on `bulk-operations`; defers activity-creation specifics to `sales-execution`.
triggers:
- "customer retention"
- "churn risk"
- "inactive customers"
- "customer follow-up"
- "at-risk accounts"
- "customers not contacted"
- "renewal"
- "account health"
---
## Resources
| File | When to use |
|---|---|
| `resources/customer-health-signals.md` | Filter cookbook of churn signals — `--filter` expressions for `notes_last_contacted`, `hs_last_sales_activity_date`, `hs_email_optout`, stale tickets, subscription status. |
## Prereqs
Read `bulk-operations/SKILL.md` first — every read/write below uses its JSONL pipe, pagination, and dry-run/digest patterns. Activity-property tables and association rules live in `sales-execution/SKILL.md`.
Schema is portal-specific. Verify each property before filtering — e.g. `hubspot properties get --type contacts notes_last_contacted`, `... hs_last_sales_activity_date`, `... --type subscriptions hs_subscription_status`. If `subscriptions` returns 403, your token lacks `subscriptions-read` — use a private-app token with that scope.
## 1 — Find inactive customers
```bash
CUTOFF=$(date -v-60d +%Y-%m-%d 2>/dev/null || date -d '60 days ago' +%Y-%m-%d)
# No outreach in 60d (calls/notes/meetings update notes_last_contacted)
hubspot objects search --type contacts \
--filter "lifecyclestage=customer AND notes_last_contacted<$CUTOFF" \
--properties email,firstname,notes_last_contacted,hubspot_owner_id
# No sales activity in 60d (broader — also catches emails/tasks)
hubspot objects search --type contacts \
--filter "lifecyclestage=customer AND hs_last_sales_activity_date<$CUTOFF" \
--properties email,firstname,hs_last_sales_activity_date
# Never contacted
hubspot objects search --type contacts \
--filter "lifecyclestage=customer AND !notes_last_contacted" \
--properties email,firstname
```
For more signals (email opt-out, stale tickets, no open deals) see `resources/customer-health-signals.md`. For >100 hits, use the pagination loop from `bulk-operations`.
To audit *why* a customer churned or moved stage — which workflow, integration, import, or UI edit last changed `lifecyclestage` — use `hubspot objects history --type contacts --properties lifecyclestage [--id <recordId>] [--include-ui]`. It flattens each property's source history into one row per change.
## 2 — Flag at-risk subscriptions
`subscriptions` is a standard object (`hubspot objects types` confirms). Enum values for `hs_subscription_status` are portal-specific — verify before filtering, then plug the exact value in:
```bash
hubspot properties options-list --type subscriptions hs_subscription_status # allowed values
# Past-due — revenue at immediate risk (substitute your verified value)
hubspot objects search --type subscriptions \
--filter "hs_subscription_status=past_due" \
--properties hs_recurring_billing_total,hs_subscription_status
# Map an at-risk subscription to its contact for outreach
hubspot associations list --from subscriptions:<sub_id> --to contacts --format jsonl
```
## 3 — Create a follow-up task or check-in note
Activity creation lives in `sales-execution` (full property tables, note + meeting flows). One anchor example — unassociated tasks are invisible in the CRM UI, so always associate:
```bash
task_id=$(hubspot objects create --type tasks \
--property hs_task_subject="Q1 retention check-in" \
--property hs_task_priority=HIGH --property hs_task_status=NOT_STARTED \
--property hs_task_type=CALL --property hs_timestamp=$(date +%s)000 \
--format json | jq -r '.id')
hubspot associations create --from tasks:$task_id --to contacts:<contact_id>
```
## 4 — Bulk task creation for a cohort
Pipe a search through `jq` into one `objects create` call, then associate. `objects create` is Additive — never digest-gated — so `--dry-run` is a plain preview and you execute by dropping it (no digest/confirm). The digest flow only applies to the irreversible writes in `bulk-operations/SKILL.md`.
```bash
DUE_MS=$(( ($(date +%s) + 2*86400) * 1000 )) # due in 2 days
# 1. Capture the cohort (same file feeds both create + associate)
hubspot objects search --type contacts \
--filter "lifecyclestage=customer AND notes_last_contacted<$CUTOFF" \
--properties firstname > /tmp/inactive.jsonl
# 2. Build task payloads — one per contact
jq -c --arg due "$DUE_MS" '{
contact_id: .id,
properties: {
hs_task_subject: ("Re-engage: " + (.properties.firstname // "customer")),
hs_task_priority: "HIGH", hs_task_status: "NOT_STARTED",
hs_task_type: "CALL", hs_timestamp: $due
}
}' /tmp/inactive.jsonl > /tmp/task_payloads.jsonl
# 3. Dry-run, then create (drop contact_id before piping)
jq -c '{properties}' /tmp/task_payloads.jsonl | hubspot objects create --type tasks --dry-run | head
jq -c '{properties}' /tmp/task_payloads.jsonl | hubspot objects create --type tasks > /tmp/created.jsonl
# 4. Associate each new task to its contact — one piped call (associations create batches 100 pairs/API call; paste preserves order)
paste <(jq -r '.id' /tmp/created.jsonl) <(jq -r '.contact_id' /tmp/task_payloads.jsonl) \
| jq -cR 'split("\t") | {from:("tasks:" + .[0]), to:("contacts:" + .[1])}' \
| hubspot associations create
```
One CLI call for the search, one for the create, and one for all associations — no `xargs -I{}` per record. The output-order guarantee of `objects create` (one result per stdin line, in order — see `bulk-operations` "Output shape") is what makes the `paste` correct.
## Known gaps
- No native churn-score / health-score property — track via a custom property.
- `hubspot segments` provides CRM lists for re-engagement cohorts — `segments members-list` pulls a list's members, and `segments create` / `update-filters` save an at-risk audience as a reusable list. Re-engagement enrollment can be built as a workflow via `hubspot workflows create` / `update` (see `workflow-automation/SKILL.md`).
- `hubspot sequences` reads Sales Hub sequences (read-only): use `sequences enrollments <contact_id>` to see whether an at-risk customer was ever engaged through a sales sequence. Sequences are a product API (Sales Hub Professional+, `automation.sequences.read` scope), not a CRM object type — the CLI cannot create sequences or enroll contacts. This list grows over time; recheck `hubspot --help` / `CHANGELOG.md` rather than assuming an API is absent.
- `hubspot associations create` batches stdin JSONL (up to 100 pairs per API call) — pipe the pairs in one call instead of looping.
© HubSpot · Apache-2.0 · HubSpot/agent-cli-skills