Guide · Grok Build
Keep Grok Build running after you close your laptop
You start a long Grok Build task, close the lid, and come back to a frozen terminal. This guide explains why that happens, what tmux does and does not fix, and two setups that keep the agent working while you are away.
The short answer
Run Grok Build on a computer that does not sleep: a desktop, a mini PC, a home server or a small VPS. Your laptop then becomes a window into that machine instead of the place where the agent lives. Closing it, losing Wi-Fi or switching to your phone no longer stops the task.
Why closing the lid stops the agent
- On macOS, Windows and most Linux desktops, closing the lid suspends the computer. Every process stops, including
grok. - The agent also needs the network to reach the model. A sleeping laptop has none.
- Keeping the laptop awake with the lid shut works for a short run while it is plugged in, but not in a bag, on battery or through a reboot.
What tmux fixes, and what it does not
tmux keeps a terminal session alive when your SSH connection drops or you close the terminal window, because a background server owns the session. That is exactly the right tool for a flaky connection. It does not help if tmux is running on the laptop itself: when the laptop sleeps, tmux sleeps with it. tmux only solves the closed-lid problem when it runs on another machine that stays on.
Option 1: SSH and tmux on a server
This is the do-it-yourself setup and needs nothing beyond a Linux server and a terminal.
- Install Grok Build on the server with xAI's installer, then sign in without a browser on that machine:
It prints a link and a code. Open the link on any device, enter the code, and the server is signed in.grok login --device-auth - Start Grok Build inside a named tmux session in your project folder:
tmux new -s grok grok - Detach with Ctrl-b then d. Close the laptop. The task keeps running on the server.
- Later, from any computer, reattach:
ssh you@your-server -t tmux attach -t grok
It works, but you live in a terminal: copy and paste through SSH can be fiddly, reviewing diffs means more commands, and using it from a phone means an SSH app and a tiny keyboard. You also keep SSH open to the internet, so use key-only logins.
Option 2: AgentPort, Grok Build in your browser
AgentPort runs Grok Build on your own computer or VPS inside a Docker container and gives you a chat for it in any browser. The agent's session lives on the server, so closing the laptop does nothing to it.
- Sign in to AgentPort, click Add machine, and copy the one-line install command.
- Paste it on the server (it needs Docker). It opens a secure outbound link, so you do not open any ports.
- In the computer's settings, go to AI Model and sign in to Grok with the same short-code flow.
- Start a chat, give Grok the task and close the laptop. Open AgentPort later on any device and the chat shows everything the agent did.
Compared with tmux, you get chat history that survives reloads and device switches, approval cards you can tap from a phone, several chats at once grouped by project, and a Changed tab with a diff per file. Step-by-step setup: Run Grok Build on your VPS.
Which machine should run it?
- A small VPS is always on and reachable. Two CPU cores and 4 GB of memory is a comfortable start for one agent plus a typical web project.
- A desktop or mini PC at home costs nothing extra if you already have one. Set it to never sleep.
- A Mac that stays on works too, as long as Docker Desktop is running and sleep is turned off.
Running unattended safely
- Work in a git repository, ideally on a branch, so every change is easy to review and undo.
- Keep the server for code and the tools the agent needs, not your personal accounts.
- Use a mode that asks before risky steps when you will not be watching closely, and read the diff before you push.
FAQ
Does Grok Build keep running if my SSH connection drops?
Only if it runs inside tmux or screen on the server. Without them, the session ends with the connection. With AgentPort, the agent runs in the server's container and does not depend on your browser staying connected.
Can I check on Grok Build from my phone?
Yes. With tmux you need an SSH app. With AgentPort you open the site in your phone's browser; see Use an AI coding agent from your phone.
Does AgentPort see my code?
No. Your browser connects straight to your server. AgentPort's cloud handles sign-in and the list of your computers.
Try it on your own computer
The Free plan covers 1 computer. Pro is $27/month for up to 3. You bring the AI login and pay that provider directly.