dots-entity-lifecycle

Prevents Unity DOTS runtime errors from unsafe entity destruction and stale references.

6|Updated Apr 2, 2026
One-click install
npx skills add https://github.com/dyCuong03/unity-agent-team --skill dots-entity-lifecycle
Or copy as Structured Prompt for Agent
Please help me install this Agent Skill.
Skill: dots-entity-lifecycle
Source: https://github.com/dyCuong03/unity-agent-team/tree/main/.claude/skills/unity-dots/dots-entity-lifecycle
Command: npx skills add https://github.com/dyCuong03/unity-agent-team --skill dots-entity-lifecycle

SYSTEM DOCUMENTATION & REQUIREMENTS

What problem does it solve?

This Skill solves Unity DOTS entity-lifecycle bugs where structural changes invalidate queries and stale Entity handles cause exceptions or orphan references.

Core Features & Use Cases

  • ECB-safe structural changes during iteration: record DestroyEntity/Add/Remove intent in an EntityCommandBuffer instead of mutating the world mid-query.
  • Two-phase teardown with ICleanupComponentData: defer true destruction until a dedicated phase removes the cleanup component.
  • Stale Entity validation & dangling ref debugging: safely check Exists/HasComponent before dereferencing and understand (Index, Version) generation behavior.
  • Subscene load/unload and orphan reference mitigation: avoid refs that become invalid when subscene-owned entities unload.
  • Failure-mode driven guidance: target common symptoms like “entity already destroyed,” immortal tombstones, and cleanup order mistakes.

Quick Start

Use dots-entity-lifecycle when you need to destroy DOTS entities safely during gameplay, implement ICleanupComponentData two-phase cleanup, and debug invalid/dangling Entity reference failures.

Frequently Asked Questions about dots-entity-lifecycle

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

FAQPage Schema
How do I safely destroy Unity DOTS entities during query iteration without causing structural change errors?

The entity already destroyed error in Unity DOTS occurs when dereferencing stale Entity handles, which you prevent by using explicit Exists and HasComponent guards to validate Entity validity before access.

What is the correct way to implement two-phase entity teardown using ICleanupComponentData?

Stale Entity handles in Unity DOTS become invalid during subscene load and unload edge cases, causing orphan references that require explicit Exists validation and ECB-driven destruction to mitigate.

How does Unity DOTS entity versioned handle generation behavior affect safe entity destruction?

Unity DOTS entity versioned handles use an Index and Version generation behavior to track validity, requiring explicit Exists and HasComponent guards before dereferencing to avoid already destroyed failures and stale entity reference exceptions.

Why do I get an entity already destroyed error when checking stale Entity references in Unity DOTS?

The entity already destroyed error in Unity DOTS occurs when dereferencing stale Entity handles, which you prevent by using explicit Exists and HasComponent guards to validate Entity validity before access.