unity-cli-loop: Unity CLI Loop: Giving AI the Keys to the Unity Editor

A local agent loop that compiles, clicks, screenshots, and replays Unity actions until the game behaves the way it should.

9 min read • View on GitHub • More from hatayama

A wide editorial scene of a Unity Editor workbench run by an AI operator. Three hands handle code, UI clicks, and a failed test screen while small tools for compile, screenshot, and replay orbit in a loop. The image explains the repo’s core idea: AI does not just suggest code, it stays inside the development cycle until the result is verified.
Unity CLI Loop turns the editor into a closed-loop workspace for an agent, not a one-off command runner.
Key Takeaways

The Editor is no longer the boundary

Most Unity automation stops at build steps. unity-cli-loop goes further: it lets an agent compile, inspect, click, and try again without leaving the local development loop. That shift matters because game development is full of failures that only show up after the editor runs, the UI responds, or the input path is replayed.

The repo is built around that constraint. It is not a script pile with an LLM bolted on. It is a control surface for an agent that needs to sense Unity, act inside it, and verify what happened.

Unity CLI Loop v2の動的コード実行ツール、Unityが一時停止中でも動くようになっています。 ・Profilerで特定フレームで止めている時のパフォーマンス調査 ・再生中、エラーが起きたタイミングで一時停止してバグ調査 などが可能になっています! https://t.co/y88X202MjE

はたやま, m_hatayama · @m_hatayama on X

Skills, not flags

The most original idea in the repo is the skills layer. Instead of expecting an agent to discover a CLI through flags and help text, the project teaches it through `.agents/skills` files and structured examples. That is a subtle but important inversion: the user interface is written for the model first, not for a human at a terminal.

.agents/skills/
  uloop-execute-dynamic-code/
    skill.md
    references/
      scene-operations.md
      prefab-operations.md
  uloop-simulate-mouse-ui/
  uloop-record-input/
  uloop-replay-input/

That shape makes the repo feel closer to a playbook than a command palette. The skill files constrain behavior, provide examples, and give the model a narrow enough surface area to act safely inside Unity’s editor and play mode.

A close-up split workbench with skill cards on one side and a live Unity interface on the other. The left side shows a stack of `.agents/skills` cards and a C# snippet, while the right side shows a UI state and a replay spool looping back to the start. The image explains how skills steer execution and how failures can be rerun deterministically.
The skills layer narrows the agent’s choices, while replay turns a one-off failure into something the system can revisit.

Why the bridge is split in two

The architecture is deliberately hybrid. TypeScript handles orchestration in a local server, while Unity stays in C# where engine access actually lives. That split is not incidental complexity. It lets the repo use web-native plumbing for communication and still keep the final execution inside the editor package.

The loop is not just transport. It is a feedback machine that can branch between code execution and UI verification, then replay the same failure path when needed.

LayerTypeScript serverUnity C# package
JobRoutes agent requests and coordinates toolsExecutes engine-specific actions inside Unity
StrengthGood at local orchestration and protocol handlingGood at direct editor, play mode, and input access
Why it mattersKeeps the control plane outside the engine processKeeps the actuation plane inside the engine process
Failure modeA bridge problem is visible and isolatedA Unity action can be tested where it actually runs

Unity CLI Loop v2の動的コード実行ツール、Unityが一時停止中でも動くようになっています。 ・Profilerで特定フレームで止めている時のパフォーマンス調査 ・再生中、エラーが起きたタイミングで一時停止してバグ調査 などが可能になっています! https://t.co/y88X202MjE

はたやま, m_hatayama · @m_hatayama on X

The dangerous superpower: execute code on demand

The repo’s most potent tool is uloop-execute-dynamic-code. Instead of hardcoding every Unity action, the system can synthesize and run C# on demand. That makes the agent more adaptable, especially when it hits a task the existing tools do not cover cleanly.

The important detail is the references directory. It works like a retrieval layer for the model, with snippets for scene operations, prefab operations, and related Unity tasks. The agent is not improvising from memory. It is composing from a local knowledge base that is already shaped for the editor.

That is why the project feels closer to an internal operator than a command runner. The model can generate the move it needs, execute it inside Unity, and then inspect the result without waiting for a human to translate intent into a script.

From screenshot to click to replay

The UI workflow is where the project stops being theoretical. Screenshot capture gives the agent eyes. Mouse simulation gives it hands. Input replay gives it memory. Together, those tools let Unity CLI Loop verify not only that code compiled, but that the thing on screen responded the way a player would experience it.

TaskTraditional Unity automationUnity CLI Loop
Compile and buildUsually the main targetOnly one step in a longer loop
Inspect UI stateOften manual or brittleCan capture screenshots and drive clicks
Reproduce a bugDepends on a developer redoing the stepsCan record and replay the same input path
Iterate after failureHuman has to diagnose the next moveAgent can try another pass immediately

That combination is what makes the repo feel different from ordinary CI. CI is about proving a build exists. This project is about proving the editor behaves correctly, then repeating the exact failure until it does not.