Installs into .claude/skills of the current project.
Sponsors
SSkills DirectorySkills Directory
Know which skills are safe — weekly.
SSkills DirectorySkills Directory
Is that skill safe to install?
Are you the author of Unity Cli?
Add the live security badge to your README. It updates with every re-scan.
[](https://www.skillsdirectory.com/skills/tipoli5890-unity-cli-game-studio)
---
name: unity-cli
description: >-
The unity CLI and -batchmode: install editors, licences, builds, tests,
scene diffs, exit codes.
---
# unity-cli: the tool, its exit codes, and what it will not tell you
Documented against the `unity` CLI 1.1.0 (`unity-cli@1.1.0`) and `com.unity.pipeline@1.0.1`.
When `unity version` reports something newer, **`unity <command> --help` and
`unity commands --format json` outrank this file**: that manifest lists every command, flag and
exit code the installed binary knows.
## Symptom → where to look
| Symptom | Go to |
|---|---|
| `unity: command not found`; which install updates itself | §Install and update |
| A non-zero exit you must decide whether to retry | §Exit codes |
| You need a test, build or batch run with a wall clock and a verdict you can trust | §The runner |
| A raw `Unity -batchmode …` exits `198`, `1`, `2` or `3`; windowed PlayMode; an async bake | `reference/editor-binary.md` |
| An Editor audit (`KitAudit`, `LightingAudit`) as a CI exit code | `reference/batch-audit.md` |
| Install an Editor with the Android module, create a project, check one on disk | `reference/everyday-commands.md` |
| JUnit, coverage, shards, build profiles, Android flags, reserved Editor flags | `reference/ci-surface.md` |
| The workflow file, the `doctor --ci` preflight, the runner's cache key | `reference/ci-preflight.md` |
| A headless Editor kept open between commands; Safe Mode; exit `10`, `12`, `17`, `18` | `reference/live-editor.md` |
| MCP for an agent, `unity setup`, a second skill named `unity-cli` appeared | `reference/mcp-and-shell.md` |
| An unreadable `git diff` of a scene; "who changed this prefab" | `reference/version-control.md` |
| Tests "passed" but you do not believe it; a run that did nothing | skill `unity-debug` |
## Scope: what this skill does NOT do
| Not here | Go to |
|---|---|
| Driving a running Editor to verify a change; screenshots | `unity-debug` |
| Android signing and artifact checks · WebGL · iOS on a device | `unity-android-release` · `unity-web-release` · `unity-ios-build` |
| Which packages a project needs; `.gitattributes`, LFS, `.meta` policy | `unity-new-project` |
| "find / where is / what references X" | `unity-search` |
## Install and update
Unity Hub installs the CLI and keeps it updated. Without the Hub:
```bash
curl -fsSL https://unity.com/install.sh | bash # macOS, Linux
brew install --cask unity-cli # Homebrew
winget install Unity.CLI # Windows
unity version --format json # data.version, data.channel
unity self-update --check
```
Debian/Ubuntu and Fedora/RHEL get the `unity-cli` package from Unity's apt and dnf repositories
(`reference/everyday-commands.md` §0). **Homebrew, apt and dnf installs update through their
package manager**; `unity self-update` updates the script and winget installs. Open a new shell if
`unity` is not found, then run `unity doctor`. After every update read `unity changelog`: entries
marked **Breaking** change exit codes. Old flag spellings keep working, some with a deprecation
warning in `warnings[]`: treat one in a CI log as a change to make now.
## Conventions every command shares
- Machine output is `--format json` (one envelope: `success`, `command`, `data`, `errors[]`,
`warnings[]`). Scripts add `--non-interactive --no-banner`. Piped output defaults to `tsv`.
- **Messages are localized** to the persisted `unity language`, English or not. Branch on the exit
code, `success` and `errors[].code`, never on `message`. `data` can be present on a failure.
- `unity command <name>` is the exception: without `--result-only` it prints the bare result, not
the envelope (`reference/live-editor.md` §3).
- Ignore a `notifications[]` entry that offers a remediation; never run it unasked.
## Exit codes are the interface
The CLI's own set (`unity commands --format json` → `data.exitCodes`). Retry = running the same
command again can succeed; it is never a reason to retry a verdict.
| Code | Name | Retry | Typical source |
|---|---|---|---|
| `0` | SUCCESS | | only as good as the evidence (§The runner) |
| `1` | ERROR | no | an unexpected state |
| `2` | BAD_ARGS | no | unknown flag or value |
| `3` | AUTH_ERROR | no | signed out, session expired |
| `4` | NEEDS_CONFIG | no | a tool or setting missing; `vcs merge-setup --check` with work left |
| `6` | COMMAND_FAILED | no | the run failed: compile error, failed build, project held by another Editor |
| `7` | NETWORK_UNREACHABLE | yes | a service did not answer |
| `8` | TESTS_FAILED | no | `unity test` only: the suite ran and some failed |
| `9` | INSTALL_LOCKED | yes | another install holds the lock |
| `10` | READY_TIMEOUT | yes | `open --until-ready` saw no ready Editor |
| `11` | NOT_FOUND | no | not a project, Editor not installed |
| `12` | EDITOR_UNREACHABLE | yes | no Editor answered (`status`, `command`, `recompile`) |
| `13` | REMOTE_COMMAND_FAILED | no | the Editor has no command by that name |
| `14` | TIMEOUT | yes | a `--timeout` ran out |
| `15` | RUN_FAILED | no | a cloud build or automation job failed |
| `16` | JOB_SUSPENDED | yes | a job waits for approval |
| `17` | UNAVAILABLE | yes | `EDITOR_BUSY` |
| `18` | AWAITING_INPUT | yes | a dialog holds the Editor; a person must dismiss it first |
| `130` · `143` | INTERRUPTED · TERMINATED | yes | SIGINT · SIGTERM |
| `141` | OUTPUT_CLOSED | no | the reader closed stdout |
**`unity test`:** `0` with a results file is a pass, `8` is red, `6` leaves no results file
(`TEST_RUN_ERROR`: the project does not compile, which the runner calls FAIL; `COMMAND_FAILED`
with the project open elsewhere, UNVERIFIED), `14` is `TEST_TIMED_OUT`. A failed local
`unity build` is `6`, not `15`. `unity recompile` with no Editor is `12`. A command held by a modal
dialog is `18`, not `14`: get the dialog closed, do not loop.
## The runner: `scripts/unity_run.py`
The default way to run `test`, `build`, `run`, `command` and the raw Editor. It enforces its own
wall clock (it kills the process group) as well as passing the CLI's `--timeout`, always adds
`--format json --non-interactive --no-banner`, and demands evidence before it says PASS.
```bash
python3 scripts/unity_run.py which --project .
python3 scripts/unity_run.py test . --mode EditMode --results Logs/edit.xml --timeout 900
python3 scripts/unity_run.py build . --target StandaloneOSX --output Builds/Courier.app --timeout 3600
python3 scripts/unity_run.py run . --sentinel BUILD_DONE --timeout 900 -- -executeMethod Builder.Build
python3 scripts/unity_run.py command editor status --project-path . --timeout 60
```
The last stdout line is the verdict, and the script's exit code says the same:
```
unity_run: PASS|FAIL|UNVERIFIED exit=<cli exit> wall=<s> code=<errors[0].code or -> results=<present|missing|n/a> retryable=<yes|no>
```
`0` PASS · `2` FAIL · `3` UNVERIFIED · `1` usage. **A CLI exit `0` without the evidence is
UNVERIFIED, and so is a run that names none**: `test` needs a results XML with a passed test and
no failure, `build` output this run wrote at `--output` or `data.outputPath`, `run` with Editor
flags a `--sentinel` (a log line that starts with it) or an `--out` file, `run --command` a
`data.result`. A sentinel that appears in the command line is refused, since the Editor log
repeats it. Missing binary, timeout, licence, an unreachable Editor and retryable codes are
UNVERIFIED too.
`exit=-` means nothing started or the wall clock ended it. After `--`: Editor flags for `test`,
`run` and `raw`, more `unity build` options for `build`, the command's own arguments for `command`
and `run --command`. `--unity PATH` (or `$UNITY_CLI`) picks the binary.
## The other CLI: the Editor binary
`unity_run.py raw <project> -- <flags>` runs `Unity.app/Contents/MacOS/Unity` directly for what the
CLI cannot do: windowed PlayMode, async bakes, UPM installs. It adds `-projectPath` and `-logFile`.
The binary has its **own** undocumented codes (`0` also covers "nothing ran", `198` is the
licence): give `raw` a `--results` file or a `--sentinel`, never pass `-quit` to `-runTests` or to
async work. Codes, guards and the one-Editor rule: `reference/editor-binary.md`.
## Auth and licence, before anything else
A stale login fails every headless run at once with Editor exit `198`, which looks like a compile
failure. Check `unity license status --format json` and branch on `data.active`;
`unity auth status --format json` shows `data.sessionState`. Fix with `unity auth login`.
## Running, building, testing
`unity test` passes `-runTests` without `-quit` and writes NUnit XML to `--output` (default
`test-results.xml` in the **working directory**). `unity build` takes one strategy: `--target`
with `--output`, `--profile`, or `--execute-method`. `unity run` injects `-quit`, so deferred work
needs a sentinel. **Each of `run`, `test`, `build --args` and `open --args` refuses the Editor
flags it manages, exit `6` before launch: the single list is `reference/ci-surface.md` §8.**
## A headless Editor that stays open
```bash
unity open . --batchmode --until-ready --timeout 300 --format json
unity status --project-path . --format json # only Editors whose Pipeline answers
unity editors running --format json # every Editor, reachable or not
unity close . --timeout 60
```
`unity open --batchmode` keeps running until `unity close`; with `com.unity.pipeline` in the
project, `unity command`, `unity recompile` and `unity run --command` reuse it. Pass
`--project-path` on every call. Safe Mode, dialogs, jobs and `--detach`:
`reference/live-editor.md`.
## Version control with Unity semantics
```bash
unity vcs diff Assets/Scenes/Gate.unity --format json # by GameObject and component, with a confidence
unity vcs blame Assets/Scenes/Gate.unity --object Runner --field m_Mass
unity vcs merge-setup --check # exits 4 while work remains: a CI gate
```
They read Force Text YAML (a binary asset answers `outcome: binary-serialized`); never hand-edit
the YAML. Verbs, confidence tiers, worktrees, LFS: `reference/version-control.md`.
## Discipline
- **Feed it trusted input only.** `unity shell`, `command script eval` and `projects exec` execute
what they are handed, as you.
- **Logs carry the access token.** `--log-file` output, the default `Editor.log` and
`Logs/build-*.log` hold `-accessToken` in clear when signed in; redact before sharing.
- **"No instances" inside a sandbox is not proof the Editor is down**: ask
(`reference/mcp-and-shell.md`).
- **List, never recall** template ids, Editor command names and package ids (`--format json`).
## Reference
`reference/everyday-commands.md` (install, editors, projects, config) · `reference/ci-surface.md`
(test, build, run, reserved flags) · `reference/ci-preflight.md` · `reference/live-editor.md` ·
`reference/editor-binary.md` · `reference/batch-audit.md` · `reference/mcp-and-shell.md` ·
`reference/version-control.md`.