3.4 KiB
3.4 KiB
name, description
| name | description |
|---|---|
| developing-godot-gdscript | Builds and refactors Godot 4 projects with idiomatic GDScript, scene composition, signals, and autoload patterns. Use when implementing gameplay, UI, tools, or architecture changes in Godot/GDScript repositories. |
Developing Godot With GDScript
Implements production-friendly Godot 4 changes using typed GDScript, scene composition, and low-coupling architecture.
Use This Skill When
- Adding or refactoring gameplay systems, UI flows, or content pipelines in Godot.
- Debugging node lifecycle, signals, resources, or autoload behavior.
- Improving maintainability, style consistency, or data flow in GDScript code.
Core Rules
- Prefer composition over deep inheritance: split reusable behavior into scenes/resources/scripts with focused responsibilities.
- Choose scenes for reusable node trees and editor-authored structure; choose scripts/resources for logic and data that do not need node hierarchy.
- Use autoloads only for truly global state/services (save systems, global config, cross-scene coordinators), not as default dependency injection.
- Favor signals over direct cross-tree mutation to reduce coupling between gameplay, UI, and services.
- Use typed GDScript where possible: annotate variables, params, and return types for safer refactors.
GDScript Implementation Checklist
- Keep naming idiomatic:
snake_casefor vars/functions/signals,PascalCaseforclass_name,UPPER_SNAKE_CASEfor constants. - Use
@exportfor editor-facing configuration and@onreadyonly for scene-dependent node lookups. - Respect lifecycle intent:
_initfor construction data,_enter_treefor tree attachment concerns,_readyfor node wiring,_process/_physics_processfor frame loops. - Distinguish frame loops clearly: use
_physics_processfor deterministic physics movement and_processfor visual or non-physics updates. - Use
matchfor clear branching on enums/states and keep functions short with early returns.
Data, Loading, And Error Handling
- Guard all file access (
FileAccess.open) and JSON parsing before indexing into parsed values. - Validate dynamic data types (
is Dictionary,is Array) before field access to avoid runtime surprises. - Use
preloadfor stable, frequently used compile-time resources; useloadfor optional or dynamic runtime assets. - Prefer
Resource/RefCountedfor plain data models when node features are unnecessary. - Use
assert/push_errorfor invalid states that should fail loudly during development.
Delivery Workflow
- Read
project.godotfirst to identify autoloads, rendering/physics settings, and project conventions. - Inspect relevant
.tscn+.gdpairs together before editing to preserve scene-script contracts. - Implement minimal, targeted changes that keep public APIs/signals stable unless change is requested.
- Run headless validation and script checks for touched scripts; run project smoke test when feasible.
- Summarize changed files, behavior impact, and any follow-up risks.
Validation Commands
Use project-provided commands when available. Typical Godot checks:
"$GODOT_BIN" --headless --path . --quit
"$GODOT_BIN" --headless --check-only --script res://path/to/changed_script.gd