Use when dotcraft-unity MCP, CLI, or unity_execute_csharp is available, or when the user asks to inspect, automate, capture, or debug Unity Editor state, scenes, assets, Console logs, or GameView output. Provides background-first Unity Editor automation through MCP or CLI.
Installs into .claude/skills of the current project.
Sponsors
SSkills DirectorySkills Directory
Know which skills are safe — weekly.
SSkills DirectorySkills Directory
Is that skill safe to install?
Are you the author of Dotcraft Unity?
Add the live security badge to your README. It updates with every re-scan.
[](https://www.skillsdirectory.com/skills/dotharness-dotcraft-unity)
---
name: dotcraft-unity
description: Use when dotcraft-unity MCP, CLI, or unity_execute_csharp is available, or when the user asks to inspect, automate, capture, or debug Unity Editor state, scenes, assets, Console logs, or GameView output. Provides background-first Unity Editor automation through MCP or CLI.
---
# DotCraft Unity
## Overview
Use `unity_execute_csharp` for short Unity Editor snippets containing optional leading `using` directives followed by method-body statements. Treat it as live editor automation: it can inspect and mutate scene, asset, and project state. Do not send namespace, class, or method declarations.
This skill governs Unity tool calls, especially `unity_execute_csharp`. It does not replace normal repository file editing workflows.
## Choose the connection
Prefer the MCP tools. Use `dotcraft-unity.exe` when they are unavailable. See the [CLI reference](references/cli.md) for setup and usage.
If a dispatched MCP or CLI call fails, times out, or disconnects, do not replay it automatically: Unity may already have executed it. The tools are `unity_execute_csharp` and `unity_recompile`. `status` and tool listing are read-only and never attach. `--pid` selects an Editor when needed.
## Inline code or a saved script
`unity_execute_csharp` takes either `code` or `path`, never both. `path` accepts either a project-relative path or an absolute path. A script file holds exactly the same thing `code` does — optional leading `using` directives followed by method-body statements — and is never compiled by Unity.
Pass `args` to parameterise a script. It arrives as a Newtonsoft `JObject` named `Args`:
```csharp
var maxRows = (int?)Args["maxRows"] ?? 20;
```
Use `path` when a task recurs — the same script re-runs from a short path instead of resending the whole snippet, and it hits the compilation cache. Use inline `code` for one-off work.
## Where scripts live
Bundled scripts ship in `scripts/` inside this skill directory and are the canonical source. Pass their absolute paths directly to `unity_execute_csharp`; do not copy them into the Unity project first.
Write project-specific scripts to `.craft/scripts/`. Before writing one, check whether the installed skill already provides it.
## References
Load only the reference needed for the current task:
- **Editor window screenshots**: Read `references/gameview-screenshot.md` when the user asks to capture, compare, inspect, or save what a Unity Editor window looks like — GameView, SceneView, or the whole Editor — or to render a specific camera viewpoint.
- **Console reading**: Read `references/console-reading.md` when the user asks to inspect, summarize, search, or diagnose Unity Console logs.
- **API helpers**: Read `references/api.md` when a `unity_execute_csharp` snippet needs loaded-type lookup or third-party component reflection.
- **Snippet failure modes**: Read `references/snippet-craft.md` when a snippet times out, fails to compile, or when the effect of a call is not visible in the same call.
- **Compilation and script reload**: Read `references/compilation-and-reload.md` before triggering compilation or reload, or starting work that must survive a reload.
## Default behavior
Keep Unity in the background: prefer read-only inspection first, then make the smallest useful change when the user's request clearly asks to fix, create, modify, or automate something in Unity. Keep each automation bounded to what was asked, and use `AssetDatabase`, `EditorSceneManager`, `PrefabUtility`, and `Undo` deliberately for asset, scene, and prefab work.
## Waiting for Editor readiness
For script compilation and reload, follow `references/compilation-and-reload.md`: `unity_recompile` (CLI `recompile`) waits for its own compilation and the bridge recovery after it. Then issue a fresh bounded read-only call. Do not infer readiness from window focus, progress bars, Editor log silence, a fixed delay, or `EditorApplication.isCompiling` read right after a request: it is still false before the requested compilation starts. Any wait loop stops on a field the tool or script reports as terminal, never on a guessed state name, file name or time of day.
For asset import or asynchronous Shader compilation that does not reload managed assemblies, use bounded external readiness probes. Require `EditorApplication.isUpdating` and `ShaderUtil.anythingCompiling` to be false in two consecutive successful probes before reporting readiness.
For script or assembly-definition changes, read the Console after the Editor becomes ready and report visible compiler errors. Do not attribute pre-existing or filtered Console errors to the current operation without evidence.
## Avoid by default
Do not call these APIs unless the user explicitly asked for the visible effect or there is no background alternative and you explain it first:
- `EditorWindow.Show()`, `ShowUtility()`, `Focus()`, `GetWindow(..., focus: true)`, or any equivalent foreground activation.
- `EditorUtility.DisplayDialog`, modal prompts, object pickers, menu execution, or other UI that requires user interaction.
- `EditorGUIUtility.PingObject`, `AssetDatabase.OpenAsset`, `Selection.activeObject`, or selection changes whose purpose is only visual navigation.
- `EditorApplication.ExecuteMenuItem`, layout changes, opening Unity windows, docking changes, or changing the active view.
- Entering or exiting Play Mode, pausing, stepping frames, or changing time scale unless the user requested runtime inspection.
- Broad `AssetDatabase.Refresh`, `ImportAsset`, `ForceReserializeAssets`, scene saves, package changes, or project-wide rewrites.
Do not block or sleep on the Unity main thread. For bounded work across editor frames, use `await ctx.WaitFrame()`, `WaitFrames`, `WaitSeconds`, or `WaitUntil`. Continuations resume on the main thread. `cancellationToken` and `ctx.ThrowIfCancellationRequested()` support cooperative cancellation. MCP/CLI calls await completion without creating detached jobs. Use the compilation and reload workflow, and bounded external readiness probes for import and Shader work. For other asynchronous actions, await a bounded readiness condition with `ctx` or return the current state and perform one bounded follow-up check.
## Confirmation policy
If the user's request clearly asks for a Unity change, perform ordinary bounded changes without extra confirmation. Ask before high-risk actions:
- Deleting scenes, assets, GameObjects, Components, prefabs, or project settings.
- Entering or exiting Play Mode, changing scenes, saving dirty scenes, or modifying build settings.
- Package Manager changes, project-wide asset import/reimport, `AssetDatabase.Refresh`, or large batch operations.
- Running external processes, opening network resources, or writing outside the workspace/project tree.
- Any action that may interrupt the user's visible Editor session.
When confirmation is needed, describe the exact Unity action and the state it may change.
## Snippet style
Keep snippets short and deterministic. Prefer one clear task per call.
Place any required ordinary, alias, `static`, or `global` using directives at the beginning of the snippet. `using var` declarations and `using (...)` statements are method-body statements and can be used normally.
Snippets already import `DotCraft.Unity`, so use `Dcu.Type`, `Dcu.Components`, `Dcu.Get`, and `Dcu.Call` directly when they replace substantial reflection or type-search code.
Validate inputs and return early with a readable message when required objects, assets, scenes, or Unity internal APIs are missing.
For mutations, use `Undo.RecordObject` or `Undo.RegisterCreatedObjectUndo` where practical, mark dirty objects deliberately, and return what changed. Avoid silent changes.
For inspection, return a compact string or small object with only the fields needed for the next decision.