К основному содержанию
скилл CX Codex

cargo-segmentation — скилл для Claude Code: сегменты и фильтры Cargo

Скилл для работы с сегментами Cargo: сохраняет именованные фильтры над моделью и считает, сколько записей в них попадает. Пригодится, когда агенту нужно собрать аудиторию для рассылки или экспорта.

Установить в Claude Code · Через Skills CLI (Vercel) Все способы и платформы ↓
npx skills add getcargohq/cargo-skills --skill cargo-segmentation -a claude-code
Открыть на GitHub

Что делает cargo-segmentation

Сегмент в Cargo — это именованный фильтр над одной моделью, сохранённый с именем, modelUuid и слагом. Он отвечает на вопрос «какие записи мне нужны», и дальше на него ссылаются batch-запуски, триггеры play и выгрузки. Сам фильтр — это JSON вида {conjonction, groups[].conditions[]}, и без сохранения он живёт только до конца вызова.

Скилл закрывает весь цикл: segment list, create, update, remove, fetch и download для разовых запросов, плюс change list и change fetch, чтобы увидеть, сколько записей добавилось, обновилось или ушло между синхронизациями. Отдельно стоит запомнить про conjonction — французское написание обязательно на обоих уровнях, и опечатка в conjunction роняет вызов с ошибкой 400. Группа с пустым conditions тоже не пройдёт: чтобы взять всё, оставьте groups пустым.

Перед созданием сегмента скилл советует сначала посмотреть, что уже есть в воркспейсе: segment list, storage model list, storage column list. Сегменты, которые play создаёт сам, помечены fromPlay: true и называются GENERATED_PLAY_SEGMENT — их не трогают руками. Для работы нужен @cargo-ai/cli из npm и вход через cargo-ai login --email, --oauth или токен. Если задача — прогнать что-то по сегменту, выгрузить строки или написать SQL напрямую, это уже другие скиллы: cargo-orchestration, cargo-analytics, cargo-storage.

Какие задачи решает

  • сохранить фильтр над моделью как именованный сегмент
  • посчитать, сколько компаний попадает под условие
  • собрать аудиторию для batch-запуска или триггера play
  • посмотреть, кто добавился и ушёл между синхронизациями
  • выгрузить записи сегмента в CSV

Примеры запросов агенту

  • собери сегмент из контактов, у которых employee_count больше 100
  • сколько компаний подходит под этот фильтр?
  • покажи, что изменилось в сегменте Closed-Won с прошлого синка

Как установить cargo-segmentation

1Через Skills CLI (Vercel)

npx skills add getcargohq/cargo-skills --skill cargo-segmentation -a claude-code

2Вручную: положить файлы

~/.claude/skills/cargo-segmentation/SKILL.md

Папка скилла целиком; для одного проекта — .claude/skills/cargo-segmentation/

По шагам, с командами для каждой платформы: Как установить скилл в Claude Code: пять способов

Вопросы о cargo-segmentation

Как установить cargo-segmentation в Claude?

Выполните npx skills add getcargohq/cargo-skills --skill cargo-segmentation -a claude-code. Скилл встанет в ~/.claude/skills/cargo-segmentation/SKILL.md.

Что делает cargo-segmentation?

Создаёт и обновляет сегменты Cargo — именованные фильтры над моделью, — считает размер аудитории и показывает изменения между синхронизациями. Работает через @cargo-ai/cli.

Почему вызов падает с ошибкой 400?

Скорее всего в JSON фильтра написано conjunction вместо conjonction. Французское написание обязательно и в самом фильтре, и в каждой группе.

Исходный текст

