Logo van Godot Gdscript Mastery

Godot Gdscript Mastery

Community
bgrenat
godot-gdscript-mastery

Expert GDScript best practices including static typing (var x: int, func returns void), signal architecture (signal up call down), unique node access (%NodeName, @onready), script structure (extends, class_name, signals, exports, methods), and performance patterns (dict.get with defaults, avoid get_node in loops). Use for code review, refactoring, or establishing project standards. Trigger keywords: static_typing, signal_architecture, unique_nodes, @onready, class_name, signal_up_call_down, gdscript_style_guide.

Overzicht

Uitgeverbgrenat
Repositorygodot-game-dev-studio
Skillnaamgodot-gdscript-mastery
Sterren
27
Forks
3
Meegeleverde bestanden
15
LicentieLGPL-3.0
Links
  • Instructies in Markdown

    Het model laadt het bestand SKILL.md alleen als dat nodig is. Dat kost dus alleen tokens als een verzoek daadwerkelijk bij de skill past.

  • Werkt met elk LLM

    AI-skills bestaan uit instructies in gewone Markdown, niet uit aanbiederspecifieke code. Daardoor werken ze met GPT, Claude, Gemini, Grok of een lokaal model.

  • Meegeleverde bestanden: 15

    Scripts, sjablonen en referentiemateriaal die het model tijdens het werken kan lezen. De bestanden kunnen alleen worden gelezen en worden nooit uitgevoerd.

  • Open source

    Gepubliceerd door bgrenat op GitHub. Bekijk de bronbestanden voordat je de skill installeert.

Installatie

Installeer de AI-skill Godot Gdscript Mastery in TypingMind om deze met elk LLM te gebruiken, of voeg de skill toe aan een andere agent die SKILL.md kan lezen.

1

Installeren in TypingMind

TypingMind installeert een skill rechtstreeks vanuit de GitHub-map. De app leest SKILL.md, bundelt de bijbehorende bestanden en slaat het resultaat lokaal op.

  1. Open de app en ga naar Plug-ins → Skills.
  2. Kies "Installeren via GitHub".
  3. Plak de onderstaande URL van de skillmap en bevestig.
    https://github.com/bgrenat/godot-game-dev-studio/tree/main/skills/godot-gdscript-mastery
  4. Schakel de skill in voor elke chat waarin je de skill wilt kunnen gebruiken.
Plug-ins → Skills → Skill toevoegen → Via GitHub-URL. Plak vervolgens de map-URL en druk op Doorgaan.
2

Installeren in een andere agent

Elke agent die het Agent Skills-formaat kan lezen, kan deze skill gebruiken — kopieer de map naar de skillmap van die agent.

Claude Code — .claude/skills
git clone --depth 1 https://github.com/bgrenat/godot-game-dev-studio.git /tmp/godot-game-dev-studio
mkdir -p .claude/skills
cp -r /tmp/godot-game-dev-studio/skills/godot-gdscript-mastery .claude/skills/godot-gdscript-mastery
Start Claude Code na het kopiëren opnieuw op, zodat de nieuwe skill wordt herkend.

Gebruik deze skill in TypingMind

Schakel Godot Gdscript Mastery in voor een chat naar keuze in TypingMind en het model doet de rest. De naam en beschrijving staan in de systeemprompt. Zodra een verzoek bij de skill past, laadt het model zelf de volledige instructies. Je hoeft de skill nooit handmatig aan te roepen. Pas als het model de skill daadwerkelijk gebruikt, kost dat tokens.

Het model laadt Godot Gdscript Mastery automatisch zodra een verzoek erbij past.

Werkt met elk AI-model

