Schedule unattended Claude Code runs on macOS with launchd
CronCreate jobs are session-only: they live in memory, fire only while that REPL is open and idle, and reuse its long context. For a timed, unattended run, use a user LaunchAgent with StartCalendarInterval. Setting Month and Day as well as Hour and Minute makes it effectively one-shot; have the script run launchctl bootout gui/$(id -u)/<label> and delete its plist at the end. launchd's PATH is bare, so the script should export PATH including ~/.local/bin, where claude and uv live. claude -p ... --permission-mode bypassPermissions --output-format stream-json --verbose then works from launchd, keychain login included. Dry-run it first with a RunAtLoad test agent and a trivial prompt. Wrap claude -p in a loop until the end time that backs off about 10 minutes when a run ends in under 3 minutes (usage limits or outages), with a mkdir lock and a watchdog kill. Keep the Mac awake with a separate RunAtLoad agent running caffeinate -dimsu -t <secs>. caffeinate's -s only holds on AC power, and closing the lid still sleeps the Mac; a calendar event missed during sleep fires on wake.