dots-singleton-patterns

Enforce DOTS singleton access with SystemAPI and RequireForUpdate guards.

6|Updated Apr 2, 2026
One-click install
npx skills add https://github.com/dyCuong03/unity-agent-team --skill dots-singleton-patterns
Or copy as Structured Prompt for Agent
Please help me install this Agent Skill.
Skill: dots-singleton-patterns
Source: https://github.com/dyCuong03/unity-agent-team/tree/main/workspace/dots-program/scratch/wave-2-orchestrator-drafts/dots-singleton-patterns
Command: npx skills add https://github.com/dyCuong03/unity-agent-team --skill dots-singleton-patterns

SYSTEM DOCUMENTATION & REQUIREMENTS

What problem does it solve?

This Skill prevents silent misuse of DOTS “singletons” by establishing the correct single-entity, single-writer mental model and the required Unity Entities APIs so your code doesn’t fail unpredictably when more than one matching entity exists.

Core Features & Use Cases

  • Correct DOTS singleton contracts: Define singleton components as living on exactly one entity and access them through SystemAPI (GetSingleton, GetSingletonRW, HasSingleton, TryGetSingleton).
  • Creation pathway guidance: Choose and document bake-time, runtime-created, or ECB-system singletons based on immutability and ownership.
  • Safety gating and runtime invariants: Use RequireForUpdate for strict existence guarantees, avoid invalid job-time access patterns, and validate the “exactly one entity” invariant to catch duplicated or missing singletons early.
  • Single-writer rule enforcement: Prevent multiple writers from using GetSingletonRW for the same component, protecting determinism and dependency ordering.

Quick Start

Use dots-singleton-patterns when you need a frame-stable shared configuration or mutable shared state in Unity DOTS that must exist on exactly one entity, then implement RequireForUpdate plus GetSingleton/GetSingletonRW to enforce the invariant at runtime.

Frequently Asked Questions about dots-singleton-patterns

High-intent search queries and answers about installing and using this skill.

FAQPage Schema
How do I safely access a singleton entity in Unity DOTS when multiple systems need the state?

To safely access a singleton entity in Unity DOTS, use SystemAPI methods like GetSingleton or GetSingletonRW while enforcing the single-writer rule to protect determinism and dependency ordering. RequireForUpdate gating ensures the singleton exists before system execution.

What is the correct way to enforce the exactly-one-entity runtime invariant for DOTS singletons?

The exactly-one-entity runtime invariant for DOTS singletons is enforced by validating runtime state and using HasSingleton or TryGetSingleton guards. This catches duplicated or missing singleton entities early before they cause unpredictable system failures.

How do I prevent burst safety violations when reading shared mutable game state in ECS?

Prevent burst safety violations in ECS by using SystemAPI GetSingleton for read-only access and GetSingletonRW for single-writer mutable access. RequireForUpdate provides strict existence guarantees to avoid invalid job-time access patterns.

Does this singleton pattern work for optional or lifecycle-dependent global configurations in Unity Entities?

Yes, this singleton pattern works for optional or lifecycle-dependent global configurations in Unity Entities by using TryGetSingleton guards. It supports frame-stable shared settings and guides bake-time or runtime-created singletons based on immutability and ownership.

When should I use RequireForUpdate gating instead of HasSingleton checks for DOTS singletons?

Use RequireForUpdate gating for strict existence guarantees when a system entirely depends on a DOTS singleton, forcing the system to skip updates safely. Use HasSingleton or TryGetSingleton checks for optional or lifecycle-dependent singletons where execution should continue regardless.

What is the single-writer rule for ECS singletons and how do I maintain it across multiple systems?

The single-writer rule for ECS singletons prevents multiple systems from using GetSingletonRW on the same component simultaneously, protecting determinism and dependency ordering. It maintains the single-entity shared state contract by ensuring only one system writes at a time.