SKILL.md · MIT
---
name: cargo-segmentation
description: "Define and use segments — named, saved filters over a Cargo model that become the audience for a batch run, a play trigger, or an export. Triggers: \"build a segment of\", \"filter my contacts where\", \"who matches this criteria\", \"save this as a list\", \"how many companies match\", \"the Closed-Won segment\", \"everyone who has not been emailed\", \"target only accounts that\", \"what is in this segment\", \"narrow this down to\". Filter JSON uses `conjonction` (not `conjunction`); misspelling it gets the call rejected with a 400. Skip when: running something over the segment — use cargo-orchestration; exporting its rows — use cargo-analytics; ad-hoc SQL over the model — use cargo-storage."
version: "1.2.1"
compatibility: Requires @cargo-ai/cli (npm). Sign in or create an account with `cargo-ai login --email` (emailed code, no browser), `--oauth`, or an API token
homepage: https://github.com/getcargohq/cargo-skills
metadata:
  author: getcargo
  openclaw:
    requires:
      bins:
        - cargo-ai
    install:
      - kind: node
        package: "@cargo-ai/cli@latest"
        bins:
          - cargo-ai
    homepage: https://github.com/getcargohq/cargo-skills
---

# Cargo CLI — Segmentation

Segments are the **audience layer** of a Cargo workspace: a named, saved filter over one model that answers "which records do I mean?" Everything downstream — a batch run, a play trigger, a CSV export, a change feed — takes a segment (or a segment-shaped filter) as its input.

> See `references/response-shapes.md` for full JSON response structures.
> See `references/troubleshooting.md` for common errors and how to fix them.
> Filter condition kinds and operators live in [`../cargo-orchestration/references/filter-syntax.md`](../cargo-orchestration/references/filter-syntax.md) — the single source of truth for filter JSON.

## Bootstrap

Already signed in (`cargo-ai whoami` returns a workspace)? Skip to the next section.

```bash
npm install -g @cargo-ai/cli            # no global install? prefix every command with `npx @cargo-ai/cli`
cargo-ai login --email [email protected]  # emailed code, no browser; creates the account on first use
                                        # alternatives: --oauth (browser) · --token <api-token> (CI)
cargo-ai whoami                         # confirm the active workspace before any write
```

Every command prints JSON to stdout; failures exit non-zero and print `{"error": "...", "status": ..., "body": ...}` to stderr. Anything that creates a run or a batch is async — pass `--wait-until-finished` or poll the matching `get`. When the full skill bundle is installed, [`../cargo/references/prerequisites.md`](../cargo/references/prerequisites.md) adds the CLI version pin, token scopes, and the admin-only surface.

## Key concepts

| Term | What it is |
|---|---|
| **Filter** | A JSON object (`{conjonction, groups[].conditions[]}`) evaluated against one model's columns. Ephemeral on its own. |
| **Segment** | A filter **saved** with a name, a `modelUuid`, and a `slug`. Has a `uuid`, a live `recordsCount`, and a history. This is what plays, batches, and exports reference. |
| **Change** | One computed delta of a segment between two syncs — how many records were `added`, `updated`, `removed`, `unchanged`. The basis of every "notify me when someone enters this audience" motion. |
| **Tracking columns** | The subset of columns (`--tracking-column-slugs`) whose value changes count as an `updated` record. Without them a record only ever registers as added or removed. |

**Filter vs segment — pick deliberately.** A one-off question ("how many companies have >100 employees?") wants `segment fetch` with an inline filter and no saved object. An audience you will run something against, schedule against, or track over time wants a real `segment create` — because only a saved segment produces changes.

## Discover resources first

Always list before creating. A workspace usually already holds the segment you are about to duplicate.

```bash
cargo-ai segmentation segment list                    # all segments (uuid, name, slug, modelUuid, recordsCount)
cargo-ai storage model list                           # find the modelUuid a segment must target
cargo-ai storage column list --model-uuid <uuid>      # the column slugs your filter conditions reference
```

Segments created automatically by a play are named `GENERATED_PLAY_SEGMENT` and carry `fromPlay: true` — **never edit or remove those by hand**; they belong to the play that owns them.

**Retrieve in the UI:** segments live under the model at `app.getcargo.io/workspaces/<WORKSPACE_UUID>/models/<MODEL_UUID>`. Get `<WORKSPACE_UUID>` from `cargo-ai whoami`.

## Quick reference

