Agent skill
schedule-task
Use when the user wants to create, set up, or configure a scheduled task in Treasure Studio. Covers TASK.md authoring, schedule.yaml configuration, script creation, and direct file-based task setup. Triggers on "create a scheduled task", "set up a recurring job", "automate daily report", "schedule a task", "cron job", etc.
Install this agent skill to your Project
npx add-skill https://github.com/treasure-data/td-skills/tree/main/studio-skills/schedule-task
SKILL.md
Schedule Task Creator
Create scheduled tasks in Treasure Studio that mix deterministic script execution with agent-driven analysis and delivery.
Task Directory Placement
Determine where to create the task based on your current working directory:
-
If inside a workspace: find the nearest ancestor directory (including the current one) that contains a
tdx.jsonfile and at least one ofgoals/oritems/folders. That directory is{workspace}.- Create under
{workspace}/schedules/{task-name}/ - Workspace context (accepted guides, goals) is automatically available at execution time
{workspace}becomes the working directory during execution
- Create under
-
Otherwise (standalone):
- Create under
~/.tdx/schedule-tasks/{task-name}/
- Create under
Workflow
CRITICAL: Never just create files and stop. Always run the task and iterate until it works.
- Capture Intent — What to automate, how often, what tools/data needed, where results go
- Ask the user for output format (Slack message, CSV, HTML report, etc.) and notification channels before creating files. Never assume a Slack channel — always confirm.
- Create the Task — Write files to the appropriate directory (workspace or standalone, see above)
- Validate — Run
schedule_validateto check schedule.yaml - Reload — Run
schedule_reloadto pick up new/changed tasks - Review — Load the
schedule-reviewskill and run a full review (structure + quality checks in parallel) - Fix Issues — Address any findings from the review
- Test Run — Run
schedule_runto execute immediately - Check Results — Use
schedule_resultsto review output.md and check for errors - Fix & Retry — If the run failed or output is wrong, edit the files and repeat from step 4
- Enable — Only after a successful test run, use
schedule_enableto activate the cron schedule
Steps 5-8 are mandatory — a task is not complete until it has been reviewed and executed successfully at least once.
Task Directory Structure
{task-dir}/
├── TASK.md # Instructions (frontmatter + markdown body)
├── schedule.yaml # Cron schedule, permissions, notifications
├── scripts/ # Deterministic scripts (bash, python, etc.)
├── reference/ # Immutable reference files (templates, specs, configs)
├── data/ # Persistent data across runs (snapshots, state, caches)
└── results/{run_id}/ # Auto-created per execution (pruned over time)
├── metadata.json # System-managed run metadata
└── output.md # Execution summary (REQUIRED — agent writes this)
Create the directory and files directly using Write/Bash tools. The system will pick them up after schedule_reload.
TASK.md Anatomy
YAML frontmatter with name and description, followed by markdown instructions:
---
name: daily-sales-report
description: Fetch sales data, analyze trends, and post to Slack
---
## Steps
1. Run `bash scripts/fetch-sales-data.sh` to download data
2. Analyze the CSV: revenue, order count, top products
3. Compare with previous run (check results/ for yesterday's output.md)
4. Write results/{run_id}/output.md with findings
5. Post summary to Slack, attach chart via slack_upload_file
## Data Files
- `data/previous-metrics.csv` — Yesterday's metrics for trend comparison. Update after analysis.
## Notes
- Revenue thresholds: flag if daily total < $10K
- Use reference/report-template.html for formatting
- If fetch script fails, retry once then report the error
Additional sections (## Notes, ## Constraints, ## Data Files, ## Output Format, etc.) are welcome. The run_id is provided to the agent automatically in the prompt.
Do NOT write Slack channel names or notification targets in TASK.md. Notification channels are configured in schedule.yaml (notify.on_success / notify.on_failure) and injected into the prompt automatically at execution time. Writing them in TASK.md causes conflicts when the yaml is updated.
Using data/ for Cross-Run State
data/ persists across runs (unlike results/ which is pruned). When a task uses data/, describe the files and their purpose in TASK.md under a ## Data Files section.
schedule.yaml Format
name: daily-sales-report
schedule: "0 9 * * 1-5"
enabled: false
status: configured # "configured" = ready to run, "template" = needs customization
catch_up: false # true = run missed schedule once on next Studio startup
skills:
- sql-skills:trino
permissions:
allow:
- Bash
- Write
- slack_post_message
- slack_upload_file
notify:
on_success: slack:channel-name # or "slack:dm" for DM
on_failure: slack:channel-name # or "slack:dm" for DM
context:
max_turns: 20
timeout: 600
autonomous: false # true = Supervisor Agent auto-continues until task complete
Task name: lowercase, hyphens/underscores only, max 64 chars. Minimum cron interval: 5 minutes.
Workspace-Only Fields
These fields are only meaningful for tasks inside a workspace schedules/ directory:
# Target Goal — agent scopes work to this goal's linked items
goal: auth-redesign
# Workspace skill to invoke (different from `skills` which lists capability packs/MCP tools)
skill: weekly-review
# Output configuration — create a Note from execution results
output:
note: true # Create a Note in workspace notes/ from output.md
note_tags: [weekly, auto] # Tags added to the auto-created Note
When goal is set, the agent receives the goal content and linked item statuses in its prompt. When output.note: true is set, a Note is automatically created in the workspace's notes/ folder after successful execution.
Status Field
configured— Task is ready to run. Use this when creating a task specific to the user's environment.template— Task is a reusable template that needs customization before enabling. Use this when the user wants to create a shareable template with placeholder values (e.g.,GITHUB_REPO,SLACK_CHANNEL) that others will customize later.
Tasks with status: template should not be enabled directly. First customize them and change status to configured before enabling.
Notification targets: use slack:channel-name for a Slack channel, or slack:dm for the user's DM. Always use slack:dm exactly — not "direct message", "DM", or other variations.
MCP Tools
| Tool | Purpose |
|---|---|
schedule_list |
List all tasks with status |
schedule_get |
Full task details including TASK.md and recent results |
schedule_validate |
Validate schedule.yaml against schema |
schedule_reload |
Reload tasks from disk (after creating/editing files) |
schedule_run |
Trigger immediate execution (for testing) |
schedule_results |
View past run summaries and output files (optional limit, default 10) |
schedule_enable / schedule_disable |
Toggle task on/off |
schedule_delete |
Remove task and all files |
Recommended Agent Skills
Expand your agent's capabilities with these related and highly-rated 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.
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.
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.
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.
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.
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.
Didn't find tool you were looking for?