Every agent's branch gets its own dev server and port, reloading as the agent codes. Access them via private link from a browser or your phone.
Run a dev server for each branch on a remote nil machine, and share each one at its own nil.invalid link. Guide: https://nil.invalid/guides/remote-dev-servers First, tell me in a sentence or two what you're about to do. Then ask me about each of these, one at a time, with a suggested default: - Branches (the branches to preview) - Machine (your dev box or another remote machine to run them on) - Checkout (the repo's folder on that machine, if it has one) - Dev server command (check package.json, e.g. npm run dev) Skip any I've answered. Then sum up the plan in three bullets and wait for me to confirm it. My answers override the steps below. If a wait times out, wait again, up to three times. If a step fails, stop and tell me what you saw. Don't open firewall ports, send localhost links, or share ports I didn't ask for. Leave work in progress alone: don't stash, reset, or switch branches in any folder. 1. Check what's needed first. If `nil connect status` shows remote access off, ask me to turn on nil connect in Settings. If `nil machine list` doesn't show the machine, run `nil terminal create --thread "$NIL_THREAD_ID" --title "Add machine" --command "nil machine create --provider manual"`, take the install command from `nil terminal output <terminal-id>`, and run it on the machine over SSH, or send it to me if you can't reach it. If the machine is a container dev environment without systemd, like Codespaces, Coder, Ona, Cloud Workstations, or an in-house container, tell me to raise its idle timeout and to add `curl -sSL <my nil address>/install.sh | sh -s -- --start --host-id <machine-id>` to its startup script, so nil comes back when it restarts. 2. Each server runs from what's committed on its branch. If a branch I named has uncommitted or unpushed changes, here or in my checkout, tell me and ask whether to commit and push them first or skip that branch. 3. If `nil project show "$NIL_PROJECT_ID"` has no source on the machine, run `nil project source add "$NIL_PROJECT_ID" --path <checkout> --machine <machine>` for my existing checkout, or `nil project source add "$NIL_PROJECT_ID" --clone --machine <machine>` if there isn't one. 4. For each branch, start a thread on the machine that starts its own server, all at once: nil thread spawn --json --project "$NIL_PROJECT_ID" --machine <machine> --new-environment worktree --base-branch <origin/branch, or the local branch if there's no remote> --title "<branch>" --prompt "Install dependencies if they're missing, then start this branch's dev server. Pick a free port, save it as WEB_PORT in .env.local (don't commit it), and run <dev server command> with HOST=127.0.0.1 and PORT set to that port in a nil terminal titled Dev server. Don't change the app's code. Reply with the port once it's listening, or with the error." 5. Wait for each thread with `nil thread wait` and read its port with `nil thread output`. 6. Share each port with `nil connect expose <port> --host <machine>`, and check that `nil connect shares --host <machine>` lists them all. Reply with a table of branch, port, and link. Then offer to save these steps as a nil skill in .nil/skills/preview-branches/SKILL.md, with my machine and dev server command filled in, so next time I can just ask for it.
Run servers on a dev box, a remote machine you already develop on. nil keeps it connected through reboots and updates.
gh auth login so they can push and open pull requests.Point nil at the checkout already on your dev box, and give every branch its own ports.
Then commit a setup script at the repo root. nil runs it in every new worktree, so each branch installs its dependencies and picks free ports. Here's an example for a pnpm project; change the install command and ports to fit yours:
#!/usr/bin/env bash
set -euo pipefail
pnpm install
free_port() { node -e 'const s=require("net").createServer().listen(0,"127.0.0.1",()=>{console.log(s.address().port);s.close()})'; }
printf 'WEB_PORT=%s\nAPI_PORT=%s\n' "$(free_port)" "$(free_port)" > .env.localEach thread gets its own worktree on the machine, so servers never step on each other.
A nil terminal runs in the thread's worktree and keeps going after you close the tab.
$ set -a; . ./.env.local; set +a $ pnpm dev --host 127.0.0.1 --port "$WEB_PORT"
Or ask the thread's agent to start it for you.
nil connect gives each port a private nil.invalid link, and live reload works through it.
Share port 3001 on this machine with nil connect and give me the link.
It replies with a link like https://my-server--3001.nil.invalid. Every link is listed under Shared ports in Settings → nil connect, where you can copy it or stop sharing when the branch is done. Open each link on your phone to check its branch.
127.0.0.1, so a server on 127.0.0.1 or 0.0.0.0 works. If it only listens on ::1, start it on 127.0.0.1 at the same port..nil-env-setup.sh from step 2, so each new worktree picks its own free ports..env.local, not a hard-coded one..worktreeinclude file at the repo root, one pattern per line.https://my-server--3001.nil.invalid, as your app's base URL.nil connect drops cookies that set a Domain attribute or are named better-auth.* or nil-connect.*. Use host-only cookies with other names.
Yes. nil connect passes WebSockets through, so hot reload works as it does on localhost.
Only you, signed in to your nil.invalid account, and devices you've paired. They aren't public, so webhooks and other services can't call them. To shut off access, open Settings → nil connect and choose Turn off, or choose Disconnect on that nil in your nil.invalid dashboard.
Yes. Your machines connect out to nil, so you don't open any ports. If your work keeps dev servers on a private network, skip the shared links and open each server over your VPN or tailnet instead.
No. Shared links only open for your nil.invalid account, and nil is built for one person.
Your repo, the tools it builds with, and any .env files. List untracked files every branch needs in a .worktreeinclude, and nil copies them from your checkout into each new worktree. nil's install command adds what nil needs.
Yes. Agents work in their own worktrees, so your checkout, editor, and terminals stay as they are.
postStartCommand, with the machine ID from nil machine list: curl -sSL https://<you>.nil.invalid/install.sh | sh -s -- --start --host-id <machine-id>nil can run machines in your own Modal account. Install the Modal Sandbox plugin, then pick Modal Sandbox as the machine when you start a new thread.
The built-in Concurrency limit plugin does this by default: each machine runs one thread per processor, and new turns wait until a running thread finishes. To change a machine's limit, open Settings → Concurrency limit.
The dev server and other terminals stop after the 30-second undo window. Five minutes later, nil removes the worktree if no other thread uses it. Its branch is deleted too once its commits are pushed or merged; unpushed work keeps the branch. Commit a .nil-env-teardown.sh to clean up anything outside the worktree, like Docker containers.
nil is free and open source, and nil connect is free. nil runs your agents on the subscriptions or API keys you already have. Machines you add cost what they do now.
Free and open source. Bring the machines and AI plans you already have.