Repeatable Unity automation for Codex, Claude, and AI-assisted workflows
Quick Start ยท Setup Guide ยท Examples ยท Contributing
- ๐ Proven Setup Flow โ A tested Windows/Codex setup flow for
unity-cli - โก PowerShell Helpers โ Reusable helpers for safe
unity-cliinvocation and Unity batch methods - ๐งฉ Custom Tool Templates โ Starter templates for writing custom
[UnityCliTool]commands - โ Validation Workflow โ Repeatable validation for compile, console, scene, prefab, resource, and test checks
- ๐ Copyable Examples โ PowerShell examples that work with Unity +
unity-cliout of the box - ๐ฏ Multi-Instance Support โ Guidance for choosing the correct Unity Editor with
--project - ๐ก๏ธ Safer Patterns โ Validation patterns for domain reloads, compile waits, and wrapper tools
Note
Prerequisite: unity-cli must be installed and available on your PATH. A Unity project must be open in the Editor.
$PSNativeCommandArgumentPassing = "Standard"
unity-cli --project C:/Path/To/YourProject status
unity-cli --project C:/Path/To/YourProject list
unity-cli --project C:/Path/To/YourProject compile_check_toolflowchart LR
A["๐ค AI Agent<br/>(Codex / Claude)"] -->|invoke| B["๐ PowerShell Helpers"]
B -->|unity-cli| C["๐ฎ Unity Editor"]
C -->|execute| D["[UnityCliTool]"]
D -->|return| E["๐ฆ JSON Result"]
E -->|parse| A
Can't see the diagram? View the text version.
AI Agent (Codex/Claude) โ PowerShell Helpers โ Unity Editor โ [UnityCliTool] โ JSON Result โ Agent
Unity_Cli_Jason/
โโโ ๐ README.md # You are here
โโโ ๐ docs/ # Setup, troubleshooting, workflow docs
โ โโโ getting-started.md
โ โโโ codex-setup.md
โ โโโ custom-tools.md
โ โโโ validation-workflow.md
โ โโโ troubleshooting.md
โโโ ๐ templates/ # Starter files for custom tools & scripts
โ โโโ cli-tool-template/
โ โโโ validation-script/
โ โโโ repo-bootstrap/
โโโ ๐ scripts/ # Setup and verification helpers
โ โโโ invoke-unity-cli-safe.ps1
โ โโโ wait-unity-ready.ps1
โ โโโ invoke-unity-batch-method.ps1
โโโ ๐ examples/ # Concrete examples & case studies
โโโ compile-check/
โโโ scene-validation/
โโโ robot-kinematics/
โโโ case-study-kine-tutor3d/
๐ง Custom Tool Invocation
$PSNativeCommandArgumentPassing = "Standard"
unity-cli --project C:/Path/To/YourProject fk_compute_tool --params '{"template":"ExampleBot","joints":"0,45"}'โ Full Validation Flow
$PSNativeCommandArgumentPassing = "Standard"
./scripts/wait-unity-ready.ps1 -ProjectPath C:/Path/To/YourProject
./scripts/invoke-unity-cli-safe.ps1 -ProjectPath C:/Path/To/YourProject compile_check_tool
./scripts/invoke-unity-cli-safe.ps1 -ProjectPath C:/Path/To/YourProject console_check_tool --params '{"type":"error"}'
./scripts/invoke-unity-cli-safe.ps1 -ProjectPath C:/Path/To/YourProject scene_validate_tool --params '{"name":"all"}'
./scripts/invoke-unity-cli-safe.ps1 -ProjectPath C:/Path/To/YourProject resource_validate_tool๐ Script Helpers Reference
| Script | Description |
|---|---|
invoke-unity-cli-safe.ps1 |
Wraps unity-cli calls with stable PowerShell defaults, retry support, and project-aware status handling |
wait-unity-ready.ps1 |
Waits for the correct Unity project to reach ready, but fails fast on no instance and project locked |
invoke-unity-batch-method.ps1 |
Runs any Unity -executeMethod in batchmode, checks for project-lock conflicts, and can retry once after compile-only passes when you provide a success pattern |
| Audience | Use Case |
|---|---|
| Unity Developers | Using AI agents (Codex, Claude, etc.) in your daily workflow |
| Teams | Building project-specific unity-cli custom tools |
| Anyone | Looking for a repeatable way to inspect, validate, and automate Unity Editor state |
Note
- Tool logs and response messages should be written in English.
- Tool names and parameter shapes should be project-agnostic and reusable across Unity projects.
- Prefer generic inputs such as
scene,required_objects, andforbidden_objectsover project-specific names. - Keep project-specific behavior behind scene paths, method names, or arrays passed through
--params.
๐ช Codex / Windows Notes
- Use registered tool names such as
compile_check_tool, not guessed kebab-case aliases. - In PowerShell, prefer
--params '{"key":"value"}'when passing strings, booleans, or comma-separated values. - Set
$PSNativeCommandArgumentPassing = "Standard"before invoking complex commands. - If more than one Unity project is open, prefer
unity-cli --project C:/Path/To/YourProject .... - After menu execution, recompiles, or build-target switches, wait for
statusto returnreadybefore chaining the next command. - Prefer
scripts/invoke-unity-cli-safe.ps1inside PowerShell automation when you want retries and clearer failure messages. - Prefer
scripts/invoke-unity-batch-method.ps1for batch-executeMethodruns instead of hand-writing raw Unity command lines every time.
Important
- EditMode automation is usually the most reliable baseline.
- PlayMode automation can be environment-sensitive and may require batch or isolated project workflows.
- Custom wrapper tools such as
run_edit_mode_tests_toolare often more reliable than JSON-heavy test commands in PowerShell scripts.
- More reusable custom tool templates
- Better PlayMode runner guidance
- More agent-specific setup notes
- Cross-platform examples beyond Windows
Issues and PRs are welcome, especially for:
- New generic custom tool templates
- Better
unity-clivalidation flows - Cross-project examples
- Windows/macOS/Linux environment notes
Built for AI-assisted Unity workflows