Godot resource data patterns

From thedivergentai/GD-Agentic-Skills · View interactive version

Godot resource data patterns is an AI agent skill from the GitHub repository thedivergentai/GD-Agentic-Skills. Expert blueprint for data-oriented design using Resource/RefCounted classes (item databases, character stats, reusable data structures). Covers typed arrays, serialization, nested resources, and resource caching. Use when implementing data systems OR inventory/stats/dialogue databases. Keywords Reso

How to use this skill

Skill file

NEVER Do in Resource Design


Decision Tree: Resource vs RefCounted vs Node

| Type | Use when | Disk / Inspector |

|------|----------|------------------|

| Resource | Shared definitions, saveable data, @export authoring | .tres/.res, Inspector ✅ |

| RefCounted | Temporary runtime calcs, non-persistent helpers | No disk / weak Inspector |

| Node | Scene entities with process/signals in the tree | Scene files |

Use Resources for: item defs, stats templates, abilities, dialogue tables, enemy configs.

Use RefCounted for: damage calc scratchpads, ephemeral state machines, non-saved utilities.

Available Scripts — MANDATORY by Scenario

| Scenario | MANDATORY read |

|----------|----------------|

| Per-instance mutable stats (HP) sharing a base .tres | resource_local_to_scene.gd |

| Nested Item → Weapon → StatusEffect trees / save whole graph | nested_resource_serialization.gd |

| Many entities sharing one config (flyweight) | resource_flyweight_caching.gd / flyweight_enemy_config.gd |

| Custom @export data containers | custom_data_resource.gd |

| Reactive stats with signals | character_stats_resource.gd |

| Inventory arrays of Resources | resource_based_inventory.gd |

| Save Resource trees to disk | resource_save_system.gd — check Error |

| Preload / O(1) cache before play | resource_preloading_strategy.gd |

| Runtime Resource.new() loot | dynamic_resource_generation.gd |

| Validate / pool / factory | resource_validator.gd / resource_pool.gd / data_factory_resource.gd |

Expert WHY (critical)

CAUTION: Runtime HP/mana on a shared .tres without duplicate(true) or resource_local_to_scene mutates the asset on disk — the "damaging one damages all" bug.

Deep dive (load on demand)

Pattern 1–7 walkthroughs (ItemData, databases, RefCounted calcs, directory scan, O(1) cache) — references/resource-patterns-deep.md. Implement nested weapons from nested_resource_serialization.gd, not memory.

Reference

Progressive disclosure: open Official Documentation links only when researching a specific API; load Related Skills when routing to a peer domain — do not preload the whole lattice.

Official Documentation

Related Skills

Prerequisites
Complements
Downstream / consumers
Master
Use this skill with your AI agent: Open on Skill Issue to copy, download, or add to your library. Works with Claude, ChatGPT, Gemini, Cursor, Windsurf and more.