$npx -y skills add forcedotcom/sf-skills --skill data360-segmentSalesforce Data Cloud Segment phase. Use this skill when the user creates or publishes segments, manages calculated insights, or troubleshoots audience SQL in Data Cloud. TRIGGER when: user creates or publishes segments, manages calculated insights, inspects segment counts or mem
| 1 | # data360-segment: Data Cloud Segment Phase |
| 2 | |
| 3 | Use this skill when the user needs **audience and insight work**: segments, calculated insights, publish workflows, member counts, or troubleshooting Data Cloud segment SQL. |
| 4 | |
| 5 | ## When This Skill Owns the Task |
| 6 | |
| 7 | Use `data360-segment` when the work involves: |
| 8 | - `sf data360 segment *` |
| 9 | - `sf data360 calculated-insight *` |
| 10 | - segment publish workflows |
| 11 | - member counts and segment troubleshooting |
| 12 | - calculated insight execution and verification |
| 13 | |
| 14 | Delegate elsewhere when the user is: |
| 15 | - still building Data Model Objects (DMOs), mappings, or identity resolution → [data360-harmonize](../data360-harmonize/SKILL.md) |
| 16 | - activating a segment downstream → [data360-activate](../data360-activate/SKILL.md) |
| 17 | - writing read-only SQL or search-index queries → [data360-query](../data360-query/SKILL.md) |
| 18 | |
| 19 | --- |
| 20 | |
| 21 | ## Required Context to Gather First |
| 22 | |
| 23 | Ask for or infer: |
| 24 | - target org alias |
| 25 | - unified DMO (Data Model Object) or base entity name |
| 26 | - whether the user wants create, publish, inspect, or troubleshoot |
| 27 | - whether the asset is a segment or calculated insight |
| 28 | - expected success metric: member count, aggregate value, or publish status |
| 29 | |
| 30 | --- |
| 31 | |
| 32 | ## Core Operating Rules |
| 33 | |
| 34 | - Treat Data Cloud segment SQL as distinct from CRM SOQL. |
| 35 | - Run the shared readiness classifier from the `data360-orchestrate` skill before mutating audience assets: `node ../data360-orchestrate/scripts/diagnose-org.mjs -o <org> --phase segment --json`. |
| 36 | - Prefer reusable JSON definitions for repeatable segment and CI creation. |
| 37 | - Use `--api-version 64.0` when segment creation behavior is unstable on newer defaults. |
| 38 | - Verify with counts or SQL after publish/run steps instead of assuming success. |
| 39 | - Use SQL joins rather than `segment members` when readable member details are needed. |
| 40 | |
| 41 | --- |
| 42 | |
| 43 | ## Recommended Workflow |
| 44 | |
| 45 | ### 1. Classify readiness for segment work |
| 46 | ```bash |
| 47 | node ../data360-orchestrate/scripts/diagnose-org.mjs -o <org> --phase segment --json |
| 48 | ``` |
| 49 | |
| 50 | ### 2. Inspect current state |
| 51 | ```bash |
| 52 | sf data360 segment list -o <org> 2>/dev/null |
| 53 | sf data360 calculated-insight list -o <org> 2>/dev/null |
| 54 | ``` |
| 55 | |
| 56 | ### 3. Create with reusable JSON definitions |
| 57 | ```bash |
| 58 | sf data360 segment create -o <org> -f segment.json --api-version 64.0 2>/dev/null |
| 59 | sf data360 calculated-insight create -o <org> -f ci.json 2>/dev/null |
| 60 | ``` |
| 61 | |
| 62 | ### 4. Publish or run explicitly |
| 63 | ```bash |
| 64 | sf data360 segment publish -o <org> --name My_Segment 2>/dev/null |
| 65 | sf data360 calculated-insight run -o <org> --name Lifetime_Value 2>/dev/null |
| 66 | ``` |
| 67 | |
| 68 | ### 5. Verify with counts or SQL |
| 69 | ```bash |
| 70 | sf data360 segment count -o <org> --name My_Segment 2>/dev/null |
| 71 | sf data360 query sql -o <org> --sql 'SELECT COUNT(*) FROM "UnifiedssotIndividualMain__dlm"' 2>/dev/null |
| 72 | ``` |
| 73 | |
| 74 | --- |
| 75 | |
| 76 | ## High-Signal Gotchas |
| 77 | |
| 78 | - Segment creation can require `--api-version 64.0`. |
| 79 | - `segment members` returns opaque IDs; use SQL joins when human-readable member details are needed. |
| 80 | - Segment SQL is not SOQL. |
| 81 | - Calculated insight assets and segment SQL have different limitations. |
| 82 | - Publish/run steps may kick off asynchronous work even when the command returns quickly. |
| 83 | - An empty segment or calculated-insight list usually means the module is reachable but unconfigured, not unavailable. |
| 84 | |
| 85 | --- |
| 86 | |
| 87 | ## Output Format |
| 88 | |
| 89 | ```text |
| 90 | Segment task: <segment / calculated-insight> |
| 91 | Action: <create / publish / inspect / troubleshoot> |
| 92 | Target org: <alias> |
| 93 | Artifacts: <definition files / commands> |
| 94 | Verification: <member count / query result / publish state> |
| 95 | Next step: <act / retrieve / follow-up> |
| 96 | ``` |
| 97 | |
| 98 | --- |
| 99 | |
| 100 | ## References |
| 101 | |
| 102 | - [../data360-orchestrate/assets/definitions/calculated-insight.template.json](../data360-orchestrate/assets/definitions/calculated-insight.template.json) |
| 103 | - [../data360-orchestrate/assets/definitions/segment.template.json](../data360-orchestrate/assets/definitions/segment.template.json) |
| 104 | - [../data360-orchestrate/references/feature-readiness.md](../data360-orchestrate/references/feature-readiness.md) |