Agent self scheduling

From Matymatyk-business/david-skills · View interactive version

Agent self scheduling is an AI agent skill from the GitHub repository Matymatyk-business/david-skills. How to make an AI coding agent run on a schedule, loop, or interval — cron jobs, heartbeats, self-starting/self-terminating loops, recurring autonomous checks. Use when the user asks to "run every N minutes/hours", "check something on a regular interval", "schedule a task", "run on a loop", "self-st

How to use this skill

Skill file

Agent Self-Scheduling

Make an agent run periodically. First question: does the agent have a built-in scheduler, or do you own the clock?

Decision: pick the camp first

Universal floor: ALL cron is 1 minute (5-field expr, no seconds) — every camp. For sub-minute / sub-second you MUST use a dumb while ...; sleep N; done loop, a TS extension, or a webhook/event hook. Never put an LLM on a tight timer.


Camp A — One-shot agents, you own the clock

These run once and exit (amnesiac unless resumed). You schedule them externally.

One-shot invocations:

claude -p "PROMPT" --output-format json --allowedTools "Read,Edit,Bash"  # Claude Code
codex exec --json "PROMPT"                                                # Codex
pi run "PROMPT"                                                           # Pi.dev (Mario Zechner; MIT; read/write/edit/bash + TS SDK)

Wrap in a clock — three options:

# 1. cron (>= 1 min). Floor is 1 minute, 5 fields, NO seconds.
*/10 * * * * cd /path/to/project && pi run "check X and report" >> ~/agent.log 2>&1

# 2. systemd timer (Linux, survives reboot, better logging) — OnUnitActiveSec=10min

# 3. dumb loop (sub-minute, or when cron unavailable)
while true; do pi run "check X"; sleep 30; done

Camp A gotchas (all three break unattended runs if ignored):

Pi specifics: Pi has NO built-in loop/scheduler/heartbeat by design — only the agent reasoning loop (not time-based). OpenClaw's runtime is built ON Pi but is a separate project. To schedule Pi: external cron/systemd, a while-sleep loop, or a TS extension for agent-side timers.

cmux (orchestration layer — NO scheduler)

cmux has NO scheduler/timer/watch/cron. It is visibility + orchestration only. Primitives: list-workspaces, read-screen (non-interruptive — safe to poll), send. An MCP wrapper cmux-agent-mcp exists.

Three ways to make cmux loop:


Camp B — Hermes (built-in scheduler daemon)

Hermes ships a gateway that ticks every 60s and runs due jobs in fresh, isolated sessions. No external cron needed.

State-check first — is the gateway running?

hermes gateway install            # user-level
hermes gateway install --system   # survives reboot (boot-time)

Create jobs (CLI or /cron add in TUI):

hermes cron create "every 1h" "summarize new emails and report" --skill himalaya
hermes cron create "0 9 * * *" "post daily standup"      # cron expr
hermes cron create "30m" "one-shot reminder in 30 min"   # one-shot delay

Schedule formats: one-shot delays (30m, 2h), recurring (every 30m, every 1d), cron (0 9 * * *), ISO timestamps.

Hermes-unique capabilities:


Heartbeat pattern (proactive self-check)

A heartbeat = a fast recurring tick that gates slower per-task checks, so one loop handles many intervals at different cadences.


Verify it actually fires (do this before reporting success)

  1. Camp A: check the log file grows after one interval, or run the wrapped command once by hand and confirm clean JSON exit (0).
  2. Camp B: hermes cron list shows the job; check next_run; trigger once with a run-now to confirm it executes and delivers.
  3. Confirm permissions/sandbox flags are present (Camp A) — the #1 silent failure is a hung permission prompt.
  4. For heartbeats, confirm a tick with nothing-due stays silent (no spam).

Pitfalls

Use this skill with your AI agent: Open on Skill Issue to copy, download, or add to your library. Works with Claude, ChatGPT, Gemini, Cursor, Windsurf and more.