Skip to content
godot-extract-to-scenes logo

Extract Code-Created Objects to Scenes

godot-extract-to-scenes

Use when building Godot features and your code creates nodes with .new() instead of using scenes. Detects Timer.new(), Area2D.new(), Sprite2D.new() and other code-created objects. Automatically generates .tscn scene files, updates parent scripts with @onready references, and creates reusable comp...

SKILL.md

Full skill instructions

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 Node*.new() pattern

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

  1. Scan - Find all .new() patterns in .gd files
  2. Analyze - Determine node type, properties, parent relationships
  3. Generate - Create .tscn scene files with proper configuration
  4. Update - Replace code creation with @onready references
  5. 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 components/ directory
  • .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.

More skills from majiayu000

xiaohongshu logo
majiayu000/claude-arsenal

xiaohongshu

xiaohongshu

286 148
View
agent-task-conductor logo
majiayu000/claude-skill-registry

agent-task-conductor

Conduct multi-agent task orchestration and workflow coordination.

663 1
View
conductor-setup logo
majiayu000/claude-skill-registry

conductor-setup

Initialize project with Conductor artifacts (product definition,

663 1
View
animation-designer logo
majiayu000/claude-skill-registry

animation-designer

Expert in web animations, transitions, and motion design using Framer Motion and CSS

663 1
View
diagramming logo
majiayu000/claude-skill-registry

diagramming

Creates Mermaid and ASCII diagrams for flowcharts, architecture, ERDs, state machines, mindmaps, and more. Use when user mentions diagram, flowchart, mermaid, ASCII diagram, text diagram, terminal diagram, visualize, C4, mindmap, architecture diagram, sequence diagram, ERD, or needs visual docume...

663 1
View
h3-pg logo
majiayu000/claude-skill-registry-data

h3-pg

PostgreSQL bindings for H3 hexagonal grid system. Use when working with H3 cells in Postgres, including spatial indexing, geometry/geography integration, and raster analysis.

23 1
View
conductor-development logo
majiayu000/claude-skill-registry

conductor-development

Context-Driven Development skill for projects using Conductor. Use this skill when you detect a `conductor/` directory in the project, when working on tasks defined in a `plan.md` file, or when the user asks about tracks, specs, or plans. Automatically applies TDD workflow, tracks task completion...

663 1
View
conductor-status logo
majiayu000/claude-skill-registry

conductor-status

Display project status, active tracks, and next actions

663 1
View
dockerization logo
majiayu000/claude-skill-registry

dockerization

Official Stakpak application containerization standard operating procedure, a step-by-step guidline to properly dockerize applications. This is a rule book curated by the Stakpak Team.

663 1
View

Popular AI tools

Kaiber logo
Video

Kaiber

Generate, edit, and beat-sync AI video with leading models in one workspace.

Paid
View
Vimcal logo
Productivity

Vimcal

The world's fastest calendar for remote work

Free
View

Transform Your Design with AI Designer by ImgCreator.ai

Freemium
View
Akool AI logo
Content & writing

Akool AI

Revolutionizing Video Production with AI-Powered Creativity

Paid
View

Extend an image past the frame and let AI fill the new aspect ratio.

Freemium
View
StarByFace logo
Security

StarByFace

Discover your celebrity doppelgänger with StarByFace!

Free
View
C

ChainClarity explains 700+ crypto whitepapers in plain English, with layered summaries, comparisons, research tools, alerts, and a $4.99 Pro plan.

Freemium
View
Opus Clip logo
Coding & apps

Opus Clip

Opus.ai: Revolutionize Your Web Experience

Free
View