```bash
cargo-ai segmentation segment list
cargo-ai segmentation segment get <segment-uuid>
cargo-ai segmentation segment create --name "<name>" --model-uuid <uuid> --filter '<json>'
cargo-ai segmentation segment update --uuid <segment-uuid> --filter '<json>'
cargo-ai segmentation segment remove <segment-uuid>
cargo-ai segmentation segment fetch    --model-uuid <uuid> --filter '<json>' --limit 50
cargo-ai segmentation segment download --model-uuid <uuid> --filter '<json>'
cargo-ai segmentation change list  --segment-uuid <segment-uuid>
cargo-ai segmentation change fetch --uuid <change-uuid> --kinds added --limit 50
cargo-ai segmentation record fetch --model-uuid <uuid> --ids <id[,id…]>
```

## Building a filter

The full condition catalogue — every `kind` (`string`, `number`, `date`, `boolean`, `array`, `object`, `objectProperty`, `any`, `vector`, `sql`, `segment`, `occurrence`, `enrollment`) and every operator — is in [`../cargo-orchestration/references/filter-syntax.md`](../cargo-orchestration/references/filter-syntax.md). The shape:

```json
{
  "conjonction": "and",
  "groups": [
    {
      "conjonction": "and",
      "conditions": [
        { "kind": "number", "columnSlug": "employee_count", "operator": "greaterThan", "value": 100 },
        { "kind": "string", "columnSlug": "email", "operator": "isNotEmpty" }
      ]
    }
  ]
}
```

> **`conjonction`, not `conjunction`.** The French spelling is intentional and required at both levels (the filter and every group): a misspelled key fails validation and the API returns a 400 naming `conjonction`. Grep your JSON for `conjunction` before every call.
>
> **Every group needs at least one condition.** A group with `"conditions": []` is rejected (`Filter groups must contain at least one condition`); match everything with `"groups": []` instead.

Match-everything filter: `{"conjonction":"and","groups":[]}`.

## Size the audience before you build it

Counting is free; running anything over an audience is not. Establish the size first, then decide.

```bash
# 1. How many records match? — inline filter, no saved object, 1 row back; read `count`
cargo-ai segmentation segment fetch \
  --model-uuid <uuid> \
  --filter '{"conjonction":"and","groups":[{"conjonction":"and","conditions":[
      {"kind":"number","columnSlug":"employee_count","operator":"greaterThan","value":100}]}]}' \
  --fetching-limit 1 --sync false --enrich false

# 2. Happy with the shape? Save it as the real audience.
cargo-ai segmentation segment create \
  --name "Mid-market accounts" \
  --model-uuid <uuid> \
  --filter '<same json>' \
  --column-slugs "name,domain,employee_count" \
  --tracking-column-slugs "employee_count,funding_stage"
```

`segment fetch` returns the match total as `count` (use `--fetching-limit`, not `--limit`: `--limit` caps membership, so `--limit 1` reports a count of 1). `segment get <uuid>` then reports `recordsCount` — the authoritative size. Cite that number, not your own estimate, before proposing a paid run over the segment.

## Fetch vs download vs record fetch

| Command | Returns | Use for |
|---|---|---|
| `segment fetch --model-uuid --filter` | Records inline as JSON, paginated (`--fetching-limit`, `--fetching-offset`) | Inspecting a handful of rows, counting, previewing a filter before saving it |
| `segment download --model-uuid --filter` | Signed URLs (`urls[]`) to the full dataset | Handing the whole audience to the user or another tool — see [`../cargo-analytics/SKILL.md`](../cargo-analytics/SKILL.md) |
| `record fetch --model-uuid --ids <ids>` | Specific records by id | Re-reading rows a change feed just told you about |

`segment fetch` refreshes the model before evaluating (`--sync`) and adds a `_segments` membership column (`--enrich`). Both default to on when omitted and cost time, so pass `--sync false --enrich false` for a size check.

**Never page a large segment into the conversation.** Use `--limit 3` to see the shape, then `download` for the rest.

## Changes — the delta feed

Every time a segment syncs, Cargo computes a change: how the membership moved. This is what turns a static list into a signal.

