unity-cli-plugin

April 17, 2026 · View on GitHub

unity-cli-plugin

AI coding agent plugin for Unity Editor — supports Claude Code & Codex CLI
Powered by unity-csharpconsole

License Unity Claude Code Codex CLI

40+ commands for scene editing, components, assets, screenshots, profiling, and more.
Depends on unity-csharpconsole — a Roslyn-powered interactive C# REPL for Unity.

Quick Start · Usage · Commands · Custom Commands · Architecture

English | 中文


You:    "Create 10 cubes in a circle and add Rigidbody to each"
Claude: Done. 10 cubes created at radius 5, each with a Rigidbody component.

⚡ CLI + Skills

CLI commands exposed through Claude Code's skill system.

  • Token-efficient. Skills load on demand.
  • Unrestricted. Falls back to a full Roslyn C# REPL — not limited to predefined tools.
  • No sidecar. Service runs inside Unity Editor. No extra process.
  • Workflow-aware. Understands Unity's compile lifecycle, play mode, domain reload.
  • Automatic custom command discovery. User-defined C# commands are synced into the skill catalog.
  • Runtime / IL2CPP support. Works with HybridCLR for runtime builds.

🚀 Quick Start — Claude Code

Prerequisites: Claude Code, Unity 2022.3+, Python 3.7+

# 1. Add the marketplace & install the plugin
claude plugin marketplace add niqibiao/unity-cli-plugin
claude plugin install unity-cli-plugin

# 2. Install the Unity package (inside your project)
claude
> /unity-cli-setup

# 3. Verify
> /unity-cli-status

🚀 Quick Start — Codex CLI (Experimental)

Note: Codex CLI does not yet officially support third-party plugin distribution. The steps below rely on the local workspace marketplace, which may change in future releases.

Prerequisites: Codex CLI, Unity 2022.3+, Python 3.7+

# 1. Start Codex in your Unity project
cd /path/to/your/unity-project
codex

# 2. Tell Codex to clone and install the plugin:
#    "Clone https://github.com/niqibiao/unity-cli-plugin/tree/codex-plugin
#     then run install.sh with the current directory"

# 3. Restart Codex, find and install the plugin
/plugins              # locate unity-cli-plugin → Install

# 4. Restart Codex again, then initialize the Unity package
$unity-cli-setup

# 5. Verify
$unity-cli-status
Manual install / already have a marketplace
cd /path/to/your/unity-project
git clone --depth=1 -b codex-plugin https://github.com/niqibiao/unity-cli-plugin.git plugins/unity-cli-plugin
rm -rf plugins/unity-cli-plugin/.git

Then add to .agents/plugins/marketplace.json:

{
  "name": "local-workspace",
  "plugins": [{
    "name": "unity-cli-plugin",
    "source": { "source": "local", "path": "./plugins/unity-cli-plugin" },
    "policy": { "installation": "INSTALLED_BY_DEFAULT", "authentication": "ON_INSTALL" },
    "category": "Productivity"
  }]
}

💬 Usage

Just tell Claude what you want:

> Add a directional light and rotate it 45 degrees on X
> Find all "Enemy" objects and list their components
> Take a screenshot of the Scene View
> Start profiler recording with deep profiling

Claude picks the right command or writes C# code as needed.

⌨️ Slash Commands

CommandDescription
/unity-cli-setupInstall the Unity package
/unity-cli-statusCheck package and service status
/unity-cli-refreshTrigger asset refresh / recompile
/unity-cli-refresh-commandsRefresh cached custom command list
/unity-cli-sync-catalogCompare local command catalog with live list

💻 Direct CLI

python cli/cs.py exec --json --project . "Debug.Log(\"Hello\")"
python cli/cs.py command --json --project . gameobject create '{"name":"Cube","primitiveType":"Cube"}'
python cli/cs.py refresh --json --project . --exit-playmode --wait 60
python cli/cs.py batch --json --project . '[{"ns":"gameobject","action":"create","args":{"name":"A"}},{"ns":"gameobject","action":"create","args":{"name":"B"}}]'
python cli/cs.py list-commands --json --project . --timeout 10
python cli/cs.py catalog sync --json --project .
python cli/cs.py catalog list --json --project .

📦 Commands

50 built-in commands across 13 namespaces. All commands support --json output.

