godot-builder

$npx mdskill add thedivergentai/GD-Agentic-Skills/godot-builder

Automates Godot 4.7+ CLI builds, asset pipelines, and CI/CD workflows.

  • Programmatically builds scene trees, UI layouts, and 3D assets.
  • Depends on Godot 4.7+ CLI and GODOT_PATH environment variable.
  • Uses headless isolation and cache invalidation for reliable automation.
  • Delivers exported builds, optimized meshes, and CI/CD pipeline scripts.

SKILL.md

.github/skills/godot-builderView on GitHub ↗
---
name: godot-builder
description: "Expert-level toolkit for modular Godot 4.7+ CLI automation and headless build orchestration. Use when you need to: (1) Build complex scene trees or UI layouts programmatically, (2) Automate expert 3D asset pipelines (glTF -> Collision), (3) Optimize procedural geometry headlessly (CSG -> Static Mesh), or (4) Engineer production-grade CI/CD pipelines. Set GODOT_PATH env var for custom engine location. Keywords: Godot CLI, headless, CI, export, builder, 4.7."
---

# Godot Builder Skill

The `godot-builder` skill provides an expert-grade foundation for programmatic game development and headless automation using the Godot 4.7-stable CLI. Override paths via `GODOT_PATH` and `GODOT_CONSOLE_PATH` environment variables.

## Expert Automation Mindset

- **Headless Isolation via XDG**: When running multiple concurrent Godot instances, always override `XDG_DATA_HOME` and `XDG_CONFIG_HOME` to prevent cache corruption between instances.
- **Cache Invalidation (Force Import)**: Programmatically delete the `.godot/imported/` directory to force the engine to re-evaluate modified global import settings.
- **Explicit Ownership**: Scene nodes MUST have their `owner` property set to the scene root, or they will be discarded during serialization.
- **Latency-Sensitive Multi-threading**: GPU interactions (textures, image data) must stay on the main thread to avoid pipeline stalls and deadlocks.

## Hardened Anti-Patterns (NEVER List)

- **NEVER** save runtime-generated UIDs headlessly; `ResourceSaver.save()` does NOT serialize UIDs in headless mode. Invoke `godot -e --headless --import` as a post-process.
- **NEVER** use `Resource.duplicate(true)` in Godot 4.4+; use `duplicate_deep(Resource.DEEP_DUPLICATE_ALL)` to prevent procedural state-bleed.
- **NEVER** hardcode `.tscn` or `.tres` extensions; always load via `uid://` or without extensions to avoid failures in exported binary builds.
- **NEVER** execute GPU-bound calls on secondary threads. Use `RenderingServer.call_on_render_thread()`.
- **NEVER** enable the Shader Baker for Dedicated Server builds; the headless backend ignores it.
- **NEVER** call `ResourceUID.set_id()` without calling `has_id()` first; it causes a fatal CLI crash.
- **NEVER** skip `RenderingServer.canvas_item_reset_physics_interpolation()` when programmatically moving low-level CanvasItems on their first frame; failure causes visual desync between rendering and physics systems.

## Expert Automation Workflows

> **Do NOT Load** the full script catalog for a single task. Load only the MANDATORY scripts named in the active workflow. Thin process wrappers (`launch_editor.py`, `run_project.py`, `stop_project.py`, `get_*`, `list_projects.py`) live in the appendix — do not preload them unless that exact CLI action is required.

### Workflow #1: The Hardened 3D Asset Pipeline
**Purpose**: Automates the ingestion of raw 3D assets into production-ready scenes with accurate physics collisions.
- **MANDATORY — read before improvising CLI flags**: [gltf_processor.py](scripts/gltf_processor.py) → [collision_generator.py](scripts/collision_generator.py) → [save_scene.py](scripts/save_scene.py). Then run `godot -e --headless --import` (or [import_automator.py](scripts/import_automator.py)) — do not invent alternate flag orders.
- **Sequence**: `gltf_processor.py` -> `collision_generator.py` -> `save_scene.py` -> headless `--import`.
- **Expert Defense**: Sets explicit `owner` for every node. Forces a final headless import to fix the missing UID serialization.
- **Failure modes / fallbacks**:
  - **UID missing after headless save**: Expected — `ResourceSaver` does not serialize UIDs headless. Fallback: re-run `--import`; if UIDs still missing, run [update_project_uids.py](scripts/update_project_uids.py) after import completes.
  - **Import hangs / never exits**: Script omitted `quit()` or editor import is waiting on GPU. Fallback: ensure the post-process script calls `get_tree().quit()`; kill the PID via [stop_project.py](scripts/stop_project.py) and retry with `XDG_*` isolation.
  - **Collision mesh empty / wrong**: Source glTF had no mesh arrays or wrong node paths. Fallback: inspect [gltf_processor.py](scripts/gltf_processor.py) output scene before regenerating collisions.

