npx skills add ...
npx skills add jwynia/agent-skills --skill godot-best-practices
Guide AI agents through Godot 4.x GDScript coding best practices including scene organization, signals, resources, state machines, and performance optimization. This skill should be used when generating GDScript code, creating Godot scenes, designing game architecture, implementing state machines, object pooling, save/load systems, or when the user asks about Godot patterns, node structure, or GDScript standards. Keywords: godot, gdscript, game development, signals, resources, scenes, nodes, state machine, object pooling, save system, autoload, export, type hints.
npx skills add jwynia/agent-skills --skill godot-best-practices
Guide AI agents in writing high-quality GDScript code for Godot 4.x. This skill provides coding standards, architecture patterns, and templates for game development.
Use this skill when:
Do NOT use this skill when:
Follow GDScript naming standards consistently:
Use explicit type hints everywhere for autocomplete and error detection:
Use modern patterns for stable, refactor-friendly references:
Use signals for decoupled communication. Follow "signal up, call down":
Choose the right loading strategy:
| Category | Prefer | Avoid |
|---|---|---|
| Node references | @onready var x: Type = $Path | get_node() in _ready() |
| Unique nodes | %UniqueName | Deep paths $A/B/C/D |
| Resource loading | preload() for small/critical | load() everywhere |
| Signals | Typed: signal x(val: int) | String: emit_signal("x") |
| Type safety | Explicit type hints | Untyped variables |
| Constants | const or @export | Magic numbers/strings |
| Null checks | is_instance_valid(node) | node != null for freed nodes |
| Coroutines | await | yield (deprecated) |
| Groups | Scene-specific groups | Global groups for everything |
| Autoloads | Services/managers only | Game logic in autoloads |
| Properties | Setters/getters | Direct mutation |
| Communication | Signal up, call down | Child calling parent methods |
Order sections consistently:
Use exports for editor-configurable values:
Use enum-based state machines for simple cases:
See references/patterns/state-machine.md for advanced implementations.
Reuse objects to avoid instantiation cost:
See references/patterns/object-pooling.md for complete implementation.
Use Resources or JSON for save data:
See references/patterns/save-load-system.md for comprehensive guide.
| Anti-Pattern | Problem | Solution |
|---|---|---|
Polling in _process | Wastes CPU on unchanged state | Use signals for state changes |
get_parent().get_parent() | Tight coupling, fragile | Signal up, or use groups |
Deep node paths $A/B/C/D | Breaks on refactor | Use %UniqueName |
load() in _process | Stuttering, memory churn | preload() or cache reference |
String signals emit_signal("x") | Typos, no autocomplete | Typed: signal_name.emit() |
Untyped @onready var x = $Node | Loses autocomplete | Always add type hint |
| Logic in autoloads | Testing difficulty, coupling | Keep autoloads thin |
| Magic numbers | Unclear meaning | Use const or @export |
node != null for freed nodes | Returns true for freed | Use is_instance_valid() |
| Circular dependencies | Load errors, unclear flow | Dependency injection or signals |
references/patterns/state-machine.md - Full state machine implementationsreferences/patterns/object-pooling.md - Complete pooling systemreferences/patterns/save-load-system.md - Comprehensive save/load guidereferences/patterns/input-handling.md - Input buffering and rebindingreferences/architecture/project-structure.md - Directory organizationreferences/architecture/scene-composition.md - Scene design patternsreferences/architecture/node-communication.md - Signals vs direct callsreferences/gdscript/type-system.md - Static typing in depthreferences/gdscript/coroutines-await.md - Async patterns with awaitassets/templates/base-script.gd.md - Standard script templateassets/templates/state-machine.gd.md - State machine templateassets/templates/autoload-manager.gd.md - Autoload singleton template