Claude-skill-registry godot-extract-to-scenes
install
source · Clone the upstream repo
git clone https://github.com/majiayu000/claude-skill-registry
Claude Code · Install into ~/.claude/skills/
T=$(mktemp -d) && git clone --depth=1 https://github.com/majiayu000/claude-skill-registry "$T" && mkdir -p ~/.claude/skills && cp -r "$T/skills/data/godot-extract-to-scenes" ~/.claude/skills/majiayu000-claude-skill-registry-godot-extract-to-scenes && rm -rf "$T"
manifest:
skills/data/godot-extract-to-scenes/SKILL.mdsource content
Extract Code-Created Objects to Scenes
Core Principle
Every node should be a scene. Code-created objects with
.new() should be rare exceptions for truly dynamic content.
What This Skill Does
Finds patterns like:
var timer = Timer.new() timer.wait_time = 2.0 timer.one_shot = true add_child(timer)
Transforms to:
@onready var timer: Timer = $Timer # Timer is now a scene node, configured in editor
Detection Patterns
Scans for:
Timer.new()
,Area2D.new()CollisionShape2D.new()
,Sprite2D.new()AnimatedSprite2D.new()
,AudioStreamPlayer.new()AudioStreamPlayer2D.new()
,Control.new()
,Label.new()Button.new()- Any
patternNode*.new()
When to Use
You're Building New Features
Your code creates objects dynamically that should actually be scenes.
You're Refactoring Legacy Code
Old code has
.new() calls that make nodes invisible in editor.
You Want Inspector Visibility
You want to configure properties in the Godot editor, not in code.
Process
- Scan - Find all
patterns in .gd files.new() - Analyze - Determine node type, properties, parent relationships
- Generate - Create .tscn scene files with proper configuration
- Update - Replace code creation with @onready references
- Commit - Git commit per component extracted
Example Transformation
Before:
# player.gd func _ready(): var hitbox = Area2D.new() hitbox.name = "Hitbox" var collision = CollisionShape2D.new() var shape = RectangleShape2D.new() shape.size = Vector2(32, 48) collision.shape = shape hitbox.add_child(collision) add_child(hitbox)
After:
# player.gd @onready var hitbox: Area2D = $Hitbox # Hitbox is now configured as scene node in player.tscn
Generated File:
# components/hitbox_component.tscn [gd_scene load_steps=2 format=3] [sub_resource type="RectangleShape2D" id="1"] size = Vector2(32, 48) [node name="Hitbox" type="Area2D"] [node name="CollisionShape2D" type="CollisionShape2D" parent="."] shape = SubResource("1")
What Gets Created
- Component library in
directorycomponents/ - .tscn scene files with proper node hierarchy
- Preset .tres files for reusable configurations
- Updated parent scripts with @onready references
- Git commits documenting each extraction
Smart Detection
Skips intentional dynamic creation:
- Objects created in loops (spawning enemies)
- Objects created conditionally (different weapon types)
- Objects with variable types (plugin systems)
Focuses on static objects:
- Same object created every time
- Properties set to constant values
- Should exist in editor for visibility
Integration
Works with:
- godot-split-scripts - Extract, then split large scripts
- godot-add-signals - Use signals with extracted components
- godot-refactor (orchestrator) - Runs as part of full refactoring
Safety
- Every operation creates a git commit
- Validation tests run after extraction
- Auto-rollback on test failure
- Original code preserved in git history
When NOT to Use
Don't extract if:
- Object is created dynamically (in loop, based on data)
- Object type varies at runtime
- Object is truly temporary (created and destroyed frequently)
- Code is already using PackedScene.instantiate()
These are legitimate uses of
.new() and should remain as code.