Scheduled Task Skill
Usage Scenarios
Use this skill when users want to:
- Set up tasks that run on a schedule (daily, weekly, monthly, custom cron)
- Create one-time tasks that run at a specific time
- Schedule automated checks, report generation, code backups, etc.
- Set up periodic monitoring or reminders
Creating Scheduled Tasks
Step 1: Gather Information
Confirm the following with the user (if not provided):
- Task name (required) — Short description
- Execution content (required) — The prompt/instructions Claude receives when the task runs
- Execution frequency (required) — One-time, daily, weekly, monthly, or custom cron
- Working directory (optional) — Defaults to current session working directory
- Notification platforms (optional) — Send notifications after task completion
Step 2: Build JSON and Execute API Call
Schedule Types
One-time execution (at):
{ "type": "at", "datetime": "2026-03-15T09:00:00" }
Cron expression (cron) — 5-field format: minute hour day month weekday
{ "type": "cron", "expression": "0 9 * * *" }
Common cron examples:
| Expression |
Meaning |
0 9 * * * |
Every day at 9:00 AM |
0 8 * * 1 |
Every Monday at 8:00 AM |
0 9 * * 1-5 |
Weekdays at 9:00 AM |
0 0 1 * * |
First day of month at midnight |
*/30 * * * * |
Every 30 minutes |
0 * * * * |
Every hour on the hour |
0 9,18 * * * |
Every day at 9:00 AM and 6:00 PM |
Create Task via API
Use the backend API to create scheduled tasks. The API endpoint should support the following payload structure:
{
"name": "Task name",
"schedule": { "type": "cron", "expression": "0 9 * * *" },
"prompt": "Detailed instructions Claude will execute when task runs...",
"workingDirectory": "/path/to/project",
"description": "Optional detailed description",
"systemPrompt": "Optional custom system prompt",
"executionMode": "auto",
"expiresAt": "2026-12-31",
"notifyPlatforms": ["dingtalk", "feishu", "telegram", "discord"],
"enabled": true
}
Field Descriptions
| Field |
Required |
Description |
name |
✅ |
Short task name |
prompt |
✅ |
Instructions Claude receives when task runs (should be clear and complete) |
schedule |
✅ |
Schedule configuration (see types above) |
workingDirectory |
❌ |
Execution directory (defaults to empty) |
description |
❌ |
Detailed description (defaults to empty) |
systemPrompt |
❌ |
Custom system prompt (defaults to empty) |
executionMode |
❌ |
"auto" / "local" / "sandbox" (defaults to "local") |
expiresAt |
❌ |
Expiration date "YYYY-MM-DD" (defaults to null, no expiration) |
notifyPlatforms |
❌ |
Notification platform array: ["dingtalk","feishu","telegram","discord"] (defaults to []) |
enabled |
❌ |
Whether to enable immediately (defaults to true) |
Step 3: Confirm Results
API returns JSON response:
- Success:
{ "success": true, "task": { "id": "...", "name": "...", ... } }
- Failure:
{ "success": false, "error": "error message" }
Confirm the following with the user:
- ✅ Task name and ID
- ⏰ Execution frequency (human-readable format, e.g., "Every day at 9:00 AM")
- 📋 Execution content summary
- 💡 Remind user they can manage tasks in Settings → Scheduled Tasks
Important Notes
Critical: Timezone Awareness: The system has a configured timezone (e.g., 'Asia/Shanghai'). ALWAYS get current time in THIS timezone for calculations. Using wrong timezone will cause schedules to fire at wrong times.
One-time vs Recurring Tasks: This is CRITICAL - ask yourself: does the user want this to happen once or repeatedly?
- One-time tasks (specific date/time mentioned like "明天下午5点去机场", "后天上午9点开会"): Calculate the EXACT date, use format
0 17 DD MM *, AND set max_calls: 1
- Recurring tasks (words like "每天", "每周", "each day", "every week"): Use standard cron like
0 17 * * *, do NOT set max_calls
- When in doubt, ask the user if this is a one-time or recurring task
Natural language time conversion: When users specify times like "下午5点/5 PM", "明天上午9点", "5分钟后", "this afternoon":
- Get current time in system timezone using a system command with TZ set (e.g.,
TZ=Asia/Shanghai date or Node.js with timezone)
- Calculate the exact target time based on current time in that timezone
- Convert to cron expression:
- "下午5点/17:00 每天" (recurring) →
0 17 * * * (no max_calls)
- "明天下午5点去机场" (one-time) → Calculate tomorrow's date, use
0 17 DD MM * + max_calls: 1
- "5分钟后" → Calculate target minute, use
MM HH * * * + max_calls: 1
- DO NOT interpret "5点" as "5 minutes" - "点" means "o'clock" in Chinese
Creation timing: For short-delay one-time tasks (e.g., "in 1 minute"), create the task immediately before performing any time-consuming operations. Don't fetch data or summarize content before creating the task.
Prompt boundaries: The prompt should describe "what to do when the task triggers", not pre-execute the task and embed static results. Example: write "Fetch yesterday's AI news and send summary" instead of fetching news first and embedding the list in the prompt.
Get current time (cross-platform):
node -e 'const d=new Date();const p=n=>String(n).padStart(2,"0");console.log(`${d.getFullYear()}-${p(d.getMonth()+1)}-${p(d.getDate())}T${p(d.getHours())}:${p(d.getMinutes())}:${p(d.getSeconds())}`)'
Auto-execution: Scheduled tasks run with auto-approve enabled for all tool calls (no manual approval needed)
Independent execution: The prompt is the only instruction Claude receives when the task runs independently, so write it clearly and completely
Auto-disable: Tasks that fail 5 consecutive times are automatically disabled
One-time tasks: Tasks with type: "at" are automatically disabled after execution
Execution sessions: Each execution creates a new session (with "[Scheduled]" prefix in title), viewable in the session list
1---2name: scheduled-task3description: Create scheduled tasks for recurring or one-time automated execution. Use when users want to set up tasks that run automatically at specified times (daily, weekly, monthly, cron, or one-time).4---56# Scheduled Task Skill78## Usage Scenarios910Use this skill when users want to:11- Set up tasks that run on a schedule (daily, weekly, monthly, custom cron)12- Create one-time tasks that run at a specific time13- Schedule automated checks, report generation, code backups, etc.14- Set up periodic monitoring or reminders1516## Creating Scheduled Tasks1718### Step 1: Gather Information1920Confirm the following with the user (if not provided):211. **Task name** (required) — Short description222. **Execution content** (required) — The prompt/instructions Claude receives when the task runs233. **Execution frequency** (required) — One-time, daily, weekly, monthly, or custom cron244. **Working directory** (optional) — Defaults to current session working directory255. **Notification platforms** (optional) — Send notifications after task completion2627### Step 2: Build JSON and Execute API Call2829#### Schedule Types3031**One-time execution (at):**32```json33{ "type": "at", "datetime": "2026-03-15T09:00:00" }34```3536**Cron expression (cron) — 5-field format: minute hour day month weekday**37```json38{ "type": "cron", "expression": "0 9 * * *" }39```4041Common cron examples:42| Expression | Meaning |43|--------|------|44| `0 9 * * *` | Every day at 9:00 AM |45| `0 8 * * 1` | Every Monday at 8:00 AM |46| `0 9 * * 1-5` | Weekdays at 9:00 AM |47| `0 0 1 * *` | First day of month at midnight |48| `*/30 * * * *` | Every 30 minutes |49| `0 * * * *` | Every hour on the hour |50| `0 9,18 * * *` | Every day at 9:00 AM and 6:00 PM |5152#### Create Task via API5354Use the backend API to create scheduled tasks. The API endpoint should support the following payload structure:5556```json57{58 "name": "Task name",59 "schedule": { "type": "cron", "expression": "0 9 * * *" },60 "prompt": "Detailed instructions Claude will execute when task runs...",61 "workingDirectory": "/path/to/project",62 "description": "Optional detailed description",63 "systemPrompt": "Optional custom system prompt",64 "executionMode": "auto",65 "expiresAt": "2026-12-31",66 "notifyPlatforms": ["dingtalk", "feishu", "telegram", "discord"],67 "enabled": true68}69```7071#### Field Descriptions7273| Field | Required | Description |74|------|------|------|75| `name` | ✅ | Short task name |76| `prompt` | ✅ | Instructions Claude receives when task runs (should be clear and complete) |77| `schedule` | ✅ | Schedule configuration (see types above) |78| `workingDirectory` | ❌ | Execution directory (defaults to empty) |79| `description` | ❌ | Detailed description (defaults to empty) |80| `systemPrompt` | ❌ | Custom system prompt (defaults to empty) |81| `executionMode` | ❌ | `"auto"` / `"local"` / `"sandbox"` (defaults to `"local"`) |82| `expiresAt` | ❌ | Expiration date `"YYYY-MM-DD"` (defaults to null, no expiration) |83| `notifyPlatforms` | ❌ | Notification platform array: `["dingtalk","feishu","telegram","discord"]` (defaults to `[]`) |84| `enabled` | ❌ | Whether to enable immediately (defaults to `true`) |8586### Step 3: Confirm Results8788API returns JSON response:89- Success: `{ "success": true, "task": { "id": "...", "name": "...", ... } }`90- Failure: `{ "success": false, "error": "error message" }`9192Confirm the following with the user:93- ✅ Task name and ID94- ⏰ Execution frequency (human-readable format, e.g., "Every day at 9:00 AM")95- 📋 Execution content summary96- 💡 Remind user they can manage tasks in Settings → Scheduled Tasks9798## Important Notes99100- **Critical: Timezone Awareness**: The system has a configured timezone (e.g., 'Asia/Shanghai'). ALWAYS get current time in THIS timezone for calculations. Using wrong timezone will cause schedules to fire at wrong times.101102- **One-time vs Recurring Tasks**: This is CRITICAL - ask yourself: does the user want this to happen once or repeatedly?103 - **One-time tasks** (specific date/time mentioned like "明天下午5点去机场", "后天上午9点开会"): Calculate the EXACT date, use format `0 17 DD MM *`, AND set `max_calls: 1`104 - **Recurring tasks** (words like "每天", "每周", "each day", "every week"): Use standard cron like `0 17 * * *`, do NOT set max_calls105 - When in doubt, ask the user if this is a one-time or recurring task106107- **Natural language time conversion**: When users specify times like "下午5点/5 PM", "明天上午9点", "5分钟后", "this afternoon":108 1. **Get current time in system timezone** using a system command with TZ set (e.g., `TZ=Asia/Shanghai date` or Node.js with timezone)109 2. **Calculate the exact target time** based on current time in that timezone110 3. **Convert to cron expression**:111 - "下午5点/17:00 每天" (recurring) → `0 17 * * *` (no max_calls)112 - "明天下午5点去机场" (one-time) → Calculate tomorrow's date, use `0 17 DD MM *` + `max_calls: 1`113 - "5分钟后" → Calculate target minute, use `MM HH * * *` + `max_calls: 1`114 4. **DO NOT** interpret "5点" as "5 minutes" - "点" means "o'clock" in Chinese115- **Creation timing**: For short-delay one-time tasks (e.g., "in 1 minute"), create the task immediately before performing any time-consuming operations. Don't fetch data or summarize content before creating the task.116- **Prompt boundaries**: The `prompt` should describe "what to do when the task triggers", not pre-execute the task and embed static results. Example: write "Fetch yesterday's AI news and send summary" instead of fetching news first and embedding the list in the prompt.117- **Get current time** (cross-platform):118 ```bash119 node -e 'const d=new Date();const p=n=>String(n).padStart(2,"0");console.log(`${d.getFullYear()}-${p(d.getMonth()+1)}-${p(d.getDate())}T${p(d.getHours())}:${p(d.getMinutes())}:${p(d.getSeconds())}`)'120 ```121- **Auto-execution**: Scheduled tasks run with auto-approve enabled for all tool calls (no manual approval needed)122- **Independent execution**: The `prompt` is the only instruction Claude receives when the task runs independently, so write it clearly and completely123- **Auto-disable**: Tasks that fail 5 consecutive times are automatically disabled124- **One-time tasks**: Tasks with `type: "at"` are automatically disabled after execution125- **Execution sessions**: Each execution creates a new session (with "[Scheduled]" prefix in title), viewable in the session list