Skip to content
Back to skills

Unity Cli Bridge

ASecurity

Use when the user wants to operate Unity through Unity CLI Bridge (`unity-cli`/`ucli`), including live command selection, asset commands, scene/prefab inspect/patch flows, QA test automation (Play Mode input simulation), console-log verification, or Unity CLI Bridge troubleshooting.

  • 3 stars
  • 0 votes
  • 0 copies
  • 4 views
  • Added October 23, 2026
toolsgoc#shellbashtestinggit

Works with

  • cli

Security analysis

A100/100

Pro scans all 13 files and shows the line behind each finding

Scanned November 11, 2026

npx -y skills add yhc509/unity-cli-bridge --skill unity-cli-bridge --agent claude-code

Installs into .claude/skills of the current project.

Are you the author of Unity Cli Bridge?

Add the live security badge to your README. It updates with every re-scan.

Security grade badge for Unity Cli Bridge
[![Security: A — Skills Directory](https://www.skillsdirectory.com/api/skills/yhc509-unity-cli-bridge/badge)](https://www.skillsdirectory.com/skills/yhc509-unity-cli-bridge)

More formats (shields.io, HTML) on the badges page. Keep it an A: scan every change in CI with Pro.

Download with Pro
SKILL.md
---
name: unity-cli-bridge
description: "Use when the user wants to operate Unity through Unity CLI Bridge (`unity-cli`/`ucli`), including live command selection, asset commands, scene/prefab inspect/patch flows, QA test automation (Play Mode input simulation), console-log verification, or Unity CLI Bridge troubleshooting."
---

<!-- unity-cli-bridge-package-version: 0.6.1 -->
<!-- unity-cli-bridge-skill-channel: plugin -->

# Unity CLI Bridge

This copy is the shared plugin skill for Unity package `com.yhc509.unity-cli-bridge` 0.6.1. It is one skill for every project, so the open project may be on a different package version. Warn the user when the versions differ, then keep going.

`unity-cli status` does not include the package version. Use it to confirm the live editor (`projectName`, `projectRoot`, `unityVersion`, and the play/compile flags). Read `version` from the resolved package file: `Packages/com.yhc509.unity-cli-bridge/package.json` when the package is embedded, otherwise `Library/PackageCache/com.yhc509.unity-cli-bridge@*/package.json`. Ignore `Packages/packages-lock.json` for this check when the dependency is `git` or `file:` — that `version` is a URL or path.

`UNKNOWN_COMMAND`, or a `PROTOCOL_MISMATCH` the CLI could not re-exec, means this project's package and this skill do not describe the same commands. Ask the user to install the matching CLI from that project's `Window > Unity CLI Manager`, and to refresh this plugin (`/plugin marketplace update unity-cli-bridge`, `codex plugin marketplace upgrade unity-cli-bridge`, or `grok plugin marketplace update unity-cli-bridge`). Loaded from the plugin, the slash command is `/unity-cli-bridge:unity-cli-bridge` (bare `/unity-cli-bridge` when the name is free).

## Workflow

1. Run `unity-cli`. `ucli` is only an optional shell alias: never try it first, and if a lookup fails see command-flows.md `Finding the executable`. Every command and subcommand takes `--help` (`unity-cli qa --help`, `unity-cli qa key --help`).
2. **Always pass `--project <path|name>`.** A project folder has `Assets/` and `Packages/`; if the working directory is not one, run `unity-cli instances list --brief`. Details: command-flows.md `Choosing the project`.
3. Check `status --project "$P" --output compact` before a write and confirm `projectName`. If no Editor is live, start it yourself with `editor launch --project "$P"` (headless, idempotent, waits until the bridge is ready).
4. After the task, run `read-console --no-stacktrace --output compact`.

## Rules that matter most

- Add `--output compact` whenever an LLM reads the output.
- `play`, `stop`, `refresh`, and `compile` wait until Unity has settled, including the domain reload. **Do not `sleep` or poll `status` after them.** `--no-wait` returns at once.
- Scripts: write the `.cs` file, run `refresh`, then `read-console --type error`. `--type error` includes Exception and Assert as well as Error; the entry `type` stays `Exception` or `Assert`.
- `execute --force --code '...'` runs C# in the Editor. Return a value with `__pucResult = ...;`. Pass inputs with `--args '{json}'` and read the string `__pucArgsJson`. A snippet is compiled once per domain (`cacheHit: true`, `compileMs: 0` on repeats), so keep `--code` identical and vary `--args`. Long work: `--timeout <s>` (max 600) and check `__pucToken`. Snippets compile with the Editor's scripting defines, including `UNITY_ASSERTIONS`, so `Debug.Assert` and `Debug.LogAssertion` are kept. Snippets can use C# 9. They cannot use covariant returns, default interface methods, function pointers, or C# 10 or newer. Set `UCB_EXECUTE_COMPILER=codedom` and restart the editor to turn the Roslyn host off.
- Inside `execute`, `Object` is `UnityEngine.Object`, so `Object.FindFirstObjectByType<T>()` compiles as written.
- Destructive or overwriting commands need `--force`. The full list, backups, and dirty-scene rules: [operating-rules.md](references/operating-rules.md).
- Before `scene patch` / `prefab patch`, inspect with `--with-values --omit-defaults` and copy paths and property names from it. Never guess `propertyPath`. Prefer `scene add-object`, `set-transform`, `assign-material` over a patch spec.
- A bare `screenshot` is already agent-sized. Pass its image coordinates straight to `qa tap --x --y`. Do not flip Y or scale. Find targets with `qa ui-dump` / `qa world-dump` instead of guessing.

## Per-frame Play Mode logic — never poll

**Never drive the game by calling `execute` in a shell loop, and never `sleep`-poll state between calls.** Register the logic once with `PucFrameLoop`, let Play Mode run, then read the result:

```bash
unity-cli play --project "$P" --output compact
unity-cli execute --force --project "$P" --output compact --code '
var bird = GameObject.Find("Bird");
PucFrameLoop.Start("autopilot", () => {
    if (bird == null) return false;
    if (bird.transform.position.y < 0f) bird.SendMessage("Flap");
    return true;
}, timeoutSeconds: 20);
__pucResult = "started";'
sleep 10
unity-cli execute --force --project "$P" --output compact --code '__pucResult = PucFrameLoop.Status("autopilot");'
```

- `PucFrameLoop.Start(name, Func<bool>, timeoutSeconds = 60)` runs once per editor frame until it returns false, throws, times out (max 600 s), or Play Mode exits. `Status(name)` gives `running|finished|timeout|stopped|play-mode-exited|error` plus `frames=`/`elapsed=`. `Stop(name)` ends one. `Running` lists them.
- A domain reload drops every loop, so start loops after `play` returns.

## QA input

- QA commands need Play Mode. With the Input System active, `qa tap`/`swipe`/`key` queue real device events.
- On the legacy Input Manager, pointer input is a simulated touch that also reads as `Input.GetMouseButtonDown(0)` and `Input.anyKeyDown`. Unity cannot inject legacy keys, so `qa key` reaches only `IQaKeyHandler` components (`QA_LEGACY_KEY_UNSUPPORTED` otherwise). Use `qa tap`, or a `PucFrameLoop` that calls the game's method.
- Multi-step input with waits: `qa run-sequence --spec-json @file`. Details: [qa-testing.md](references/qa-testing.md).

## Read next

- [operating-rules.md](references/operating-rules.md): editor lifecycle, force/backup rules, inspect sizing, `PROTOCOL_MISMATCH`, records, components, convenience commands
- [command-flows.md](references/command-flows.md): project selection, everyday commands, assets, scenes, test runner, verification
- [prefab-workflows.md](references/prefab-workflows.md): prefab create/inspect/patch specs
- [scene-spec.md](references/scene-spec.md): scene inspect fields and scene patch operations
- [qa-testing.md](references/qa-testing.md): Play Mode input, coordinates, waits, sequences
- [profiling.md](references/profiling.md): profile/memory loops and how to read the numbers
- [troubleshooting.md](references/troubleshooting.md): stale instances, busy, live-connection problems, logs
- `assets/`: JSON templates

Files in this skill

  • SKILL.md6.5 KB
  • agents/openai.yaml284 B
  • assets/prefab-create-basic.json231 B
  • assets/prefab-patch-boxcollider.json512 B
  • assets/scene-patch-basic.json380 B
  • assets/scriptable-object-data.json37 B
  • references/command-flows.md12.8 KB
  • references/operating-rules.md12.8 KB
  • references/prefab-workflows.md3 KB
  • references/profiling.md27.2 KB
  • references/qa-testing.md22.6 KB
  • references/scene-spec.md3.7 KB
  • references/troubleshooting.md2.8 KB

Attribution

Is this your skill, or is something wrong with this listing? Request removal or report an issue. Author removals are honored within 72 hours.

View all in tools →

Comments

Loading comments…

Newsletter

Get the weekly list of safe new skills, and the ones we pulled.