Game Development Entity Reference Boundary
Use this skill when the hard part is not behavior architecture or event topology alone, but how systems refer to gameplay entities safely over time without every subsystem inventing its own accidental pointer policy.
This skill is for designing, reviewing, or refactoring a reusable entity-reference boundary in gameplay, AI, interaction, event, command, and coordination-heavy systems. Its job is to define what counts as stable identity, when direct references are safe, when handles or IDs are safer, how lookup and ownership should work, how stale references are detected, and how cross-system payloads avoid carrying dead or misleading pointers.
If the engine is unspecified, keep the recommendation engine-agnostic first. Only use engine-native guidance when the task explicitly depends on runtime features such as Godot node paths and instance lifetimes, Unity scene-object references, or equivalent framework constraints.
For reusable identity shapes, handle-versus-reference trade-offs, and lifetime cautions, see references/identity-vs-reference.md.
Purpose
This skill is used to:
- determine whether a reusable entity-reference boundary is justified at all
- define the boundary between one local direct reference and shared reference semantics
- choose stable identity, direct reference, or handle-based lookup deliberately
- make lifetime policy, payload safety, lookup rules, and stale-reference behavior explicit enough to review
- return a structured entity-reference design or review artifact another agent can implement incrementally
Use this skill when
Invoke this skill for requests such as:
- commands, events, or coordinators keep carrying references that may be stale by the time they are consumed
- several systems refer to the same entities but disagree on whether IDs, handles, or direct pointers are allowed
- pooled objects, delayed actions, or scene transitions keep breaking reference assumptions
- a team needs clearer rules for what may be stored long-term versus resolved on demand
- requests that explicitly mention
entity identity, handle, reference boundary, stale reference, target handle, NodePath, instance ID, lookup, or payload safety
Trigger examples
- "Should this event carry a direct object reference or a stable handle?"
- "Our delayed commands keep firing on dead targets"
- "How do we prevent pooled objects from reusing identity in unsafe ways?"
- "Nobody can explain which systems are allowed to store raw references anymore"
Do not use this skill when
Do not use this skill when:
- the hard problem is still choosing behavior architecture, command flow, or event topology; use the narrower skill first
- one local direct reference is already sufficient and no shared lifetime contract is needed
- the task is primarily truth ownership or blackboard freshness rather than reference safety
- the task is primarily timing cadence rather than reference invalidation or lookup policy
- the task is a localized runtime bug investigation rather than reference-boundary design or review
Pattern
- Primary pattern: Tool Wrapper
- Secondary pattern: Reviewer
Related skills and routing notes
- Start with
game-development-command-flow or game-development-coordinator if the main problem is ownership of cross-system handoff rather than reference form itself.
- Pair with
game-development-world-state-facts when the supposed stale-reference issue is really stale observed truth or blackboard freshness.
- Pair with
game-development-state-change-notification when payloads need safe identity forms instead of raw references and consumers must react after delayed delivery.
- Pair with
game-development-object-pool when pooled reuse is the main reason direct references or instance identities keep becoming unsafe.
- Hand off to
game-development-events-and-signals or game-development-coordinator once identity, handle, and lifetime rules are clear and the next question is system collaboration structure.
Diagnostic checklist
Evaluate these questions before recommending or refining an entity-reference boundary:
| Question |
Healthy sign |
Warning sign |
| Is there real shared reference pressure? |
Several systems need the same identity semantics |
One local field is being over-abstracted |
| Is identity explicit? |
The system can name what makes an entity stable across consumers |
Identity is whatever object happens to be nearby |
| Does lifetime matter? |
Delayed use, pooling, or scene changes can invalidate references |
Consumers assume references live forever |
| Are payload rules clear? |
Events and commands know what may be carried safely |
Cross-system messages casually ship raw pointers |
| Is lookup ownership defined? |
Systems know where and how handles resolve |
Every consumer performs ad-hoc global lookups |
| Is stale detection reviewable? |
The team can explain how dead or reused references are handled |
Stale references fail as vague nulls or ghost behavior |
Decision rules
Before recommending a reusable entity-reference boundary, ask whether the smaller honest answer is:
- one local direct reference at a legitimate call site
- one subsystem-private handle rule
- one fact-model or freshness problem rather than a reference-boundary problem
- one timing or delayed-execution issue rather than an identity-policy issue
- one engine-specific editor hookup rather than a shared runtime reference contract
Reject a shared reference layer if it mostly renames obvious object fields without improving safety, lifetime clarity, or cross-system consistency.
Prefer a local direct reference when
- the reference is used immediately and locally
- there is no delayed execution, pooling, or cross-system handoff risk
- abstraction would mostly hide an obvious owner and lifetime
Prefer stable identity or handles when
- references may outlive the current frame or call stack
- commands, events, or queues cross subsystem boundaries
- pooled objects or scene reloads can invalidate direct references
- the design needs lookup or reacquisition rather than pointer persistence
Prefer read-time lookup when
- consumers need current truth about whether the target still exists
- direct reference retention would create stale payload risk
- the system benefits from explicit failure handling when resolution fails
Prefer payload-safe projections when
- messages only need identity or lightweight targeting data, not full object access
- several consumers need to decide independently whether and how to resolve the target
- reviewability improves when payloads stop smuggling full object authority
Escalate to adjacent foundations when
- the real issue is stale world facts rather than stale references
- the real issue is reevaluation cadence rather than reference invalidation policy
- the real issue is notification topology rather than payload safety semantics
- the real issue is condition or target eligibility logic rather than identity boundaries
Workflow
Follow this sequence every time.
1. Identify the reference boundary
State what entity-reference question the system is trying to answer before naming registries, lookups, or payload classes.
Examples:
- whether an event may carry a direct target reference
- whether queued commands should store IDs or handles instead of pointers
- whether pooled entities need stable identity separate from object instances
- how consumers detect that a referenced entity no longer exists
2. Separate identity, direct references, and handles
List the important reference forms explicitly.
Typical categories:
- stable identity or ID
- direct runtime reference
- handle or lookup token
- path-based lookup or locator
- local-only transient reference
3. Define ownership and lookup strategy
For each important entity family, specify:
- what counts as stable identity
- who issues or owns that identity
- how handles resolve
- who is allowed to perform lookup
- what happens when resolution fails or returns a reused entity unexpectedly
4. Define lifetime and invalidation rules
Specify:
- how long each reference form may be retained
- what scene changes, pooling, despawn, or reload events invalidate it
- whether invalid references become null, unresolved, rejected, or explicitly stale
- who owns cleanup for stale handles or dead payloads
5. Define payload safety rules
Specify:
- what events, commands, blackboards, or queues may carry
- whether cross-system messages may include direct references, IDs, or only projections
- what minimum data is needed to re-resolve safely
- how payloads avoid accidentally granting too much access or lifetime assumption
6. Define observability and debugging expectations
Specify:
- how reviewers can tell whether a reference is direct, stable, or lookup-based
- what logs, tags, or diagnostics help classify stale-reference failures
- whether pooled identity reuse must be visible in debug tools
- what evidence shows consumers are following the same reference policy
7. Separate entity-reference policy from adjacent concerns
Clarify what stays outside the reference model, such as:
- event delivery topology in full
- world-fact truth ownership
- timing policy in full
- full networking identity doctrine by default
- behavior architecture selection
8. Plan the rollout
Migrate incrementally: isolate one drifting reference family, define stable identity and lookup rules, tighten payload policy, replace unsafe direct references gradually, add stale-detection visibility, and verify before widening the boundary.
Output contract
Return the result using assets/reference-boundary-template.md in this section order.
If the best answer is not a reusable reference boundary, still use the template and say that explicitly instead of wrapping one honest local pointer in ceremonial handle theater.
Return the result in these sections:
- Identity boundary
- Local reference vs shared reference model decision
- Reference forms and lookup strategy
- Ownership and lifetime policy
- Payload safety and stale-reference handling
- Observability and debugging notes
- Related foundations and handoff notes
- Engine integration notes
- Migration plan
- Verification notes
Keep the section order stable so entity-reference recommendations are easy to compare across reviews and refactor passes.
Engine-specific notes
Godot / .NET
- Be explicit about whether systems rely on direct node references,
NodePath, instance IDs, or custom gameplay IDs.
- Do not let scene-tree convenience become an accidental lifetime guarantee across queues, autoloads, or pooled nodes.
- Be careful when pooled or reparented nodes can make a once-valid reference look alive while meaningfully pointing at the wrong gameplay identity.
Unity
- Distinguish clearly between serialized scene references, runtime object references, and stable gameplay identity.
- Avoid assuming inspector references remain the right runtime boundary for delayed or cross-system payloads.
- Be explicit when pooled object reuse or scene reloads make direct references unsafe outside narrow local use.
Generic C# / engine-neutral
- Prefer named identity types and lookup rules over generic
object references passed everywhere.
- Keep direct-reference retention narrow when delayed execution or object reuse exists.
- Use structured stale-reference diagnostics only where they materially improve debugging or reviewability.
Common pitfalls
- abstracting one local direct reference into a shared identity framework with no reuse benefit
- treating object existence as stable gameplay identity without saying so
- letting events or commands carry raw references long after their safe lifetime
- mixing stable IDs, handles, and direct pointers without naming which one a consumer has
- relying on global lookups with no ownership or failure policy
- ignoring pooled-object reuse when designing supposedly stable references
- hiding stale-reference failure as vague null checks or silent no-ops
- accidentally expanding a reference-boundary skill into full networking, save/load, or targeting doctrine
Companion files
references/identity-vs-reference.md — reusable heuristics for stable identity, handles, direct references, lookup strategies, and abstraction cautions
references/stale-reference-checklist.md — reusable review checklist for lifetime policy, payload safety, pooling, delayed commands, and stale-reference handling
assets/reference-boundary-template.md — reusable output template for returning the entity-reference design or review artifact
Validation
A good result should satisfy all of the following:
- a simpler local-reference alternative was considered first
- the identity boundary is explicit
- stable identity, direct references, and handle forms are distinguished clearly
- lookup and ownership rules are concrete enough to review
- lifetime, invalidation, and stale-reference behavior are stated explicitly
- payload safety expectations are clear where cross-system messages exist
- observability and debugging expectations are addressed where needed
- the design does not quietly expand into world-facts, timing doctrine, or full networking identity policy by accident
Completion rule
This skill is complete when the agent has:
- decided whether a reusable entity-reference boundary is justified at all
- identified the identity boundary and key reference forms
- defined lookup, ownership, lifetime, and payload-safety rules
- specified stale-reference handling and debugging expectations
- described engine integration notes where relevant
- returned a concrete migration and verification brief
1---2name: game-development-entity-reference-boundary3description: Use when a cross-engine gameplay task needs a Layer 1 foundation for entity identity, stale references, payload safety, or handle-versus-pointer trade-offs, and the agent must define or review a reusable entity-reference boundary with explicit identity rules, lookup strategy, lifetime policy, payload safety, and debugging expectations.4---56# Game Development Entity Reference Boundary78Use this skill when the hard part is not behavior architecture or event topology alone, but **how systems refer to gameplay entities safely over time without every subsystem inventing its own accidental pointer policy**.910This skill is for designing, reviewing, or refactoring a reusable entity-reference boundary in gameplay, AI, interaction, event, command, and coordination-heavy systems. Its job is to define what counts as stable identity, when direct references are safe, when handles or IDs are safer, how lookup and ownership should work, how stale references are detected, and how cross-system payloads avoid carrying dead or misleading pointers.1112If the engine is unspecified, keep the recommendation engine-agnostic first. Only use engine-native guidance when the task explicitly depends on runtime features such as Godot node paths and instance lifetimes, Unity scene-object references, or equivalent framework constraints.1314For reusable identity shapes, handle-versus-reference trade-offs, and lifetime cautions, see `references/identity-vs-reference.md`.1516## Purpose1718This skill is used to:1920- determine whether a reusable entity-reference boundary is justified at all21- define the boundary between one local direct reference and shared reference semantics22- choose stable identity, direct reference, or handle-based lookup deliberately23- make lifetime policy, payload safety, lookup rules, and stale-reference behavior explicit enough to review24- return a structured entity-reference design or review artifact another agent can implement incrementally2526## Use this skill when2728Invoke this skill for requests such as:2930- commands, events, or coordinators keep carrying references that may be stale by the time they are consumed31- several systems refer to the same entities but disagree on whether IDs, handles, or direct pointers are allowed32- pooled objects, delayed actions, or scene transitions keep breaking reference assumptions33- a team needs clearer rules for what may be stored long-term versus resolved on demand34- requests that explicitly mention `entity identity`, `handle`, `reference boundary`, `stale reference`, `target handle`, `NodePath`, `instance ID`, `lookup`, or `payload safety`3536### Trigger examples3738- "Should this event carry a direct object reference or a stable handle?"39- "Our delayed commands keep firing on dead targets"40- "How do we prevent pooled objects from reusing identity in unsafe ways?"41- "Nobody can explain which systems are allowed to store raw references anymore"4243## Do not use this skill when4445Do not use this skill when:4647- the hard problem is still choosing behavior architecture, command flow, or event topology; use the narrower skill first48- one local direct reference is already sufficient and no shared lifetime contract is needed49- the task is primarily truth ownership or blackboard freshness rather than reference safety50- the task is primarily timing cadence rather than reference invalidation or lookup policy51- the task is a localized runtime bug investigation rather than reference-boundary design or review5253## Pattern5455- Primary pattern: **Tool Wrapper**56- Secondary pattern: **Reviewer**5758## Related skills and routing notes5960- Start with `game-development-command-flow` or `game-development-coordinator` if the main problem is ownership of cross-system handoff rather than reference form itself.61- Pair with `game-development-world-state-facts` when the supposed stale-reference issue is really stale observed truth or blackboard freshness.62- Pair with `game-development-state-change-notification` when payloads need safe identity forms instead of raw references and consumers must react after delayed delivery.63- Pair with `game-development-object-pool` when pooled reuse is the main reason direct references or instance identities keep becoming unsafe.64- Hand off to `game-development-events-and-signals` or `game-development-coordinator` once identity, handle, and lifetime rules are clear and the next question is system collaboration structure.6566## Diagnostic checklist6768Evaluate these questions before recommending or refining an entity-reference boundary:6970| Question | Healthy sign | Warning sign |71| --- | --- | --- |72| Is there real shared reference pressure? | Several systems need the same identity semantics | One local field is being over-abstracted |73| Is identity explicit? | The system can name what makes an entity stable across consumers | Identity is whatever object happens to be nearby |74| Does lifetime matter? | Delayed use, pooling, or scene changes can invalidate references | Consumers assume references live forever |75| Are payload rules clear? | Events and commands know what may be carried safely | Cross-system messages casually ship raw pointers |76| Is lookup ownership defined? | Systems know where and how handles resolve | Every consumer performs ad-hoc global lookups |77| Is stale detection reviewable? | The team can explain how dead or reused references are handled | Stale references fail as vague nulls or ghost behavior |7879## Decision rules8081Before recommending a reusable entity-reference boundary, ask whether the smaller honest answer is:8283- one local direct reference at a legitimate call site84- one subsystem-private handle rule85- one fact-model or freshness problem rather than a reference-boundary problem86- one timing or delayed-execution issue rather than an identity-policy issue87- one engine-specific editor hookup rather than a shared runtime reference contract8889Reject a shared reference layer if it mostly renames obvious object fields without improving safety, lifetime clarity, or cross-system consistency.9091### Prefer a local direct reference when9293- the reference is used immediately and locally94- there is no delayed execution, pooling, or cross-system handoff risk95- abstraction would mostly hide an obvious owner and lifetime9697### Prefer stable identity or handles when9899- references may outlive the current frame or call stack100- commands, events, or queues cross subsystem boundaries101- pooled objects or scene reloads can invalidate direct references102- the design needs lookup or reacquisition rather than pointer persistence103104### Prefer read-time lookup when105106- consumers need current truth about whether the target still exists107- direct reference retention would create stale payload risk108- the system benefits from explicit failure handling when resolution fails109110### Prefer payload-safe projections when111112- messages only need identity or lightweight targeting data, not full object access113- several consumers need to decide independently whether and how to resolve the target114- reviewability improves when payloads stop smuggling full object authority115116### Escalate to adjacent foundations when117118- the real issue is stale world facts rather than stale references119- the real issue is reevaluation cadence rather than reference invalidation policy120- the real issue is notification topology rather than payload safety semantics121- the real issue is condition or target eligibility logic rather than identity boundaries122123## Workflow124125Follow this sequence every time.126127### 1. Identify the reference boundary128129State what entity-reference question the system is trying to answer before naming registries, lookups, or payload classes.130131Examples:132133- whether an event may carry a direct target reference134- whether queued commands should store IDs or handles instead of pointers135- whether pooled entities need stable identity separate from object instances136- how consumers detect that a referenced entity no longer exists137138### 2. Separate identity, direct references, and handles139140List the important reference forms explicitly.141142Typical categories:143144- stable identity or ID145- direct runtime reference146- handle or lookup token147- path-based lookup or locator148- local-only transient reference149150### 3. Define ownership and lookup strategy151152For each important entity family, specify:153154- what counts as stable identity155- who issues or owns that identity156- how handles resolve157- who is allowed to perform lookup158- what happens when resolution fails or returns a reused entity unexpectedly159160### 4. Define lifetime and invalidation rules161162Specify:163164- how long each reference form may be retained165- what scene changes, pooling, despawn, or reload events invalidate it166- whether invalid references become null, unresolved, rejected, or explicitly stale167- who owns cleanup for stale handles or dead payloads168169### 5. Define payload safety rules170171Specify:172173- what events, commands, blackboards, or queues may carry174- whether cross-system messages may include direct references, IDs, or only projections175- what minimum data is needed to re-resolve safely176- how payloads avoid accidentally granting too much access or lifetime assumption177178### 6. Define observability and debugging expectations179180Specify:181182- how reviewers can tell whether a reference is direct, stable, or lookup-based183- what logs, tags, or diagnostics help classify stale-reference failures184- whether pooled identity reuse must be visible in debug tools185- what evidence shows consumers are following the same reference policy186187### 7. Separate entity-reference policy from adjacent concerns188189Clarify what stays outside the reference model, such as:190191- event delivery topology in full192- world-fact truth ownership193- timing policy in full194- full networking identity doctrine by default195- behavior architecture selection196197### 8. Plan the rollout198199Migrate incrementally: isolate one drifting reference family, define stable identity and lookup rules, tighten payload policy, replace unsafe direct references gradually, add stale-detection visibility, and verify before widening the boundary.200201## Output contract202203Return the result using `assets/reference-boundary-template.md` in this section order.204205If the best answer is **not** a reusable reference boundary, still use the template and say that explicitly instead of wrapping one honest local pointer in ceremonial handle theater.206207Return the result in these sections:2082091. **Identity boundary**2102. **Local reference vs shared reference model decision**2113. **Reference forms and lookup strategy**2124. **Ownership and lifetime policy**2135. **Payload safety and stale-reference handling**2146. **Observability and debugging notes**2157. **Related foundations and handoff notes**2168. **Engine integration notes**2179. **Migration plan**21810. **Verification notes**219220Keep the section order stable so entity-reference recommendations are easy to compare across reviews and refactor passes.221222## Engine-specific notes223224### Godot / .NET225226- Be explicit about whether systems rely on direct node references, `NodePath`, instance IDs, or custom gameplay IDs.227- Do not let scene-tree convenience become an accidental lifetime guarantee across queues, autoloads, or pooled nodes.228- Be careful when pooled or reparented nodes can make a once-valid reference look alive while meaningfully pointing at the wrong gameplay identity.229230### Unity231232- Distinguish clearly between serialized scene references, runtime object references, and stable gameplay identity.233- Avoid assuming inspector references remain the right runtime boundary for delayed or cross-system payloads.234- Be explicit when pooled object reuse or scene reloads make direct references unsafe outside narrow local use.235236### Generic C# / engine-neutral237238- Prefer named identity types and lookup rules over generic `object` references passed everywhere.239- Keep direct-reference retention narrow when delayed execution or object reuse exists.240- Use structured stale-reference diagnostics only where they materially improve debugging or reviewability.241242## Common pitfalls243244- abstracting one local direct reference into a shared identity framework with no reuse benefit245- treating object existence as stable gameplay identity without saying so246- letting events or commands carry raw references long after their safe lifetime247- mixing stable IDs, handles, and direct pointers without naming which one a consumer has248- relying on global lookups with no ownership or failure policy249- ignoring pooled-object reuse when designing supposedly stable references250- hiding stale-reference failure as vague null checks or silent no-ops251- accidentally expanding a reference-boundary skill into full networking, save/load, or targeting doctrine252253## Companion files254255- `references/identity-vs-reference.md` — reusable heuristics for stable identity, handles, direct references, lookup strategies, and abstraction cautions256- `references/stale-reference-checklist.md` — reusable review checklist for lifetime policy, payload safety, pooling, delayed commands, and stale-reference handling257- `assets/reference-boundary-template.md` — reusable output template for returning the entity-reference design or review artifact258259## Validation260261A good result should satisfy all of the following:262263- a simpler local-reference alternative was considered first264- the identity boundary is explicit265- stable identity, direct references, and handle forms are distinguished clearly266- lookup and ownership rules are concrete enough to review267- lifetime, invalidation, and stale-reference behavior are stated explicitly268- payload safety expectations are clear where cross-system messages exist269- observability and debugging expectations are addressed where needed270- the design does not quietly expand into world-facts, timing doctrine, or full networking identity policy by accident271272## Completion rule273274This skill is complete when the agent has:275276- decided whether a reusable entity-reference boundary is justified at all277- identified the identity boundary and key reference forms278- defined lookup, ownership, lifetime, and payload-safety rules279- specified stale-reference handling and debugging expectations280- described engine integration notes where relevant281- returned a concrete migration and verification brief