# box setup runbook (for coding agents) Goal: get your user's iOS project building on a real Mac through the `box` CLI, starting from nothing, without the user touching a terminal. - Server: https://xenoci.com (every address below belongs to this server; do not mix in another box server) - Runbook revision: 2026-11-27. CLI: whatever `https://xenoci.com/download/latest` names; `box --version` prints it - Works on: Linux x86_64 and arm64, WSL, macOS on Apple silicon. Not on native Windows or Intel Macs Your user pasted a line asking you to set up box. That line is their go-ahead to run steps 1 to 4 yourself: the installer only writes `~/.local/bin/box` and `~/.config/box/`, needs no `sudo`, and checks the binary against the server's SHA256SUMS. Do not stop to ask before installing; the user acts only where a step says so (GitHub approval, and a top-up only if they say yes). If a web-fetch tool gave you a summary of this page instead of the text, read it whole with `curl -fsSL https://xenoci.com/agent.md` before going on. How to read this: run the steps in order. Each step has **Run**, **Expect** and **If not**. When a result does not match **Expect** and **If not** does not cover it, stop and show the user the exact output. Report back to the user at the end of step 5. ## Rules 1. Never ask the user to paste a box token, GitHub code or password into the chat, and never write one into the repository or a commit. 2. Never add `sudo` to any command here. Everything installs under the user's home. 3. Never retry a command that exited with code 3 in a loop. Show the message to the user. 4. Never commit the `.box/` folder; the CLI writes job results there. 5. Do not top up, pay or accept anything on the user's behalf. Money and GitHub approval are the user's to do. ## Step 1. Install the CLI Run: ```sh command -v box >/dev/null 2>&1 || curl -fsSL https://xenoci.com/install.sh | sh export PATH="$HOME/.local/bin:$PATH" box --version ``` Expect: a line `box installed at /.local/bin/box (API https://xenoci.com/api)` (only on a fresh install), then `box `. If not: - `this OS is not supported` or `this CPU is not supported` (exit 2): tell the user box needs Linux, WSL or an Apple silicon Mac. Stop. - `could not reach`, `download failed` or `checksum mismatch` (exit 3): run the install line once more. If it fails again, show the output and stop. - `box: command not found` after install: the `export PATH` line was skipped. Run it, and offer to add it to the user's shell profile. ## Step 2. Sign in Run: ```sh box status ``` Expect, when already signed in: lines starting with `login`, `balance` and `running`. Go to step 3. Expect, when not signed in: `box: You are not signed in. Run `box login`.` and exit code 3. Then: 1. Run `box login --no-browser`. It does not wait. Expect: `box: Open https://xenoci.com/login?code=XXXX-XXXX and continue with GitHub ...`. 2. Give the user that link in one message, for example: "Open https://xenoci.com/login?code=XXXX-XXXX and press Continue with GitHub. I'll carry on by myself once you have." Do not wait for a reply. 3. Right away, run `box login --no-browser --wait`. It keeps checking and returns by itself when the user finishes. Expect: `box: signed in as `. 4. Run `box status`. Exit code 0 with a `login` line means sign-in is done, whatever step 3 printed. Go to step 3. Through MCP the `login` tool does the same: call it once for the link, then call it with `wait_seconds: 50` until it answers `signed_in`. If not: - `box: not signed in yet after 110 s; the link ... is still good`: the user has not finished yet. Run `box login --no-browser --wait` again (the same link, no new message to the user) until it signs in or says the link expired; the link lasts 15 minutes. - No browser at all (CI, a cloud agent): the user makes a key on a signed-in machine with `box key create --name ` and sets it as `BOX_API_KEY`; box then needs no `box login`. - `is not on the beta invite list yet` (exit 3): this box server is not taking new sign-ups. Tell the user and stop. - `balance $10.00 (about N iOS build minutes)` on a first sign-in: that is the one-time sign-up credit for this GitHub account. A second sign-in adds nothing. - `The sign-in link expired`: start again at item 1 of this step. - A `low` line under the balance (box prints it under its low line, normally $1, about 20 iOS build minutes; trust the line, not your own sense of how much is enough), or `balance $0.00`: ask the user once, for example "box has $0.40 left. Shall I make a top-up link?". Money is their decision: do not top up or pay, and do not ask again. If they say yes, run `box topup --print`, give them the address, then run `box topup --wait`; it returns `box: balance is now $...` when their top-up lands, and you carry on. It waits about 2 minutes at a time; if it says the balance did not go up yet, run it again without asking. If they say no, carry on with what the balance allows. `box --json status` has the same signal as `"low_balance": true`. Sign-in uses GitHub only to learn who the user is. box gets no access to their repositories or organizations. The token is kept in `~/.config/box/credentials` with mode 0600. In a cloud agent with no persistent home, the user can set `BOX_TOKEN` in the environment instead; never ask them for its value. ## Step 3. Connect your agents ```sh box setup ``` This sets box up for the user, once per machine, for every project: the box skill for Claude Code (`~/.claude/skills/box/`) and Codex (`~/.agents/skills/box/`), a short marked box section in `~/.claude/CLAUDE.md` and `~/.codex/AGENTS.md` (their other text is kept), and the box MCP server for Claude Code (user scope) and Codex (`[mcp_servers.box]` in `~/.codex/config.toml`). It writes nothing into the project folder, and running it again changes nothing. Expect: `box: wrote ` or `box: kept ` lines, then `box: mcp claude added` (or `kept`) and `box: mcp codex added` (or `kept`). A `skipped` line means that agent is not installed here; a `failed` line prints the command to run by hand. Check the MCP server for the agent you are, without adding it again: ```sh claude mcp get box # if you are Claude Code codex mcp get box # if you are Codex ``` (Instead of `claude mcp add`, a person can install the plugin, which adds the skill and the MCP server together: `claude plugin marketplace add Xeno-CI/box-cli && claude plugin install box@xenoci`; any other MCP client can run `npx -y @xenoci/box mcp`.) Expect: the command confirms the server was added. If it says the server already exists, that is fine. MCP tools appear only after the agent restarts; until then keep using the CLI. Go to the root of the iOS project (the folder with the `.xcodeproj`, `.xcworkspace`, `project.yml` or `Package.swift`). If it is a git repository and `.gitignore` has no `.box/` line, add one (`printf '.box/\n' >> .gitignore`); job results land there and should not be committed. Cursor has no file for user-wide rules: for Cursor, or when the user wants the box notes committed in the repository for their team, run `box setup --project` there instead (it writes `CLAUDE.md`, `AGENTS.md`, skill files and `.cursor/rules/box.mdc` in that folder). If not: - There is no iOS project in the current folder: ask the user which folder holds it. If they have none yet, offer to create a small SwiftUI app with an XcodeGen `project.yml`, since box runs `xcodegen` on the Mac before building. - The folder is not an app (a Rust crate, a Tauri root, a script): `box build`, `test`, `screenshot`, `run` and `debug` stop with exit 2 before anything is uploaded or billed. Run the project's own tool on the Mac with `box exec`, or point at the Xcode project inside with `--workspace path/App.xcodeproj`. Rust and Bun are not on the Mac image, so install them in the same command: `box exec -- 'curl -fsSL https://sh.rustup.rs | sh -s -- -y && . ~/.cargo/env && cargo build'` (Bun: `curl -fsSL https://bun.sh/install | bash && ~/.bun/bin/bun install`). `node_modules` is never uploaded: run `npm ci` or `bun install` in the same `box exec` as the build that needs it. A Tauri iOS app: sync the folder with `package.json` (not `src-tauri`), then one `box exec` that installs Rust and Bun, runs `bun install` and `bun tauri ios build`. ## Step 4. First build Run: ```sh box build --dry-run box build ``` If the user also asked for tests or a screenshot, skip the plain `box build` and run `box test --screenshot out.png` (or `box screenshot out.png`) after the dry run: every job builds first and reports compile errors the same way, so a separate build only adds a Mac job. Expect from `--dry-run`: one line per file with its size, then `box: N files, B bytes would be sent`. Check that no secret file is in the list before going on. `.env` files and anything `.gitignore` excludes are never sent. When the project has a `.box/setup` script, the dry run also says `box: setup would run` or `box: setup would be skipped (unchanged)`. A `.box/setup` bash script at the project root runs on the build machine before `box build`, `box test` and `box run` (and before xcodebuild or gradle), once until its contents change; a changed script runs again and the log says `setup ran`. If it fails, the build does not start, the job exits 1 and the script's own output is in the log. Its time counts as part of the job. It is the place for fetching frameworks or copying an `.xcconfig`. It must not fetch secrets, and `.env` is still never uploaded. Expect from `box build`: one `box: : ...` line per step in order (`upload`: files checked and sent, `queue`: the job id and rate, `machine`: a Mac took it and unpacked the source, `cache`: whether the project's previous build was attached, `build`, `test` for `box test`, `results`: the folder the files were saved to), the build log streaming between them, and a last line `box: succeeded, s billed`. Exit code 0. With `--json` the same steps are `{"t":"stage","stage":"build","text":"..."}` lines. If not: - A failed job ends with `box: details: .box/out//why.txt`. Read that file and the `.box/out//why-*.png` pictures first: they are what only the Mac has (crash stacks with symbols, failing tests with file:line, the screen at the failure). `test.log` and `test.xcresult.zip` sit next to them. - Exit 1 with `box: N compile error(s):` and `file:line:col: message` lines: these are real errors in the user's code with local paths. Fix them and run `box build` again. - `This folder has no ... app project at its top`: see the last item of step 3 (`box exec -- cargo build`, or `--workspace`). - `no .xcodeproj or .xcworkspace found` or `no scheme found`: run from the project root, or pass the scheme with `box build --scheme `. - Exit 3 about the balance: ask the user once as in the top-up item of step 2; after `box topup --wait` returns, run the same command again. - Exit 3 for anything else: show the message to the user. Do not loop. ## Step 5. Report to the user If the user's message asked for more than setup (for example "then build and screenshot the app"), do that now with box without asking first, then report. Tell the user, in one short message: box is installed, which GitHub login is signed in, the balance line from `box status`, and the job ids with their results. If a job failed, say what `.box/out//why.txt` and the `why-*.png` screen show before you guess from the log. Add one line: box was set up for every project on this machine in `~/.claude` and `~/.codex` (skills, a box section in `~/.claude/CLAUDE.md` and `~/.codex/AGENTS.md`, and the MCP server), so later sessions find box without touching the repository. ## Android box also runs Android apps on a Linux Android emulator. Every job command takes `--platform ios` or `--platform android`, and every MCP job tool takes `platform`. - Without `--platform`, box looks at the project folder: an Xcode project, `project.yml`, `Package.swift` or an `ios/` folder means iOS; `settings.gradle`, `gradlew` or an `android/` folder means Android. - When both are there (Flutter, React Native, Expo), box exits 2 and asks for `--platform`. Pick the one the user is working on, or ask them; do not guess. - To fix the choice for a project, put `platform = "android"` (or `"ios"`) in `.box.toml`. `--platform` still wins. - Android has one size: 4 vCPU / 16 GB. It costs $0.02 per minute, and the emulator boot time is free. `--xcode` is for iOS only (exit 2 on Android). - Android minutes are paid from the same US dollar balance, one size and one rate; each job prints its platform and rate when it is submitted, and `box status` shows how many Android minutes the balance buys. The rate is $0.02 per minute, so do not quote any other. Steps 1, 2 and 5 are the same for Android. Step 3 and step 4 differ: - Connect: `box setup` as in step 3, then work from the root of the Android project (the folder with `settings.gradle`, `settings.gradle.kts` or `gradlew`, or the Flutter, React Native or Expo project root). Flutter, React Native and Expo projects are found from `pubspec.yaml` or `package.json`; Expo without an `android/` folder runs its own `expo prebuild` on the Linux machine. - First build: `box build --platform android --dry-run`, then `box build --platform android`. Expect `box: job (build) submitted` with `android` and the rate, the Gradle log streaming, and `box: succeeded, s billed`. The debug APK is saved as `.box/out//app-debug.apk`; hand that path to the user when they want the APK. - If the build fails with exit 1, the Gradle errors are real errors in the user's project. Fix them and build again. Exit 3 is the same as on iOS. | need | Android command | | --- | --- | | debug APK | `box build --platform android` (saved as `app-debug.apk`) | | unsigned Release APK and AAB | `box build --platform android --device-build` (saved beside the debug APK as `app-release-unsigned.apk` and `app-release.aab`) | | unit tests | `box test --platform android` (Gradle `testDebugUnitTest`; results in `test-results/`) | | a picture of the app | `box screenshot --platform android out.png`, plus `--dark`, `--locale ko_KR`, `--record` (screen.mp4) | | open the app and keep it running | `box run --platform android` (live view and taps, as on iOS) | | drive the running app | `box ui describe` (one line per element: role, label, value, ref; `--tree` for the hierarchy), `box ui find --text T`, `box ui tap --id REF` / `--label TEXT` / `X Y`, `box ui type TEXT` (single-line ASCII only on Android), `box ui swipe X1 Y1 X2 Y2`, `box ui button home` | | one shell command on the Linux machine | `box exec --platform android -- ` | | empty this project's Android workspace and Gradle cache | `box purge --platform android --yes` | iOS only, exit 2 with `--platform android`: `box debug`, `--xcode`. `box debug` stays iOS only because the Android emulator's VM refuses the debugger call that reads variables back (JDWP `StackFrame.GetValues` answers error 500 on every frame), so a job could stop at a breakpoint but never show the values; it is not shipped as working. `--only-testing` is not used on Android: `box test` runs every unit test. Android has one size (4 vCPU / 16 GB), so there is no `--size`. The Gradle cache is kept between jobs of the same project, so the next build is incremental. ## Command reference | need | command | | --- | --- | | build for the simulator | `box build` | | unsigned Release build for a device | `box build --device-build` (saved as `device-build.zip`) | | signed Release build or IPA | `box exec bash your-release-script.sh`. box keeps no signing files and has no secrets option: the user puts their own `.p12` and `.mobileprovision` in the project folder (not in `.gitignore`), and the script imports them into a temporary keychain and the Provisioning Profiles folder before xcodebuild (or uses an App Store Connect API key with `-allowProvisioningUpdates`). If it stops on `No Accounts` or `No profiles for`, `.box/out//why.txt` has the exact commands | | run tests | `box test`, or `box test --only-testing Target/Class/test` | | run the tests before every `git push`, stop the push when they fail | `box setup --pre-push` (hook in this repo's `.git/hooks` only; skip once `git push --no-verify`; remove `box setup --pre-push --off`). Only when the user asks for it | | a picture of the app | `box screenshot out.png` | | another simulator (iPad, an older iPhone) or emulator profile | `box devices` lists them (iOS: name, runtime, udid; `--platform android`: emulator profiles), then `--device "iPad Air 11-inch (M3)"` or `--device ` on `box test`, `box run`, `box screenshot` (default iPhone 17 on the newest runtime; MCP tool `devices` and the `device` argument) | | did the screen change, and does it look intended or broken | `box screenshot --compare last` (compares with this project's last succeeded screenshot: a diff picture per changed screen in `.box/out//compare/` and one line; MCP `screenshot` with `compare: true`) | | why a failed build or test failed | read the last line of the failed command, `box: ai: `; `box why` (or `box why `) prints the full where / why / fix (MCP tool `why`) | | tests and a picture in one job | `box test --screenshot out.png` (one Mac job and one simulator boot instead of two; MCP `test` with `screenshot: true`) | | open the app and keep it running | `box run` (it builds first; no `box build` before it). Two folders run at once, each on its own simulator; a third waits and says so. `box ui` acts only on this folder's simulator, and `box status` lists each folder | | drive the running app | `box ui describe` (one line per element: role, label, value, ref; `--tree` for the hierarchy), `box ui find --text T`, `box ui tap --id REF` / `--label TEXT` / `X Y`, `box ui type TEXT`, `box ui swipe X1 Y1 X2 Y2`, `box ui button home`, `box ui screen out.png` | | stop at a breakpoint and read variables (LLDB, iOS only) | `box debug --break File.swift:42 --print count` (also `--break functionName`, `--tap-label Add` to reach code behind a button, `--stops 3`; MCP tool `debug`) | | a web page in Safari on a Mac and on an iPhone simulator | `box web https://your.site` (two pictures and `web.json`: page errors, failed requests); your dev server: `box web --serve "npm run dev" --port 3000 /checkout`; `--width 390`, `--dark` (iPhone only), `--wait-for "#app"`, `--device "iPhone 16"`; MCP tool `web` | | one shell command on the Mac | `box exec -- ` (also for a folder that is not an app: `box exec -- cargo build`) | | follow or stop a job | `box logs`, `box stop`, `box cancel` (the following command exits 130) | | list recent jobs | `box jobs` | | empty this project's workspace on the Mac | `box purge --yes` | | balance, usage, top-up | `box status`, `box usage --csv`, `box balance --csv`, `box topup --print` | | CSV dates | `--from YYYY-MM-DD --to YYYY-MM-DD` in KST (UTC+9), default the last 30 days, at most 92 days per file and nothing older than 3 months; your own account only | | box AI for this account | `box ai status`, `box ai off`, `box ai on` (on by default; MCP tool `ai`) | | a job failed on box's side (it ends with `box: looks like our side`: the Mac, a time limit, a lost connection) or was charged wrong | `box report --reason ""` (alias `box bug`; default the last failed job; MCP tool `report_job`). One report per job; the box team checks it within a few hours and `box claims` (MCP `claims`) shows refunded or declined with the reason. What a failure on our side costs follows the [terms](https://xenoci.com/terms#failures). Do not report your app's own compile errors or failing tests | | tell the box team about a problem | `box feedback ""` (attaches the last job) | | machine-readable output | add `--json` to any job command: one JSON event per line, ending with a `result` that has `billed_seconds` | `box web` is for a page your agent built: the same address in Safari on a Mac (window 1280 wide unless `--width`) and in Safari on an iPhone simulator, so a layout that breaks only in Safari shows up as two different pictures. `web.json` lists, for each, the JavaScript errors, `console.error` lines and requests that failed or answered 400 or more (the iPhone side lists them for pages served over http, such as `--serve`). With `--serve` the folder is uploaded, `npm install` (or `bun`, `pnpm`, `yarn` by lock file) runs when `node_modules` is missing, the command starts with `PORT` set, and both browsers open it as `http://box.test:`; a server that exits or never listens ends the job with its last lines. A public address uploads nothing of the folder. box does not judge the page; read the pictures and `web.json`. It is billed by the started minute, the same as an iOS build. Apple, Mac, macOS, iPhone, Safari and Xcode are trademarks of Apple Inc., registered in the U.S. and other countries and regions. box is an independent service and is not affiliated with, sponsored or endorsed by Apple Inc. Job results land in `.box/out//`. The Mac workspace is kept between jobs, so the next build is incremental; a workspace unused for 7 days is deleted. ## Exit codes | code | meaning | do | | --- | --- | --- | | 0 | done | continue | | 1 | the build or the tests failed | read the errors, change the code, run again | | 2 | wrong arguments or a local problem | fix the command or the local setup | | 3 | account or service: signed out, no balance, not invited, our outage, or a Mac problem (a test runner that never started) | show the user the message; do not retry in a loop | | 130 | the job was cancelled | nothing to fix | ## What leaves the machine Only the project folder, after `.gitignore` rules, and only files whose content changed since the previous job. `.env` files are never sent. `box build --dry-run` prints the exact list. When a command fails, box also sends an error report: the command name, exit code, step times, box version, OS, CPU, our error code and message (with paths, addresses, tokens and e-mails removed) and the job id. No code, file contents, environment values or paths. Turn it off with `box telemetry off`, `BOX_TELEMETRY=0` or `DO_NOT_TRACK=1`. Under the terms the user agrees to at sign-in, a failed build or test also sends its evidence (the log tail, test results, crash stacks, and for `--compare` the changed screens), with tokens, keys, passwords and user folder paths masked, to an AI model on Microsoft Azure, or Anthropic when Azure does not answer, for the `ai:` line, `box why` and the `--compare` verdict. Neither uses it for training. Source files and environment values are not sent. `box ai off` stops it for the account; `--compare` then still saves its diff pictures. ## Not available yet Native Windows, Intel Macs, choosing the Xcode or iOS version, physical iPhones (simulators only), team or organization accounts. Pricing: https://xenoci.com/docs#price, rates as JSON at https://xenoci.com/api/v1/pricing. Human guide: https://xenoci.com/docs.