Installs into .claude/skills of the current project.
Sponsors
SSkills DirectorySkills Directory
Know which skills are safe — weekly.
SSkills DirectorySkills Directory
Is that skill safe to install?
Are you the author of Godot Gdscript?
Add the live security badge to your README. It updates with every re-scan.
[](https://www.skillsdirectory.com/skills/tipoli5890-godot-gdscript)
---
name: godot-gdscript
description: >-
GDScript in Godot that holds up: static typing, warnings as errors, signals, await, lambdas,
class_name or preload, resources as data, @tool.
---
# godot-gdscript — typed, warned and testable
Typed GDScript turns most runtime errors into load errors, which a headless gate can see. The
rest of the method is about the places where GDScript stays silent: a lambda that changed its own
copy, an `await` that never returns, a resource two scenes share without knowing it.
## Load what the situation needs
| The situation | Read |
|---|---|
| Typing a script; `:=` that fails to parse; typed arrays and dictionaries; casts; `class_name` or `preload` | `reference/typing.md` |
| Raising warnings to errors; what a warning message means; untyped legacy code; "(Warning treated as error.)" | `reference/warnings.md` |
| Signals that fire twice or never; `bind`; a lambda that changed nothing; an `await` that hangs; one-shot connections | `reference/signals-await.md` |
| Data in `.tres` files; `@export`; a value two instances share; `@tool` scripts | `reference/resources-as-data.md` |
| A ready typed resource and a signal hub to start from | `templates/parcel_data.gd` · `templates/courier_signals.gd` |
| Old Godot syntax (`yield`, `onready var`, `export var`) | `godot-version-guard` |
| Scene and resource text, ids, `[connection]` sections | `godot-scene-files` |
| Unit tests for GDScript | `godot-testing` |
| C# instead of GDScript | `godot-csharp` |
| Autoloads, scene changes, saving | `godot-scene-flow` |
## Typed by default
```gdscript
extends Node
signal parcel_delivered(parcel_id: StringName, reward: int)
const ParcelData = preload("parcel_data.gd")
@export var speed: float = 4.0
var carrying: Array[ParcelData] = []
var gate_codes: Dictionary[StringName, int] = {}
@onready var spawn: Marker2D = %Spawn
func deliver(late_seconds: float) -> int:
var total: int = 0
for parcel: ParcelData in carrying:
total += parcel.delivery_reward(late_seconds)
parcel_delivered.emit(parcel.id, parcel.delivery_reward(late_seconds))
carrying.clear()
return total
```
- Every variable, parameter and return has a type; `:=` is fine when the value has one.
`var x := d["a"]` does not, and is a parse error at any level.
- A Variant (a `Dictionary` value, `get()`, `json.data`) goes into a typed local before use:
`var n: float = d["n"]`. A float into an `int` truncates without a word (2.7 becomes 2).
- `$Node` and `%Unique` lookups in a member initialiser need `@onready`; without it the script
fails to load by default.
## Warnings as errors: the strict profile
Level 1 warnings print nothing headless. Level 2 makes the script fail to load with the message
and "(Warning treated as error.)", which a gate sees.
```bash
python3 scripts/gdscript_strict.py settings # the [debug] block for project.godot
GODOT_BIN=/path/to/Godot python3 scripts/gdscript_strict.py check path/to/project
GODOT_BIN=/path/to/Godot python3 scripts/gdscript_strict.py --selftest
```
The profile raises 21 warnings to 2: `untyped_declaration`, the four `unsafe_*` access and call
warnings, unused and shadowed names, `confusable_capture_reassignment`,
`int_as_enum_without_cast`, `narrowing_conversion`, `integer_division`, unreachable and
standalone code. `check` copies the project to a temp folder under a name of its own (the
project and its `user://` folder are never touched), puts the profile in the copy's
`override.cfg`, imports it, loads every `.gd`, and prints one `FAIL` line per message: exit 0
clean, 2 a script failed, 3 nothing verified, 1 usage. The selftest proves the templates load
under the profile, an untyped counter-example fails with "has no static type ... (Warning
treated as error.)" and loads under the default levels, a driver exercises both templates, and a
project folder with an autoload, a `class_name` and a uid reference passes untouched. Every
message, its fix, `@warning_ignore` and `directory_rules` for legacy folders:
`reference/warnings.md`.
The scripts the other godot-dev skills ship load with `untyped_declaration` at 2, the level
`godot-new-project` sets, but not all of them under the whole profile: the JSON readers and
`Variant` helpers trip mostly the `unsafe_*` warnings. Under the profile, keep a copied script in a
folder `directory_rules` holds at 0, or type it before it counts as done.
## Signals and await in one screen
| Do | Because |
|---|---|
| `sig.emit(...)`, `sig.connect(callable)` | a misspelt signal fails at load; `emit_signal("name")` fails only when it runs |
| guard with `is_connected` | a second `connect` of one callable is an `ERROR:` line and returns 31 |
| `CONNECT_ONE_SHOT` for "the first time only" | it runs once over two emits |
| `bind` knowing the order | bound arguments come after the emitted ones |
| connect methods of the listener, not lambdas capturing nodes | a freed target's method connection is removed; a lambda capturing a freed node errors at the next emit |
| capture an `Array` to share state with a lambda | locals are captured by value: `count += 1` inside changes only the lambda's copy |
| give every important `await` a timeout | an `await` on a freed emitter never returns, and nothing is printed |
| `await process_frame` first in an `-s` script's `_initialize` | the root is not inside the tree yet; `get_tree()` is null |
`templates/courier_signals.gd` carries `connect_once` and `wait_for_gate(gate, timeout_s)`, the
timed `await` that disconnects itself; the selftest drives both.
## class_name or preload
Prefer `const ParcelData = preload("parcel_data.gd")`: local to the file, no import needed, no
global name to collide, and usable as a type (`var p: ParcelData`). Use `class_name` only when the
editor must list the type (a custom `Resource` in New Resource, a node in Create Node) or the
whole project needs it, and pick a name that carries the subject (`class_name CourierRunParcel`,
not `class_name Parcel`). Two scripts with one `class_name` make one of them fail to load ("hides a global script
class"), and `class_name` resolves only after an `--import` has written the class cache.
## Resources as data
A `Resource` script with `@export` fields plus `.tres` files is the data layer: parcel kinds,
sentry tunings, route definitions. `templates/parcel_data.gd` is one, `templates/parcel_express.tres`
an instance of it by relative path. Three facts decide most bugs:
- `load()` of one path returns one shared object; a `[sub_resource]` in a scene is shared by every
instance unless `resource_local_to_scene` is set; `duplicate()` makes a copy.
- Setters run when a `.tres` loads, so validation in a setter covers the files too.
- A key the script does not have is dropped without a message: renaming an `@export` loses
every saved value.
`@tool` scripts run in the editor; `Engine.is_editor_hint()` is false in a headless run, also in a
`@tool` script, so a headless check covers only the game branch (`reference/resources-as-data.md`).
## Discipline
- **Type first, then run.** A script that does not load under the profile is not done.
- **Load is not proof.** `load()` returns non-null for a script that fails to compile; read
the error lines (a `Logger` tap, or `gdscript_strict.py check`).
- **Warnings at 2 in CI, not in heads.** Level 1 is invisible headless.
- **Silence is suspicious.** A dropped property, a coroutine that never resumes and a
self-copying lambda all print nothing; test the outcome, not the absence of errors.
- **One owner per signal.** The node that changes the state emits; others connect. A signal
emitted from three places is three behaviours with one name.
The editor's warning panel, the inspector widgets of `@export_*` hints, `@tool` behaviour
inside the editor and warnings in an exported game are outside a headless check.
## Scope — what this skill does NOT do
| Not here | Go to |
|---|---|
| Old Godot syntax, renamed APIs, converting a project | `godot-version-guard` |
| `.tscn` and `.tres` text, ids, uids | `godot-scene-files` |
| Test runners, assertions, CI exit codes | `godot-testing` |
| Proving a whole project loads and runs, the verdict | `godot-verify` |
| C# scripts | `godot-csharp` |
| Autoload state, scene changes, saves | `godot-scene-flow` |