[FEATURE] Scheduled tasks: skip the run when a cheap check finds nothing to do
Preflight Checklist
- [x] I have searched existing requests and this feature hasn't been requested yet
- [x] This is a single feature request (not multiple features)
Problem Statement
Many scheduled tasks are watchers: check whether something changed, act only if it did. Most of their runs find nothing, and each of those still starts a full Claude Code session, spends the tokens to load the prompt and run the check, and leaves an unread marker in the desktop app for a run that did nothing.
The run can't clean up after itself either. The sidebar tools refuse in scheduled runs ("Sidebar tools are unavailable in unattended sessions"), and archive_session on its own session always asks for permission, which nobody is there to give (#94418 describes the same dead end).
#74547 asks for this kind of gate on CronCreate, where every fire lands in one growing session. This is the desktop app's scheduled tasks in ~/.claude/scheduled-tasks/, where each run is a fresh session, so the cost per run is flat but every empty run still costs a session and shows up unread.
Proposed Solution
Let a scheduled task carry a small script that runs before the session and decides whether it starts at all. If there is nothing to do, no session is created.
This looks already built. Desktop 2.7032.0 ships unlisted start_watching/stop_watching tools on the scheduled-tasks server, a watcher field on the task (scriptPath, scriptSha256, mcpTools, fireThreshold, lastCursors), and a runWatcherGate() that skips dispatch below the threshold. The script is pinned by hash, and a changed one has to be approved again through start_watching. The gate never runs, since the Cowork scheduler is created with watchersEnabled: () => false and the Code tab's scheduler doesn't pass it at all.
Alternative Solutions
- Turning off
notifyOnCompletiononly drops the ping, the empty session and its cost stay - An external cron job that starts
claude -ponly when needed works, but the run is then no longer a scheduled task in the app, with its history and permissions
Priority
Medium - Would be very helpful
Feature Category
Other
Use Case Example
- A scheduled task runs twice a day and checks the GitHub issues and PRs I filed for new activity
- Most days nothing moved, and the run ends with "No new activity"
- With a watcher, that check is one
ghcall and no session starts - When something did move, the task runs as it does today
Additional Context
Claude Code 2.1.280, Claude desktop 2.7032.0, macOS 26.5.1