gameobject

ActionDescription
findFind GameObjects by name, tag, or component type
createCreate a new GameObject (empty or primitive)
destroyDestroy a GameObject
getGet detailed info about a GameObject
modifyChange name, tag, layer, active state, or static flag
set_parentReparent a GameObject
duplicateDuplicate a GameObject

component

ActionDescription
addAdd a component to a GameObject
removeRemove a component from a GameObject
getGet serialized field data of a component
modifyModify serialized fields of a component

transform

ActionDescription
getGet position, rotation, and scale
setSet position, rotation, and/or scale (local or world)

scene

ActionDescription
hierarchyGet the full scene hierarchy tree, optionally with component info

prefab

ActionDescription
createCreate a prefab asset from a scene GameObject
instantiateInstantiate a prefab into the active scene
unpackUnpack a prefab instance

material

ActionDescription
createCreate a new material asset with a specified shader
getGet material properties from an asset or a Renderer
assignAssign a material to a Renderer component

screenshot

ActionDescription
scene_viewCapture the Scene View to an image file
game_viewCapture the Game View to an image file

profiler

ActionDescription
startStart Profiler recording (optional deep profiling)
stopStop Profiler recording
statusGet current Profiler state
saveSave recorded profiler data to a .raw file

editor

ActionDescription
statusGet editor state and play mode info
playmode.statusGet current play mode state
playmode.enterEnter play mode
playmode.exitExit play mode
menu.openExecute a menu item by path
window.openOpen an editor window by type name
console.clearClear the editor console
console.markWrite a searchable marker to the editor log

asset

ActionDescription
moveMove or rename an asset
copyCopy an asset to a new path
deleteDelete one or more assets
create_folderCreate a folder in the Asset Database

project

ActionDescription
scene.listList all scenes in the project
scene.openOpen a scene by path
scene.saveSave the current scene
selection.getGet the current editor selection
selection.setSet the editor selection
asset.listList assets by type filter
asset.importImport an asset by path
asset.reimportReimport an asset by path

session

ActionDescription
listList active REPL sessions
inspectInspect a session's state
resetReset a session's compiler and executor

command

ActionDescription
listList all registered commands (built-in + custom)

🔧 Custom Commands

Custom commands are supported. See unity-csharpconsole for how to define and register them.

The plugin maintains a persistent per-project catalog of custom commands. Run cs catalog sync to pull the latest list from Unity and cache it to disk; run cs catalog list to view the cached catalog offline without connecting to the Editor.

🏗️ Architecture

Claude Code                      Unity Editor
┌──────────────────┐            ┌──────────────────────────┐
│  Skills          │            │  com.zh1zh1.csharpconsole│
│  ┌────────────┐  │            │  ┌────────────────────┐  │
│  │ cli-command│──┼── HTTP ──▶ │  │ ConsoleHttpService │  │
│  │ cli-exec   │  │            │  │  ├─ CommandRouter  │  │
│  └────────────┘  │            │  │  ├─ REPL Compiler  │  │
│                  │            │  │  └─ REPL Executor  │  │
│  Python CLI      │            │  └────────────────────┘  │
│  ┌────────────┐  │            │                          │
│  │ cs.py      │  │            │  40+ CommandActions      │
│  │ core_bridge│  │            │  (GameObject, Component, │
│  └────────────┘  │            │   Prefab, Material, ...) │
└──────────────────┘            └──────────────────────────┘
  • Plugin layer: Skills and slash commands invoked by Claude Code
  • CLI layer: Python dispatcher, serializes requests to JSON
  • Unity layer: unity-csharpconsole — HTTP service, auto-discovered command handlers, Roslyn C# REPL

Auto-detects project root and service port. No manual configuration.

❓ Troubleshooting

ProblemSolution
service: UNREACHABLEMake sure Unity Editor is open with the project loaded
package: NOT FOUNDRun /unity-cli-setup or check Packages/manifest.json
Port conflictService auto-advances to the next free port. Check Temp/CSharpConsole/refresh_state.json
Commands not foundEnsure the package compiled successfully (no errors in Unity Console)
Version mismatchRun /unity-cli-status to check version info. Update the package if protocol differs

License

Apache-2.0


If this plugin saves you time, consider giving it a star. It helps others find it.