Skip to content

gamedev-skills/awesome-gamedev-agent-skills / skills/godot/godot-gdscript

godot-gdscript

Verified

GDScript 2.0 for Godot 4.7: static typing, @export and @onready, await and coroutines, and porting 3.x code. Use for .gd parse errors ("Cannot infer the type"), a coroutine that never resumes, a null @onready variable or upgrade breakage. Not for signals (`godot-signals-groups`), scenes (`godot-nodes-scenes`), C# (`godot-csharp`) or CI tests (`godot-gdscript-headless-testing`).

FileKindSize
SKILL.mdskill md7.2 KB
assets/check_scripts_compile.gdother1.6 KB
references/annotations-and-typing.mdmarkdown3.9 KB

assets/check_scripts_compile.gd

View on GitHub
# Headless check that every GDScript file in a Godot 4.7 project parses and compiles.
# Unlike `--check-only`, it runs with the project's autoloads and global classes
# registered, so scripts that use an autoload by name are not reported as broken.
#
# Run from the project folder (import first on a fresh checkout):
#   godot --headless --path . --import
#   godot --headless --path . --script /abs/path/to/check_scripts_compile.gd
# Exit code 0 means every script compiled and 1 means at least one did not; the
# engine prints the parse error and line above each "BROKEN" line on stderr.
# Loading a script runs no _ready()/_init(), but static variable initialisers do run.
extends SceneTree


func _initialize() -> void:
	var own_path: String = get_script().resource_path
	var broken := 0
	var total := 0
	for path in gd_files("res://"):
		if path == own_path:
			continue  # this runner, if it was copied into the project
		total += 1
		var script := load(path) as Script
		if script == null or not script.can_instantiate():
			broken += 1
			printerr("BROKEN ", path)
	print("scripts checked: %d, broken: %d" % [total, broken])
	quit(1 if broken > 0 else 0)


func gd_files(dir: String) -> PackedStringArray:
	var out := PackedStringArray()
	if FileAccess.file_exists(dir.path_join(".gdignore")):
		return out
	for file in DirAccess.get_files_at(dir):
		if file.get_extension() == "gd":
			out.append(dir.path_join(file))
	for sub in DirAccess.get_directories_at(dir):
		if not sub.begins_with("."):  # skips .godot/ and other hidden folders
			out.append_array(gd_files(dir.path_join(sub)))
	return out
finishing-a-development-branchobra/superpowersUse when implementation is complete, all tests pass, and you need to decide how to integrate the workStars: 322kUpdated Claude CodeCodexVerifiedInstall
systematic-debuggingobra/superpowersUse when encountering any bug, test failure, or unexpected behavior, before proposing fixesStars: 322kUpdated Claude CodeCodexVerifiedInstall
test-driven-developmentobra/superpowersUse when implementing any feature or bugfix, before writing implementation codeStars: 322kUpdated Claude CodeCodexVerifiedInstall
skill-creatoranthropics/skillsCreate new skills, modify and improve existing skills, and measure skill performance. Use when users want to create a skill from scratch, edit, or optimize an existing skill, run evals to test a skill, benchmark skill performance with variance analysis, or optimize a skill's description for better triggering accuracy.Stars: 198kUpdated Claude CodeCodexVerifiedInstall