AI-skills zijn gewone Markdown-instructies in plaats van aanbiederspecifieke code. Daardoor is Godot Gdscript Mastery niet gebonden aan het model waarvoor de skill is geschreven. Installeer de skill één keer in TypingMind en gebruik deze met GPT-5, Claude, Gemini, Grok, DeepSeek, Mistral, Llama of een lokaal model dat je zelf draait — allemaal met je eigen API-sleutels.

  • Alleen geladen wanneer nodig

    De systeemprompt bevat alleen de naam en beschrijving. De instructies worden bij het eerste bijpassende verzoek opgehaald, dus een ongebruikte skill kost niets.

  • Wissel van model tijdens een chat

    Omdat de skill uit instructies bestaat en niet uit code, blijft deze werken als je van model wisselt — het volgende model leest hetzelfde SKILL.md-bestand.

Skillinstructies

Dit is de inhoud van SKILL.md die het model laadt. Lees deze vóór de installatie — een skill bestaat uit instructies die je model zal volgen.

GDScript Mastery

Expert guidance for writing performant, maintainable GDScript following official Godot standards.

Available Scripts

typed_collections_mastery.gd

Expert performance optimization using statically typed Arrays and Dictionaries.

functional_lambda_logic.gd

Advanced list processing using reduce(), all(), and any() with clean lambda syntax.

safe_type_casting.gd

Best practices for using the as operator for crash-proof object identification.

typed_signal_definitions.gd

Enforcing type safety across script boundaries using strictly typed signal arguments.

callable_binding_context.gd

Injecting extra context into signal callbacks using Callable.bind().

unbind_signal_args.gd

Safely discarding unneeded signal arguments using Callable.unbind().

await_sequence_manager.gd

Managing complex asynchronous flows and timers using await without thread-blocking.

array_preallocation_perf.gd

Eliminating memory reallocation lag by pre-sizing large arrays with resize().

static_var_singleton_alt.gd

Using static var for global state management as an alternative to heavy Autoloads.

dictionary_safe_iteration.gd

The correct pattern for erasing dictionary keys while iterating to avoid runtime errors.

NEVER Do in GDScript

  • NEVER use @onready and @export on the same variable — Initialization order will cause @onready to overwrite the Inspector value [1].
  • NEVER modify a Dictionary's size while iterating it — Use dict.keys().duplicate() or iterate a clone to safely erase elements [2, 3].
  • NEVER use string-based connect("signal", ...) — Always use the Signal object syntax (button.pressed.connect(...)) for compile-time safety [4].
  • NEVER attempt to override non-virtual native engine methods — Overriding queue_free() or get_class() is unsupported and will be ignored by engine callbacks [5, 6].
  • NEVER use dynamic get_node() or $ inside _process() — Fetching paths every frame stalls the CPU. Cache and use @onready [7, 8].
  • NEVER use Parent.method() calls — Violates "Signal Up, Call Down". Use signals to communicate with parents.
  • NEVER use is followed by a hard cast — If the type check passes but the object changes, it crashes. Use as and check for null.
  • NEVER use print() for production debugging — Use push_error(), push_warning(), or breakpoints to ensure errors are visible in the console/logs.
  • NEVER pre-load huge resources in _ready() — This causes frame stutters. Use ResourceLoader.load_threaded_request() for async loading.
  • NEVER use global variables in Autoloads when static var is sufficient — Static variables offer better encapsulation and less project pollution [24].

Godot 4.7: GDScript

  • Typed override methods inherit return type — overrides require explicit return (add return null if needed).
  • Setting packed array elements no longer invokes the whole-array property setter.

Core Directives

1. Strong Typing & Performance

Always use static typing. In Godot 4.x, this enables optimized opcodes by bypassing runtime Variant type-checking.

  • Opcode Optimization: When types are known at compile-time, the engine uses faster, typed execution paths.
    • Why it's faster: Dynamic variables are internally tracked as 24-byte Variant structures [3]. Every operation on a dynamic variable requires the engine to evaluate the underlying type at runtime, incurring significant overhead [2, 4].
    • Safe Lines: Confirm optimizations in the script editor; green line numbers in the gutter indicate guaranteed type safety and optimized execution [6, 7].
  • Typed Global Methods: Use typed math functions for a performance boost (e.g., use absf(), ceili(), clampf() instead of the generic abs(), ceil(), clamp()).
  • Rule: Prefer explicit inference := when the type is obvious: var pos := Vector2(10, 10).
  • Rule: Always specify return types for functions: func _ready() -> void:.

