unity-cli

June 26, 2026 · View on GitHub

unity-cli

AI coding agent skill for Unity Editor — works with any skills-compatible agent (Claude Code, Codex, …)
Powered by unity-csharpconsole

License Unity Claude Code

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 the agent'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.
  • Self-evolving snippet library — project-local C# snippets (.md files, no compilation) with validation gate, usage tracking, and aging. Discover and grow via cs snippets.

🚀 Quick Start

Important

Install scope = the Unity project, not global — never your home / global skills directory. The bundled CLI locates your Unity project by walking up from its own file location, so detection only works when the skill lives inside the project; a home / global install sits outside every project and never finds one.

1 · Install the unity-cli skill:

cd path/to/your/UnityProject      # from the PROJECT, never your home/global dir
npx skills add niqibiao/unity-cli-skill --copy

2 · Initialize:

In your AI agent, run unity-cli setup.

Prerequisites: a skills-compatible agent (e.g. Claude Code or Codex CLI 0.139+), Node.js (for npx), Unity 2022.3+, Python 3.7+

💬 Usage

Just tell your agent 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

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

🧩 One skill, many subcommands

Everything ships in one skill (unity-cli); its cs subcommands cover every operation, and the agent triggers it automatically (in any skills-compatible agent):

SubcommandDescription
cs setupInstall the package into the manifest (version-check if present)
cs status / cs healthPackage and service status
cs command --inputStructured Unity Editor commands
cs execRun raw C# in the Editor (fallback)
cs refreshTrigger asset refresh / recompile
cs catalog sync / cs list-commandsCustom-command catalog + maintainer audit
cs snippets …Reusable C# snippet library
cs snippets doctorSnippet library health audit

📦 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)

snippets

ActionDescription
listBrowse the local snippet library
showShow a snippet's full content and metadata
searchSearch snippets by keyword
useRun a snippet (executes its C# code)
addAdd a new snippet to the library
updateUpdate an existing snippet
deprecateMark a snippet as deprecated
pruneRemove aged-out or deprecated snippets
statsShow usage statistics for the snippet library

🔧 Custom Commands

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

The skill 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

AI Agent                         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, ...) │
└──────────────────┘            └──────────────────────────┘
  • Skill layer: one unity-cli skill invoked by your agent
  • 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 cs setup to add the package, then open Unity to let it resolve
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 cs status to see versions; align the Unity package with the CLI major.minor

License

Apache-2.0


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