[{"data":1,"prerenderedAt":-1},["ShallowReactive",2],{"skill:01M6KR9ND6GCDPFSXV4TR2BY9X":3,"skill-same:01M6KR9ND6GCDPFSXV4TR2BY9X":78},{"skillNo":4,"name":5,"nameZh":6,"description":7,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":12,"repositoryNo":13,"starsCount":14,"licenseSpdxId":15,"licenseFileUrl":6,"sourceHtmlUrl":16,"categories":17,"keywords":28,"publishedAt":50,"linkOnly":51,"markdownContent":52,"markdownBody":53,"frontMatter":54,"refName":55,"commitSha":56,"skillDirectory":57,"forksCount":58,"repositoryHtmlUrl":59,"repositoryHomepageUrl":6,"ownerHtmlUrl":60,"ownerBlogUrl":61,"ownerDescription":62,"updatedAt":63,"install":64,"resources":77},"01M6KR9ND6GCDPFSXV4TR2BY9X","godot-code-review",null,"Use when reviewing GDScript or C# Godot code — checklist of best practices, common anti-patterns, and Godot-specific pitfalls. Triggers on \"review this script\", \"check my code\", \"any issues with this\", \"what's wrong with this code\", including a short pasted snippet.","jame581\u002FGodotPrompter","jame581","https:\u002F\u002Favatars.githubusercontent.com\u002Fu\u002F21112138?v=4","01M6KR3KEQ9Z30WVJRR2E2ZVXE","Jan Mesarč","01M6KR3KJVRMPDSMASQPBCBVK3",964,"MIT","https:\u002F\u002Fgithub.com\u002Fjame581\u002FGodotPrompter\u002Fblob\u002Fmaster\u002Fskills\u002Fgodot-code-review\u002FSKILL.md",[18,23],{"categoryNo":19,"categoryName":20,"taxonomyType":21,"taxonomyTypeDesc":22},"01JBSEEDCAT000000000000007","代码审查","SCENARIO","使用场景",{"categoryNo":24,"categoryName":25,"taxonomyType":26,"taxonomyTypeDesc":27},"01JBSEEDCAT000000000000030","开发工程师","PROFESSION","适用职业",[29,30,31,32,33,34,35,36,37,38,39,40,41,42,43,44,45,46,47,48,49],"review","code","code review","godot code review","godot","when","gdscript","my","pitfalls","C#","script","with","triggers","patterns","anti-patterns","use","short","check","common","issues","best practices","2026-11-10 10:12:30",false,"---\nname: godot-code-review\ndescription: Use when reviewing GDScript or C# Godot code — checklist of best practices, common anti-patterns, and Godot-specific pitfalls. Triggers on \"review this script\", \"check my code\", \"any issues with this\", \"what's wrong with this code\", including a short pasted snippet.\n---\n\n# Godot Code Review\n\nA structured review guide for Godot 4.3+ projects covering GDScript and C#. Work through each checklist section, then produce a review summary using the output template at the end.\n\n> **Related skills:** **godot-testing** for TDD and test coverage, **scene-organization** for scene tree best practices, **godot-optimization** for performance review.\n\n---\n\n## 1. Node & Scene Architecture\n\n- [ ] Each scene has a single, clear responsibility (player, enemy, UI widget, etc.)\n- [ ] Inheritance chains are shallow — prefer composition via child nodes over deep `extends` hierarchies\n- [ ] Autoloads (singletons) are used sparingly; only truly global state belongs there\n- [ ] Node references traverse only to direct children — no `get_parent()` chains\n- [ ] `@onready` (GDScript) or `GetNode\u003CT>()` (C#) targets direct children or named paths within the same scene\n\n### Anti-pattern — `get_parent()` chain\n\n```gdscript\n# BAD: tight coupling, breaks if the tree changes\nfunc take_damage(amount: int) -> void:\n    get_parent().get_parent().get_node(\"HUD\").update_health(health)\n```\n\n```csharp\n\u002F\u002F BAD: tight coupling, breaks if the tree changes\npublic void TakeDamage(int amount)\n{\n    GetParent().GetParent().GetNode(\"HUD\").Call(\"UpdateHealth\", _health);\n}\n```\n\n### Fix — emit a signal instead\n\n```gdscript\n# GOOD: parent\u002Fancestor listens; child stays decoupled\nsignal health_changed(new_health: int)\n\nfunc take_damage(amount: int) -> void:\n    health -= amount\n    health_changed.emit(health)\n```\n\n```csharp\n\u002F\u002F GOOD: parent\u002Fancestor listens; child stays decoupled\n[Signal]\npublic delegate void HealthChangedEventHandler(int newHealth);\n\npublic void TakeDamage(int amount)\n{\n    _health -= amount;\n    EmitSignal(SignalName.HealthChanged, _health);\n}\n```\n\n---\n\n## 2. GDScript Style\n\n- [ ] Variables and functions use `snake_case`\n- [ ] Class names declared with `class_name` use `PascalCase`\n- [ ] Constants use `SCREAMING_SNAKE_CASE`\n- [ ] All function parameters and return types carry type hints\n- [ ] `@export` variables include an explicit type\n- [ ] Signal declarations appear at the top of the file, before variables\n\n### Bad — untyped\n\n```gdscript\nvar speed = 200\nvar health = 100\n\nfunc move(direction):\n    position += direction * speed\n\nfunc heal(amount):\n    health += amount\n    return health\n```\n\n```csharp\n\u002F\u002F BAD: no explicit types, weak contracts\nfloat speed = 200;\nint health = 100;\n\npublic void Move(object direction)\n{\n    Position += (Vector2)direction * speed;\n}\n\npublic object Heal(object amount)\n{\n    health += (int)amount;\n    return health;\n}\n```\n\n### Good — typed\n\n```gdscript\nclass_name PlayerController\nextends CharacterBody2D\n\nsignal health_changed(new_health: int)\nsignal player_died()\n\nconst MAX_HEALTH: int = 100\nconst BASE_SPEED: float = 200.0\n\n@export var speed: float = BASE_SPEED\n@export var max_health: int = MAX_HEALTH\n\nvar health: int = max_health\n\nfunc move(direction: Vector2) -> void:\n    velocity = direction * speed\n    move_and_slide()\n\nfunc heal(amount: int) -> int:\n    health = mini(health + amount, max_health)\n    health_changed.emit(health)\n    return health\n```\n\n```csharp\n\u002F\u002F GOOD: strongly typed, proper C# conventions\npublic partial class PlayerController : CharacterBody2D\n{\n    [Signal]\n    public delegate void HealthChangedEventHandler(int newHealth);\n    [Signal]\n    public delegate void PlayerDiedEventHandler();\n\n    private const int MaxHealth = 100;\n    private const float BaseSpeed = 200f;\n\n    [Export] public float Speed { get; set; } = BaseSpeed;\n    [Export] public int MaxHp { get; set; } = MaxHealth;\n\n    private int _health;\n\n    public override void _Ready()\n    {\n        _health = MaxHp;\n    }\n\n    public void Move(Vector2 direction)\n    {\n        Velocity = direction * Speed;\n        MoveAndSlide();\n    }\n\n    public int Heal(int amount)\n    {\n        _health = Mathf.Min(_health + amount, MaxHp);\n        EmitSignal(SignalName.HealthChanged, _health);\n        return _health;\n    }\n}\n```\n\n---\n\n## 3. C# Style\n\n- [ ] Node scripts use `partial class` to allow Godot source generators to work\n- [ ] Methods and properties use `PascalCase`; local variables use `camelCase`\n- [ ] `[Export]` properties use `PascalCase`\n- [ ] `[Signal]` delegates follow the `\u003CEventName>EventHandler` naming pattern\n- [ ] `GetNode\u003CT>()` results are null-checked or cached in `_Ready()` and validated\n\n```csharp\n\u002F\u002F GOOD\npublic partial class PlayerController : CharacterBody2D\n{\n    [Signal]\n    public delegate void HealthChangedEventHandler(int newHealth);\n\n    [Export] public float Speed { get; set; } = 200f;\n    [Export] public int MaxHealth { get; set; } = 100;\n\n    private int _health;\n    private AnimationPlayer _animationPlayer = null!;\n\n    public override void _Ready()\n    {\n        _animationPlayer = GetNode\u003CAnimationPlayer>(\"AnimationPlayer\");\n        \u002F\u002F Validate at startup rather than silently failing later\n        if (_animationPlayer is null)\n            GD.PushError(\"AnimationPlayer node not found on PlayerController\");\n\n        _health = MaxHealth;\n    }\n\n    public void TakeDamage(int amount)\n    {\n        _health = Mathf.Max(_health - amount, 0);\n        EmitSignal(SignalName.HealthChanged, _health);\n    }\n}\n```\n\n---\n\n## 4. Performance\n\n- [ ] `get_node()` \u002F `$NodePath` is never called inside `_process()` or `_physics_process()` — always cache with `@onready`\n- [ ] `load()` is not called in hot paths — use `preload()` for compile-time loading or cache the result\n- [ ] `_process()` is disabled (`set_process(false)`) when the node does not need per-frame updates\n- [ ] `StringName` (or `&\"string\"` literal) is used for comparisons inside `_process()` or tight loops\n\n### Anti-pattern — uncached node lookup in `_process()`\n\n```gdscript\n# BAD: get_node() traverses the tree every frame\nfunc _process(delta: float) -> void:\n    get_node(\"HUD\u002FHealthBar\").value = health\n    get_node(\"HUD\u002FLabel\").text = str(health)\n```\n\n```csharp\n\u002F\u002F BAD: GetNode() traverses the tree every frame\npublic override void _Process(double delta)\n{\n    GetNode\u003CProgressBar>(\"HUD\u002FHealthBar\").Value = _health;\n    GetNode\u003CLabel>(\"HUD\u002FLabel\").Text = _health.ToString();\n}\n```\n\n### Fix — cache with `@onready`\n\n```gdscript\n# GOOD: resolved once at scene load\n@onready var _health_bar: ProgressBar = $HUD\u002FHealthBar\n@onready var _health_label: Label = $HUD\u002FLabel\n\nfunc _process(delta: float) -> void:\n    _health_bar.value = health\n    _health_label.text = str(health)\n```\n\n```csharp\n\u002F\u002F GOOD: resolved once in _Ready()\nprivate ProgressBar _healthBar = null!;\nprivate Label _healthLabel = null!;\n\npublic override void _Ready()\n{\n    _healthBar = GetNode\u003CProgressBar>(\"HUD\u002FHealthBar\");\n    _healthLabel = GetNode\u003CLabel>(\"HUD\u002FLabel\");\n}\n\npublic override void _Process(double delta)\n{\n    _healthBar.Value = _health;\n    _healthLabel.Text = _health.ToString();\n}\n```\n\n### StringName in hot paths\n\n```gdscript\n# BAD: a String compared to a StringName is compared character by character\nif animation_name == \"run\":\n    pass\n\n# GOOD: StringName literal — a pointer comparison\nif animation_name == &\"run\":\n    pass\n```\n\n```csharp\n\u002F\u002F BAD: allocates a new StringName each frame\nif (animationName == \"run\") { }\n\n\u002F\u002F GOOD: cache StringName as a static field\nprivate static readonly StringName RunAnim = new(\"run\");\n\npublic override void _Process(double delta)\n{\n    if (animationName == RunAnim) { }\n}\n```\n\n---\n\n## 5. Input Handling\n\n- [ ] All actions use Input Map names (Project > Project Settings > Input Map), not hardcoded key constants\n- [ ] `_unhandled_input()` is preferred over `_input()` to allow UI controls to consume events first\n- [ ] Continuous movement is driven by `Input.get_vector()` \u002F `Input.is_action_pressed()` inside `_physics_process()`\n- [ ] Discrete one-shot actions (jump, shoot) are handled in `_unhandled_input()`\n\n```gdscript\n# Continuous movement — physics process\nfunc _physics_process(delta: float) -> void:\n    var direction: Vector2 = Input.get_vector(\n        &\"ui_left\", &\"ui_right\", &\"ui_up\", &\"ui_down\"\n    )\n    velocity = direction * speed\n    move_and_slide()\n\n# Discrete action — unhandled input\nfunc _unhandled_input(event: InputEvent) -> void:\n    if event.is_action_pressed(&\"jump\"):\n        _jump()\n```\n\n```csharp\n\u002F\u002F Continuous movement — physics process\npublic override void _PhysicsProcess(double delta)\n{\n    Vector2 direction = Input.GetVector(\n        \"ui_left\", \"ui_right\", \"ui_up\", \"ui_down\"\n    );\n    Velocity = direction * Speed;\n    MoveAndSlide();\n}\n\n\u002F\u002F Discrete action — unhandled input\npublic override void _UnhandledInput(InputEvent @event)\n{\n    if (@event.IsActionPressed(\"jump\"))\n    {\n        Jump();\n    }\n}\n```\n\n---\n\n## 6. Signals & Communication\n\n- [ ] Signals travel **up** the tree (child emits, parent\u002Fancestor connects); method calls go **down** (parent calls child method)\n- [ ] Connections are established in `_ready()` or wired in the editor — not in `_process()` or one-off callbacks\n- [ ] There are no circular signal dependencies between nodes\n- [ ] Signal names use **past tense** to describe what happened\n\n```gdscript\n# Good signal names\nsignal health_changed(new_health: int)   # past tense\nsignal enemy_died()                       # past tense\nsignal item_collected(item: ItemData)     # past tense\n\n# Bad signal names (present\u002Fimperative tense)\n# signal update_health(value: int)\n# signal die()\n# signal collect_item(item: ItemData)\n```\n\n```csharp\n\u002F\u002F Good signal names — past tense, EventHandler suffix\n[Signal]\npublic delegate void HealthChangedEventHandler(int newHealth);\n[Signal]\npublic delegate void EnemyDiedEventHandler();\n[Signal]\npublic delegate void ItemCollectedEventHandler(ItemData item);\n\n\u002F\u002F Bad signal names (present\u002Fimperative tense)\n\u002F\u002F public delegate void UpdateHealthEventHandler(int value);\n\u002F\u002F public delegate void DieEventHandler();\n\u002F\u002F public delegate void CollectItemEventHandler(ItemData item);\n```\n\n```gdscript\n# Parent connects to child signal in _ready()\nfunc _ready() -> void:\n    $Enemy.enemy_died.connect(_on_enemy_died)\n    $Player.health_changed.connect(_on_player_health_changed)\n```\n\n```csharp\n\u002F\u002F Parent connects to child signal in _Ready()\npublic override void _Ready()\n{\n    GetNode\u003CEnemy>(\"Enemy\").EnemyDied += OnEnemyDied;\n    GetNode\u003CPlayer>(\"Player\").HealthChanged += OnPlayerHealthChanged;\n}\n```\n\n---\n\n## 7. Resource Management\n\n- [ ] `preload()` is used for resources known at edit time (scenes, textures, audio); `load()` is used for paths resolved at runtime\n- [ ] Large or level-specific resources loaded at runtime use `ResourceLoader.load_threaded_request()` to avoid frame stalls\n- [ ] Dynamically instantiated nodes are freed with `queue_free()`, not `free()`, to avoid use-after-free crashes\n\n```gdscript\n# Compile-time — path is validated by the editor\nconst BULLET_SCENE: PackedScene = preload(\"res:\u002F\u002Fscenes\u002Fbullet.tscn\")\n\n# Runtime — path comes from data\nfunc _load_level(path: String) -> void:\n    ResourceLoader.load_threaded_request(path)\n\nfunc _check_load(path: String) -> void:\n    if ResourceLoader.load_threaded_get_status(path) == ResourceLoader.THREAD_LOAD_LOADED:\n        var scene: PackedScene = ResourceLoader.load_threaded_get(path)\n        get_tree().change_scene_to_packed(scene)\n\n# Cleanup\nfunc _on_enemy_died() -> void:\n    queue_free()   # safe — deferred until end of frame\n```\n\n```csharp\n\u002F\u002F Compile-time equivalent — load once in a static field or _Ready()\nprivate static readonly PackedScene BulletScene =\n    GD.Load\u003CPackedScene>(\"res:\u002F\u002Fscenes\u002Fbullet.tscn\");\n\n\u002F\u002F Runtime — path comes from data\nprivate void LoadLevel(string path)\n{\n    ResourceLoader.LoadThreadedRequest(path);\n}\n\nprivate void CheckLoad(string path)\n{\n    if (ResourceLoader.LoadThreadedGetStatus(path) == ResourceLoader.ThreadLoadStatus.Loaded)\n    {\n        var scene = ResourceLoader.LoadThreadedGet(path) as PackedScene;\n        GetTree().ChangeSceneToPacked(scene);\n    }\n}\n\n\u002F\u002F Cleanup\nprivate void OnEnemyDied()\n{\n    QueueFree(); \u002F\u002F safe — deferred until end of frame\n}\n```\n\n---\n\n## 8. Error-Prone Patterns\n\n| Pattern | Problem | Fix |\n|---|---|---|\n| `await get_tree().create_timer(t).timeout` after `queue_free()` (GDScript) | The freed node's coroutine is dropped silently: no error, and nothing after the `await` runs, so `is_instance_valid(self)` there never fires | Do must-run work before `queue_free()`; re-check *other* nodes with `is_instance_valid()` after `await`; use `create_tween()` for effects that should die with the node |\n| Fragile node paths like `$A\u002FB\u002FC\u002FD\u002FE` | Fails at runtime (`Node not found`) when the scene tree is reorganized | Refactor to direct children + signals, or export a `NodePath` |\n| `call_deferred()` used everywhere | Defers are appropriate for cross-frame safety, not a general solution; overuse hides real design issues | Only defer when crossing physics\u002Fmain thread boundaries or breaking a call cycle |\n| `set_physics_process(true)` called inside `_physics_process()` | Redundant call every frame; wastes CPU | Call once at the point you actually want to enable\u002Fdisable processing |\n| Directly setting `position` on a `CharacterBody2D` | Bypasses collision; teleports the body and can cause tunnelling | Use `move_and_slide()` with `velocity`; only set `position`\u002F`global_position` for intentional teleports |\n\n---\n\n## 9. Review Output Format\n\nUse this template when delivering a review:\n\n```\n## Code Review — \u003CFileName or Feature>\n\n### Critical\nIssues that will cause bugs, crashes, or significant performance problems.\n\n- [ ] \u003Cnode\u002Fline> — \u003Cissue> — **Suggested fix:** \u003Cfix>\n\n### Improvements\nCode quality, style, or maintainability concerns that should be addressed.\n\n- [ ] \u003Cnode\u002Fline> — \u003Cissue> — **Suggested fix:** \u003Cfix>\n\n### Positive\nWhat the code does well — reinforce good patterns.\n\n- \u003Cobservation>\n\n---\nReviewed against: Godot 4.3+ best practices\n```\n\n### Example\n\n```\n## Code Review — PlayerController.gd\n\n### Critical\n- [ ] _process() line 42 — `get_node(\"HUD\u002FHealthBar\")` called every frame — **Suggested fix:** Cache with `@onready var _health_bar: ProgressBar = $HUD\u002FHealthBar`\n- [ ] take_damage() line 67 — no type hints on parameter or return — **Suggested fix:** `func take_damage(amount: int) -> void:`\n\n### Improvements\n- [ ] Line 12 — signal `updateHealth` should be past tense — **Suggested fix:** Rename to `health_changed`\n- [ ] Line 8 — `var speed = 200` missing type hint — **Suggested fix:** `var speed: float = 200.0`\n\n### Positive\n- Signals are declared at the top of the file\n- Constants correctly use SCREAMING_SNAKE_CASE\n- `queue_free()` used correctly for cleanup\n\n---\nReviewed against: Godot 4.3+ best practices\n```\n","# Godot Code Review\n\nA structured review guide for Godot 4.3+ projects covering GDScript and C#. Work through each checklist section, then produce a review summary using the output template at the end.\n\n> **Related skills:** **godot-testing** for TDD and test coverage, **scene-organization** for scene tree best practices, **godot-optimization** for performance review.\n\n---\n\n## 1. Node & Scene Architecture\n\n- [ ] Each scene has a single, clear responsibility (player, enemy, UI widget, etc.)\n- [ ] Inheritance chains are shallow — prefer composition via child nodes over deep `extends` hierarchies\n- [ ] Autoloads (singletons) are used sparingly; only truly global state belongs there\n- [ ] Node references traverse only to direct children — no `get_parent()` chains\n- [ ] `@onready` (GDScript) or `GetNode\u003CT>()` (C#) targets direct children or named paths within the same scene\n\n### Anti-pattern — `get_parent()` chain\n\n```gdscript\n# BAD: tight coupling, breaks if the tree changes\nfunc take_damage(amount: int) -> void:\n    get_parent().get_parent().get_node(\"HUD\").update_health(health)\n```\n\n```csharp\n\u002F\u002F BAD: tight coupling, breaks if the tree changes\npublic void TakeDamage(int amount)\n{\n    GetParent().GetParent().GetNode(\"HUD\").Call(\"UpdateHealth\", _health);\n}\n```\n\n### Fix — emit a signal instead\n\n```gdscript\n# GOOD: parent\u002Fancestor listens; child stays decoupled\nsignal health_changed(new_health: int)\n\nfunc take_damage(amount: int) -> void:\n    health -= amount\n    health_changed.emit(health)\n```\n\n```csharp\n\u002F\u002F GOOD: parent\u002Fancestor listens; child stays decoupled\n[Signal]\npublic delegate void HealthChangedEventHandler(int newHealth);\n\npublic void TakeDamage(int amount)\n{\n    _health -= amount;\n    EmitSignal(SignalName.HealthChanged, _health);\n}\n```\n\n---\n\n## 2. GDScript Style\n\n- [ ] Variables and functions use `snake_case`\n- [ ] Class names declared with `class_name` use `PascalCase`\n- [ ] Constants use `SCREAMING_SNAKE_CASE`\n- [ ] All function parameters and return types carry type hints\n- [ ] `@export` variables include an explicit type\n- [ ] Signal declarations appear at the top of the file, before variables\n\n### Bad — untyped\n\n```gdscript\nvar speed = 200\nvar health = 100\n\nfunc move(direction):\n    position += direction * speed\n\nfunc heal(amount):\n    health += amount\n    return health\n```\n\n```csharp\n\u002F\u002F BAD: no explicit types, weak contracts\nfloat speed = 200;\nint health = 100;\n\npublic void Move(object direction)\n{\n    Position += (Vector2)direction * speed;\n}\n\npublic object Heal(object amount)\n{\n    health += (int)amount;\n    return health;\n}\n```\n\n### Good — typed\n\n```gdscript\nclass_name PlayerController\nextends CharacterBody2D\n\nsignal health_changed(new_health: int)\nsignal player_died()\n\nconst MAX_HEALTH: int = 100\nconst BASE_SPEED: float = 200.0\n\n@export var speed: float = BASE_SPEED\n@export var max_health: int = MAX_HEALTH\n\nvar health: int = max_health\n\nfunc move(direction: Vector2) -> void:\n    velocity = direction * speed\n    move_and_slide()\n\nfunc heal(amount: int) -> int:\n    health = mini(health + amount, max_health)\n    health_changed.emit(health)\n    return health\n```\n\n```csharp\n\u002F\u002F GOOD: strongly typed, proper C# conventions\npublic partial class PlayerController : CharacterBody2D\n{\n    [Signal]\n    public delegate void HealthChangedEventHandler(int newHealth);\n    [Signal]\n    public delegate void PlayerDiedEventHandler();\n\n    private const int MaxHealth = 100;\n    private const float BaseSpeed = 200f;\n\n    [Export] public float Speed { get; set; } = BaseSpeed;\n    [Export] public int MaxHp { get; set; } = MaxHealth;\n\n    private int _health;\n\n    public override void _Ready()\n    {\n        _health = MaxHp;\n    }\n\n    public void Move(Vector2 direction)\n    {\n        Velocity = direction * Speed;\n        MoveAndSlide();\n    }\n\n    public int Heal(int amount)\n    {\n        _health = Mathf.Min(_health + amount, MaxHp);\n        EmitSignal(SignalName.HealthChanged, _health);\n        return _health;\n    }\n}\n```\n\n---\n\n## 3. C# Style\n\n- [ ] Node scripts use `partial class` to allow Godot source generators to work\n- [ ] Methods and properties use `PascalCase`; local variables use `camelCase`\n- [ ] `[Export]` properties use `PascalCase`\n- [ ] `[Signal]` delegates follow the `\u003CEventName>EventHandler` naming pattern\n- [ ] `GetNode\u003CT>()` results are null-checked or cached in `_Ready()` and validated\n\n```csharp\n\u002F\u002F GOOD\npublic partial class PlayerController : CharacterBody2D\n{\n    [Signal]\n    public delegate void HealthChangedEventHandler(int newHealth);\n\n    [Export] public float Speed { get; set; } = 200f;\n    [Export] public int MaxHealth { get; set; } = 100;\n\n    private int _health;\n    private AnimationPlayer _animationPlayer = null!;\n\n    public override void _Ready()\n    {\n        _animationPlayer = GetNode\u003CAnimationPlayer>(\"AnimationPlayer\");\n        \u002F\u002F Validate at startup rather than silently failing later\n        if (_animationPlayer is null)\n            GD.PushError(\"AnimationPlayer node not found on PlayerController\");\n\n        _health = MaxHealth;\n    }\n\n    public void TakeDamage(int amount)\n    {\n        _health = Mathf.Max(_health - amount, 0);\n        EmitSignal(SignalName.HealthChanged, _health);\n    }\n}\n```\n\n---\n\n## 4. Performance\n\n- [ ] `get_node()` \u002F `$NodePath` is never called inside `_process()` or `_physics_process()` — always cache with `@onready`\n- [ ] `load()` is not called in hot paths — use `preload()` for compile-time loading or cache the result\n- [ ] `_process()` is disabled (`set_process(false)`) when the node does not need per-frame updates\n- [ ] `StringName` (or `&\"string\"` literal) is used for comparisons inside `_process()` or tight loops\n\n### Anti-pattern — uncached node lookup in `_process()`\n\n```gdscript\n# BAD: get_node() traverses the tree every frame\nfunc _process(delta: float) -> void:\n    get_node(\"HUD\u002FHealthBar\").value = health\n    get_node(\"HUD\u002FLabel\").text = str(health)\n```\n\n```csharp\n\u002F\u002F BAD: GetNode() traverses the tree every frame\npublic override void _Process(double delta)\n{\n    GetNode\u003CProgressBar>(\"HUD\u002FHealthBar\").Value = _health;\n    GetNode\u003CLabel>(\"HUD\u002FLabel\").Text = _health.ToString();\n}\n```\n\n### Fix — cache with `@onready`\n\n```gdscript\n# GOOD: resolved once at scene load\n@onready var _health_bar: ProgressBar = $HUD\u002FHealthBar\n@onready var _health_label: Label = $HUD\u002FLabel\n\nfunc _process(delta: float) -> void:\n    _health_bar.value = health\n    _health_label.text = str(health)\n```\n\n```csharp\n\u002F\u002F GOOD: resolved once in _Ready()\nprivate ProgressBar _healthBar = null!;\nprivate Label _healthLabel = null!;\n\npublic override void _Ready()\n{\n    _healthBar = GetNode\u003CProgressBar>(\"HUD\u002FHealthBar\");\n    _healthLabel = GetNode\u003CLabel>(\"HUD\u002FLabel\");\n}\n\npublic override void _Process(double delta)\n{\n    _healthBar.Value = _health;\n    _healthLabel.Text = _health.ToString();\n}\n```\n\n### StringName in hot paths\n\n```gdscript\n# BAD: a String compared to a StringName is compared character by character\nif animation_name == \"run\":\n    pass\n\n# GOOD: StringName literal — a pointer comparison\nif animation_name == &\"run\":\n    pass\n```\n\n```csharp\n\u002F\u002F BAD: allocates a new StringName each frame\nif (animationName == \"run\") { }\n\n\u002F\u002F GOOD: cache StringName as a static field\nprivate static readonly StringName RunAnim = new(\"run\");\n\npublic override void _Process(double delta)\n{\n    if (animationName == RunAnim) { }\n}\n```\n\n---\n\n## 5. Input Handling\n\n- [ ] All actions use Input Map names (Project > Project Settings > Input Map), not hardcoded key constants\n- [ ] `_unhandled_input()` is preferred over `_input()` to allow UI controls to consume events first\n- [ ] Continuous movement is driven by `Input.get_vector()` \u002F `Input.is_action_pressed()` inside `_physics_process()`\n- [ ] Discrete one-shot actions (jump, shoot) are handled in `_unhandled_input()`\n\n```gdscript\n# Continuous movement — physics process\nfunc _physics_process(delta: float) -> void:\n    var direction: Vector2 = Input.get_vector(\n        &\"ui_left\", &\"ui_right\", &\"ui_up\", &\"ui_down\"\n    )\n    velocity = direction * speed\n    move_and_slide()\n\n# Discrete action — unhandled input\nfunc _unhandled_input(event: InputEvent) -> void:\n    if event.is_action_pressed(&\"jump\"):\n        _jump()\n```\n\n```csharp\n\u002F\u002F Continuous movement — physics process\npublic override void _PhysicsProcess(double delta)\n{\n    Vector2 direction = Input.GetVector(\n        \"ui_left\", \"ui_right\", \"ui_up\", \"ui_down\"\n    );\n    Velocity = direction * Speed;\n    MoveAndSlide();\n}\n\n\u002F\u002F Discrete action — unhandled input\npublic override void _UnhandledInput(InputEvent @event)\n{\n    if (@event.IsActionPressed(\"jump\"))\n    {\n        Jump();\n    }\n}\n```\n\n---\n\n## 6. Signals & Communication\n\n- [ ] Signals travel **up** the tree (child emits, parent\u002Fancestor connects); method calls go **down** (parent calls child method)\n- [ ] Connections are established in `_ready()` or wired in the editor — not in `_process()` or one-off callbacks\n- [ ] There are no circular signal dependencies between nodes\n- [ ] Signal names use **past tense** to describe what happened\n\n```gdscript\n# Good signal names\nsignal health_changed(new_health: int)   # past tense\nsignal enemy_died()                       # past tense\nsignal item_collected(item: ItemData)     # past tense\n\n# Bad signal names (present\u002Fimperative tense)\n# signal update_health(value: int)\n# signal die()\n# signal collect_item(item: ItemData)\n```\n\n```csharp\n\u002F\u002F Good signal names — past tense, EventHandler suffix\n[Signal]\npublic delegate void HealthChangedEventHandler(int newHealth);\n[Signal]\npublic delegate void EnemyDiedEventHandler();\n[Signal]\npublic delegate void ItemCollectedEventHandler(ItemData item);\n\n\u002F\u002F Bad signal names (present\u002Fimperative tense)\n\u002F\u002F public delegate void UpdateHealthEventHandler(int value);\n\u002F\u002F public delegate void DieEventHandler();\n\u002F\u002F public delegate void CollectItemEventHandler(ItemData item);\n```\n\n```gdscript\n# Parent connects to child signal in _ready()\nfunc _ready() -> void:\n    $Enemy.enemy_died.connect(_on_enemy_died)\n    $Player.health_changed.connect(_on_player_health_changed)\n```\n\n```csharp\n\u002F\u002F Parent connects to child signal in _Ready()\npublic override void _Ready()\n{\n    GetNode\u003CEnemy>(\"Enemy\").EnemyDied += OnEnemyDied;\n    GetNode\u003CPlayer>(\"Player\").HealthChanged += OnPlayerHealthChanged;\n}\n```\n\n---\n\n## 7. Resource Management\n\n- [ ] `preload()` is used for resources known at edit time (scenes, textures, audio); `load()` is used for paths resolved at runtime\n- [ ] Large or level-specific resources loaded at runtime use `ResourceLoader.load_threaded_request()` to avoid frame stalls\n- [ ] Dynamically instantiated nodes are freed with `queue_free()`, not `free()`, to avoid use-after-free crashes\n\n```gdscript\n# Compile-time — path is validated by the editor\nconst BULLET_SCENE: PackedScene = preload(\"res:\u002F\u002Fscenes\u002Fbullet.tscn\")\n\n# Runtime — path comes from data\nfunc _load_level(path: String) -> void:\n    ResourceLoader.load_threaded_request(path)\n\nfunc _check_load(path: String) -> void:\n    if ResourceLoader.load_threaded_get_status(path) == ResourceLoader.THREAD_LOAD_LOADED:\n        var scene: PackedScene = ResourceLoader.load_threaded_get(path)\n        get_tree().change_scene_to_packed(scene)\n\n# Cleanup\nfunc _on_enemy_died() -> void:\n    queue_free()   # safe — deferred until end of frame\n```\n\n```csharp\n\u002F\u002F Compile-time equivalent — load once in a static field or _Ready()\nprivate static readonly PackedScene BulletScene =\n    GD.Load\u003CPackedScene>(\"res:\u002F\u002Fscenes\u002Fbullet.tscn\");\n\n\u002F\u002F Runtime — path comes from data\nprivate void LoadLevel(string path)\n{\n    ResourceLoader.LoadThreadedRequest(path);\n}\n\nprivate void CheckLoad(string path)\n{\n    if (ResourceLoader.LoadThreadedGetStatus(path) == ResourceLoader.ThreadLoadStatus.Loaded)\n    {\n        var scene = ResourceLoader.LoadThreadedGet(path) as PackedScene;\n        GetTree().ChangeSceneToPacked(scene);\n    }\n}\n\n\u002F\u002F Cleanup\nprivate void OnEnemyDied()\n{\n    QueueFree(); \u002F\u002F safe — deferred until end of frame\n}\n```\n\n---\n\n## 8. Error-Prone Patterns\n\n| Pattern | Problem | Fix |\n|---|---|---|\n| `await get_tree().create_timer(t).timeout` after `queue_free()` (GDScript) | The freed node's coroutine is dropped silently: no error, and nothing after the `await` runs, so `is_instance_valid(self)` there never fires | Do must-run work before `queue_free()`; re-check *other* nodes with `is_instance_valid()` after `await`; use `create_tween()` for effects that should die with the node |\n| Fragile node paths like `$A\u002FB\u002FC\u002FD\u002FE` | Fails at runtime (`Node not found`) when the scene tree is reorganized | Refactor to direct children + signals, or export a `NodePath` |\n| `call_deferred()` used everywhere | Defers are appropriate for cross-frame safety, not a general solution; overuse hides real design issues | Only defer when crossing physics\u002Fmain thread boundaries or breaking a call cycle |\n| `set_physics_process(true)` called inside `_physics_process()` | Redundant call every frame; wastes CPU | Call once at the point you actually want to enable\u002Fdisable processing |\n| Directly setting `position` on a `CharacterBody2D` | Bypasses collision; teleports the body and can cause tunnelling | Use `move_and_slide()` with `velocity`; only set `position`\u002F`global_position` for intentional teleports |\n\n---\n\n## 9. Review Output Format\n\nUse this template when delivering a review:\n\n```\n## Code Review — \u003CFileName or Feature>\n\n### Critical\nIssues that will cause bugs, crashes, or significant performance problems.\n\n- [ ] \u003Cnode\u002Fline> — \u003Cissue> — **Suggested fix:** \u003Cfix>\n\n### Improvements\nCode quality, style, or maintainability concerns that should be addressed.\n\n- [ ] \u003Cnode\u002Fline> — \u003Cissue> — **Suggested fix:** \u003Cfix>\n\n### Positive\nWhat the code does well — reinforce good patterns.\n\n- \u003Cobservation>\n\n---\nReviewed against: Godot 4.3+ best practices\n```\n\n### Example\n\n```\n## Code Review — PlayerController.gd\n\n### Critical\n- [ ] _process() line 42 — `get_node(\"HUD\u002FHealthBar\")` called every frame — **Suggested fix:** Cache with `@onready var _health_bar: ProgressBar = $HUD\u002FHealthBar`\n- [ ] take_damage() line 67 — no type hints on parameter or return — **Suggested fix:** `func take_damage(amount: int) -> void:`\n\n### Improvements\n- [ ] Line 12 — signal `updateHealth` should be past tense — **Suggested fix:** Rename to `health_changed`\n- [ ] Line 8 — `var speed = 200` missing type hint — **Suggested fix:** `var speed: float = 200.0`\n\n### Positive\n- Signals are declared at the top of the file\n- Constants correctly use SCREAMING_SNAKE_CASE\n- `queue_free()` used correctly for cleanup\n\n---\nReviewed against: Godot 4.3+ best practices\n```\n",{"name":5,"description":7},"master","d7b26cdb5fae14d4ef7b713c5bf259395e75c3c6","skills\u002Fgodot-code-review",63,"https:\u002F\u002Fgithub.com\u002Fjame581\u002FGodotPrompter","https:\u002F\u002Fgithub.com\u002Fjame581","https:\u002F\u002Fjanmesarc.online\u002F","Software engineer. My biggest passion is game development.","2026-11-14 20:45:49",{"source":8,"skillName":5,"commands":65,"prompt":75,"zipAvailable":76},[66,69,72],{"tool":67,"command":68},"npx","npx skills add jame581\u002FGodotPrompter --skill godot-code-review",{"tool":70,"command":71},"bunx","bunx skills add jame581\u002FGodotPrompter --skill godot-code-review",{"tool":73,"command":74},"pnpm","pnpm dlx skills add jame581\u002FGodotPrompter --skill godot-code-review","安装技能，技能地址：https:\u002F\u002Fgithub.com\u002Fjame581\u002FGodotPrompter\u002Fblob\u002Fmaster\u002Fskills\u002Fgodot-code-review\u002FSKILL.md",true,[],[79,98,119,147,168,185],{"skillNo":80,"name":81,"nameZh":6,"description":82,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":12,"repositoryNo":13,"starsCount":14,"licenseSpdxId":15,"licenseFileUrl":6,"sourceHtmlUrl":83,"categories":84,"keywords":85,"publishedAt":50},"01M6KRFE5BR2PSD08ZKDAS66R7","xr-development","Use when building VR\u002FAR\u002FXR applications — OpenXR setup, XROrigin3D, hand tracking, controllers, passthrough, and Meta Quest deployment in Godot 4.3+","https:\u002F\u002Fgithub.com\u002Fjame581\u002FGodotPrompter\u002Fblob\u002Fmaster\u002Fskills\u002Fxr-development\u002FSKILL.md",[],[86,87,34,88,33,89,90,91,92,93,94,44,95,96,97],"xr development","development","deployment","vr","setup","tracking","godot 4","ar","hand","Meta","applications","quest",{"skillNo":99,"name":100,"nameZh":6,"description":101,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":12,"repositoryNo":13,"starsCount":14,"licenseSpdxId":15,"licenseFileUrl":6,"sourceHtmlUrl":102,"categories":103,"keywords":104,"publishedAt":50},"01M6KRF8GZTG1TAS506MFBSGFC","web-services","Use when a Godot game calls a web server — HTTPRequest, downloads, REST\u002FJSON APIs, auth headers, WebSocketPeer clients, TLS, retries, and keeping secrets out of the build. Not for game networking\u002FRPCs (multiplayer-basics) or browser export (web-export)","https:\u002F\u002Fgithub.com\u002Fjame581\u002FGodotPrompter\u002Fblob\u002Fmaster\u002Fskills\u002Fweb-services\u002FSKILL.md",[],[105,106,107,108,109,110,111,112,44,34,33,113,114,115,116,117,118],"web services","web","services","tls","retries","calling","auth","downloads","clients","headers","secrets","json","build","REST",{"skillNo":120,"name":121,"nameZh":6,"description":122,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":12,"repositoryNo":13,"starsCount":14,"licenseSpdxId":15,"licenseFileUrl":6,"sourceHtmlUrl":123,"categories":124,"keywords":128,"publishedAt":50},"01M6KRF38Q4WSKAYFS56PG87T0","web-export","Use when shipping a Godot game to the browser — Web export preset options, threads vs no-threads and COOP\u002FCOEP headers, hosting on itch.io or your own server, PWA, JavaScriptBridge, user:\u002F\u002F persistence, audio and input limits, and load size","https:\u002F\u002Fgithub.com\u002Fjame581\u002FGodotPrompter\u002Fblob\u002Fmaster\u002Fskills\u002Fweb-export\u002FSKILL.md",[125],{"categoryNo":126,"categoryName":127,"taxonomyType":21,"taxonomyTypeDesc":22},"01JBSEEDCAT000000000000016","图像与多媒体",[106,129,130,131,132,133,134,135,114,136,137,34,138,139,140,141,142,143,44,144,145,146],"export","web export","threads","limits","shipping","size","options","hosting","input","Coop","preset","browser","game","io","load","pwa","Audio","server",{"skillNo":148,"name":149,"nameZh":6,"description":150,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":12,"repositoryNo":13,"starsCount":14,"licenseSpdxId":15,"licenseFileUrl":6,"sourceHtmlUrl":151,"categories":152,"keywords":159,"publishedAt":50},"01M6KREYFETEBH62ZTN6EZH2X3","using-godot-prompter","Bootstrap skill — establishes how to find and use GodotPrompter skills, with platform-specific tool mapping","https:\u002F\u002Fgithub.com\u002Fjame581\u002FGodotPrompter\u002Fblob\u002Fmaster\u002Fskills\u002Fusing-godot-prompter\u002FSKILL.md",[153,156],{"categoryNo":154,"categoryName":155,"taxonomyType":21,"taxonomyTypeDesc":22},"01JBSEEDCAT000000000000023","Skill与智能体开发",{"categoryNo":157,"categoryName":158,"taxonomyType":26,"taxonomyTypeDesc":27},"01JBSEEDCAT000000000000032","设计师",[33,160,161,40,162,44,163,164,165,166,167],"using godot prompter","find","bootstrap","tool","platform","mapping","how","how to",{"skillNo":169,"name":170,"nameZh":6,"description":171,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":12,"repositoryNo":13,"starsCount":14,"licenseSpdxId":15,"licenseFileUrl":6,"sourceHtmlUrl":172,"categories":173,"keywords":174,"publishedAt":50},"01M6KRER5G7EQWKGAFN8QJKQ69","tween-animation","Use when implementing tweens — property animation, method tweening, chaining, parallel sequences, easing, and common UI\u002Fgameplay motion recipes","https:\u002F\u002Fgithub.com\u002Fjame581\u002FGodotPrompter\u002Fblob\u002Fmaster\u002Fskills\u002Ftween-animation\u002FSKILL.md",[],[175,176,44,177,178,179,180,181,182,47,183,34,184],"tween animation","Animation","motion","parallel","gameplay","chaining","ui","recipes","implementing","sequences",{"skillNo":186,"name":187,"nameZh":6,"description":188,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":12,"repositoryNo":13,"starsCount":14,"licenseSpdxId":15,"licenseFileUrl":6,"sourceHtmlUrl":189,"categories":190,"keywords":191,"publishedAt":50},"01M6KREKGCQMVDV8WX7HWX8BZG","state-machine","Use when building a state machine or refactoring logic into one — enum, node, and resource-based FSM patterns with trade-offs. Not for adding states to an existing one","https:\u002F\u002Fgithub.com\u002Fjame581\u002FGodotPrompter\u002Fblob\u002Fmaster\u002Fskills\u002Fstate-machine\u002FSKILL.md",[],[192,193,194,33,34,42,195,196,197,198,40,44,183,199],"state","state machine","machine","node","fsm","state machines","trade","trade-offs"]