2. Signal Architecture

  • Connect in _ready(): Preferably connect signals in code to maintain visibility, rather than just in the editor.
  • Typed Signals: Define signals with types: signal item_collected(item: ItemResource).
  • Pattern: "Signal Up, Call Down". Children should never call methods on parents; they should emit signals instead.

3. Node Access & Lifecycle Safety

  • @onready vs _init():
    • Use _init() ONLY for constructor logic (data initialization, memory allocation).
    • Use @onready for node dependencies. Child nodes are NOT available in _init().
    • DANGER: Avoid _init(args) for nodes that will be part of a Scene. It breaks PackedScene.instantiate(). Use @export for parameter injection.
  • Unique Names: Use %UniqueNames for nodes that are critical to the script's logic.
  • Onready Overrides: Prefer @onready var sprite = %Sprite2D over calling get_node() in every function.

4. Callable & Signal (First-Class Citizens)

In Godot 4, Callable and Signal are built-in types. They can be stored in variables and passed as arguments.

  • No Strings: Always connect via references: button.pressed.connect(_on_pressed).
  • Anonymous Lambdas: Use for quick inline logic: timer.timeout.connect(func(): print("Time up!")).
  • Binding Context: Use Callable.bind() to pass extra arguments to a signal callback: hit.connect(_on_hit.bind("Sword")).

5. Code Structure

Follow the standard Godot script layout:

  1. extends
  2. class_name
  3. signals / enums / constants
  4. @export / @onready / properties
  5. _init() / _ready() / _process()
  6. Public methods
  7. Private methods (prefixed with _)

Common "Architect" Patterns

1. Refactoring Checklist: Godot 3.x to 4.x

Essential syntax shifts when porting legacy scripts to GDScript 2.0.

  • Annotations: Replace export, onready, tool with @export, @onready, and @tool.
    • Example: @export_enum("A", "B") var type: int replaces legacy string hints.
  • Coroutines: Replace yield() with the await keyword.
    • Example: await get_tree().create_timer(1.0).timeout
    • Common Pattern: await get_tree().process_frame replaces yield(get_tree(), "idle_frame").
  • Properties: Replace setget with inline property syntax.
    • Syntax: var x: int: set(v): x = v; get: return x
  • Signals: Migrate from string-based connections to first-class Callable references.
    • Connection: btn.pressed.connect(_on_pressed) (deprecated: btn.connect("pressed", ...)).
    • Emission: my_signal.emit(args) (deprecated: emit_signal("my_signal", ...)).
  • Node Renames: Be aware of renamed nodes (e.g., KinematicBody3D -> CharacterBody3D, Position2D -> Marker2D).
  • Lifecycle Calls: Explicitly call super() in overridden _ready(), _process(), or _init() if parent logic is required.

2. Static Utility Libraries

Use static members to build lightweight helper libraries that bypass the SceneTree.

  • Static Functions: Call via class name without instantiating: MathUtils.calculate(val).
    • Restriction: No access to self, instance variables, or non-static methods.
  • Static Variables: Shared globally across the project.
    • Restriction: Cannot use @export or @onready on static variables.
  • @static_unload: Place at the top of the script to instruct the engine to unload the script when no references remain.
    • CRITICAL: Due to a current engine bug, scripts with static variables may not be automatically freed. Manually nullify large static data structures (like Dictionaries or Arrays of Resources) when no longer needed to prevent memory leaks.

3. The "Safe" Dictionary Lookup

Avoid dict["key"] if you aren't 100% sure it exists. Use dict.get("key", default).

4. Scene Unique Nodes

When building complex UI, always toggle "Access as Scene Unique Name" on critical nodes (Labels, Buttons) and access them via %Name.

Reference

  • Official Docs: tutorials/scripting/gdscript/gdscript_styleguide.rst
  • Official Docs: tutorials/best_practices/logic_preferences.rst

