Skip to content
Back to skills

Godot Scene Files

ASecurity

Edit Godot .tscn and .tres as text: ext_resource and sub_resource ids, uids and .uid files, instanced scenes, building scenes from a script.

  • 5 stars
  • 0 votes
  • 0 copies
  • 0 views
  • Added December 3, 2026
ai-agentspythongobashnodegit

Security analysis

A100/100

Pro scans all 7 files and shows the line behind each finding

Scanned December 3, 2026

npx -y skills add tipoLi5890/game-studio --skill godot-scene-files --agent claude-code

Installs into .claude/skills of the current project.

Are you the author of Godot Scene Files?

Add the live security badge to your README. It updates with every re-scan.

Security grade badge for Godot Scene Files
[![Security: A — Skills Directory](https://www.skillsdirectory.com/api/skills/tipoli5890-godot-scene-files/badge)](https://www.skillsdirectory.com/skills/tipoli5890-godot-scene-files)

More formats (shields.io, HTML) on the badges page. Keep it an A: scan every change in CI with Pro.

Download with Pro
SKILL.md
---
name: godot-scene-files
description: >-
  Edit Godot .tscn and .tres as text: ext_resource and sub_resource ids, uids and .uid files,
  instanced scenes, building scenes from a script.
---

# godot-scene-files — scenes and resources as text

A scene file is plain text an agent can write directly, as long as the ids, paths and uids agree.
The engine is strict about some mistakes (a dangling id fails the whole file) and silent about
others (a duplicate id, a misspelt property, a connection to a node that is not there): the
silent ones are what this skill's two scripts exist for.

## Load what the situation needs

| The situation | Read |
|---|---|
| Writing or editing a `.tscn` or `.tres` by hand; what each section means; what is safe to touch | `reference/tscn-format.md` |
| "Parse Error" on load; a node or a connection that vanished; a property that did not stick | `reference/tscn-format.md` → "What is silently dropped", then `scripts/scene_tree.py` |
| `uid=`, `.uid` files, "invalid UID ... using text path instead", "UID duplicate detected"; moving files | `reference/uids.md` |
| Generating a scene from code or data; nodes missing from the saved file; saved connections | `reference/build-from-script.md` · `resources/build_scene.gd` |
| GDScript itself, typed resources as data | `godot-gdscript` |
| `.import` files of models and their settings | `godot-3d-models` |
| Whether the whole project loads and runs headless | `godot-verify` |
| `project.godot` and which generated files to commit | `godot-new-project` |

## A scene in one screen

```ini
[gd_scene format=3]

[ext_resource type="Script" path="gate_switch.gd" id="1"]
[ext_resource type="PackedScene" path="parcel_token.tscn" id="2"]

[sub_resource type="RectangleShape2D" id="gate_shape"]
size = Vector2(16, 96)

[node name="GateRoom" type="Node2D"]
script = ExtResource("1")

[node name="ParcelA" parent="." instance=ExtResource("2")]
position = Vector2(96, 0)

[node name="Gate" type="StaticBody2D" parent="."]

[node name="GateShape" type="CollisionShape2D" parent="Gate"]
shape = SubResource("gate_shape")

[connection signal="body_entered" from="ParcelA" to="." method="on_parcel_touched"]
```

- **Order:** header, `[ext_resource]`s, `[sub_resource]`s (each before its first use), the root
  `[node]` (no `parent`), the other nodes (each after its parent), `[connection]`s, `[editable]`.
- **Ids** are strings unique per file. The saver writes `1_k8xps`-style ids and new ones on every
  save; by hand, short ones are fine.
- **Paths:** `res://...` from the project root, or relative to the file's own folder
  (`path="gate_switch.gd"`), which keeps a folder movable. `ResourceSaver` always writes
  `res://`.
- **No `uid=` by hand.** An unknown uid falls back to the path with a `WARNING:` on every load.

## What the engine does with a broken file

| Edit | Engine | Caught by |
|---|---|---|
| `ExtResource("9")` with no id 9; `SubResource("x")` used before its section | the whole file fails to load | `scene_lint.py`, `scene_tree.py` |
| an `ext_resource` path to a missing file | `ERROR: ... referenced non-existent resource`; the scene loads without it | both |
| two `ext_resource` (or `sub_resource`) with one id | **loads silently**, one wins | `scene_lint.py` |
| a `parent=` naming no node | a warning; the node lands under a mangled name | both |
| two siblings with one name | loads; connections reach the wrong node | `scene_lint.py` |
| `[connection]` to a misspelt node or method | **no error** at load | `scene_lint.py` (nodes), `scene_tree.py` (nodes and methods) |
| a misspelt property (`positon = ...`) | **ignored silently** | `scene_tree.py` (on nodes) |
| a type that does not exist (`type="Area2d"`) | an error and a plain `Node` placeholder | `scene_tree.py` |
| `instance=` of a script, not a scene | "Scene instance is missing" | both |
| a `.tres` with no `[resource]` | fails: "Unexpected end of file" | `scene_lint.py` |
| one header uid in two files | `WARNING: UID duplicate detected` at import | `scene_lint.py` (files linted together) |

## The two scripts

```bash
python3 scripts/scene_lint.py levels/ --project .          # text only, no Godot: ids, order, paths, nodes
GODOT_BIN=/path/to/Godot python3 scripts/scene_tree.py levels/gate_room.tscn --expect gate_room.tree
```

- `scene_lint.py` reads strings as strings (a multi-line `text = "..."` whose line starts with
  `[` is not a section; `ExtResource("x")` inside a string is not a reference) and prints `FAIL`
  and `WARN` lines, then `scene-lint: PASS|FAIL ...`. Exit 0 no failure, 2 a failure, 3 a path it
  cannot read, 1 usage. `--strict` fails warnings too (a format other than 3, an unused
  resource). Its selftest lints 24 fixtures written to a temp folder.
- `scene_tree.py` copies the scene's project into a temp folder (the real one is never opened or
  imported), imports it, loads and instantiates the scene in a fresh process, and prints the tree
  (`Depot/Parcels/ParcelA Area2D instance=res://...`), the connections, and every problem.
  `--expect` compares `path type` per node with a file. Exit 0, 2 a problem, 3 nothing verified
  (no Godot, no sentinel), 1 usage.
- `resources/build_scene.gd` builds `parcel_token.tscn` and `depot.tscn` (an instanced scene
  with an override, a unique name, a persistent connection, a node left unowned on purpose) and
  checks each saved node count. `scene_tree.py --selftest` runs it in a temp project, lints what
  it wrote, loads `depot.tscn` in a second process against the expected tree, and requires three
  broken scenes to fail.

## Building from a script, in four rules

1. `add_child`, then `owner = root`: the other order is "Invalid owner" and the node is lost.
2. Only nodes owned by the root are saved; an instance is saved as one line, its children come
   from its own file.
3. Only connections made with `CONNECT_PERSIST`, to a method of a node in the scene, are saved.
4. Re-read the saved file (in a second process when it counts) and compare the tree; a forgotten
   owner gives no error, only a smaller scene.

## Discipline

- **Lint, then load.** Text checks catch what the engine forgives; the engine catches what
  text cannot know (properties, methods, types). Run both after a hand edit, then the project's
  headless gate (`godot-verify`).
- **Edit small, regenerate big.** Change values and add plain nodes by hand; instanced
  sub-trees, editable children and anything with uids come from the editor or a builder script.
- **Never invent a uid, never strip one the editor wrote.**
- **Diff structure, not text.** Saves rewrite ids; compare `scene_tree.py` output instead.
- **Rename with every reference.** A node rename changes every `parent=`, `[connection]` and
  `NodePath` that names it; grep the folder for the old name before calling it done.

What the editor writes when it saves (uids on headers and references, id and `unique_id`
handling), editable children as the editor shows them and building scenes from an `@tool`
script inside the editor are editor behaviour: run `scene_lint.py` and `scene_tree.py` on an
editor-saved file rather than assume its shape.

## Scope — what this skill does NOT do

| Not here | Go to |
|---|---|
| Writing GDScript, typed `Resource` classes | `godot-gdscript` |
| Model import files, post-import scripts | `godot-3d-models` |
| Proving the project loads and runs, the verdict | `godot-verify` |
| `project.godot`, `.gitignore` for `.godot/` | `godot-new-project` |
| Scenes changed at run time, save files | `godot-scene-flow` |
| Old-format scenes from an earlier engine | `godot-version-guard` |

Files in this skill

  • SKILL.md7.4 KB
  • reference/build-from-script.md4.9 KB
  • reference/tscn-format.md6.6 KB
  • reference/uids.md3.8 KB
  • resources/build_scene.gd4.8 KB
  • scripts/scene_lint.py19.5 KB
  • scripts/scene_tree.py19.3 KB

Attribution

Is this your skill, or is something wrong with this listing? Request removal or report an issue. Author removals are honored within 72 hours.

View all in ai-agents →

Comments

Loading comments…

Newsletter

Get the weekly list of safe new skills, and the ones we pulled.