### Workflow #2: Procedural Level Optimization & 4.4+ Scaling
**Purpose**: Generates optimized procedural level chunks without shared resource state corruption between instances.
- **MANDATORY — read before improvising**: [csg_optimizer.py](scripts/csg_optimizer.py) → [navmesh_baker.py](scripts/navmesh_baker.py). Apply `duplicate_deep(Resource.DEEP_DUPLICATE_ALL)` between bake steps — do not use `duplicate(true)`.
- **Sequence**: `csg_optimizer.py` -> `duplicate_deep(ALL)` -> `navmesh_baker.py`.
- **Expert Defense**: Uses `duplicate_deep` to isolate materials/resources. Bakes CSG to static geometry before triggering NavMesh pathfinding.
- **Failure modes / fallbacks**:
  - **NavMesh bake on live CSG**: Pathfinding holes / empty regions. Fallback: confirm CSG→static mesh bake finished before [navmesh_baker.py](scripts/navmesh_baker.py).
  - **Material/state bleed across chunks**: Used shallow duplicate. Fallback: re-bake with `DEEP_DUPLICATE_ALL` per instance.
  - **Headless bake hang**: Missing `quit()` after bake. Fallback: add explicit quit; isolate via `XDG_DATA_HOME` / `XDG_CONFIG_HOME`.

### Workflow #3: Production CI/CD & Force-Import Validation
**Purpose**: Validates cross-platform builds and ensures global project settings (VRAM compression) are strictly applied.
- **MANDATORY — read before improvising export flags**: [test_runner.py](scripts/test_runner.py) → [profile_generator.py](scripts/profile_generator.py) → [ci_export_prepper.gd](scripts/ci_export_prepper.gd) → [ci_exporter.py](scripts/ci_exporter.py).
- **Sequence**: `rm -rf .godot/imported` -> `test_runner.py` -> `profile_generator.py` -> `ci_exporter.py`.
- **Expert Defense**: Forces full re-import to validate asset compression. Isolates CI runs via XDG variables. Injects secure keystore paths from environment variables.
- **Failure modes / fallbacks**:
  - **Export preset missing / wrong platform**: `export_presets.cfg` not mutated for the target. Fallback: run [ci_export_prepper.gd](scripts/ci_export_prepper.gd) headlessly before `--export-release`; verify preset name matches CI matrix.
  - **Hung headless CI (no exit)**: Script never called `quit()`. Fallback: always end `-s` scripts with `quit()`; treat non-zero hang as kill + retry with XDG isolation.
  - **UID / import validation fail after cache wipe**: Re-import incomplete. Fallback: re-run `--import`, then [update_project_uids.py](scripts/update_project_uids.py); do not export until import finishes cleanly.

---

## Automation & CI/CD Pipelines (Godot 4.7)

Professional Godot building requires a "Zero-Touch" philosophy for assets and binary exports.

### 1. Programmatic Asset Re-import
- **NEVER** manually select 500 textures to change their compression.
- Use `ConfigFile` to mutate `.import` files and `EditorFileSystem.reimport_files()` to trigger a batch update on the main thread safely.

### 2. Orphan Asset Detection (Slop Scan)
- **NEVER** trust `res://` is clean. Over time, deleted scenes leave behind orphaned textures and sounds that bloat the final build.
- Use `ResourceLoader.get_dependencies()` to recursively trace exactly which assets are linked to your "Main Scene" and flag anything else as slop.

### 3. Headless CI/CD Context
- Use `--headless --script` for versioning tasks (mutating `export_presets.cfg`) before running the final `--export-release`.
- **Tip**: Always call `quit()` at the end of a headless script, or your CI runner will hang indefinitely.

---

## Expert Pipeline Scripts (load on demand)

Primary automation scripts — open only when the matching workflow requires them.

