llm-workflow
БесплатноБез исполняемых скриптовНе проверенUse when building TD workflows that include LLM processing steps — data pipeline with LLM summarization, Slack/email notification, or any end-to-end…
от treasure-data★ 23 звезды на GitHubОб этом скилле
LLM Workflow
Build TD workflows that chain data queries, LLM processing, and notifications into end-to-end automation.
[td> / py> pipeline] → [LLM summarize] → [Slack / Mail notify]
For digdag syntax and operator reference, see the digdag skill.
End-to-End Template
Steps 1-4 are shared. Step 5 depends on notification channel — Slack (requires Bot App) or Mail (no setup needed on TD).
Steps 1-4: Pipeline + LLM (shared)
timezone: Asia/Tokyo
schedule:
daily>: "07:00:00"
_export:
td:
database: my_database
engine: presto
output_db: my_analytics
llm_endpoint: "https://llm-proxy.us01.treasuredata.com/v1/messages"
# 1. Setup
+setup:
td_ddl>:
create_databases: ["${output_db}"]
# 2. Build tables
+build_tables:
_parallel: true
+summary_a:
td>: queries/summary_a.sql
database: ${output_db}
create_table: summary_a
+summary_b:
td>: queries/summary_b.sql
database: ${output_db}
create_table: summary_b
# 3. Extract KPIs (single row for LLM context)
+extract_kpis:
td>: queries/kpi_snapshot.sql
store_last_results: true
# 4. LLM summarize
+llm_summarize:
http>: ${llm_endpoint}
method: POST
timeout: 300
headers:
- x-api-key: ${secret:td.apikey}
- anthropic-version: 2023-06-01
content:
model: claude-haiku-4-5-20251001
max_tokens: 1024
messages:
- role: user
content: |
Summarize this daily KPI snapshot. Be concise (under 300 chars).
Date: ${session_date}
Metric A: ${td.last_results.metric_a}
Metric B: ${td.last_results.metric_b}
content_format: json
store_content: true
Step 5a: Notify via Slack (Bot API)
Requires Slack Bot App with chat:write scope. Add after step 4:
_export:
slack:
post_url: "https://slack.com/api/chat.postMessage"
channel: "C0XXXXXXXXX"
# 5. Post to Slack — JSON.parse extracts LLM text inline (no py> needed)
+post_to_slack:
http>: ${slack.post_url}
method: POST
headers:
- content-type: "application/json"
- Authorization: "Bearer ${secret:slack.bot_user_oauth_token}"
content:
channel: ${slack.channel}
text: ${JSON.parse(http.last_content).content[0].text}
store_content: true
_error:
+notify_failure:
http>: ${slack.post_url}
method: POST
headers:
- content-type: "application/json"
- Authorization: "Bearer ${secret:slack.bot_user_oauth_token}"
content:
channel: ${slack.channel}
text: "Workflow failed for ${session_date}"
Step 5b: Notify via Email (no setup needed)
TD's built-in SMTP relay handles delivery — no secrets required. LLM response must be extracted via py> into a template variable:
# 5. Extract LLM response and send email
+extract_summary:
py>: tasks.ResponseExtractor.run
docker:
image: "treasuredata/customscript-python:3.12.11-td1"
+send_report:
mail>: templates/report.html
subject: "Daily Report ${session_date}"
to: [[email protected]]
html: true
_error:
+notify_failure:
mail>:
data: "Workflow failed for ${session_date}"
subject: "ALERT: workflow failure ${session_date}"
to: [[email protected]]
tasks/__init__.py:
import digdag
import json
class ResponseExtractor:
def run(self):
response = digdag.env.params.get("http", {}).get("last_content", "{}")
body = json.loads(response) if isinstance(response, str) else response
text = body.get("content", [{}])[0].get("text", "")
digdag.env.store({"llm_summary": text})
templates/report.html — use inline CSS only (email clients strip <link> tags):
<h2>Daily Report: ${session_date}</h2>
<div>${llm_summary}</div>
Key patterns
timeout: 300on LLM calls —http>defaults to 30s which is insufficient. Always set 300+ for LLM Proxy, 3600 for TD Agentstore_last_results: trueexposes${td.last_results.*}— design the query to return exactly one rowstore_content: trueonhttp>stores the raw response in${http.last_content}${JSON.parse(http.last_content).content[0].text}extracts LLM text inline (Slack path, no py> needed)py>extraction needed for Mail path becausemail>templates cannot useJSON.parse()
Passing Query Results to LLM
store_last_results: true stores only the first row. For multi-row data, choose the right pattern:
| Pattern | When to use |
|---|---|
| Single row | KPI snapshot, aggregated metrics |
| SQL aggregation | Multi-row → one text column via array_join/listagg (no py> needed) |
| py> formatting | Large tables, complex formatting (markdown table, CSV) |
For detailed examples of each pattern: llm-patterns.md
LLM Summarize
Two options — always ask the user which to use:
| Option | Prerequisites | Best for |
|---|---|---|
| Raw LLM (TD LLM Proxy) | None — works with td.apikey |
Summarization, classification, |
Установить llm-workflow в Claude Code и Claude Desktop
Зарегайся, чтобы установить скилл
Создай бесплатный аккаунт, чтобы открыть команду установки и сохранить скилл в библиотеку.
- Открой команду установки в одну строку
- Сохраняй скиллы в синхронизируемую библиотеку
- Уведомления, когда скиллы обновляются
Разрешённые инструменты
Инструменты, которые скиллу разрешено вызывать.
Без ограничений — скилл может использовать любой инструмент.
Вложенные файлы
FAQ
Что делает скилл llm-workflow?
Use when building TD workflows that include LLM processing steps — data pipeline with LLM summarization, Slack/email notification, or any end-to-end automation. Covers patterns for query data, LLM analysis via TD LLM Proxy or TD Agent, and notification via Slack (Webhook/Bot API) or email. Also trigger on: LLM in workflow, workflow with Slack notification, automated report workflow, KPI summary pipeline, data-to-insight workflow.
Как установить скилл llm-workflow?
Скопируй папку скилла в ~/.claude/skills (вкладка Claude Code выше делает это одной командой), либо поставь как плагин.
Скилл llm-workflow запускает скрипты?
Нет, скилл состоит только из инструкций (SKILL.md), без исполняемых скриптов.
Похожие скиллы
docx
Use this skill whenever the user wants to create, read, edit, or manipulate Word documents (.docx files) or Word templates (.dotx files). Triggers include…
от AnthropicUse this skill whenever the user wants to do anything with PDF files. This includes reading or extracting text/tables from PDFs, combining or merging multiple…
от Anthropicxlsx
Use this skill any time a spreadsheet file is the primary input or output. This means any task where the user wants to: open, read, edit, or fix an existing…
от Anthropicpptx
Use this skill any time a .pptx or .potx file is involved in any way — as input, output, or both. This includes: creating slide decks, pitch decks, or…
от Anthropic