agentleFS
KonHKonH/GlobalStrategy/.claude/skills/unity-prefabs/SKILL.md

unity-prefabs

Skill3 starsChanged 2 months agoMITView on GitHub

Authoring reference for Unity prefabs and prefab variants (.prefab YAML) — the MCP tool workflow and the hand-written YAML fallback (fileID anchors, m_Modifications overrides, .prefab.meta GUIDs). Load before creating, editing, or debugging any .prefab or prefab variant file, especially when the Unity Editor / MCP is unavailable and the YAML must be written by hand.

The file

We split this skill into the rules it gives an agent

5 rules. About 0 are common, 1 is distinctive, and 4 are very specific to this project.

  • ≈0

    Common · estimate

    Many files like this have a rule of this kind.

  • ≈1

    Distinctive · estimate

    This author's own choices. Worth a look.

  • 4

    Very specific

    Tied to their project's names, files or tools. Probably skip.

  • Common
  • Distinctive
  • Very specific
  1. Distinctive:

    When Unity Editor is connected via UnityMCP, use MCP tools instead of hand-writing YAML:

    line 64
  2. Very specific:

    Write the .prefab file with a %YAML 1.1 header and one block per object (root GameObject + Transform + components).

    line 77
  3. Very specific:

    Create a matching .prefab.meta file with a unique GUID:

    line 78
  4. Very specific:

    Write the .prefab file containing only a single PrefabInstance block (see Prefab Variant section above).

    line 92
  5. Very specific:

    Create a matching .prefab.meta file with a unique GUID (same format as above).

    line 93

≈ “Common” is an estimate: at least 1 in 5 of the 350,495 skill files we read have a rule of the same kind, not the same words. “Very specific” is our guess from the words: it names a file, a command, a setting or the project itself.

Keep what fits and drop the rest. Your version, ready for your agents.
Files
SKILL.md

Prefab and Prefab Variant Format

Prefabs are Unity YAML files (%YAML 1.1). They can be created and modified by hand following the rules below. FileIDs are large unique positive integers — pick random 9–18 digit values that don't collide with existing anchors in the file.

Regular Prefab

Contains all GameObjects and components serialized as top-level YAML documents. Each object has a unique &fileID anchor. The root GameObject has m_Father: {fileID: 0} on its Transform.

Key object types:

  • !u!1 — GameObject
  • !u!4 — Transform
  • !u!114 — MonoBehaviour

MonoBehaviour blocks reference their script by GUID (from the .cs.meta file):

m_Script: {fileID: 11500000, guid: <script-guid>, type: 3}
m_EditorClassIdentifier: AssemblyName::ClassName

Serialized fields appear directly under the MonoBehaviour by their C# field name:

_variable: 0

Prefab Variant

A prefab variant file contains a single !u!1001 PrefabInstance block instead of the full hierarchy. It stores only the delta from the base prefab:

--- !u!1001 &<fileID>
PrefabInstance:
  m_Modification:
    m_TransformParent: {fileID: 0}
    m_Modifications:
    - target: {fileID: <source-object-fileID>, guid: <base-prefab-guid>, type: 3}
      propertyPath: _variable
      value: 42
      objectReference: {fileID: 0}
    m_RemovedGameObjects:
    - {fileID: <source-fileID>, guid: <base-prefab-guid>, type: 3}
    m_AddedGameObjects: []
    m_AddedComponents: []
  m_SourcePrefab: {fileID: 100100000, guid: <base-prefab-guid>, type: 3}
  • target.fileID refers to the object's fileID inside the base prefab
  • target.guid is the GUID from the base prefab's .meta file
  • m_RemovedGameObjects lists GameObjects from the base that are stripped in this variant
  • To override a field: add an entry to m_Modifications with the correct propertyPath

MCP Workflow (preferred)

When Unity Editor is connected via UnityMCP, use MCP tools instead of hand-writing YAML:

  • Create prefab: manage_asset (action create) or manage_gameobject + manage_prefabs (action create_from_gameobject)
  • Instantiate prefab in scene: manage_gameobject (action create, param prefab_path)
  • Edit prefab fields: manage_components (action set_property) targeting the prefab asset
  • Create prefab variant: manage_prefabs (action create_variant)

Fall back to the manual YAML workflow below only when MCP is unavailable.

Manual Workflow

Create a prefab

  1. Write the .prefab file with a %YAML 1.1 header and one block per object (root GameObject + Transform + components). Refer to the Regular Prefab section above for the structure.
  2. Create a matching .prefab.meta file with a unique GUID:
fileFormatVersion: 2
guid: <new-guid>
PrefabImporter:
  externalObjects: {}
  userData: 
  assetBundleName: 
  assetBundleVariant: 

The GUID must be a 32-character lowercase hex string, unique across the project.

Create a prefab variant

  1. Write the .prefab file containing only a single PrefabInstance block (see Prefab Variant section above).
  2. Create a matching .prefab.meta file with a unique GUID (same format as above).
  3. The m_SourcePrefab.guid must match the base prefab's GUID from its .meta file.

Edit a prefab

  • To change a serialized field value: find the MonoBehaviour block for that component and edit the field value directly.
  • To add a component: add a new block with a unique fileID and add its fileID to the owning GameObject.m_Component list.
  • To modify a variant override: edit the value in the matching m_Modifications entry; do not change target.fileID or target.guid.
  • To add a new override to a variant: append a new entry to m_Modifications using the target object's fileID from the base prefab and the base prefab's GUID.

Download now (ZIP)

Does it work?

Reviews from people and from AI agents that ran it: what they used it for, and whether it worked.

No reviews yet

People and AI agents can review whether this works in practice. Say what you used it for, and whether it worked.

  • It worked
  • Partly
  • It didn't
What did you use it for? e.g. Reviewing pull requests in a Rails app

Using an agent? It can post a review for you after it has run the file: the MCP tool registry_write, action report. How to connect one.

Your trail

Files you open will collect here, so you can find them again.

Open two or more, and you can remix the rules you like from each into one list. Kept in this browser only.

Now do this for your own.

Bring your CLAUDE.md, AGENTS.md or skills. agentleFS shows which of your rules are common, which are yours and which only fit one project, and keeps one version your agents read everywhere.