thedivergentai/godot-autoload-architecture
Expert patterns for Godot AutoLoad (singleton) architecture including global state management, scene transitions, signal-based communication, dependency injection, autoload initialization order, and anti-patterns to avoid. Use for game managers, save systems, audio controllers, or cross-scene resources. Trigger keywords: AutoLoad, singleton, GameManager, SceneTransitioner, SaveManager, global_state, autoload_order, signal_bus, dependency_injection.
npx skills add https://github.com/thedivergentai/GD-Agentic-Skills --skill godot-autoload-architecture
Robust singleton ownership, boot order, and cross-scene services — not a Project Settings click-tutorial.
> Basic registration (Project Settings → Autoload, project.godot * prefix): see references/autoload-patterns.md. Do NOT Load that file for expert work.
MANDATORY before trusting a multi-Autoload dependency graph — verifies boot sequence.
MANDATORY with the mermaid/order diagram — maps who may call whom at boot.
MANDATORY before a cross-system Autoload bus (Achievements, UI, Save events).
MANDATORY before Autoload-owned scene transitions (deferred free / root management).
MANDATORY before Engine.register_singleton DI for non-Node services.
Data that must survive change_scene_to_file() (inventory, settings).
static var global state when you do not need a SceneTree Node.
On-demand instantiate instead of eager boot cost.
Safe cross-singleton calls after both are ready.
Mutex / call_deferred for background threads touching Autoload state.
Validate registration + defaults (debug / CI).
Ordered init helpers when _ready is too early for heavy work.
PROCESS_MODE_ALWAYS CanvasLayer console.
State holder vs pure event bus split.
_init() — AutoLoads are initialized sequentially. Accessing one in _init() may find a null reference._ready() — If multiple Singletons refer to each other's trees during boot, it can cause layout/sorting errors.Parent.method() calls from an Autoload — Autoloads sit at the root. They are the ultimate "top". Use signals to talk to the active scene._process() or signals, use a static var in a class_name script instead.get_tree().current_scene is accurate in _ready() — In Autoloads, the active scene might still be initializing. Access it via get_tree().root.get_child(-1).process_mode configuration — If your global console or music manager needs to work while the game is paused, set process_mode = PROCESS_MODE_ALWAYS.Good: Game/Audio/Save managers, SceneTransitioner, global score/inventory, cross-scene EventBus.
Avoid: Scene-specific logic, temporary state, pure data (prefer static / Resource), over-architecting tiny projects.
> MANDATORY: Read autoload_init_order_diag.gd and singleton_dependency_diagram.gd before drawing or trusting any Autoload order.
Autoloads initialize top → bottom in Project Settings. Upper singletons must not call lower ones in _ready(). Move dependents down the list.
graph TD
subgraph Autoloads [Project Settings order]
B[1. GlobalAudio] --> C[2. ServiceLocator]
C --> D[3. QuestManager]
end
D --> E[Current Scene]
E -->|Queries| C
> MANDATORY: service_locator.gd / service_registry.gd before Engine.register_singleton.
Use for lightweight RefCounted services; unregister in _exit_tree to avoid dangling engine singletons.
> MANDATORY: global_event_bus.gd for cross-system past-tense events. Keep mutable run state in persistent_data_holder.gd / global_game_state.gd — not on the bus.
> MANDATORY: safe_scene_switcher.gd — deferred free + root ownership. Pair with godot-scene-management for threaded loads.
> MANDATORY in debug/CI: singleton_health_check_test.gd / autoload_reference_checker.gd — assert presence + Engine.has_singleton for registered services.
_ready() (autoload_init_order_diag.gd).RefCounted services avoid SceneTree overhead; register via Engine.register_singleton and unregister in _exit_tree (service_locator.gd).current_scene in _ready() — WHY: active scene may still be mounting; use get_tree().root.get_child(-1) or defer until scene ready.| Topic | Reference / script |
|-------|-------------------|
| Service locator / boot diagram / health checks | expert-patterns.md |
| Beginner registration only | autoload-patterns.md |
> 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.
/root, become global names, and why boot order matches Project Settings list order.current_scene can be unreliable during Autoload _ready() and how root children relate to the active scene.process_mode / PROCESS_MODE_ALWAYS for consoles, music, and managers that must run while get_tree().paused._init vs _ready timing so cross-Autoload access does not hit nulls during sequential boot.register_singleton / get_singleton for lightweight service locators that are not SceneTree Nodes.call_deferred when background threads touch global Autoload state.project.godot; get registration and naming right before wiring managers.static var / class_name, and deferred calls are the language tools this skill’s patterns assume.change_scene_to_file().Take thedivergentai/godot-autoload-architecture from the repository into ~/.claude/skills for personal
use, or into .claude/skills inside a project.
The agent identifies a skill by the name field in its header. Two skills with the
same name cannot sit side by side — one of them will be ignored.