Automate update and maintenance of data dictionaries in Treasure Data - generates 80-90% of column descriptions automatically, allowing users to review results, make changes, and fill in gaps. Orchestrates schema extraction, AI-powered description generation, human review, and write-back as single workflow.
61
77%
Does it follow best practices?
Run evals on this skill
Adds up to 20 points to the overall score
Passed
No findings from the security scan
Fix and improve this skill with Tessl
tessl review fix ./semantic-layer/data-dictionary-helper/SKILL.mdAutomate the update and maintenance of data dictionaries in Treasure Data - with 80-90% automated column descriptions that you can review, edit, and enhance. From schema extraction through TD write-back, this skill handles the heavy lifting while keeping you in control.
/data-dictionary [segment-name]Example:
/data-dictionary customer_360If segment name not provided, will list available Parent Segments.
This skill orchestrates 6 sequential stages:
Each stage creates artifacts used by subsequent stages. Workflow supports resume from partial runs.
Purpose: Collect business context to inform description generation.
Process: Ask 4 context questions ONE at a time (conversational, not all at once):
Output: Context stored in memory for Stage 3.
Progress:
✅ Stage 1 complete: Context gathered
➡️ Next: Stage 2 (Schema Extraction)Purpose: Extract schema from TD Parent Segment with sample data for PII detection.
Command:
node src/index.js extract $SEGMENT --sampleWhere $SEGMENT is the segment name from $ARGUMENTS[0].
Output:
✅ Stage 2 complete: Schema extracted
📁 Artifacts created:
- ./schemas/{segment}.json
➡️ Next: Stage 3 (Description Generation)Error Handling: If extraction fails:
Resume Detection:
If ./schemas/{segment}.json already exists:
Purpose: Generate AI-powered column descriptions using Claude.
API Key Detection: Before running generation, check for API key:
if [ -z "$ANTHROPIC_API_KEY" ]; then
echo "API key not found. Using Claude Code mode..."
USE_CLAUDE_CODE=true
else
echo "API key detected. Using API mode..."
USE_CLAUDE_CODE=false
fiCommand (API Mode):
node src/index.js generate $SEGMENTCommand (Claude Code Mode):
node src/index.js generate $SEGMENT --claude-codeIn Claude Code mode, the CLI will print instructions for manual generation. Follow those instructions:
./descriptions/{segment}-descriptions.jsonOutput:
✅ Stage 3 complete: Descriptions generated
📁 Artifacts created:
- ./descriptions/{segment}-descriptions.json
➡️ Next: Stage 4 (Review Export)Error Handling: If generation fails:
--claude-code flagResume Detection:
If ./descriptions/{segment}-descriptions.json already exists:
Purpose: Export descriptions to CSV for human review and editing.
Command:
node src/index.js review $SEGMENTThis command will:
./reviews/{segment}-descriptions.csvCSV Format:
6 columns: table, column, type, source, description, is_pii
table = table type (attribute, behavior, master)column = column nametype = data type (may be empty — this is optional and doesn't affect write-back)source = source databasedescription = AI-generated description (editable)is_pii = PII flag (TRUE/FALSE)Edit the description and is_pii columns as needed. Do NOT modify other columns (they are validated as immutable).
Output:
✅ Stage 4 complete: CSV exported and opened for review
📁 Artifacts created:
- ./reviews/{segment}-descriptions.csv
Please review and edit the CSV file, then save and close it.
Type "done" when ready to continue.
➡️ Next: Stage 5 (Validation)Error Handling: If export fails:
If file opening fails (headless system, no default app):
Resume Detection:
If ./reviews/{segment}-descriptions.csv already exists:
Purpose: Validate edited CSV and import back to JSON format.
Command:
node src/index.js validate $SEGMENTThis command will:
Output (Success):
✅ Stage 5 complete: Validation passed
📁 Validation summary:
- Segments: 1
- Tables: 3
- Columns: 45
- Status: Ready for write-back
Proceed with write-back? (y/n)
➡️ Next: Stage 6 (Write-back)Output (Errors Found):
❌ Stage 5 failed: Validation errors found
📁 Error log created:
- ./reviews/{segment}-descriptions-errors.csv
Please fix errors in CSV and retry validation.
Options: [R] Retry validation | [E] ExitError Handling: If validation fails:
{segment}-descriptions-errors.csv with row/column/issue detailsConfirmation Gate: After successful validation, require explicit confirmation:
Purpose: Publish descriptions to Treasure Data source tables using the /v3/table/update-schema API. Once written, the CDP propagates these descriptions to Parent Segment output tables when the Audience workflow runs. The Knowledge Base tool then returns them as comment, enabling Audience Agents to understand column semantics.
API Endpoint: POST /v3/table/update-schema/{database}/{table}
Schema Format: 4-element arrays: [name, type, alias, description]
string, long, int)null to preserve existing)Important: Do NOT use /v3/table/update — that endpoint's 3rd element (alias) only accepts SQL identifiers (lowercase, digits, underscore). The /v3/table/update-schema endpoint supports a 4th element for free-text descriptions.
Auth: Uses TD_API_KEY env var, or auto-detects TDX_API_KEY__* env vars. EU endpoint is auto-detected from key naming (e.g., TDX_API_KEY__TDX_STUDIO_EU01_256 → api.eu01.treasuredata.com).
Table Name Resolution: The review CSV table column contains table types (attribute, behavior, master), not actual TD table names. The writeback command loads the descriptions JSON to resolve actual (database, table_name) pairs.
Dry-run Preview (Required): Before actual write-back, run dry-run to preview changes:
node src/index.js writeback $SEGMENT --dry-runOutput:
Dry-run mode: No changes will be made to TD
Tables to update:
db_customer_360.customer_master (15 columns)
db_customer_360.customer_attributes (12 columns)
db_customer_360.customer_behaviors (18 columns)
Total: 3 tables, 45 columns
Review complete. Proceed with actual write-back? (y/n)Confirmation Gate: Require explicit confirmation after dry-run preview:
Actual Write-back:
node src/index.js writeback $SEGMENTOutput (Success):
✅ Stage 6 complete: Write-back successful
📁 Artifacts created:
- ./snapshots/{segment}-{timestamp}.json (type: before)
- ./snapshots/{segment}-{timestamp}.json (type: after)
Write-back results:
✅ db_customer_360.customer_master (15 columns updated)
✅ db_customer_360.customer_attributes (12 columns updated)
✅ db_customer_360.customer_behaviors (18 columns updated)
Total: 3/3 tables succeeded
Workflow complete! 🎉
Descriptions will propagate to Parent Segment output tables when the Audience workflow runs next.
Verify with: SHOW COLUMNS FROM {database}.{table} (check Comment column)Output (Partial Failure):
⚠️ Stage 6 partial success: Some tables failed
📁 Artifacts created:
- ./snapshots/{segment}-{timestamp}.json (type: before)
- ./reviews/{segment}-writeback-errors.json
Write-back results:
✅ db_customer_360.customer_master (15 columns updated)
❌ db_customer_360.customer_attributes (API error: 500)
✅ db_customer_360.customer_behaviors (18 columns updated)
Total: 2/3 tables succeeded
Error log: ./reviews/{segment}-writeback-errors.json
Options: [R] Retry failed tables | [V] View errors | [X] Rollback | [E] ExitError Handling: If write-back fails (partial or complete):
{segment}-writeback-errors.jsonRollback Option: If user chooses rollback after write-back failure:
node src/index.js rollback $SEGMENTThis will:
Resume Detection:
If ./snapshots/{segment}*-before.json exists:
When workflow starts, check for existing artifacts to determine position:
# Check Stage 2 completion
if [ -f "./schemas/$SEGMENT.json" ]; then
STAGE_2_COMPLETE=true
fi
# Check Stage 3 completion
if [ -f "./descriptions/${SEGMENT}-descriptions.json" ]; then
STAGE_3_COMPLETE=true
fi
# Check Stage 4 completion
if [ -f "./reviews/${SEGMENT}-descriptions.csv" ]; then
STAGE_4_COMPLETE=true
fi
# Check Stage 6 completion
if ls ./snapshots/${SEGMENT}*-before.json 1> /dev/null 2>&1; then
STAGE_6_COMPLETE=true
fiResume Logic:
Resume Prompt:
Found existing artifacts:
✅ Stage 2: ./schemas/{segment}.json
✅ Stage 3: ./descriptions/{segment}-descriptions.json
✅ Stage 4: ./reviews/{segment}-descriptions.csv
Resume from Stage 5 (Validation) or start fresh?
Options: [R] Resume | [F] Fresh startAfter each stage completes, display:
Example:
✅ Stage 3 complete: Descriptions generated
📁 Artifacts created:
- ./descriptions/customer_360-descriptions.json (45 columns)
➡️ Next: Stage 4 (Review Export)Each stage offers context-appropriate recovery options:
| Stage | Error Type | Options |
|---|---|---|
| 2. Extraction | Command failure | [R] Retry, [E] Exit |
| 3. Generation | API/generation failure | [R] Retry, [C] Claude Code mode, [E] Exit |
| 4. Review Export | Export failure | [R] Retry, [E] Exit |
| 5. Validation | CSV errors | [R] Retry (after fixing CSV), [E] Exit |
| 6. Write-back | Partial/complete failure | [R] Retry failed, [V] View errors, [X] Rollback, [E] Exit |
For CI/CD or non-interactive workflows, use skip flags:
Stage 4 (Review Export):
node src/index.js review $SEGMENT --skip-reviewExports CSV but doesn't open file or prompt for "done".
Stage 5 (Validation): Confirmation prompt can be skipped by piping "y":
echo "y" | node src/index.js validate $SEGMENTStage 6 (Write-back):
node src/index.js writeback $SEGMENT --skip-reviewSkips all confirmation prompts and proceeds directly.
The workflow uses file system as state store:
| Artifact | Location | Purpose |
|---|---|---|
| Schema JSON | ./schemas/{segment}.json | Extracted schema with samples |
| Descriptions JSON | ./descriptions/{segment}-descriptions.json | Generated descriptions |
| CSV Export | ./reviews/{segment}-descriptions.csv | Human-editable review format |
| CSV Errors | ./reviews/{segment}-descriptions-errors.csv | Validation error details |
| Before Snapshot | ./snapshots/{segment}-{timestamp}.json | Pre-write-back state |
| After Snapshot | ./snapshots/{segment}-{timestamp}.json | Post-write-back state |
| Writeback Errors | ./reviews/{segment}-writeback-errors.json | Write-back failure details |
All artifacts use segment name as identifier for resume detection.
User: /data-dictionary customer_360treasure-data/td-skills
9f8ee16
If you maintain this skill, you can claim it as your own. Once claimed, you can manage eval scenarios, bundle related skills, attach documentation or rules, and ensure cross-agent compatibility.