AGENT SKILL

unity-foundation

Lightweight Unity Foundation skill always loaded for architect, unity-dev, and data-tool agents. Covers asmdef design, scene lifecycle contracts, project structure, asset hygiene, and Unity-specific code quality. Does NOT replace core ECS skills — ECS guidance always takes precedence when both apply.

License 许可
MIT
最近更新
2026-07-25
Stars
★ 8
Forks
0

01 前言 Front Matter

name
unity-foundation
metadata
{ "tier": 1, "source": "https://docs.unity3d.com/Manual/AssemblyDefinitionFiles.html", "version": "Unity 6 (6000.0)" }
use-when
Always load as P2 foundation context for architect, unity-dev, and data-tool agents. Load when assembly boundaries, scene lifecycle, or project structure decisions must be made.
platforms
[ "claude-code", "codex", "copilot", "cursor", "windsurf" ]
description
Lightweight Unity Foundation skill always loaded for architect, unity-dev, and data-tool agents. Covers asmdef design, scene lifecycle contracts, project structure, asset hygiene, and Unity-specific code quality. Does NOT replace core ECS skills — ECS guidance always takes precedence when both apply.
do-not-use-when
Never the primary ECS skill — load unity-dots-best-practices for ECS work. Do not load for tester or verifier roles. Do not load for triage.
task-categories
[ "foundation", "structure", "assemblies", "scene-management" ]

03 SKILL.md 正文

Unity Foundation

This skill is SECONDARY to core ECS skills. When ECS and foundation guidance conflict, ECS wins.

Assembly Design (asmdef)

  • Split editor code from runtime in separate assemblies (runtime.asmdef, editor.asmdef)
  • Keep test code in a dedicated tests.asmdef — never reference test code from runtime
  • Dependency direction: Tests → Runtime ← Editor (never Runtime → Editor)
  • For ECS: additional split — authoring.asmdef references runtime.asmdef only
  • Minimize inter-assembly dependencies to reduce compile times in large repos

Scene Lifecycle Contracts

For hybrid ECS + MonoBehaviour projects:

  • Define explicit entry/exit contracts for each scene (what ECS state exists on entry, what is cleaned on exit)
  • MonoBehaviour bootstrap: one entry point ([DefaultExecutionOrder(-10000)]), no static singletons
  • ECS world lifecycle: world is created at bootstrap, systems initialize in OnCreate, dispose in OnDestroy
  • Hybrid boundary: MonoBehaviour components that exist for baker input only — mark with clear naming convention

Project Navigation (for large repos)

  • Before reading code: check workspace/repo-knowledge.md for prior system mapping
  • Before designing: check workspace/ecs-registry.md for existing components
  • Use perception REST skills to read live scene state when code reading is insufficient
  • Use CRG get_architecture_overview for code-level system discovery

Unity-Specific Code Quality

  • Every Update/LateUpdate/FixedUpdate must open with guard clauses (isInitialized, null checks)
  • Prefer early returns over nested conditionals
  • Keep MonoBehaviour lifecycle methods as thin wrappers — delegate to plain C# classes
  • For ECS: ISystem methods are already guard-free by design — no MonoBehaviour guard clauses needed
  • Debug.Log is NOT stripped in Player builds by default — use conditional compilation or custom logger

Unity-Skills REST Integration

When calling Unity-Skills REST skills:

  1. Always check GET /health before first skill call — verify currentMode
  2. Respect the permission mode — do not call SemiAuto skills without checking mode
  3. Call unity_diagnose first for any debugging task — it provides an aggregated health snapshot
  4. Prefer read-only skills (perception, debug, console) over mutating skills unless mutation is required
  5. Batch-first: when touching 2+ objects, prefer *_batch skills over repeated single calls
  6. Do NOT call workflow or smart modules — they conflict with agent orchestration

04 同仓库更多 Skills

dyCuong03
dyCuong03/unity-agent-team

dots-update-groups

How to choose the right ECS system group and ordering so per-frame and per-fixed-step work is deterministic and never races its own readers. Covers InitializationSystemGroup / SimulationSystemGroup / PresentationSystemGroup / FixedStepSimulationSystemGroup / VariableRateSimulationSystemGroup, UpdateBefore / UpdateAfter peer ordering, OrderFirst / OrderLast group-boundary placement, RateManager, and the cross-group ordering trap. Use when adding an ISystem, fixing "value visible one frame late" bugs, or coupling simulation to a fixed timestep.

★ 8
dyCuong03
dyCuong03/unity-agent-team

dots-transform-patterns

The Entities 1.x transform model — LocalTransform (writable input) vs LocalToWorld (system-owned matrix), Parent/Child hierarchy, reparenting cost, uniform vs non-uniform scale (PostTransformMatrix), and when to opt out with custom transform systems. Use when designing parent/child hierarchies, runtime reparenting (mount/dismount/socket), or choosing transform components at the Baker boundary.

★ 8
dyCuong03
dyCuong03/unity-agent-team

dots-singleton-patterns

Model cross-system shared configuration and game state as a single-entity component with a strict single-writer contract. Covers RequireForUpdate gating, SystemAPI.GetSingleton / GetSingletonRW / HasSingleton / TryGetSingleton, bake-time vs runtime-created vs ECB-system singletons, the "exactly one entity" runtime invariant, and the single-writer rule. Use when designing frame-stable global config, shared mutable state, or any component intended to exist on exactly one entity.

★ 8
dyCuong03
dyCuong03/unity-agent-team

dots-hybrid-bridge

The one-way bridge between DOTS-owned runtime state and Unity-owned presentation. Covers UnityObjectRef for managed asset refs in components, the DOTS-writes / Unity-reads ownership rule, when to use managed IComponentData vs UnityObjectRef vs CompanionComponent, baker-bridge vs runtime-bridge, and SubScene boundary rules. Use when an entity must reference Unity assets (Mesh, Material, AudioClip, ScriptableObject), a MonoBehaviour view must read entity state, or input/UI must trigger ECS work.

★ 8
dyCuong03
dyCuong03/unity-agent-team

dots-event-driven-ecs

Model one-frame events and external requests in ECS without dual ownership, polling, or persistent state leaks. Covers request-tag pattern with ECB, enableable command components (no structural change), event buffers (IBufferElementData), explicit consumer ownership, one-frame latency rules, and the banned C# event / UnityEvent / static bus anti-patterns. Use when input/UI/network must trigger ECS work, when a one-frame signal fans out to N consumers (damage, hit, collision), or when state changes must be processed exactly once.

★ 8
dyCuong03
dyCuong03/unity-agent-team

valid_skill

A complete, well-formed test fixture skill for SkillHub validation testing. Covers basic task routing and code review for Unity projects.

★ 8