GitHub Copilot CLI can schedule prompts with /every and /after inside live sessions or via cron using copilot -p. Build reliable loops. Read now.
What scheduled prompts do in Copilot CLI
GitHub Copilot CLI can run prompts on a schedule instead of only when you type them. Two session-level controls matter most: /every and /after. Use /every when a task should repeat on a fixed interval while the session stays open—status checks, log skims, or “is the build still green?” style loops. Use /after when the next prompt should wait for a delay once, such as giving a deploy or long test run time to finish before you ask for a summary.
Both commands live inside an active session. They keep the agent in the loop without you babysitting the terminal, but they still depend on that session remaining alive. If the shell exits, the schedule exits with it. That distinction drives how you choose between interactive scheduling and headless automation.
Live sessions vs cron with copilot -p
Inside a live session, /every and /after are ideal for work you are already watching. You can adjust wording mid-stream, cancel a loop, or add follow-up context when output looks wrong. The tradeoff is continuity: laptop sleep, network drops, or closing the terminal stop the schedule. Treat live scheduling as a working-session tool, not a overnight job runner.
For unattended runs, pair your system scheduler with non-interactive invocation via copilot -p. Cron (or an equivalent timer) starts a fresh CLI process, passes a single prompt, and exits when the turn completes. You own the cadence in the crontab; Copilot owns the reasoning for that one shot. This pattern is better for nightly reports, recurring repo audits, and anything that must survive logout. Keep prompts self-contained—assume no chat history, no prior tool state, and no human to clarify intent.
Building loops that stay reliable
Reliable automation is less about clever prompts and more about clear boundaries. Each scheduled run should answer a narrow question, write durable output (a file, a comment, a log line), and fail loudly when prerequisites are missing. Prefer idempotent work: scanning the same branch twice should not create duplicate noise or conflict with itself. If a step needs secrets or repo access, configure those outside the prompt so a cold start can succeed.
- Scope one job per schedule entry; chain jobs by reading prior artifacts, not by stuffing multi-hour workflows into a single prompt.
- Pin working directory and environment in the wrapper script so cron and interactive runs behave the same.
- Cap verbosity: ask for structured summaries or diffs, not full dumps that bury signal.
- Decide what “done” means—exit codes, empty findings, or a written report—and check that condition after each run.
When you need both styles, use live /every and /after while iterating on the prompt, then promote the stable wording to a cron-driven copilot -p job. That path turns exploratory loops into something you can leave running without watching the session.
Practical defaults to start with
Start with a short interval only while validating behavior, then lengthen it once the prompt is trustworthy. For one-shot follow-ups after a long command, /after is enough; for continuous monitoring in a session you already have open, /every is the right lever. Outside the session, let cron define time and let each copilot -p call be a clean unit of work with an explicit path to results. Build the loop around repeatable inputs and inspectable outputs, and scheduled prompts become a reliable part of your day-to-day tooling instead of a fragile side process.