AgentSkillsCN

new-scene

创建全新的 Godot 场景,并为其配备脚本与合理的节点层级结构。无论是用于塑造角色、敌人、NPC、道具、关卡,还是其他各类游戏对象,此功能都能助您事半功倍。

SKILL.md
--- frontmatter
name: new-scene
description: Create a new Godot scene with script and proper node hierarchy. Use for creating characters, enemies, NPCs, items, levels, or any game object.
argument-hint: <scene-type> <name> [details...]
disable-model-invocation: true

Create New Godot Scene

Create a new scene and accompanying GDScript for: $ARGUMENTS

Step 1 — Determine Scene Type

Parse the arguments to determine the scene type. Common types:

TypeRoot NodeTypical ChildrenDirectory
character / playerCharacterBody2DAnimatedSprite2D, CollisionShape2Dgame/scenes/characters/
enemyCharacterBody2DAnimatedSprite2D, CollisionShape2D, NavigationAgent2Dgame/scenes/enemies/
npcCharacterBody2D or Area2DAnimatedSprite2D, CollisionShape2D, Area2D (interaction zone)game/scenes/npcs/
item / pickupArea2DSprite2D, CollisionShape2Dgame/scenes/items/
projectileArea2DSprite2D, CollisionShape2Dgame/scenes/projectiles/
level / mapNode2DTileMapLayer, Camera2D, spawn markersgame/scenes/levels/
effectNode2DAnimatedSprite2D or GPUParticles2Dgame/scenes/effects/

If the type is ambiguous, ask the user.

Step 2 — Look Up Documentation (MANDATORY — do not skip)

You MUST complete ALL of these before writing any code:

  1. Call the godot-docs subagent for the root node type and key child types:
    code
    Task(subagent_type="godot-docs", prompt="Look up [ROOT_NODE_TYPE] and [CHILD_TYPES]. I need properties, methods, signals, and code examples for creating a [SCENE_TYPE] scene.")
    
  2. Read the scene architecture best practices:
    code
    Read("docs/best-practices/01-scene-architecture.md")
    
  3. If this scene has signals, also read docs/best-practices/02-signals-and-communication.md

Step 3 — Create Directory Structure

Ensure the target directory exists under game/scenes/.

Step 4 — Create the Scene (.tscn)

Create a .tscn file with the proper Godot scene format. Use [gd_scene] header, [ext_resource] for external assets, [sub_resource] for inline resources, and [node] entries.

Scene File Template

code
[gd_scene load_steps=2 format=3]

[ext_resource type="Script" path="res://scenes/<category>/<name>.gd" id="1"]

[node name="<RootName>" type="<RootType>"]
script = ExtResource("1")

[node name="<ChildName>" type="<ChildType>" parent="."]

Step 5 — Create the Script (.gd)

Generate a GDScript file following these conventions from CLAUDE.md:

Script Template

gdscript
class_name <PascalCaseName>
extends <RootNodeType>
## <Brief description of what this scene/entity does.>


signal <relevant_signal>


enum <RelevantEnum> {
	VALUE_ONE,
	VALUE_TWO,
}


const <RELEVANT_CONSTANT>: <type> = <value>


@export var <exported_property>: <type> = <default>


var <internal_property>: <type> = <default>


@onready var <child_ref>: <Type> = $<ChildNodeName>


func _ready() -> void:
	pass


func _physics_process(delta: float) -> void:
	pass

Code Style Rules (from CLAUDE.md)

  • Use tabs for indentation
  • Use static typing everywhere
  • Use double quotes for strings
  • Use @export for inspector-exposed variables
  • Use @onready for child node references
  • Use and/or/not over &&/||/!
  • Trailing commas in multiline arrays, dicts, enums
  • Two blank lines between functions
  • Lines under 100 characters (prefer 80)
  • Signals in past tense (e.g., health_changed, died)
  • Private members prefixed with _

Step 6 — Report

After creating files, report:

  1. Files created (with full paths)
  2. Node hierarchy of the scene
  3. Signals and exports defined
  4. Suggested next steps (e.g., "Add sprite frames", "Set collision shape", "Connect signals")