#11221: cli: add schedule subcommand (local-first command scheduler)
docs
cli
stale
Cluster:
Cron Enhancements and Fixes
Adds a new CLI (add/list/remove/run-now) with local-first persistence (schedule.json + schedule-runs.jsonl), overlap locks, and no-shell execution. Includes docs at docs/cli/schedule.md and unit tests (vitest) for store + lock.\n\nMotivation: make recurring kit workflows easy/portable, with standardized run logs for future UI/alerts.\n\nNotes: This is a best-effort contribution; happy to iterate if maintainers want tweaks.
<!-- greptile_comment -->
<h2>Greptile Overview</h2>
<h3>Greptile Summary</h3>
This PR introduces a new `openclaw schedule` subcommand group (add/list/remove/run-now) backed by local-first persistence in `~/.openclaw/schedule.json` and an append-only run log (`schedule-runs.jsonl`). It adds a simple per-job lock file mechanism to prevent overlapping runs and runs commands via `spawn(..., { shell: false })`.
Main areas touched:
- CLI registration (`src/cli/program/register.subclis.ts`, `src/cli/schedule-cli/**`)
- Scheduling core: types, store (load/save/add/remove/get), run logging, and lock handling (`src/schedule/**`)
- New docs and vitest unit tests for store/lock.
Two correctness issues need addressing before merge (see inline comments): JSON mode can hang for chatty commands due to undrained stdio pipes, and the commander option collectors can throw when `prev` is undefined.
<h3>Confidence Score: 3/5</h3>
- This PR is close to mergeable but has two runtime edge cases that can break `schedule` usage.
- Core logic is straightforward and covered by basic unit tests, but the current implementation can hang in `run-now --json` for commands with large output and can throw at runtime when parsing repeatable options depending on commander behavior.
- src/schedule/run.ts, src/cli/schedule-cli/register.schedule-add.ts
<!-- greptile_other_comments_section -->
<sub>(2/5) Greptile learns from your feedback when you react with thumbs up/down!</sub>
<!-- /greptile_comment -->
Most Similar PRs
#11227: cli: add reflect add/list/show (local JSONL reflections)
by itskai-dev · 2026-02-07
84.7%
#22764: docs: comprehensive cron system study for portability reference
by Ahsd-digital · 2026-02-21
73.9%
#14430: Cron: anti-zombie scheduler recovery and in-flight job persistence
by philga7 · 2026-02-12
72.8%
#13988: feat(backup): add backup/restore CLI with local + S3 storage
by n24q02m · 2026-02-11
72.7%
#10367: CLI/Ops: resilient browser fill + failover hardening + operations t...
by cluster2600 · 2026-02-06
72.5%
#20561: feat: add Sisyphus-style orchestration features
by dfggggx198601 · 2026-02-19
72.2%
#18179: CLI: add sessions --json-debug diagnostics
by p6l-richard · 2026-02-16
71.8%
#13168: perf: short-circuit --version to skip process respawn and full modu...
by RamiNoodle733 · 2026-02-10
71.7%
#11159: fix(cli): parse --profile flag after subcommand name
by hclsys · 2026-02-07
71.5%
#6730: feat: Make OpenAI Codex CLI models usable - reasoning effort directive
by levineam · 2026-02-02
71.3%