GitHub Copilot CLI schedules prompts with /every and /after inside live sessions; build safer cron loops, logging, and checks. Full breakdown.
What /every and /after actually do
GitHub Copilot CLI can schedule prompts from inside a live session with two simple ideas: run something on a repeating interval, and run something once after a delay. /every keeps a prompt on a loop while the session stays open. /after queues a one-shot follow-up so you do not have to sit and wait for a long task to finish before the next step starts.
That matters because scheduling lives inside the session, not outside it. If the session ends, the schedule ends with it. Treat these commands as in-process helpers for work you already own in that terminal, not as a replacement for a system scheduler that must survive restarts, logouts, or machine sleep.
Safer loops beat clever loops
Repeating prompts invite the classic cron failure mode: a second run starts before the first finishes, or a failed run leaves state half-applied and the next cycle makes it worse. Design every scheduled prompt as if it might overlap, fail mid-way, or run twice by accident.
- Make the work idempotent: re-running should not double-apply changes or spam the same action.
- Guard with a lock or a “busy” check so a long run skips the next tick instead of stacking jobs.
- Bound scope tightly: one clear task per schedule, not a chain that grows with each success.
- Fail closed: if a precondition is missing, exit early with a clear reason instead of improvising.
Prefer short, single-purpose prompts over multi-step agents that “figure it out.” A narrow prompt is easier to log, reason about, and stop when something looks wrong.
Logging and checks you can trust
If you cannot tell what ran, when it ran, and whether it finished cleanly, you do not have automation—you have a roulette wheel. Write a short status line on every cycle: timestamp, prompt label, start/end, success or failure, and any path or identifier the job touched. Keep logs append-only and easy to grep so a bad night of runs is still reconstructable in the morning.
Pair logging with cheap preflight checks. Confirm the session still has the context you need, the working directory is correct, required tools respond, and any output target is writable. After the prompt, verify a concrete outcome: expected file present, command exit status non-zero only when it should be, or a marker file updated. Checks turn vague “it seemed fine” into a pass/fail you can automate around.
When to use session schedules vs real cron
Use /every and /after for interactive workflows: poll a long job, nudge a multi-step repair while you watch the terminal, or space out follow-ups so you stay in flow without babysitting. Keep the human in the loop when the action can change production systems or write irreversible data.
Reach for a real system scheduler when the job must run unattended, survive session exit, or run on a fixed wall-clock cadence regardless of who is logged in. The durable pattern is still the same: small units of work, locks against overlap, explicit logs, and post-run checks. Scheduled prompts done right are boring on purpose—predictable intervals, clear ownership of state, and an easy kill switch when the loop stops earning its keep.