```bash
# What deltas exist for this segment?
cargo-ai segmentation change list --segment-uuid <segment-uuid>
# → { "changes": [ { "uuid", "totalRecordsCount", "addedRecordsCount",
#                    "updatedRecordsCount", "removedRecordsCount",
#                    "unchangedRecordsCount", "createdAt" } ] }

# Only the deltas where something entered (or moved, or left)
cargo-ai segmentation change list --segment-uuid <segment-uuid> --has-records added --limit 20

# One delta's counts, by its uuid → { "change": {...} }
cargo-ai segmentation change get <change-uuid>

# Which records actually entered the audience in that delta?
cargo-ai segmentation change fetch --uuid <change-uuid> --kinds added --limit 50

# The whole delta as files, when it is too big to page → { "urls": [...] }
cargo-ai segmentation change download --uuid <change-uuid> --kinds added,removed
```

`--kinds` is **required** on `change fetch` and takes `added`, `updated`, `removed`, or `unchanged` (comma-separated). Returned rows carry the `_kind`, `_id`, `_title`, and `_time` meta-columns alongside the model's own columns. `change download` returns signed URLs rather than rows, and takes the same four kinds (`unchanged` from CLI 1.0.128, cargo#6369; before it the API refused that one).

`change list --not-empty` keeps only the deltas where a record was added, updated or removed, and `--has-records` takes any of the four kinds. Both need CLI 1.0.128 (cargo#6369): before it the API answered `--not-empty` with a 400 (`Unrecognized key: "notEmpty"`) and refused `--has-records unchanged`, so on an older CLI use `--has-records <kind>` to skip empty deltas.

`updatedRecordsCount` is always `0` unless the segment was created with `--tracking-column-slugs` — the tracked columns define what "updated" means. Set them at creation time when the segment is meant to feed a monitoring motion.

A segment's most recent delta is also inlined on `segment list` / `segment get` as `lastChange`, so a "what moved?" question rarely needs a second call.

## What consumes a segment

Segments are an input, not an outcome. Once one exists:

- **Run something over it** — batch a connector action or workflow across every member: [`../cargo-orchestration/SKILL.md`](../cargo-orchestration/SKILL.md). Batches enroll from a segment; sample 10–20 records and get explicit approval before enrolling the full audience.
- **Trigger a play on entry** — a play fires as records enter its audience. A play is created from a `--model-uuid`, a `--filter`, and `--change-kinds`, and generates its own `GENERATED_PLAY_SEGMENT`; see [`../cargo-orchestration/references/examples/plays.md`](../cargo-orchestration/references/examples/plays.md).
- **Export it** — [`../cargo-analytics/SKILL.md`](../cargo-analytics/SKILL.md) (`segment download` needs `--model-uuid`, *not* `--segment-uuid` — a frequent 400).
- **Watch it** — alert when the audience empties, stalls, or spikes: [`../cargo-observability/SKILL.md`](../cargo-observability/SKILL.md).
- **Act on it as GTM** — signal segments (job change, funding, tech intent) drive the recipes in [`../cargo-gtm/SKILL.md`](../cargo-gtm/SKILL.md).
- **Declare it as code** — `defineSegment` in [`../cargo-project/SKILL.md`](../cargo-project/SKILL.md) when the audience should live in git.

## Gotchas

- **`conjonction`, never `conjunction`** — the call is rejected with a 400.
- **`segment download` takes `--model-uuid`, not `--segment-uuid`.** The filter travels with the request; the segment UUID is not a valid input there.
- **`change fetch` needs `--uuid` (the *change* UUID) plus `--kinds`.** Passing the segment UUID returns a 400.
- **`change list` needs `--segment-uuid`.** Calling it bare returns a 400 complaining that `segmentUuid` is undefined.
- **`--help` on `change` and `record` subcommands prints the parent help** rather than the subcommand's flags (CLI ≥ 1.0.48). Use the Quick reference above; file a report if it still bites.
- **A segment belongs to exactly one model.** Cross-model audiences are a relationship + filter on the joined column, not two segments.
- **`fromPlay: true` segments are owned by a play.** Editing one changes what that play targets; removing one breaks it.
- **`--limit` on a segment caps membership**, it is not a display page size — `--fetching-limit` is the page size.

## When the CLI fails

Two failed attempts on the same command, or behavior that contradicts this skill, goes to the team:

```bash
cargo-ai workspaceManagement report create \
  --title "<one-line summary>" \
  --description "<commands run, errorMessage verbatim, expected vs actual, UUIDs>"
```

© getcargo · MIT · getcargohq/cargo-skills

Похожие скиллы

Все скиллы по теме «Настройка агента: память, контекст, субагенты» →
sales-account-segmentation Maya-Beth Finotti Скилл строит модель сегментации клиентской базы B2B и B2C между ICP и тирингом. Помогает рассчитать скоринг соответствия по сделкам за последние 12 месяцев и разметить карту расширения в CRM. CX Codex +1 25 700установок developer-segmentation Samuel Berthe Разбивает абстрактных «разработчиков» на три-пять названных сегментов с размером, рейтингом и одним явно отвергнутым. Пригодится, когда непонятно, для кого строить SDK или документацию. CX Codex +1 10 300установок source-part-segmentation RobLe3 Разбивает пересекающиеся части исходного изображения на именованные маски до того, как из контуров начнут строить меш. CX Codex +1 727установок list-segment-builder aaron-he-zhu Скилл разбирает выгрузку из ESP, CRM или GA4 на поведенческие, RFM- и lifecycle-сегменты и собирает suppression-лист. Нужен до того, как вы начнёте рассылать. CX Codex +1 1 000установок cargo-workflows mohitmishra786 Скилл ведёт агента по воркспейсам Cargo, фичам, build.rs, кэшу сборки и аудиту зависимостей. Пригодится, когда Rust-проект разрастается до нескольких крейтов. CX Codex +1 558установок crm-client-lifecycle JoelLewis Помогает навести порядок в CRM консалтинговой фирмы: сегменты клиентов, привязка счетов к домохозяйствам, уровни сервиса и работа с оттоком. CX Codex +1 657установок

Из того же набора19

cargo-hosting Скилл учит агента создавать, собирать и выкатывать статические веб-приложения и edge-воркеры через Cargo CLI. Пригодится, когда нужно быстро получить рабочий URL для дашборда или вебхука. CX Codex +1 9 700установок cargo-cdk Скилл-заглушка для перехода на cargo-project. Он перенаправляет агента на новое имя навыка после переименования в CLI cargo-ai. CX Codex +1 8 800установок cargo-quickstart Проводит первое знакомство с Cargo: один вопрос о персоне, 25 живых лидов и чек по кредитам. Нужен, когда воркспейс пустой и непонятно, с чего начать. CX Codex +1 8 800установок cargo-diagnostics Скилл разбирает, что именно сделал запуск или батч Cargo: проходит по узлам, рисует граф с упавшим шагом, группирует ошибки по причине и считает расход кредитов. CX Codex +1 8 700установок cargo-observability Настраивает фоновые проверки воркспейса Cargo и запускает действия агента при сбоях. Пригодится для контроля ошибок в пайплайнах и свежести данных. CX Codex +1 6 200установок cargo-mailbox-management Скилл для работы с отправляющими ящиками Cargo: заводит инбоксы на домене, прогревает их и читает ответы. Нужен, когда рассылка идёт через Cargo. CX Codex +1 5 100установок cargo-mcp Скилл учит агента работать с облачным сервером Cargo через протокол MCP без установки CLI. Пригодится для точечного запуска действий и проверки баланса кредитов прямо в чате. CX Codex +1 4 600установок cargo-project Описывает рабочее пространство Cargo как код на TypeScript и разворачивает его через CLI. Пригодится для версионирования агентов, моделей и коннекторов в Git. CX Codex +1 3 000установок

Спонсоры проекта

Компании, которые помогают держать аналитику открытой