Claude Code × unity-mcp: A New Way to Build Games
Building a game in Unity typically involves juggling planning documents, spec sheets, implementation, testing, and deployment — all of which can be overwhelming for solo developers. What if you could have an AI assistant that understands your Unity project and helps you through every step?
That's exactly what Claude Code combined with unity-mcp makes possible. Using hcg-workflows, an open-source skill set, you get an 8-phase development workflow that takes you from initial concept all the way to a WebGL build deployed on GitHub Pages — with Claude Code guiding the process.
What Is unity-mcp? Bridging Claude Code and Unity Editor
unity-mcp is a tool that connects Claude Code to Unity Editor via MCP (Model Context Protocol). Normally, Claude Code excels at text-based code generation and file manipulation but can't directly interact with GUI-based development environments like Unity.
With unity-mcp installed, Claude Code gains the ability to:
- Read console logs (
read_console) to detect compile errors - Start and stop Play Mode to check for runtime errors
- Capture screenshots for visual verification of game screens
- Execute menu items to trigger custom commands
A key advantage of CoplayDev/unity-mcp is that it requires no additional runtimes like Node.js. The setup is GUI-driven and intuitive for game developers.
The 8-Phase Development Workflow
hcg-workflows adopts a Spec-Driven Development approach. Instead of letting the AI jump straight into writing code, it creates specification documents step by step before any implementation begins.
Workflow Overview
| Phase | Stage | Description |
|---|---|---|
| Phase 0 | MCP Connection | Verify unity-mcp is properly connected |
| Phase 1 | Game Design | Define concept and core mechanics |
| Phase 2 | Feature Spec | List and organize required features |
| Phase 3 | Technical Spec | Architecture and component design |
| Phase 4 | Test Spec | Test cases and validation criteria |
| Phase 5 | Task Breakdown | Split implementation into granular tasks |
| Phase 6 | Implementation | Generate and integrate C# scripts |
| Phase 7 | Verification | 3-level testing (L1/L2/L3) |
| Phase 8 | Release | WebGL build and GitHub Pages deployment |
The critical insight here is that Phases 1–5 lock down the specs before Phase 6 begins coding. Without specs, AI-generated code tends to drift in unexpected directions — a problem this workflow explicitly solves.
Setup Guide
Step 1: Install unity-mcp
Add the package through Unity Package Manager:
// Unity Editor → Window → Package Manager → + → Add package from git URL
"com.coplaydev.unity-mcp": "https://github.com/CoplayDev/unity-mcp.git?path=/MCPForUnity"
After installation, you'll see the "MCP For Unity" tab in the Unity Editor toolbar.
Step 2: Connect to Claude Code
# In the MCP For Unity tab:
# 1. Select "Claude Code"
# 2. Click Configure
# 3. Click Start Session to establish the connectionOnce connected, Claude Code can read Unity's console output and control Play Mode.
Step 3: Add the hcg-workflows Skills
# Clone the skills repository
git clone https://github.com/umezy/hcg-workflows.git
# Copy skills to Claude Code's skills directory
cp -r hcg-workflows/* .claude/skills/
# Reload VS Code to apply changesYou can now use the /dev-game command to kick off the workflow.
Key Skills in Detail
dev-game — The 8-Phase Orchestrator
This is the main skill. Running /dev-game starts the workflow from Phase 0.
# Run in Claude Code terminal
/dev-game
# Example output:
# Phase 0: Checking MCP connection...
# ✅ Connected to Unity Editor
# Phase 1: Creating game design document
# What genre and concept would you like for your game?unity-check — 3-Level Verification System
This skill validates the quality of AI-generated code at three different levels.
# L1: Compile error check (fastest)
/unity-check --level 1
# → Uses read_console to scan for errors
# L2: Runtime error check (enters Play Mode)
/unity-check --level 2
# → Play → wait a few seconds → Stop → check logs
# L3: Visual verification (screenshot analysis)
/unity-check --level 3
# → Play → capture screenshot → AI analyzes the screenunity-audio-generator — Procedural Sound Effects in C#
Generate sound effects and background music entirely from C# code using waveform synthesis — no external audio files needed.
// Generate a WAV file from waveform patterns
// Combines Sine, Square, Noise patterns with parameters
public static AudioClip GenerateJumpSE()
{
int sampleRate = 44100;
float duration = 0.3f;
int samples = (int)(sampleRate * duration);
float[] data = new float[samples];
for (int i = 0; i < samples; i++)
{
float t = (float)i / sampleRate;
// Rising frequency for a jump sound effect
float freq = 300f + t * 2000f;
data[i] = Mathf.Sin(2f * Mathf.PI * freq * t) * (1f - t / duration);
}
AudioClip clip = AudioClip.Create("JumpSE", samples, 1, sampleRate, false);
clip.SetData(data, 0);
return clip;
// Expected output: A 0.3-second rising-frequency jump sound effect
}McpRemoteControl Pattern — AI-Driven Automated Testing
Register custom menu items using the [MenuItem] attribute so the AI can manipulate game state for automated testing.
// Remote control menu accessible by AI
public class McpRemoteControl
{
[MenuItem("MCP/Start GodMode Test")]
public static void StartGodModeTest()
{
// Make the player invincible and auto-play
var player = GameObject.FindWithTag("Player");
player.GetComponent<Health>().SetInvincible(true);
// Run a 30-70 second god mode auto-test
EditorCoroutineUtility.StartCoroutine(AutoPlayTest(60f));
}
// Expected behavior: 60-second auto-play test with invincibility enabled
}Wrapping Up: Building Games with AI
The Claude Code × unity-mcp workflow isn't about having AI build your game for you — it's about building games together with AI. Spec-driven development prevents the AI from going off track, while the 3-level verification system ensures quality at every step.
For solo developers and indie studios, this approach can dramatically reduce the effort required to go from concept to deployment. It's well worth exploring.
For more on building Claude Code skills, check out our Custom Skills Development Guide. To learn about setting up MCP servers, see How to Build an MCP Server with Claude Code.