All skills
jwynia avatar

/godot-best-practices

@99a8797
by J Wyniajwynia/agent-skills160 stars
20

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.

Use this Skill: https://skilld.dev/gh/jwynia/agent-skills/godot-best-practices

This session only. Nothing lands on disk.

assetstemplatesbase-script.gd.md

≈910 tokens on demand. Your agent reads this file only when SKILL.md points to it.

Base Script Template

Standard template for new GDScript files in Godot 4.x.

Usage

Copy and customize for new scripts. Replace all ${placeholders} with actual values. Remove unused sections.

Template

class_name ${ClassName}
extends ${ParentClass}
## ${Brief one-line description of this class.}
##
## ${Optional longer description explaining purpose, usage, and any
## important notes about how this class should be used.}


# === Signals ===

## Emitted when ${describe when signal fires}
signal ${signal_name}(${param}: ${Type})


# === Enums ===

enum ${EnumName} {
    ${VALUE_ONE},
    ${VALUE_TWO},
    ${VALUE_THREE},
}


# === Exports ===

@export_group("${Group Name}")
## ${Description of this property}
@export var ${property_name}: ${Type} = ${default_value}

@export_group("${Another Group}")
@export var ${another_property}: ${Type}


# === Constants ===

const ${CONSTANT_NAME}: ${Type} = ${value}


# === Public Variables ===

## ${Description of this public variable}
var ${public_var}: ${Type} = ${default}


# === Private Variables ===

var _${private_var}: ${Type}
var _${another_private}: ${Type} = ${default}


# === Onready References ===

@onready var _${node_ref}: ${NodeType} = $${NodePath}
@onready var _${unique_ref}: ${NodeType} = %${UniqueName}


# === Lifecycle Methods ===

func _ready() -> void:
    ${# Initialize state, connect signals}
    pass


func _process(delta: float) -> void:
    ${# Called every frame}
    pass


func _physics_process(delta: float) -> void:
    ${# Called every physics frame (fixed timestep)}
    pass


func _input(event: InputEvent) -> void:
    ${# Handle input events}
    pass


func _unhandled_input(event: InputEvent) -> void:
    ${# Handle input not consumed by UI}
    pass


# === Public Methods ===

## ${Description of what this method does}
## ${param_name}: ${Description of parameter}
## Returns: ${Description of return value}
func ${public_method}(${param}: ${Type}) -> ${ReturnType}:
    ${# Implementation}
    return ${value}


# === Private Methods ===

func _${private_method}() -> void:
    ${# Internal implementation}
    pass


# === Signal Handlers ===

func _on_${signal_source}_${signal_name}(${params}) -> void:
    ${# Handle signal}
    pass

Section Order

Keep sections in this order for consistency:

  1. class_name and extends
  2. Class documentation (##)
  3. Signals
  4. Enums
  5. Exports (grouped with @export_group)
  6. Constants
  7. Public variables
  8. Private variables (prefixed with _)
  9. @onready references
  10. Lifecycle methods (_ready, _process, etc.)
  11. Public methods
  12. Private methods (prefixed with _)
  13. Signal handlers (prefixed with _on_)

Minimal Template

For simple scripts:

class_name ${ClassName}
extends ${ParentClass}
## ${Brief description}


func _ready() -> void:
    pass

Component Template

For reusable components:

class_name ${ComponentName}Component
extends Node
## ${Description of component purpose}


# === Signals ===

signal ${state_changed}(${new_value}: ${Type})


# === Exports ===

@export var ${configurable_value}: ${Type} = ${default}


# === Public Methods ===

func ${main_action}(${param}: ${Type}) -> void:
    ${# Component logic}
    ${state_changed}.emit(${new_value})

Notes

  • Always include class_name for discoverability
  • Use ## for documentation comments (shown in editor)
  • Use # for implementation comments
  • Type everything: variables, parameters, return values
  • Prefix private members with _
  • Use @onready for node references
  • Prefer %UniqueName for stable references

Source: SKILL.md on GitHub

1 warning16d5 checks · Risk SAFE
  • Gen Agent Trust Hub16d

    This skill provides a comprehensive guide and templates for Godot 4.x GDScript development. It contains only instructional content, code snippets, and architectural patterns. No security risks or malicious behaviors were detected.

  • Socket16d

    No alerts

  • Snyk16d

    Risk: LOW · No issues

  • Runlayer7mo

    13/13 files flagged

  • ZeroLeaks5mo

    Score: 93/100 · 2 sections analyzed

Signed by skilld at 99a8797. This ties the file your Agent reads to that commit on GitHub. It does not review the instructions.

Last checked against GitHub 2 months ago.

Dormantupdated 8 months ago
compatibility
Requires Godot 4.x project. GDScript only (not C#).
Other metadata
metadata
{
  "author": "agent-skills",
  "version": "1.0",
  "godot_version": "4.x",
  "type": "utility",
  "mode": "assistive",
  "domain": "gamedev"
}

README badge

README badge for jwynia/agent-skills/godot-best-practices