### Scene & Asset Pipelines
- **gltf_processor.py**: Headlessly converts raw `.glb/.gltf` assets into Godot Scenes.
- **collision_generator.py**: Generates `ConcavePolygonShape3D` physics from mesh data.
- **save_scene.py**: Safely packs and persists the current node tree to disk (set `owner` first).
- **csg_optimizer.py**: Bakes procedural CSG boolean operations into static meshes.
- **navmesh_baker.py**: Executes asynchronous headless NavMesh pathfinding baking.
- **tilemap_generator.py**: Procedurally builds TileMapLayer grids from JSON data.
- **ui_assembler.py**: Constructs complex GUI layouts from standardized JSON structures.
- **create_scene.py** / **add_node.py** / **load_sprite.py**: Programmatic scene tree builders.
- **export_mesh_library.py**: Converts 3D scenes into `.meshlib` resources for GridMaps.
- **orphan_asset_scanner.gd**: Recursive dependency tracer for identifying unused resources.

### CI / Import / Export Pipelines
- **ci_exporter.py**: Orchestrates multi-platform release exports headlessly.
- **ci_export_prepper.gd**: Headless versioning script for `export_presets.cfg`.
- **profile_generator.py**: Generates feature profiles for module-stripping optimization.
- **test_runner.py**: Executes headless unit and integration tests (GUT/doctest).
- **import_automator.py** / **asset_reimport_utility.gd**: Batch import enforcement.
- **update_project_uids.py** / **get_uid.py**: UID sync after headless saves.
- **config_compiler.py**: Compiles JSON/CSV data into optimized `.cfg` config files.

### Appendix: Thin Process Wrappers (Do NOT preload)

Convenience CLI only — not expert pipeline prose. Load when you need that exact process action.

- **launch_editor.py** / **run_project.py** / **stop_project.py**: Editor/game process lifecycle.
- **get_debug_output.py** / **get_godot_version.py** / **get_project_info.py** / **list_projects.py**: Read-only project/process introspection.

## Reference

> Progressive disclosure: open Official Documentation links only when researching a specific API; load Related Skills when routing to a peer domain — do not preload the whole lattice.

