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, o
By jwynia · 2,021 installs
npx skills add jwynia/agent-skills --skill godot-best-practices
Source repository · Upstream listing
Godot 4.x GDScript 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.
When to Use This Skill
Use this skill when:
Generating new GDScript code
Creating or organizing Godot scenes
Designing game architecture and node hierarchies
Implementing state machines, object pools, or save systems
Answering questions about GDScript patterns or Godot conventions
Reviewing GDScript code for quality issues
Do NOT use this skill when:
Working with C in Godot (use C patterns)
Working with Godot 3.x (syntax differs significantly)
Using GDExtension/C++ (different paradigm)
Working with Godot's visual scripting
Core Principles
1. Naming Conventions
Follow GDScript naming standards consistently:
2. Type Hints (Static Typing)
Use explicit type hints everywhere for autocomplete and error detection:
3. Node References
Use modern patterns for stable, refactor friendly references:
4. Signal Driven Architecture
Use signals for decoupled communication. Follow "signal up, call down":
5. Resource Loading
Choose the right loading strategy:
Quick Reference
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
Code Generation Guidelines
Script Structure
Order sections consistently:
Export Annotations
Use exports for editor configurable values:
Common Game Patterns
State Machine (Overview)
Use enum based state machines for simple cases:
See references/patterns/state machine.md for advanced implementations.
Object Pooling (Overview)
Reuse objects to avoid instantiation cost:
See references/patterns/object pooling.md for complete implementation.
Save/Load (Overview)
Use Resources or JSON for save data:
See references/patterns/save load system.md for comprehensive guide.
Common Anti Patterns
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
Additional Resources
Pattern Guides
references/patterns/state machine.md Full state machine implementations
references/patterns/object pooling.md Complete pooling system
references/patterns/save load system.md Comprehensive save/load guide
references/patterns/input handling.md Input buffering and rebinding
Architecture
references/architecture/project structure.md Directory organization
references/architecture/scene composition.md Scene design patterns
references/architecture/node communication.md Signals vs direct calls
GDScript Deep Dives
references/gdscript/type system.md Static typing in depth
references/gdscript/coroutines await.md Async patterns with await
Templates
assets/templates/base script.gd.md Standard script template
assets/templates/state machine.gd.md State machine template
assets/templates/autoload manager.gd.md Autoload singleton template
Limitations
GDScript only (not C , GDExtension, or VisualScript)
Godot 4.x syntax (some patterns differ from 3.x)
Game focused patterns (not editor plugin development)
No runtime validation scripts (GDScript requires Godot runtime)