validate-segment
Validates CDP segment YAML configurations against the TD CDP API specification. Use when reviewing segment rules for correctness, checking operator types and values, or troubleshooting segment configuration errors before pushing to Treasure Data.
When & Why to Use This Skill
This Claude skill provides automated validation for Customer Data Platform (CDP) segment YAML configurations, ensuring they strictly adhere to the Treasure Data (TD) CDP API specification. It helps developers and data engineers catch syntax errors, invalid operator types, and incorrect time unit formats before deployment, significantly reducing the risk of configuration failures and ensuring data integrity within the Treasure Data ecosystem.
Use Cases
- Pre-deployment Validation: Use the skill to check YAML files locally against API specifications to ensure they are error-free before pushing to the live Treasure Data environment.
- Syntax & Logic Troubleshooting: Quickly identify and fix common configuration mistakes, such as using plural time units (e.g., 'days') instead of the required singular form ('day').
- Complex Rule Review: Validate intricate segment rules involving behavior aggregations, nested conditions, and specific operator types like 'TimeWithinPast' or 'Regexp'.
- Dry-run Previews: Leverage the dry-run capability to preview configuration changes and verify the structural integrity of segment definitions without affecting production data.
| name | validate-segment |
|---|---|
| description | Validates CDP segment YAML configurations against the TD CDP API specification. Use when reviewing segment rules for correctness, checking operator types and values, or troubleshooting segment configuration errors before pushing to Treasure Data. |
Segment YAML Validation
tdx sg validate # Validate all YAML files locally
tdx sg validate path/to/segment.yml # Validate specific file
tdx sg push --dry-run # Preview changes before push
Required Structure
name: string
kind: batch # batch | realtime | funnel_stage
rule:
type: And # And | Or
conditions:
- type: Value
attribute: field_name
operator:
type: OperatorType
value: ...
Operators Quick Reference
| Type | Value | Notes |
|---|---|---|
Equal, NotEqual |
single value | |
Greater, GreaterEqual, Less, LessEqual |
number | |
In, NotIn |
array | ["US", "CA"] |
Contain, StartWith, EndWith |
array | ["@gmail.com"] |
Regexp |
string | regex pattern |
IsNull |
(none) | |
TimeWithinPast, TimeWithinNext |
number + unit | value: 30, unit: day |
include, exclude |
segment name | reuse existing segment |
Time Units (Singular Form Only)
year | quarter | month | week | day | hour | minute | second
Common mistake: days → day, months → month
Behavior Aggregation Structure
# Behavior condition with aggregation
- type: Value
attribute: field_name # Or "" for pure count
operator:
type: GreaterEqual
value: 1
aggregation:
type: Count # Count | Sum | Avg | Min | Max
source: behavior_name # Behavior from parent segment
Required fields: aggregation.type and source must both be present
Related Skills
- segment - Full segment management