### Official Documentation
- [Command line tutorial](https://docs.godotengine.org/en/stable/tutorials/editor/command_line_tutorial.html) — `--headless`, `--path`, `-s`/`--script`, `--import`, and `--export-*` flags that every builder wrapper invokes.
- [Exporting projects](https://docs.godotengine.org/en/stable/tutorials/export/exporting_projects.html) — Export presets, CLI release/debug export flow, and why CI must mutate `export_presets.cfg` before `--export-release`.
- [Feature tags](https://docs.godotengine.org/en/stable/tutorials/export/feature_tags.html) — Custom/feature-profile tags used when stripping modules or gating CI smoke paths with `OS.has_feature`.
- [Exporting for dedicated servers](https://docs.godotengine.org/en/stable/tutorials/export/exporting_for_dedicated_servers.html) — Headless/server export constraints (no GPU bake assumptions) that pair with CI isolation via XDG vars.
- [Import process](https://docs.godotengine.org/en/stable/tutorials/assets_pipeline/import_process.html) — `.import` + `.godot/imported` lifecycle; why deleting imported cache forces project-wide revalidation.
- [Importing 3D scenes](https://docs.godotengine.org/en/stable/tutorials/assets_pipeline/importing_3d_scenes/index.html) — glTF→scene pipeline entry before `GLTFDocument`/`ResourceSaver` automation.
- [Available 3D formats](https://docs.godotengine.org/en/stable/tutorials/assets_pipeline/importing_3d_scenes/available_formats.html) — glTF/GLB expectations for headless converters and collision generation.
- [Using CSG tools](https://docs.godotengine.org/en/stable/tutorials/3d/csg_tools.html) — Why procedural CSG must bake to static meshes before shipping or NavMesh baking.
- [Using NavigationMeshes](https://docs.godotengine.org/en/stable/tutorials/navigation/navigation_using_navigationmeshes.html) — Headless NavMesh bake ownership and region setup after CSG/static geometry lands.
- [ResourceUID](https://docs.godotengine.org/en/stable/classes/class_resourceuid.html) — Safe `has_id`/`set_id`/`uid://` sync after headless saves (UIDs are not serialized by `ResourceSaver` headless).
- [ResourceSaver](https://docs.godotengine.org/en/stable/classes/class_resourcesaver.html) — Pack/save API for programmatic `.tscn` writes; ownership must be set before `PackedScene.pack`.
- [EditorFileSystem](https://docs.godotengine.org/en/stable/classes/class_editorfilesystem.html) — `reimport_files()` for batch import enforcement from `@tool` EditorScripts.

### Related Skills

#### Prerequisites
- [godot-project-foundations](https://github.com/thedivergentai/gd-agentic-skills/blob/main/skills/godot-project-foundations/SKILL.md) — Feature folders, `project.godot` metadata, and VCS ignores must exist before CLI launch/import/export automation.
- [godot-gdscript-mastery](https://github.com/thedivergentai/gd-agentic-skills/blob/main/skills/godot-gdscript-mastery/SKILL.md) — Headless `SceneTree` workers, typed Resources, and `quit()` lifecycle patterns used by every `-s` script.
- [godot-resource-data-patterns](https://github.com/thedivergentai/gd-agentic-skills/blob/main/skills/godot-resource-data-patterns/SKILL.md) — `PackedScene`, UID paths, and deep-duplicate rules that prevent procedural state-bleed across builder runs.

#### Complements
- [godot-export-builds](https://github.com/thedivergentai/gd-agentic-skills/blob/main/skills/godot-export-builds/SKILL.md) — Platform templates, codesign/keystore, and filter rules that sit on top of `ci_exporter.py` orchestration.
- [godot-3d-world-building](https://github.com/thedivergentai/gd-agentic-skills/blob/main/skills/godot-3d-world-building/SKILL.md) — CSG/GridMap/MeshLibrary authoring that this skill bakes and exports headlessly.
- [godot-navigation-pathfinding](https://github.com/thedivergentai/gd-agentic-skills/blob/main/skills/godot-navigation-pathfinding/SKILL.md) — Runtime agents and layer costs that consume NavMeshes produced by `navmesh_baker.py`.
- [godot-tilemap-mastery](https://github.com/thedivergentai/gd-agentic-skills/blob/main/skills/godot-tilemap-mastery/SKILL.md) — TileSet/TileMapLayer conventions for scenes generated by `tilemap_generator.py`.
- [godot-ui-containers](https://github.com/thedivergentai/gd-agentic-skills/blob/main/skills/godot-ui-containers/SKILL.md) — Container layout rules that `ui_assembler.py` should emit instead of absolute Control positions.
- [godot-physics-3d](https://github.com/thedivergentai/gd-agentic-skills/blob/main/skills/godot-physics-3d/SKILL.md) — Collision layers/shapes for trimesh bodies created by `collision_generator.py`.

#### Downstream / consumers
- [godot-testing-patterns](https://github.com/thedivergentai/gd-agentic-skills/blob/main/skills/godot-testing-patterns/SKILL.md) — GUT/integration suites launched through `test_runner.py` in CI after import/export steps.
- [godot-performance-optimization](https://github.com/thedivergentai/gd-agentic-skills/blob/main/skills/godot-performance-optimization/SKILL.md) — Escalate when orphan scans, import compression, or export size still miss budgets.
- [godot-monte-carlo-balancer](https://github.com/thedivergentai/gd-agentic-skills/blob/main/skills/godot-monte-carlo-balancer/SKILL.md) — Headless `test_runner` calibration loops for balance sims after builder CI smoke passes.
- [godot-debugging-profiling](https://github.com/thedivergentai/gd-agentic-skills/blob/main/skills/godot-debugging-profiling/SKILL.md) — Consume `get_debug_output.py` logs when headless imports/exports fail without a GUI.

#### Master
- [godot-master](https://github.com/thedivergentai/gd-agentic-skills/blob/main/skills/godot-master/SKILL.md) — Library router and mirrored module entry; open when discovering which Domain Skill owns a cross-cutting build/automation concern.

More from thedivergentai/GD-Agentic-Skills

SkillDescription
godot-2d-animationExpert patterns for 2D animation in Godot using AnimatedSprite2D and skeletal cutout rigs. Use when implementing sprite frame animations, procedural animation (squash/stretch), cutout bone hierarchies, or frame-perfect timing systems. Trigger keywords: AnimatedSprite2D, SpriteFrames, animation_finished, animation_looped, frame_changed, frame_progress, set_frame_and_progress, cutout animation, skeletal 2D, Bone2D, procedural animation, animation state machine, advance(0).
godot-2d-physicsExpert patterns for Godot 2D physics including collision layers/masks, Area2D triggers, raycasting, and PhysicsDirectSpaceState2D queries. Use when implementing collision detection, trigger zones, line-of-sight systems, or manual physics queries. Trigger keywords: CollisionShape2D, CollisionPolygon2D, collision_layer, collision_mask, set_collision_layer_value, set_collision_mask_value, Area2D, body_entered, body_exited, RayCast2D, force_raycast_update, PhysicsPointQueryParameters2D, PhysicsShapeQueryParameters2D, direct_space_state, move_and_collide, move_and_slide.
godot-3d-lightingExpert patterns for Godot 3D lighting including DirectionalLight3D shadow cascades, OmniLight3D attenuation, SpotLight3D projectors, VoxelGI vs SDFGI, and LightmapGI baking. Use when implementing realistic 3D lighting, shadow optimization, global illumination, or light probes. Trigger keywords: DirectionalLight3D, OmniLight3D, SpotLight3D, shadow_enabled, directional_shadow_mode, directional_shadow_split, omni_range, omni_attenuation, spot_range, spot_angle, VoxelGI, SDFGI, LightmapGI, ReflectionProbe, Environment, WorldEnvironment.
godot-3d-materialsExpert patterns for Godot 3D PBR materials using StandardMaterial3D including albedo, metallic/roughness workflows, normal maps, ORM texture packing, transparency modes, and shader conversion. Use when creating realistic 3D surfaces, PBR workflows, or material optimization. Trigger keywords: StandardMaterial3D, BaseMaterial3D, albedo_texture, metallic, metallic_texture, roughness, roughness_texture, normal_texture, normal_enabled, orm_texture, transparency, alpha_scissor, alpha_hash, cull_mode, ShaderMaterial, shader parameters.
godot-3d-world-buildingExpert patterns for 3D level design using GridMap with MeshLibrary, CSG constructive solid geometry, occlusion, and runtime GridMap builders. Use when building 3D levels, modular tilesets, or BSP-style geometry. For sky/fog/Environment recipes, route to godot-3d-lighting. Trigger keywords: GridMap, MeshLibrary, set_cell_item, get_cell_item, map_to_local, local_to_map, CSGCombiner3D, CSGBox3D, CSGSphere3D, CSGPolygon3D, OccluderInstance3D, bake CSG.
godot-ability-systemExpert patterns for RPG/action ability systems including cooldown strategies, combo systems, ability chaining, skill trees with prerequisites, upgrade paths, and resource management. Use when implementing unlockable abilities, character progression, or complex skill systems. Trigger keywords: PlayerAbility, AbilityManager, cooldown, SkillTree, SkillNode, prerequisites, can_use, execute, ComboSystem, ability_chain, global_cooldown, charge_system, upgrade_path.
godot-adapt-2d-to-3dExpert patterns for migrating 2D games to 3D including node type conversions, camera systems (third-person, first-person, orbit), physics layer migration, sprite-to-model art pipeline, and control scheme adaptations. Use when porting 2D projects to 3D or adding 3D elements. Trigger keywords: CharacterBody2D to CharacterBody3D, Area2D to Area3D, Camera2D to Camera3D, Vector2 to Vector3, collision_layer migration, sprite to MeshInstance3D, 2D to 3D conversion.
godot-adapt-3d-to-2dExpert patterns for simplifying 3D games to 2D including dimension reduction strategies, 2.5D fake-depth, isometric ports, camera flattening, physics conversion, 3D-to-sprite art pipeline, and control simplification. Use when porting 3D to 2D, building 2.5D / isometric / fake-depth gameplay, creating 2D versions for mobile, or prototyping. Trigger keywords: CharacterBody3D to CharacterBody2D, Camera3D to Camera2D, Vector3 to Vector2, flatten Z-axis, 2.5D, isometric, fake depth, Y-sort, simulated Z, orthogonal projection, 3D to sprite conversion, performance optimization.
godot-adapt-desktop-to-mobileExpert patterns for porting desktop games to mobile including touch control schemes (virtual joystick, gesture detection), UI scaling for small screens, performance optimization for mobile GPUs, battery life management, and platform-specific features. Use when creating mobile ports or cross-platform mobile builds. Trigger keywords: TouchScreenButton, virtual_joystick, gesture_detector, InputEventScreenTouch, InputEventScreenDrag, mobile_optimization, battery_saving, adaptive_performance, MOBILE_ENABLED.
godot-adapt-mobile-to-desktopExpert patterns for scaling mobile games to desktop including mouse/keyboard controls, increased resolution and graphical fidelity, expanded UI layouts, settings menus, window management, and platform-specific features. Use when creating desktop ports or cross-platform releases. Trigger keywords: mouse_controls, keyboard_shortcuts, resolution_scaling, graphics_settings, fullscreen_toggle, window_modes, Steam_integration, desktop_optimization.