Related

Meegeleverde bestanden

Zolang de skill geladen is, leest het model deze bestanden als dat nodig is. Het model kan ze alleen lezen; ze worden nooit uitgevoerd.

Veelgestelde vragen

Wat doet de AI-skill Godot Gdscript Mastery?

Expert GDScript best practices including static typing (var x: int, func returns void), signal architecture (signal up call down), unique node access (%NodeName, @onready), script structure (extends, class_name, signals, exports, methods), and performance patterns (dict.get with defaults, avoid get_node in loops). Use for code review, refactoring, or establishing project standards. Trigger keywords: static_typing, signal_architecture, unique_nodes, @onready, class_name, signal_up_call_down, gdscript_style_guide.

Waarom Godot Gdscript Mastery gebruiken in TypingMind?

Omdat je deze skill één keer installeert en met elk model kunt gebruiken. Godot Gdscript Mastery bestaat uit gewone Markdown in plaats van aanbiederspecifieke code. Dezelfde skill werkt dus met GPT-5, Claude, Gemini, Grok of een lokaal model. Ook als je midden in een chat van model wisselt, blijft de skill werken. TypingMind werkt met je eigen API-sleutels, dus je betaalt aanbieders rechtstreeks in plaats van een abonnement per gebruikersplek af te sluiten. Je skills en chats blijven in je eigen opslag.

Hoe installeer ik Godot Gdscript Mastery in TypingMind?

Open Plug-ins → Skills → Installeren vanaf GitHub in TypingMind en plak https://github.com/bgrenat/godot-game-dev-studio/tree/main/skills/godot-gdscript-mastery. TypingMind leest het bestand SKILL.md, bundelt de bijbehorende bestanden en installeert het geheel als een skill die je per chat kunt inschakelen.

Welke AI-modellen kunnen Godot Gdscript Mastery gebruiken?

Elk model dat je in TypingMind koppelt. AI-skills bestaan uit gewone Markdown-instructies in plaats van aanbiederspecifieke code. GPT, Claude, Gemini, Grok en lokale modellen kunnen deze skill dus allemaal laden wanneer een verzoek erbij past.

Hoeveel AI-modellen kan ik met Godot Gdscript Mastery gebruiken?

Zoveel als je wilt. Je kunt Godot Gdscript Mastery gebruiken met elk model dat skills ondersteunt, zoals GPT, Claude, Gemini, Grok, DeepSeek, Mistral of Llama. Allemaal in TypingMind met je eigen API-sleutels.

Is de AI-skill Godot Gdscript Mastery gratis?

Ja. Deze skill is door bgrenat op GitHub gepubliceerd onder de licentie LGPL-3.0. Je betaalt alleen je eigen AI-aanbieder voor de tokens die je gebruikt.

Wat zijn AI-skills?

Een AI-skill is een herbruikbare bundel instructies die een AI-model leert hoe het één specifieke taak moet uitvoeren. De skill volgt het open Agent Skills-formaat: het bestand SKILL.md bevat de naam en beschrijving van de skill. Daarnaast kan de skill scripts, sjablonen of referentiebestanden bevatten die het model nodig heeft. Het model leest de instructies alleen als je verzoek bij de skill past. Een geïnstalleerde skill kost dus niets zolang deze niet wordt gebruikt.

Waarin verschillen AI-skills van plug-ins of MCP-servers?

Een plug-in of MCP-server geeft een model nieuwe tools om aan te roepen: code die ergens wordt uitgevoerd en een resultaat teruggeeft. Een AI-skill geeft het model juist kennis en een werkwijze: hoe het een taak moet aanpakken, welke stappen het moet volgen en hoe goede uitvoer eruitziet. Skills bestaan uit gewone Markdown en hebben dus geen server, API-sleutel of runtime nodig. Ze werken met elk model.

Bekijk alles

Maak nu je eigen AI-werkruimte

Schrijf je in voor onze nieuwsbrief en blijf op de hoogte van nieuwe functies en toekomstige weggeefacties 👇