Skip to content

:hedgehog: PostHog is the leading platform for building self-driving products. Our developer tools – AI observability, analytics, session replay, flags, experiments, error tracking, logs, and more – capture all the context agents need to diagnose problems, uncover opportunities, and ship fixes. Steer it all from Slack, web, desktop, or the MCP.

fix(devbox): refresh access hint and devbox skill (#100560)

Raúl Negrón-Otero7306554060d6
diff --git a/.agents/skills/setting-up-devbox/SKILL.md b/.agents/skills/setting-up-devbox/SKILL.md
index e70b2b8ab4aa..20f2eefdc384 100644
--- a/.agents/skills/setting-up-devbox/SKILL.md
+++ b/.agents/skills/setting-up-devbox/SKILL.md
@@ -1,156 +1,160 @@
---
name: setting-up-devbox
-description: Guide a PostHog engineer through spinning up, connecting to, running commands on, and mirroring local code to a remote devbox (a Coder workspace running the full PostHog stack). Use when asked to set up a devbox, start or connect to a devbox, configure remote dev, get gh CLI / Claude Code authed on a devbox, run a command on a devbox, sync a local checkout so you can edit locally while the stack runs remotely (devbox:sync), or diagnose why a devbox command fails. Covers the tailnet prerequisite, hogli devbox commands, Coder user secrets for auth, one-way local->remote sync via mutagen, and verifying with devbox:exec. How each dev personalizes their box is left to them.
+description: Starts, connects to, and troubleshoots a PostHog devbox, a remote Coder workspace for PostHog development that can also run the full stack, through `hogli devbox:*` commands. Use when asked to spin up or resume a devbox, open a shell or editor on it, run a command on it, mirror a local checkout to it (devbox:sync), run the PostHog app on it and share a link, clone, update, share, or free disk on a devbox, store gh or Claude Code tokens for it, or diagnose a failing devbox command (tailnet, DNS, Coder CLI version, SSH). Not for running the stack on the local machine or for changing the Coder template in posthog-cloud-infra.
---
# Setting up a PostHog devbox
-A devbox is a Coder workspace running the full PostHog stack on an EC2 instance, managed through `hogli devbox:*` (the only supported interface — drive those commands, don't reimplement them). It ships ready to use: the repo cloned at `~/posthog`, the stack pre-warmed, and Claude Code installed. This skill gets a dev connected and working; how they personalize beyond that is their choice, not something to push.
+A devbox is a Coder workspace on EC2 for PostHog development.
+Drive it through `hogli devbox:*` and don't reimplement what those commands do.
+A new box has the repo at `~/posthog` on `master`, prewarmed dependencies, and Claude Code installed.
+`hogli devbox:<command> --help` has the current flags.
+This skill covers the order of operations and what the help text leaves out.
-## Prerequisite: tailnet access (the thing people miss)
+People use a box in different ways: a shell or editor for general development, a remote target for a local checkout, or a host for the running PostHog app.
+Work out which one the user wants, and don't start the PostHog stack unless they ask for the app.
-The devbox control plane lives inside a private VPC reachable only over Tailscale. Two things have to be true, and they fail in ways that look identical at the reachability check — _every_ `hogli devbox:*` command dies there, and it is neither an auth nor an install problem, so no amount of re-running `devbox:setup` fixes it:
+## Get a box
-1. **You are signed into the `posthog.com` tailnet.** PostHog has several tailnets — `dev`, `prod-us`, `prod-eu` and `internal` exist for CI runners and subnet routers, and none of them route you to devboxes. Humans want `posthog.com` and nothing else.
-2. **Your email is in `group:engineering`** in [`tailnet-policy.hujson`](https://github.com/PostHog/posthog-cloud-infra/blob/main/tailnet-policy.hujson) (`posthog-cloud-infra`), the ACL that grants the route to the Coder control plane (`10.70.0.1:443`).
+Copy this checklist and track it:
-Check the tailnet first — it's cheap, and it's the more common of the two:
-
-```bash
-tailscale switch --list # the active tailnet is marked; you want posthog.com
-tailscale switch posthog.com # if you've signed into it before
-tailscale logout && tailscale login # otherwise — pick posthog.com at the tailnet picker
-# on macOS when `tailscale` isn't on PATH:
-/Applications/Tailscale.app/Contents/MacOS/Tailscale switch --list
+```text
+- [ ] 1. hogli devbox:doctor: the tailnet and control plane checks are ok
+- [ ] 2. hogli devbox:setup has run on this machine
+- [ ] 3. hogli devbox:start: the box is running
+- [ ] 4. The user is connected the way they asked for
+- [ ] 5. hogli devbox:stop when the user is done
```
-Being on the wrong tailnet is sticky and invisible: the picker only appears at first sign-in, so someone who clicked past it a year ago has been on `dev` ever since and was never asked again. In the GUI it's **Add account** → sign in as usual → select `posthog.com`. Suspect this whenever a dev says "it used to work on my other laptop" or is on a new machine.
-
-If the tailnet is right and `hogli devbox:doctor` still reports the control plane unreachable, the fix is a PR adding the user to `group:engineering` in `tailnet-policy.hujson` (then ask Team DevEx if still blocked). Diagnose both of these before touching anything else.
+### 1. Check access
-### Control plane unreachable with a DNS cause?
+`hogli devbox:doctor` is read-only: it never prompts or changes host config.
+Commands that reach a box run the same reachability check first, so fix a failure here before anything else.
-When doctor shows `[ok] Tailscale connected` but fails reachability with a **DNS** cause (`DNS lookup for coder.dev.posthog.dev failed`), the name is never reaching the internal resolver. In order:
+- The active tailnet must be `posthog.com`. Doctor prints it and names a wrong tailnet as the cause.
+- Every PostHog employee has the route to the Coder control plane through `group:employees` in the tailnet policy. Nobody needs a PR to get access.
+- If doctor reports the control plane unreachable, read [references/access-troubleshooting.md](references/access-troubleshooting.md) before changing anything.
+- `[missing] Commit signing agent` does not block starting or using a box. It matters only for signed commits made on the box.
-1. **Wrong tailnet** (above). The other tailnets have no route to `dev.posthog.dev`, and this is what it looks like. Rule it out first.
-2. **MagicDNS off.** "Use Tailscale DNS" in the client's DNS settings is what points the machine at the internal resolver; without it nothing internal resolves.
-3. **Stale resolver upstream.** MagicDNS on and names still failing, but `tailscale ping <internal-ip>` pongs and the service loads over its raw IP? That's the machine's router/ISP resolver. Adding `8.8.8.8` or `1.1.1.1` to the host's DNS settings has fixed this for several people.
+### 2. Set up this machine once
-To confirm it's resolution rather than the grant: `dig coder.dev.posthog.dev @10.90.0.2` answering while the system resolver fails proves the name exists and only the resolution path is missing.
+`hogli devbox:setup` is interactive, so ask the user to run it in their own terminal.
+It installs the Coder CLI at the server's version into `~/.hogli/bin`, logs in, installs the pinned mutagen binary for `devbox:sync`, and writes the `coder.*` SSH host entries that `devbox:ssh` and `devbox:exec` use.
+`~/.hogli/bin` is not on `PATH`, so call that CLI as `~/.hogli/bin/coder` when a step needs `coder` directly.
+Each optional step has a `--configure-<step>` and `--skip-configure-<step>` flag: `ssh`, `git-identity`, `git-signing`, `region`, `dotfiles`, `claude`.
+Run it again when a command prints `Coder CLI vX does not match server vY`, because it reinstalls the matching CLI.
-**Do not reach for an exit node.** Devboxes are reached as tailnet peers, so an exit node is not required for devbox access — it just routes all of the dev's traffic through infra, which is noticeably slower, and it masks whichever of the three causes above is the real one. Don't suggest `/etc/hosts` or `/etc/resolver` workarounds either: they hardcode internal ELB IPs that rotate.
+On Linux, the reachability check can run `sudo tailscale set --accept-routes` and prompt for a password.
+Run setup interactively once before an agent drives devbox commands unattended.
-Full write-up, kept current by Team Cloud Foundations: [wiki.posthog.com/access/vpn](https://wiki.posthog.com/access/vpn#which-tailnet).
-
-## Workflow
-
-### 1. Check state — `hogli devbox:doctor`
+### 3. Start the box
```bash
-hogli devbox:doctor # read-only: tailnet access, reachability, auth, ssh config, saved setup
+hogli devbox:start
```
-A safe probe — it never prompts or mutates host config (unlike `devbox:setup`). It names the active tailnet on its own line (`Tailnet: … (need posthog.com)`) and, when that's the problem, says so outright (`Cause: Signed into the 'dev' tailnet, not 'posthog.com'.`) — trust that over any other symptom. If it flags the control plane unreachable, resolve the tailnet (and then the ACL grant) before anything else. For more detail: `hogli devbox:list` (your boxes), `hogli devbox:status` (state, template freshness), `hogli devbox:secret:list` (secret names only).
+This creates the box on first use and resumes it after a stop.
+It brings up the PostHog stack only when the workspace has `--start-app` set, which is covered in [Run the PostHog app](#run-the-posthog-app).
+`--disk` (`100` or `200` GiB) applies only when the box is created.
+`--region` (`us-east-1` or `eu-central-1`) starts that region's default box and creates it if it doesn't exist, so leave it off when resuming an existing box.
+A box's region can't change.
-### 2. One-time local setup — `hogli devbox:setup`
+The default box is `devbox-<coder-user>`, and a labeled box is `devbox-<coder-user>-<label>`.
+Boxes in `eu-central-1` add an `-eu` suffix, for example `devbox-<coder-user>-eu`.
+`hogli devbox:list` shows the exact names.
+Target a labeled box with `-n <label>` on commands that act on a box.
-Interactive: checks Tailscale + Coder reachability, installs and authenticates the `coder` CLI (plus the pinned mutagen binary that backs `devbox:sync`), and writes the SSH host entries that `devbox:ssh`/`devbox:exec` rely on. It then _offers_ git identity, git signing, a dotfiles repo, and your Claude token — all optional; `--skip-*` anything you don't want. Re-run one step with its flag, e.g. `hogli devbox:setup --configure-git-signing`.
+### 4. Connect
-### 3. Start and connect — `hogli devbox:start`
+Match what the user asked for:
-```bash
-hogli devbox:start # create or resume your box
-hogli devbox:ssh # shell in
-hogli devbox:open --vscode # or --cursor / --web
-hogli devbox:stop # when done — preserves disk, stops billing
-```
+- **Shell:** `hogli devbox:ssh`.
+- **Editor:** `hogli devbox:open --vscode`, `--cursor`, or `--web`.
+- **Commands from an agent:** `hogli devbox:exec`, described in [Run commands on the box](#run-commands-on-the-box).
+- **Edit locally, run on the box:** read [references/sync.md](references/sync.md) before using `hogli devbox:sync`.
+- **The running app:** follow [Run the PostHog app](#run-the-posthog-app).
-### 4. Fast QA and agent resume
+### 5. Stop when done
-Before recreating sync, restarting PostHog, or making a new devbox, check whether the existing box is already usable:
+`hogli devbox:stop` keeps the disk and stops billing.
+Stops, starts, and `devbox:update` keep `/home`.
+`hogli devbox:destroy` deletes it, so don't keep anything irreplaceable only on a box.
-```bash
-hogli devbox:status
-hogli devbox:exec -- bash -lc 'cd ~/posthog && git status --short --branch && git rev-parse --short HEAD'
-hogli devbox:sync --status
-hogli devbox:exec -- bash -lc "curl -sf -o /dev/null -w '%{http_code}' http://127.0.0.1:8010/"
-```
+## Run commands on the box
-Use `-n <name>` on each command for a labeled box. If the forwarded app serves the intended branch/SHA, the target route loads, and route-critical APIs work, keep going and note unrelated degraded units rather than chasing perfect all-process health. When startup time matters, record rough timings for devbox start/resume, sync readiness, first route response, and first target-route load.
+`hogli devbox:exec -- <command>` runs one command over SSH and returns its exit code.
+Wrap the command in `bash -lc '...'`.
+A non-login shell doesn't reliably load the shell profile, so tools on a login-shell `PATH` such as `~/.local/bin` report "command not found".
+Put `--` between hogli's flags and the command's own.
+`devbox:exec` and `devbox:ssh` fail to connect until `devbox:setup` has written the SSH config.
-For agent-managed startup, `hogli devbox:start --start-app` is the supported path for new/stopped boxes. The flag is sticky and starts the regular PostHog stack in the background. If the box is already running without the app, start it inside the box:
+## Run the PostHog app
-```bash
-hogli devbox:exec -- bash -lc 'cd ~/posthog && ./bin/hogli up -d -y'
-```
+Use this section only when the user wants the app, for example to QA a change or share a link.
+
+### Start the stack
-Use the target route, route-critical APIs, and process-specific phrocs checks as the readiness gate.
+- **New or stopped box:** `hogli devbox:start --start-app`. The flag stays set on the workspace, so every later start brings the stack up in the background until `hogli devbox:start --no-start-app` turns it off. Either flag takes effect only when the box is created or starts from stopped; on a running box hogli skips it and prints a note.
+- **Running box:** `hogli devbox:exec -- bash -lc 'cd ~/posthog && ./bin/hogli up -d -y'`.
-### 5. Auth, if you want it (optional)
+### Wait for it
-To have `gh` or Claude Code authenticated on the box, store the token once as a Coder user secret. It's injected as an env var into every box you start, so you set it once rather than per box:
+The stack keeps booting after the start command returns.
+Poll in a bounded loop until this prints `200` or `302`.
+A `000` or `502` means the stack is still booting.
```bash
-hogli devbox:secret:set GH_TOKEN --env GH_TOKEN
-hogli devbox:secret:set CLAUDE_CODE_OAUTH_TOKEN --env CLAUDE_CODE_OAUTH_TOKEN
-# also supported: ANTHROPIC_API_KEY, OPENAI_API_KEY, OP_SERVICE_ACCOUNT_TOKEN, AWS_CREDENTIALS (--file)
+hogli devbox:exec -- bash -lc "curl -s -o /dev/null -w '%{http_code}' --max-time 10 http://127.0.0.1:8010/"
```
-Authing `gh` / Claude on a devbox is fine — that's what these are for. Set the value from `--file` or the hidden prompt; never paste a token into a command line or into this conversation. Restart a running box to pick up a newly set secret.
-
-### 6. Make it yours — your call
+When resuming QA on an existing box, check it before recreating sync, restarting the stack, or making a new box:
-The box is usable as shipped; personalize it however suits you, or not at all. Two supported paths, neither required, don't push one over the other:
+```bash
+hogli devbox:status
+hogli devbox:exec -- bash -lc 'cd ~/posthog && git status --short --branch && git rev-parse --short HEAD'
+hogli devbox:sync --json
+```
-- **Tweak the box directly** — `devbox:ssh` in and install tools, add aliases, clone repos. Changes under `/home` survive stop/start and template updates, but a `devbox:destroy` (or a brand-new box) starts fresh.
-- **A dotfiles repo** — if you'd rather keep portable, version-controlled config that re-applies to every box: `hogli devbox:setup --configure-dotfiles` points the box at your `dotfiles_uri`, and Coder clones it (running an executable `~/dotfiles/install.sh` if present) on each start.
+Keep going when the app serves the intended branch and SHA, the target route loads, and its APIs work.
+Note unrelated degraded processes instead of chasing full health.
-### 7. Run commands on the box — `hogli devbox:exec`
+### Give the user the URL
-`devbox:exec` runs one command over SSH and propagates its exit code — handy for scripts, agents, and quick checks without opening a shell:
+The template exposes the app as a Coder subdomain app that only the box owner can open:
-```bash
-hogli devbox:exec -- bash -lc 'gh auth status'
-hogli devbox:exec -- bash -lc 'cd ~/posthog && git status'
-hogli devbox:exec -n api -- bash -lc 'uname -a' # -n targets a labeled box
+```text
+https://app--<workspace>--<coder-user>.<coder-host>
```
-Wrap commands in `bash -lc '...'`: a non-login shell doesn't reliably source `~/.bashrc`/`~/.zshrc`, so a bare `gh auth status` can report "command not found" for anything on a login-shell `PATH` (e.g. `~/.local/bin`) — a false negative. The login shell also keeps the exit code trustworthy, so `&&` chaining and `if` checks work. Use `--` to separate hogli's flags from the command's own.
-
-`devbox:exec` is not side-effect-free: like every `devbox:*` command it runs the reachability check first, which on Linux may `sudo tailscale set --accept-routes` and prompt for a password. Run `hogli devbox:setup` once interactively so routes and SSH config are in place before an agent drives `devbox:exec` unattended.
+`<coder-host>` is the host of `Coder URL` in `hogli devbox:doctor`, and `hogli devbox:list` shows the workspace name.
+For example, `devbox-jane-d` owned by `jane-d` on `coder.dev.posthog.dev` is `https://app--devbox-jane-d--jane-d.coder.dev.posthog.dev`.
+The user must be on the tailnet, and the browser goes through Coder sign-in first.
-## Editing locally, running on the box — `hogli devbox:sync`
-
-When you want your fast local checkout to stay the place you edit but the heavy stack (`hogli up`) to run on the box, `hogli devbox:sync` mirrors your repo onto the box over [mutagen](https://mutagen.io), one-way: local is the source of truth, nothing comes back. Reach for this in an agentic loop — edit with your normal local tools, let the mirror carry each change, and drive the remote stack with `devbox:exec` — instead of committing and pushing every iteration or editing over Remote-SSH.
+Verify the link before handing it over.
+Coder runs the template's health check against the app, so read that status instead of sending a request with the user's session token:
```bash
-hogli devbox:start # the box must be running first
-hogli devbox:sync # create the mirror (idempotent: re-run just reports status)
-# edit files locally — changes propagate within seconds
-hogli devbox:exec -- bash -lc 'cd ~/posthog && pnpm --filter=@posthog/frontend typescript:check'
-hogli devbox:sync --status # watching / paused / conflicts
-hogli devbox:sync --terminate # tear the mirror down when done
+~/.hogli/bin/coder list --output json | jq -r '.[] | select(.name=="<workspace>") | .latest_build.resources[]?.agents[]?.apps[]? | select(.slug=="app") | .health'
```
-Before relying on sync, verify the remote branch/SHA and `devbox:sync --status`. If the box already matches and sync is watching without source-file conflicts, do not recreate it for cleanliness. Source-file conflicts block reliable QA until resolved; box-local config conflicts such as `.env` can be acceptable when the tracked source is clean.
-
-The non-obvious parts:
-
-- **It runs on your machine and pushes to the box — not the reverse.** Don't invoke it through `devbox:exec`. It mirrors whichever checkout you run it from (it walks up from the cwd for `hogli.yaml` + `.git`), so run it from the repo root you are editing — including a `/wt` worktree.
-- **`one-way-safe` preserves remote-only files.** The AMI's prewarmed `node_modules`, venv, and `target/` are never deleted — they aren't in your local checkout and the mode leaves remote-only content alone. Lockfiles _do_ sync, so the box reconciles deps on its next start.
-- **The first sync of a feature branch conflicts per diverged file.** The AMI is always on `master`; every file your branch changed relative to the box's `master` surfaces as a conflict in `--status`. That is expected one-way-safe behavior, and it is per-path — non-conflicting files (including brand-new ones) still sync. Resolve a path, or check the matching branch out on the box, only if you specifically need that file mirrored.
-- **Don't also edit those files on the box.** Editing over Remote-SSH while the mirror is live fights the local source of truth; `devbox:open --vscode|--cursor` warns when a sync is active for exactly this reason.
+`healthy` means Coder routes the URL to a working app.
+`initializing` means the check hasn't passed yet, and `unhealthy` means it keeps failing.
-The packaged ignore defaults are seeded once to `~/.hogli/mutagen.yml` and never overwritten — it is yours to tweak. If a newer hogli ships updated ignore defaults, `rm ~/.hogli/mutagen.yml` and re-run `devbox:setup` to pick them up.
+`hogli devbox:forward` is the alternative when the user wants `localhost`.
+It tunnels box port 8010 to `localhost:8010` and holds the terminal until stopped.
+Pass `--port 8011` when a local stack already uses 8010.
-## Persistence & multiple boxes
+## Other tasks
-- `devbox:stop` → `devbox:start` and template/AMI updates preserve `/home` (the instance is stopped, not terminated). A `devbox:destroy` wipes it — intentional, so don't keep anything irreplaceable only inside a box.
-- You can run more than one box. Box-local changes don't carry between them; user secrets do (user-scoped), and a dotfiles repo does if you use one. That's the practical reason to reach for those if you find yourself re-doing setup — but it's a choice, not a requirement.
+- **Tokens on the box:** store them as Coder user secrets, which reach every box the user owns. `hogli devbox:secret:set GH_TOKEN` reads the value from a hidden prompt or from `--file`. Never put a token on a command line or in the conversation. A secret reaches only boxes started after it is set, so run `hogli devbox:restart` on a running box. The template documents `CLAUDE_CODE_OAUTH_TOKEN`, `GH_TOKEN`, `OP_SERVICE_ACCOUNT_TOKEN`, `ANTHROPIC_API_KEY`, `OPENAI_API_KEY`, and `POSTHOG_GIT_SIGNING_KEY`, which `hogli devbox:setup --configure-git-signing` sets. `devbox:secret:list` shows names, env vars, and descriptions, never values.
+- **A second box with the same state:** `hogli devbox:clone --as <label>` copies a running box's full disk, including any secrets on it, into `devbox-<coder-user>-<label>` in the source box's region. Stop the stack on the source first for a consistent copy. It asks for confirmation, so pass `-y` only after the user agrees. Only the owner can clone a box.
+- **Template updates:** `hogli devbox:update` applies the latest template when the box is outdated.
+- **Disk full:** `hogli devbox:cleanup:disk -n <label>` cleans a labeled box. With no workspace it cleans this machine instead, and the default box has no label, so clean the default box with `hogli devbox:exec -- bash -lc 'cd ~/posthog && ./bin/hogli devbox:cleanup:disk'`. `--docker` also prunes stopped containers, and `--cargo` also removes Rust build output, which forces a full rebuild.
+- **Pairing:** `hogli devbox:share --user <coder-user> --role use` grants access, and `devbox:users` lists usernames. `devbox:unshare` removes access only after `hogli devbox:restart`.
+- **Build and agent logs:** `hogli devbox:logs -f`.
+- **Personal setup:** the box works as shipped. Changes made on the box survive stops and updates. `hogli devbox:setup --configure-dotfiles` saves a dotfiles repo that the box applies on start, running its executable `install.sh`. A new repo URL reaches a box when it next starts from stopped or runs `devbox:update`, not on `devbox:restart`. Neither is required, so don't push one over the other.
## Gotchas
-- **Never echo secret values** into the transcript, logs, a PR, or a command line. `devbox:secret:set` reads from a hidden prompt or `--file`; `secret:list` shows names only. Keep it that way.
-- **Secrets need a restart.** A new or changed secret only reaches boxes started afterward — `hogli devbox:restart` to pick it up on a running box.
-- **`devbox:exec`/`devbox:ssh` need `devbox:setup` to have run** (it writes the `coder.*` SSH host config). Without it they fail at connection; `devbox:doctor` shows whether SSH access is configured.
-- **`code-server` (browser IDE) has no SSH agent forwarding**, so commit signing via a forwarded key won't work there — use VS Code Desktop / Cursor / JetBrains (SSH-based) when you need to sign.
+- Never echo a secret value into the transcript, logs, a PR, or a command line.
+- `code-server` (`devbox:open --web`) has no SSH agent forwarding, so commit signing fails there. Use VS Code Desktop, Cursor, or JetBrains over SSH to sign commits.
diff --git a/.agents/skills/setting-up-devbox/references/access-troubleshooting.md b/.agents/skills/setting-up-devbox/references/access-troubleshooting.md
new file mode 100644
index 000000000000..50a0f251ee47
--- /dev/null
+++ b/.agents/skills/setting-up-devbox/references/access-troubleshooting.md
@@ -0,0 +1,48 @@
+# Devbox access troubleshooting
+
+Commands that reach a box check that the Coder control plane is reachable before they do anything.
+Two conditions must hold, and re-running `devbox:setup` fixes neither.
+Doctor names a wrong tailnet as its own cause, and a missing grant usually shows as TCP blocked.
+
+## 1. The `posthog.com` tailnet
+
+PostHog runs several tailnets.
+`dev`, `prod-us`, `prod-eu`, and `internal` serve CI runners and subnet routers, and none of them route to devboxes.
+People need `posthog.com`.
+
+```bash
+tailscale switch --list # marks the active tailnet
+tailscale switch posthog.com # if already signed into it
+tailscale logout && tailscale login # otherwise, then pick posthog.com
+# macOS, when tailscale isn't on PATH:
+/Applications/Tailscale.app/Contents/MacOS/Tailscale switch --list
+```
+
+The tailnet picker appears only at first sign-in, so a wrong choice persists without any warning.
+In the GUI, use **Add account**, sign in, and select `posthog.com`.
+Suspect this first on a new laptop, or when the user says it worked on another machine.
+
+## 2. The ACL grant
+
+`tailnet-policy.hujson` in `PostHog/posthog-cloud-infra` grants `group:employees` the remote-dev VPC (`10.70.0.0/16`), which hosts the Coder control plane.
+Every employee has access, so there is no group to join and no PR to open.
+If the tailnet is right and doctor still reports the control plane unreachable without a DNS cause, follow its `Next:` line, then ask Team DevEx.
+
+## DNS failures
+
+Doctor can show `[ok] Tailscale connected` and still fail reachability with a DNS cause (`DNS lookup for coder.dev.posthog.dev failed`).
+That means the name never reaches the internal resolver.
+Check in this order:
+
+1. **Wrong tailnet.** Doctor checks the tailnet before DNS, so a DNS cause usually means the tailnet is right or unknown. Confirm the `Tailnet:` line anyway.
+2. **MagicDNS off.** "Use Tailscale DNS" in the client's DNS settings points the machine at the internal resolver. Without it, no internal name resolves.
+3. **Stale upstream resolver.** MagicDNS is on and `tailscale ping <internal-ip>` answers, but names still fail. The router or ISP resolver is the problem. Adding `8.8.8.8` or `1.1.1.1` to the host's DNS settings has fixed this.
+
+If `dig coder.dev.posthog.dev @10.90.0.2` answers while the system resolver fails, the name exists and only the resolution path is broken.
+
+## Don't
+
+- Don't suggest an exit node. Devboxes are tailnet peers, so an exit node isn't needed. It routes all of the user's traffic through infra, which is slower, and it hides the real cause.
+- Don't suggest `/etc/hosts` or `/etc/resolver` entries. They pin internal load balancer IPs that rotate.
+
+Team Cloud Foundations keeps the full write-up at [wiki.posthog.com/access/vpn](https://wiki.posthog.com/access/vpn#which-tailnet).
diff --git a/.agents/skills/setting-up-devbox/references/sync.md b/.agents/skills/setting-up-devbox/references/sync.md
new file mode 100644
index 000000000000..16ec32de5e6c
--- /dev/null
+++ b/.agents/skills/setting-up-devbox/references/sync.md
@@ -0,0 +1,32 @@
+# Editing locally with `hogli devbox:sync`
+
+`hogli devbox:sync` mirrors the local checkout onto the box with [mutagen](https://mutagen.io), in one direction.
+Local files are the source of truth, and nothing syncs back.
+Use it in an agent loop: edit with local tools, let the mirror carry each change, and run the stack and checks on the box with `devbox:exec`.
+This replaces committing and pushing on every iteration, or editing over Remote-SSH.
+
+```bash
+hogli devbox:start # the box must be running
+hogli devbox:sync # create the mirror; re-running does nothing, so use --status
+hogli devbox:exec -- bash -lc 'cd ~/posthog && pnpm --filter=@posthog/frontend typescript:check'
+hogli devbox:sync --json # sync state as JSON, for scripts and agents
+hogli devbox:sync --flush # push pending changes now
+hogli devbox:sync --pause # stop mirroring; --resume starts it again
+hogli devbox:sync --terminate # remove the mirror when done
+```
+
+## Behavior to know
+
+- **Run it locally, from the checkout to mirror.** It walks up from the working directory to find `hogli.yaml` and `.git`, so run it from the repo root being edited, including a worktree. Never run it through `devbox:exec`.
+- **Remote-only files stay.** The sync mode is `one-way-safe`, so the box's prewarmed `node_modules`, virtualenv, and `target/` are never deleted. Files that exist on the box but not locally when the mirror is created also stay, such as files the branch deleted, so remove them on the box when a check could pick them up. Lockfiles do sync, so after a lockfile change install dependencies on the box through `devbox:exec` before trusting its checks.
+- **A feature branch conflicts on first sync.** A new box is on `master`, so every file the branch changed shows as a conflict in the sync state. Conflicts are per path: other files, including new ones, still sync. Resolve a path, or check out the same branch on the box, only when that file must be mirrored.
+- **Don't edit mirrored files on the box.** Remote edits fight the local source of truth. `devbox:open --vscode` and `--cursor` warn when a sync is active.
+- **Check before recreating.** Compare the box's branch and SHA and the sync state first. If they match and no source file conflicts, keep the existing mirror. Source-file conflicts block reliable QA until resolved. A conflict in box-local config such as `.env` is acceptable when tracked source is clean.
+
+## Ignore rules
+
+hogli seeds `~/.hogli/mutagen.yml` from its packaged defaults, and the user can edit it.
+hogli refreshes an unedited copy when it ships new defaults.
+It leaves an edited copy alone, and also a copy seeded before hogli recorded the seed.
+To pick up new defaults in either case, delete the file and run `hogli devbox:setup` again.
+A mirror reads the file only when it is created, so after any change to the file, recreate the mirror with `hogli devbox:sync --terminate` and then `hogli devbox:sync`.
diff --git a/docs/internal/coder-workspaces.md b/docs/internal/coder-workspaces.md
index e0b4a28eff4b..29fc77af28a6 100644
--- a/docs/internal/coder-workspaces.md
+++ b/docs/internal/coder-workspaces.md
@@ -19,7 +19,7 @@ hogli devbox:doctor # read-only health check: tailnet access, reach
hogli devbox:exec -- bash -lc 'gh auth status' # run one command on the box and get its exit code
```
-`devbox:doctor` is the first thing to run when a devbox command misbehaves — it names the likely cause (most often the Tailscale ACL grant) instead of failing cryptically.
+`devbox:doctor` is the first thing to run when a devbox command misbehaves. It names the likely cause, most often the wrong tailnet, instead of failing cryptically.
## Common scenarios
diff --git a/tools/hogli-commands/hogli_commands/devbox/cli.py b/tools/hogli-commands/hogli_commands/devbox/cli.py
index 22b95b0a08ce..9a3f4909006c 100644
--- a/tools/hogli-commands/hogli_commands/devbox/cli.py
+++ b/tools/hogli-commands/hogli_commands/devbox/cli.py
@@ -8,6 +8,7 @@ from __future__ import annotations
import os
import sys
import errno
+import shlex
import shutil
import socket
import tempfile
@@ -109,17 +110,16 @@ from .config import (
_LEGACY_KEYCHAIN_SERVICE = "posthog-claude-oauth-token"
_POSTHOG_COMMIT_SIGNING_HANDBOOK_URL = "https://posthog.com/handbook/engineering/security#commit-signing"
-# Reaching a devbox requires a Tailscale ACL grant. Engineers get it from
-# group:engineering in the cloud-infra tailnet policy; without it the Coder
-# control plane (10.70.0.1:443) is simply unroutable and every devbox command
-# fails at the reachability check.
-_TAILNET_POLICY_URL = "https://github.com/PostHog/posthog-cloud-infra/blob/main/tailnet-policy.hujson"
+# Reaching a devbox requires a Tailscale ACL grant. The cloud-infra tailnet
+# policy grants group:employees the remote-dev VPC (10.70.0.0/16) that hosts the
+# Coder control plane; without it every devbox command fails at the
+# reachability check.
_TAILNET_ACCESS_PREREQ = (
- f"Devbox access needs you on the `{EXPECTED_TAILNET}` tailnet (not dev / "
- "prod-us / prod-eu / internal — those are for CI runners and subnet "
- "routers), with your email in `group:engineering` in "
- "posthog-cloud-infra/tailnet-policy.hujson.\n"
- f" Not granted yet? Add yourself via PR: {_TAILNET_POLICY_URL}"
+ f"Devbox access needs you on the `{EXPECTED_TAILNET}` tailnet. The dev, "
+ "prod-us, prod-eu and internal tailnets are for CI runners and subnet "
+ "routers and don't reach devboxes. Every PostHog employee has access "
+ "through `group:employees` in posthog-cloud-infra/tailnet-policy.hujson.\n"
+ " Still blocked on the right tailnet? Ask Team DevEx."
)
WORKSPACE_STATUS_COLORS = {
@@ -841,9 +841,9 @@ def devbox_doctor() -> None:
Safe for an agent to run as a probe -- it never prompts or mutates host
config the way `devbox:setup` does. Run it first when a devbox command
- fails, and as step zero of the `setting-up-devbox` skill. The tailnet ACL
- grant is the prerequisite people most often miss, so it is surfaced
- explicitly whenever the control plane is unreachable.
+ fails, and as step zero of the `setting-up-devbox` skill. The wrong tailnet
+ is the prerequisite people most often miss, so the access prerequisite is
+ surfaced explicitly whenever the control plane is unreachable.
"""
click.echo(click.style("Devbox doctor", bold=True))
click.echo(f" Coder URL: {get_coder_url()}")
@@ -2032,12 +2032,14 @@ def devbox_cleanup_disk(workspace: str | None, prune_docker: bool, prune_cargo:
_fail(
"SSH access for devboxes isn't configured. Run `hogli devbox:setup` (it runs `coder config-ssh`), then retry."
)
- remote_cmd = ["hogli", "devbox:cleanup:disk"]
+ remote_cmd = ["./bin/hogli", "devbox:cleanup:disk"]
if prune_docker:
remote_cmd.append("--docker")
if prune_cargo:
remote_cmd.append("--cargo")
- exec_replace(name, remote_cmd)
+ # `hogli` is not on the devbox PATH, even in a login shell, so run the
+ # checkout's copy from inside the repo.
+ exec_replace(name, ["bash", "-lc", f"cd ~/posthog && {shlex.join(remote_cmd)}"])
return # unreachable; exec_replace replaces the process
home = Path.home()
diff --git a/tools/hogli-commands/hogli_commands/devbox/coder.py b/tools/hogli-commands/hogli_commands/devbox/coder.py
index 5d2e281ab2c3..c2fc055d249e 100644
--- a/tools/hogli-commands/hogli_commands/devbox/coder.py
+++ b/tools/hogli-commands/hogli_commands/devbox/coder.py
@@ -674,8 +674,8 @@ def _diagnose_blocked_route(
cause="No peer on your tailnet advertises subnet routes.",
next_step=(
f"Either you are not on the '{EXPECTED_TAILNET}' tailnet (check "
- "the name above), or your account has not been added to the "
- f"Tailscale policy yet. See {_TAILSCALE_RUNBOOK_URL} for both, "
+ "the name above), or your account is outside `group:employees` "
+ f"in the Tailscale policy. See {_TAILSCALE_RUNBOOK_URL} for both, "
"then reach out to Team DevEx with the facts below."
),
facts=facts,
@@ -697,9 +697,9 @@ def _diagnose_blocked_route(
cause="TCP is blocked despite an online subnet router on your tailnet.",
next_step=(
"A non-Tailscale VPN or a local firewall is likely intercepting, "
- "or the Tailscale policy does not grant your account devbox "
- f"access. Disable other VPNs and see {_TAILSCALE_RUNBOOK_URL} to "
- "confirm policy membership, or reach out to Team DevEx."
+ "or your account is outside `group:employees` in the Tailscale "
+ f"policy. Disable other VPNs and see {_TAILSCALE_RUNBOOK_URL}, or "
+ "reach out to Team DevEx."
),
facts=facts,
)