Unity Asmdef Graph
ASecurityUse when a Unity player build fails to compile while the editor is fine, on CS0246 or CS0234 errors for UnityEditor or another assembly, on "cyclic references" errors, after adding, moving or editing .asmdef files, when splitting code into assemblies to cut compile times, or when asked how the project's code is organized. Without opening Unity, draws the assembly graph (Mermaid or Graphviz) and finds cyclic references, unresolved or mixed name/GUID references, duplicate assembly names, player...
- 3 stars
- 0 votes
- 0 copies
- 2 views
- Added November 29, 2026
Works with
Security analysis
100/100Pro scans all 2 files and shows the line behind each finding
npx -y skills add flxnsee/gamedev-toolkit --skill unity-asmdef-graph --agent claude-codeAre you the author of Unity Asmdef Graph?
Add the live security badge to your README. It updates with every re-scan.
[](https://www.skillsdirectory.com/skills/flxnsee-unity-asmdef-graph)---
name: unity-asmdef-graph
description: Use when a Unity player build fails to compile while the editor is fine, on CS0246 or CS0234 errors for UnityEditor or another assembly, on "cyclic references" errors, after adding, moving or editing .asmdef files, when splitting code into assemblies to cut compile times, or when asked how the project's code is organized. Without opening Unity, draws the assembly graph (Mermaid or Graphviz) and finds cyclic references, unresolved or mixed name/GUID references, duplicate assembly names, player assemblies that reference Editor-only or test assemblies, platform mismatches, Editor folders inside runtime asmdef folders, and UnityEditor code outside #if UNITY_EDITOR.
license: MIT
compatibility: Python 3.10+, standard library only. Unity itself is not required. Reads Library/PackageCache if present to resolve package assemblies.
metadata:
author: gamedev-toolkit
version: "0.1.0"
---
# Unity assembly definitions: graph and checks
An `.asmdef` file turns its folder (and subfolders without their own `.asmdef`/`.asmref`)
into a separate assembly. Scripts outside any asmdef go to the predefined assemblies:
`Assembly-CSharp`, `Assembly-CSharp-Editor` (scripts in `Editor/` folders) and the
`-firstpass` variants (`Plugins/`). Most "works in the editor, fails in the build" bugs
come from code landing in the wrong assembly.
## Run the checker
`${CLAUDE_SKILL_DIR}` is this skill's folder, where its scripts are. Run the commands from the
project folder as shown, without searching for the script. If the variable was not filled
in, use the base directory shown when the skill loaded.
```bash
python "${CLAUDE_SKILL_DIR}/scripts/asmdef_graph.py" path/to/UnityProject # report + assembly table
python "${CLAUDE_SKILL_DIR}/scripts/asmdef_graph.py" . --json # for parsing
python "${CLAUDE_SKILL_DIR}/scripts/asmdef_graph.py" . --graph mermaid > assemblies.mmd
```
Exit code `0` = no errors, `1` = errors, `2` = not a Unity project (needs `Assets/` and
`ProjectSettings/`). Package assemblies are resolved from `Library/PackageCache`; if the
project was never opened in Unity, references into packages are only warnings. Each finding
names the file and says how to fix it. The assembly table lists every assembly with its
kind, script count and references; show the user the Mermaid graph before restructuring.
## Things the checker can't see
- **Code in an asmdef that uses a class from `Assembly-CSharp`.** This is the usual error
right after adding the first asmdef ("type or namespace could not be found"). Asmdef
assemblies can't see predefined assemblies, so give that class an asmdef too, starting
from the lowest-level code.
- Type-level problems in general: it reads asmdef JSON and scans scripts for `UnityEditor`,
it doesn't compile C#.
- `defineConstraints` and `versionDefines` that disable an assembly at build time.
## Rules for agents
1. **Creating an `.asmdef` moves every script below it into a new assembly.** Run the
checker before and after, and tell the user that Unity recompiles everything.
2. Write minimal JSON (Unity fills in defaults on save). Keep the project's reference form:
names or `GUID:`, never both in one file.
3. Never edit or delete an asmdef's `.meta`: its GUID is what `GUID:` references point to.
4. A new asmdef has `autoReferenced: true` by default, so `Assembly-CSharp` scripts can
still use it. Set it to `false` only if the user asks.
5. Don't merge assemblies back into one to fix a cycle unless the user agrees: that undoes
the compile-time win.
## Reference
- [references/fix-recipes.md](references/fix-recipes.md): an Editor asmdef template, which
`#if` guards are safe, breaking cycles, and the test-assembly setup. Read it when a fix
needs a new asmdef or a guard.
Files in this skill
- SKILL.md
- scripts/asmdef_graph.py
Attribution
Related skills
View all in development →Comments
Loading comments…
Newsletter
Get the weekly list of safe new skills, and the ones we pulled.