Agent skill

parent-segment-analysis

Query and analyze CDP parent segment database data. Use `tdx ps desc -o` to get output database schema, then query customers and behavior tables. Use when exploring parent segment data, building reports, or analyzing customer attributes and behaviors.

Stars 16
Forks 23

Install this agent skill to your Project

npx add-skill https://github.com/treasure-data/td-skills/tree/main/tdx-skills/parent-segment-analysis

SKILL.md

tdx Parent-Segment-Analysis - CDP Parent Segment Data Analysis

Workflow

  1. Get output database schema
  2. Read ALL columns from the schema file to understand available data
  3. Identify relevant columns for the analysis (use sub-agent if schema is large)
  4. Query customers or behavior tables

Get Output Database Schema

Parent segments generate an output database (cdp_audience_{id}) with:

  • customers table - master + all attributes joined
  • behavior_{name} tables - one per behavior
bash
# Save schema to file (recommended for large schema data)
tdx ps desc "Customer 360" -o customer_360_schema.json

# Output summary:
# Schema saved to customer_360_schema.json
#   Database: cdp_audience_12345
#   Tables: 1 customers + 5 behaviors
#   Columns: 42 total

Schema JSON Structure

One column per line for grep and progressive disclosure:

json
{
  "database": "cdp_audience_12345",
  "parent_segment": "Customer 360",
  "parent_id": "12345",
  "customers": {
    "table": "customers",
    "columns": [
      { "name": "cdp_customer_id", "type": "varchar" },
      { "name": "email", "type": "varchar" }
    ]
  },
  "behaviors": [
    {
      "table": "behavior_purchases",
      "columns": [
        { "name": "cdp_customer_id", "type": "varchar" },
        { "name": "amount", "type": "double" }
      ]
    }
  ]
}

Discovering Relevant Columns

IMPORTANT: Always read the full schema file first to understand what data is available. After reviewing the schema, you can use grep/search to find specific columns.

For large schemas: use a sub-agent to discover relevant columns for your analysis goal

Analysis Guidelines

  • Check null ratios for identified customer columns and exclude null values from aggregations to ensure accurate analysis.
  • Build queries incrementally rather than attempting everything at once.
  • Provide an extremely brief summary of key findings in one sentence.
  • Always be very explicit and detailed about the data sources you are using, including table names, column names.

Array Columns

  • For SQL queries needing array analysis/aggregation: Use CROSS JOIN UNNEST.
    sql
    SELECT
      tag,
      count(0) AS cnt
    FROM customers
    CROSS JOIN UNNEST(tags) AS t(tag)
    GROUP BY 1 ORDER BY 2 DESC LIMIT 10
    
  • Don't use the same name for alias as column name (e.g., use tag not tags for the alias)
  • Never use ARRAY_CONTAINS — use contains(array_column, value) or filter via CROSS JOIN UNNEST

Time Function Usage

Always first check the format of the time column before applying time functions.

Time functions:

  • td_interval(time, '-1d') — filter records within a time interval
  • td_time_parse('2024-01-01', 'UTC') — parse a time string into Unix timestamp (seconds)

Related Skills

  • parent-segment - Manage parent segment configuration
  • segment - Create child segments from parent segment data
  • trino - Trino SQL syntax and TD-specific functions

Expand your agent's capabilities with these related and highly-rated skills.

treasure-data/td-skills

email-campaign

This skill should be used when the user asks to "create an email", "build an email campaign", "design an email template", "generate an email for a segment", "preview an email", or "push an email to Engage". Generates enterprise-grade HTML email templates with live preview in Treasure Studio and natural language editing, then pushes the final version to Treasure Engage.

16 23
Explore
treasure-data/td-skills

action-report

YAML format reference for action reports rendered via preview_action_report. MUST be read before writing any action report YAML — defines the report structure (title, summary, actions array) and action item fields (as_is, to_be, reason, priority, category, impact) with incremental build workflow. Required by seo-analysis and any skill that produces prioritized recommendations.

16 23
Explore
treasure-data/td-skills

grid-dashboard

YAML format reference for grid dashboards rendered via preview_grid_dashboard. MUST be read before writing any dashboard YAML — defines the page structure, 6 cell types (kpi, gauge, scores, table, chart, markdown), grid layout rules, cell merging syntax, and incremental build workflow. Required by seo-analysis and any skill that produces visual data dashboards.

16 23
Explore
treasure-data/td-skills

seo-analysis

Runs SEO and AEO (Answer Engine Optimization) analysis on websites or specific pages. Use when the user mentions SEO, AEO, search rankings, search optimization, or wants to analyze how their pages perform in search engines and AI answers. Produces a data dashboard and action report with before/after recommendations.

16 23
Explore
treasure-data/td-skills

aps-doc-core

Core documentation generation patterns and framework for Treasure Data pipeline layers. Provides shared templates, quality validation, testing framework, and Confluence integration used by all layer-specific documentation skills.

16 23
Explore
treasure-data/td-skills

aps-doc-id-unification

Expert documentation generation for ID unification layers. Documents identity resolution algorithms, merge strategies, match rules, entity graphs, and multi-workflow orchestration. Use when documenting ID unification processes.

16 23
Explore

Didn't find tool you were looking for?

Be as detailed as possible for better results