godot-resource-data-patterns
Installation
SKILL.md
NEVER Do in Resource Design
- NEVER modify resource instances directly — Without
.duplicate(), changing a value (like HP) modifies the shared.tresfor everyone. - NEVER use untyped arrays in Resources —
@export var items: Arrayallows logic errors. Always useArray[ResourceClass]for type safety. - NEVER store Node references in Resources — Objects that only exist in a specific SceneTree cannot be serialized. Store
NodePathorUID. - NEVER perform heavy calculations in Resource getters/setters — Resources should be data containers. Offload logic to Nodes or specialized RefCounted classes.
- NEVER skip
ResourceSaver.save()error checks — Saving can fail due to permissions, disk space, or path issues. Always check the return code. - NEVER use Resources for high-frequency runtime data — If a value changes 60 times a second (like velocity), a standard variable is faster than a Resource property.
- NEVER allow circular Resource references — If A.tres references B.tres and B.tres references A.tres, the engine may crash on load.
- NEVER forget the
_initdefaults — Resources created vianew()or in the Inspector need default values in their constructor to be editable. - NEVER share a Resource between entities if they need unique state — Use
resource_local_to_scene = trueorduplicate()for components. - NEVER use
.tresfor massive datasets — If you have 10,000 items, a JSON or custom binary format might be more efficient than individualized Resource files.