docs/sdk/guides/scheduled-agents.mdx
The SDK supports running agents on cron schedules. Scheduled agents persist across process restarts and run independently of any client application.
Scheduled agents rely on the hub-spoke architecture that is part of ClineCore. The hub runs as a background process on your machine. It starts automatically when needed and persists schedules across restarts.
import { ClineCore } from "@cline/sdk"
const cline = await ClineCore.create({
clientName: "scheduler",
automation: true,
})
await cline.automation.start()
// Use cline.automation to reconcile specs, ingest events, and list runs.
An easy way to schedule task is to use Cline CLI for scheduling task, if you've already installed via npm i -g cline
Run cline schedule to open an interactive menu for creating and managing schedules, browsing execution history, and viewing performance statistics.
# Daily at 9 AM on weekdays
cline schedule create "PR summary" \
--cron "0 9 * * MON-FRI" \
--prompt "List all open PRs, their review status, and any that have been open more than 3 days" \
--workspace /path/to/repo \
--model anthropic/claude-sonnet-4-6
# Every 6 hours
cline schedule create "Health check" \
--cron "0 */6 * * *" \
--prompt "Run the test suite and report any failures" \
--workspace /path/to/project
# Monday mornings
cline schedule create "Weekly digest" \
--cron "0 8 * * MON" \
--prompt "Summarize last week's commits, PRs merged, and issues closed"
# List all schedules
cline schedule list
# Trigger a schedule immediately (without waiting for cron)
cline schedule trigger <schedule-id>
# Pause a schedule
cline schedule pause <schedule-id>
# Resume a paused schedule
cline schedule resume <schedule-id>
# Delete a schedule
cline schedule delete <schedule-id>
# View execution history
cline schedule executions <schedule-id>
| Expression | Schedule |
|---|---|
0 9 * * MON-FRI | 9 AM, Monday through Friday |
0 */6 * * * | Every 6 hours |
0 8 * * MON | 8 AM every Monday |
30 17 * * * | 5:30 PM every day |
0 0 1 * * | Midnight on the 1st of each month |
*/30 * * * * | Every 30 minutes |
cline schedule create "Standup prep" \
--cron "0 8 * * MON-FRI" \
--prompt "Summarize: (1) PRs merged yesterday, (2) PRs currently in review, (3) open issues assigned to team members. Format as a brief standup update." \
--workspace /path/to/repo
cline schedule create "Dependency check" \
--cron "0 10 * * MON" \
--prompt "Check for outdated npm dependencies. For any with security vulnerabilities, create a branch with the update and open a PR." \
--workspace /path/to/project
cline schedule create "Code health" \
--cron "0 6 * * MON" \
--prompt "Analyze the codebase for: (1) files with no test coverage, (2) TODO/FIXME comments older than 30 days, (3) functions longer than 100 lines. Produce a health report." \
--workspace /path/to/project
The scheduler enforces limits to prevent resource exhaustion:
Combine scheduled agents with connectors in CLI to route results to messaging platforms:
# Start a Telegram connector
cline connect telegram -m my_bot -k $BOT_TOKEN
# Schedule an agent whose output gets sent to Telegram
cline schedule create "Morning briefing" \
--cron "0 8 * * *" \
--prompt "Summarize overnight activity in the repo"