# How to Use Claude Code with Unity Engine

Connect Claude Code to Unity Engine using AI Game Developer. Step-by-step: installation, configuration, and your first AI-powered scene inspection.

_Last updated: 2026-01-12_

Claude Code is one of the best AI agents available, powered by models like Opus 4.5. In this tutorial we connect it directly to Unity Engine so it can read your scenes, call Unity APIs, and modify your project — all from the terminal.

[Video: How to Use Claude Code with Unity Engine] (https://www.youtube.com/watch?v=dACQfUE_aZY)

## What You Need

- Unity 2021.3 or newer
- Node.js ^20.19.0 or >=22.12.0 (for CLI)
- Claude Code installed (terminal-based AI agent)
- AI Game Developer — the bridge between AI agents and Unity: github.com/IvanMurzak/Unity-MCP

## Installing AI Game Developer

AI Game Developer works as a bridge between advanced AI agents and models and Unity Engine. You can install it manually through the Unity Editor or use the CLI for a fully automated setup.

### Option A: Manual Install (Unity Editor)

1. Download the installer from the AI Game Developer GitHub page
2. Double-click the installer file to open it in Unity
3. Click "Import" in the Unity import window
4. Wait for Unity to finish compiling

### Option B: CLI Install (Recommended)

The unity-mcp-cli tool automates the entire setup from the command line — no manual clicking required. Install it globally and use it to add the plugin to any Unity project.

```bash
# Install the CLI globally
npm install -g unity-mcp-cli

# Install the AI Game Developer plugin into your Unity project
unity-mcp-cli install-plugin ./MyUnityProject
```

The install-plugin command modifies your project's Packages/manifest.json directly — it adds the OpenUPM scoped registry and the plugin dependency. It never downgrades an existing installation. After running it, open the project in Unity to complete the package installation.

## Configuring the Connection

Once the package is imported, the AI Game Developer window appears. Scroll down to find the Claude Code section and click "Configure" — that's all the configuration needed. Then click "Connect" to start the connection process. You'll see errors at first because Claude Code isn't running yet — that's expected.

### CLI: Setup MCP for Claude Code

The CLI can configure the MCP integration for Claude Code automatically — no Unity Editor UI needed. It writes the correct config files so Claude Code discovers the AI Game Developer server on launch.

```bash
# Configure Claude Code MCP integration
unity-mcp-cli setup-mcp claude-code ./MyUnityProject

# Generate skill files so Claude Code knows about available tools
unity-mcp-cli setup-skills claude-code ./MyUnityProject
```

## Launching Claude Code

You can launch Claude Code from Visual Studio Code or directly from the terminal. For this tutorial we use the terminal approach. Open the terminal in your Unity project folder — you can do this by right-clicking in the Assets folder in Unity, selecting "Show in Explorer", then right-clicking and choosing "Open in Terminal".

```bash
# Navigate to your Unity project folder and start Claude Code
cd /path/to/your/unity/project
claude
```

Once Claude Code starts, the status in the AI Game Developer window switches to "Connected". To verify everything is working, type /mcp in Claude Code — you should see "AI Game Developer" listed and connected.

## Testing AI in Your Unity Scene

With the connection established, try asking AI something like "What do you see in this scene in the Unity project?" The AI will use MCP tools provided by AI Game Developer to read your scene hierarchy, inspect GameObjects, and report back what it finds. It iterates step by step — reading the scene data, examining nested objects, and building a complete picture of your project.

When Claude Code asks for permission to use a tool, you can choose option 2 to allow it and skip future prompts for the same tool. The AI will then read your scene, identify objects like meshes, lights, and nested hierarchies, and provide a detailed description of everything it found.

## Optimizing Context

AI Game Developer exposes many MCP tools to the AI. A key tip: disable the tools you don't need. Every enabled tool consumes AI context, and keeping the context clean lets the AI work more efficiently and produce better results. You can toggle tools on and off in the AI Game Developer window — or use the CLI.

```bash
# List current tool/prompt/resource configuration
unity-mcp-cli configure ./MyUnityProject --list

# Enable only the tools you need
unity-mcp-cli configure ./MyUnityProject \
  --enable-tools gameobject-create,gameobject-find,scene-get-data \
  --disable-all-prompts

# Or enable everything at once
unity-mcp-cli configure ./MyUnityProject \
  --enable-all-tools \
  --enable-all-prompts
```

- Disable tools you don't use to keep the AI context lean
- Consider disabling Resources if you don't need them
- Prompts are slash commands — type / in Claude Code to see available commands like "set up an animation" or "add a component"
- Check the Connected status indicator to confirm the link is active

## What You Can Do From Here

With Claude Code connected to Unity, you can ask the AI to do anything the MCP tools support — inspect scenes, create GameObjects, modify components, generate animations, build UI, and much more. The AI has access to a comprehensive set of tools and can call any of them based on your natural language prompts.

You can also run MCP tools directly from the command line without going through the AI, which is useful for scripting and CI pipelines.

```bash
# Check connection status at a glance
unity-mcp-cli status ./MyUnityProject

# Run an MCP tool directly from the CLI
unity-mcp-cli run-tool gameobject-find ./MyUnityProject --input '{"query":"Player"}'

# Run Unity tests via MCP
unity-mcp-cli run-tool tests-run ./MyUnityProject --input '{"testMode":"EditMode"}'
```

### Full Automation: From Zero to Connected

The CLI can automate the entire workflow — create a project, install the plugin, configure Claude Code, open Unity, wait for the connection, and run tools. Here is a complete script that sets everything up from scratch.

```bash
# 1. Create a new Unity project
unity-mcp-cli create-project ./MyAIGame --unity 6000.3.1f1

# 2. Install the AI Game Developer plugin
unity-mcp-cli install-plugin ./MyAIGame

# 3. Enable all MCP tools
unity-mcp-cli configure ./MyAIGame --enable-all-tools

# 4. Configure Claude Code MCP integration
unity-mcp-cli setup-mcp claude-code ./MyAIGame

# 5. Open the project with MCP connection
unity-mcp-cli open ./MyAIGame --keep-connected

# 6. Wait for Unity and MCP server to be ready
unity-mcp-cli wait-for-ready ./MyAIGame

# 7. Generate Claude Code skills
unity-mcp-cli setup-skills claude-code ./MyAIGame

# 8. Verify by running a tool
unity-mcp-cli run-tool tests-run ./MyAIGame --input '{"testMode":"EditMode"}'
```

## Get Started

AI Game Developer is open source. Install the Unity package, configure Claude Code, and start prompting. The CLI tool is available on npm for automated workflows. Check the quickstart guide at ai-game.dev/docs/quickstart for detailed setup instructions.

- AI Game Developer (Unity-MCP): github.com/IvanMurzak/Unity-MCP
- AI Animation Extension: github.com/IvanMurzak/Unity-AI-Animation
- CLI Tool: npmjs.com/package/unity-mcp-cli
- Download: ai-game.dev/download
- Next: Generate animations with AI — ai-game.dev/blog/generating-unity-animations-with-ai

---

Source (HTML): https://ai-game.dev/blog/claude-code-unity-tutorial
