How to schedule Grok Build: /loop, grok -p in cron and CodeAgentSwarm
By CodeAgentSwarm · Updated October 31, 2026
/loop, which runs a prompt now and then again on an interval, and loops expire after 7 days. For a job pinned to 08:00 every weekday that keeps going, use cron with grok -p or CodeAgentSwarm Scheduled Conversations.Can Grok Build run on a schedule?
- Repeat something for a while:
/loop 30m <prompt>. - At set times, week after week: cron with
grok -p, or CodeAgentSwarm.
Grok Build /loop
/loop "runs a prompt on a recurring interval". The interval takes Ns (minimum 60), Nm, Nh or Nd; the prompt fires immediately and then repeats, each firing as a new agent turn. Loops expire after 7 days and at most 50 scheduled tasks can be active at once. Grok Build background tasks
xAI also notes that /loop is one of the commands that appear only when their feature is available. Modes and commands
A Grok Build cron job with grok -p
# crontab -e: weekdays at 09:00
0 9 * * 1-5 cd ~/code/my-app && grok -p "Review yesterday's commits and flag risky changes." --output-format plain >> ~/logs/grok-cron.log 2>&1Output formats are plain, json or streaming-json. Scripts can authenticate with XAI_API_KEY, and --no-auto-update skips background update checks. The Grok Build headless guide covers the flags in detail. xAI headless docs
Schedule Grok Build in CodeAgentSwarm
- Open Scheduled in the top bar and press New schedule. Or type the prompt in a Grok Build Chat and pick Schedule this prompt… from the send menu.
- Pick the Project and choose Grok Build as the agent. Model, reasoning and permissions are optional: leave them on Default or set them like in the Chat composer.
- Write the prompt the agent should run every time.
- Under When, choose At set times (up to 24 a day), Every few hours (1, 2, 3, 4, 6, 8 or 12) or When I run it, and the days.
- Choose Visible (opens a Chat) or Headless (no tab, result in Scheduled), and whether each run continues the same conversation or starts a new one. Press Create schedule.

Prompts worth scheduling with Grok Build
- Every weekday at 09:00: review yesterday's commits and flag anything that needs a second look.
- Every 4 hours: run the tests and explain new failures, without editing files.
- Sundays at 11:00: update the README sections that no longer match the code, and show the diff.
What happens on each run
- With Continue the same conversation, a visible run goes to the Grok Build agent that already holds the conversation, and never opens a second copy. With Start a new conversation, each run opens a fresh agent. If it is busy, Skip if still working (on by default) skips that slot; turn it off and the prompt waits in the queue.
- The Chat marks every scheduled run, so you can tell your own messages from the scheduled ones and reply to a run like any other message.
- If CodeAgentSwarm was closed or the computer asleep at the set time, If missed, run when the app opens runs it once, late. A week away gives one run, not seven.
- Schedules run on your computer, so CodeAgentSwarm has to be open. Your phone can list, edit and run them from the Scheduled tab.
FAQ
Is /loop in Grok Build a cron job?
Not quite. It runs a prompt now and then on an interval of at least 60 seconds, and loops expire after 7 days. It is not pinned to clock times.
How do I run Grok Build from cron?
Add a crontab line that changes to the project and runs grok -p with your prompt. XAI_API_KEY and --no-auto-update help for unattended runs.
Can I schedule Grok Build on Windows?
Yes. CodeAgentSwarm schedules work the same on macOS, Windows and Linux, so you do not need Task Scheduler.