#cloud-config users: - name: grok shell: /bin/bash sudo: "ALL=(ALL) NOPASSWD:ALL" lock_passwd: true write_files: - path: /home/grok/.grok/AGENTS.md owner: "grok:grok" permissions: '0644' defer: true content: | # You are running inside a box (template: grok) A box is a trust-less, network-isolated, ephemeral VM created by the `box` CLI. Keep this context in mind: - **Creds-free by default.** The box starts with no xAI and no git credentials. If you need to authenticate, the operator runs `grok login` interactively (SuperGrok / X Premium+). For git, the operator adds their own credentials (a PAT or `gh auth login`). Never assume credentials are present; never ask for or store secrets on disk beyond what the operator sets up. - **Isolated.** The box reaches the public internet but nothing on the host or local network. There is no inbound path. - **Disposable.** Nothing here is backed up. State is discarded when the box is removed; the operator persists work via git push and via `box snapshot`. - **Bootstrap runbook.** If the repository you are working in contains a `.box/` folder (older repos may use `.claudebox/`), read it as your setup runbook — how to install dependencies, start services, template environment files, seed data, and smoke-test — and follow it. It is documentation for you, not a script the host runs. package_update: true packages: - git - gh - curl - ca-certificates - gnupg - ripgrep - jq - tmux - age - unzip - build-essential runcmd: - curl -fsSL https://get.docker.com | sh - usermod -aG docker grok # The OFFICIAL installer, read at https://x.ai/cli/install.sh rather than # guessed at. What it actually does: # · installs the CLI as `grok` (with an `agent` alias) — NOT `grok-build` # · BIN_DIR defaults to $HOME/.grok/bin, and what it puts there is a # SYMLINK into its versioned download dir (so `find -type f` misses it) # · GROK_BIN_DIR overrides that directory # # Run it AS grok, not root: the binary symlink points into the invoking # user's download dir, and root's home is 0700 — a symlink into it would be # unreadable to the grok user, giving a CLI that exists and cannot run. - sudo -u grok bash -lc 'curl -fsSL https://x.ai/cli/install.sh | bash' # 'box exec -- grok …' is a NON-interactive shell: it reads no rc files, # so ~/.grok/bin is never on its PATH. Symlink onto the system PATH — the # same fix the claude template needed (#15). Assert the result: a CLI that # silently is not on PATH is what cost the last drill run. - | if [ -e /home/grok/.grok/bin/grok ]; then ln -sf /home/grok/.grok/bin/grok /usr/local/bin/grok echo "grok: linked /usr/local/bin/grok -> /home/grok/.grok/bin/grok" /usr/local/bin/grok --version >/dev/null 2>&1 \ && echo "grok: 'grok --version' answers from the system PATH" \ || echo "grok: WARNING - linked, but 'grok --version' does not answer" >&2 else echo "grok: installer produced no ~/.grok/bin/grok - upstream layout changed?" >&2 find /home/grok -maxdepth 4 \( -type f -o -type l \) -perm -u+x 2>/dev/null | head -20 >&2 fi - echo 'export PATH="$HOME/.grok/bin:$PATH"' >> /home/grok/.bashrc