godot-gdscript

A set of coding rules for Godot, a game engine, including how scripts access game objects and how objects communicate.

In plain words
What is it for?
Use it when writing GDScript or C# components, connecting scenes, handling signals, loading resources, or investigating game performance and cleanup problems.
Why use it?
It helps avoid slow frame updates, tangled scene hierarchies, broken references, memory leaks, and signal errors.

Skill for Claude CodeCodex

Install

Getting it into your agent

One page per mod, every tool's command on it. A separate URL per tool would split the same page into five that compete with each other.

agentmods
npx agentmods add skills/wade-devcode/awesome-coding-skills-cn/godot-gdscript
Any agent
npx skills add Wade-DevCode/awesome-coding-skills-cn --skill godot-gdscript
Clone the repo
git clone --depth 1 https://github.com/Wade-DevCode/awesome-coding-skills-cn

Made for: Claude Code, Codex.

Per session 30 Skills are progressive disclosure: only the name and description are preloaded; the body loads when the skill is used.
When invoked 2,345 The whole file, excluding the scripts and references it only reads on demand.
Security scan A 0 findings. Scan, not verified.
Origin original No closer match found in the catalogue.
Token cost

What it costs to keep this loaded

Counted locally with the o200k_base tokenizer, which is exact for GPT models; Claude uses its own tokenizer and its counts differ. Treat this as one consistent yardstick across the catalogue rather than a bill. Prices are per million input tokens.

ModelPer sessionOnce invoked
Fable 5 $0.00030 $0.02345
Opus 5 $0.00015 $0.01172
Sonnet 5 $0.00006 $0.00469
Haiku 4.5 $0.00003 $0.00234

Measured 2d ago against content hash 05549632c99f, method: parsed. Prices are Anthropic first-party input rates as of 2026-08-30, from the pricing page.

Security

Grade A, and why

godot-gdscript scanned grade A with 0 findings against 26 rules in 11 categories — prompt injection, anti-refusal, data exfiltration, privilege escalation, supply chain, agent snooping, system-prompt leakage, SSRF and excessive agency — measured 2d ago.

A static scan of the body, not an audit. Every finding is printed with the line that produced it so you can judge whether it matters here. A mod is markdown that instructs an agent; that is exactly why what it instructs is worth reading.

Nothing flagged

None of the 26 patterns this scan looks for appear in this file: no shell pipes, no recursive deletes, no credential paths, no hidden text, no instruction-override or anti-refusal phrasing, no agent-config snooping. That is not a guarantee, it is the absence of the things that are checkable.

skills/godot-gdscript/SKILL.md · 146 lines

How it starts

The opening of the file, as written. The whole thing — 146 lines — stays where its author put it; the contents beside it link to each section on GitHub.

Godot

何时用

  • 新建或修改任何 GDScript 脚本或 C# 组件脚本时。
  • 节点间通信方式有疑问(是用 get_node、直接引用还是 signal)时。
  • _process_physics_process 里的逻辑越写越多、帧率下降时。
  • 场景实例化、资源加载/释放方式不确定时。
  • 遇到内存泄漏、孤立节点、信号未断开等问题时。

核心规则

1. 节点与场景:@onready 缓存,场景实例化代替继承

规则: 节点引用用 @onready_ready() 阶段一次性缓存;不在 _process 里反复 get_node();复用结构用场景实例化,而不是多层继承。

为什么——真实会犯的错:_process(delta) 里每帧写 $AnimationPlayer.play("run"),GDScript 每次都要解析节点路径字符串、在节点树里做查找,场景节点数量一多(几百个)帧率肉眼可见地跌。另一个常见错误:用继承堆叠 Enemy → FlyingEnemy → BossEnemy → FinalBoss,四层下来 _ready 调用顺序、信号连接变得极难追踪,改一层上面全乱。

怎么做:

  • 节点引用用 @onready var anim: AnimationPlayer = $AnimationPlayer,只在 _ready() 时解析一次路径,后续直接用变量。
  • 逻辑上独立、可复用的结构拆成独立场景(.tscn),用 instantiate() 生成,而不是靠继承叠加。
  • get_node() 只在 _ready()、事件回调里调用,不放进 _process_physics_process

2. signal 解耦:通信走信号,连接必须断开

规则: 节点间跨层通信用 signal;子节点不直接持有父节点引用;场景卸载或节点销毁前断开信号连接,防止内存泄漏和空引用回调。

为什么——真实会犯的错: Enemy 脚本里写了 get_parent().get_node("HUD").show_damage(damage),这条路径硬绑了节点树结构,一旦 HUD 改了层级或名称,运行时立刻报 null,且错误信息只提示"尝试调用 null 上的方法",找来找去才发现是节点路径变了。另一个事故:动态生成的子弹连接了 GameManager 的信号,子弹 queue_free() 后没有断开,GameManager 还保持对已销毁节点的引用,触发回调时崩溃或静默错误。

怎么做:

  • 子节点向上通信 → 发射 signal,父节点监听,子节点不引用父节点。
  • 跨系统通信 → 用 Autoload(单例)中转,或通过 signal bus。
  • 动态节点连接信号时,在 _exit_tree()queue_free() 前调用 signal.disconnect(callback) 断开。
  • connect(..., CONNECT_ONE_SHOT) 处理只触发一次的事件,自动断开更安全。

3. _process vs _physics_process:物理归物理,能事件驱动就不轮询

规则: 涉及物理体、碰撞、速度的逻辑一律放 _physics_process(delta);纯表现层更新可放 _process(delta);能用信号/事件触发的逻辑不轮询。

为什么——真实会犯的错:_process 里移动 CharacterBody2D,与物理引擎以不同频率运行,出现抖动和碰撞穿透,在低帧机器上更明显。另一个方向:把大量 UI 状态检测("玩家血量是否低于 20%")放在 _physics_process 里每帧判断,不必要地占用物理线程。还有把"按下攻击键"的检测放在 _process 里,输入延迟和物理帧不对齐,打击感差。

怎么做:

  • move_and_slide()、碰撞查询、刚体速度赋值 → 全进 _physics_process
  • 摄像机插值、粒子参数更新等纯视觉逻辑 → 可放 _process
  • 玩家输入 → _unhandled_input()_input() 回调,不在 _process 里 poll Input.is_action_pressed()(除非需要持续检测,如长按移动)。
  • 状态变化通知(血量减少 → 更新 UI)→ 发射 signal,不在 _process 里每帧比对旧值。

Read the full file on GitHub · 146 lines

Changes

What this file has done since we first saw it

Hashed on every crawl. A supply-chain change to an agent config is a question of when, not whether, so the history is kept rather than the latest state alone.

  1. 2d ago First seen · 146 lines · 30 tokens per session scan A 05549632c99f

Subscribe to this mod's changes

godot-gdscript is a skill published in the GitHub repository Wade-DevCode/awesome-coding-skills-cn (6 stars, last pushed 2mo ago), licensed MIT. It adds 30 tokens to every session and 2,345 once invoked, about $0.0002 per session on Opus 5. A static security scan graded it A with 0 findings. No closer match exists in the catalogue, so it is treated as the original; first seen 2026-08-31.

Related

Other skills, from other repositories

chinese-documentation

中文文档排版参考——中英文空格、全半角标点、术语保留、链接格式、中文文案排版指北约定。仅在用户显式 /chinese-documentation 时调用,不要根据上下文自动触发。.

jnMetaCode/superpowers-zh · 62 tokens

chinese-git-workflow

国内 Git 平台配置参考——Gitee、Coding.net、极狐 GitLab、CNB 的 SSH/HTTPS/凭据/CI 接入差异与镜像同步配置。仅在用户显式 /chinese-git-workflow 时调用,不要根据上下文自动触发。.

jnMetaCode/superpowers-zh · 69 tokens

brainstorming

在任何创造性工作之前必须使用此技能——创建功能、构建组件、添加功能或修改行为。在实现之前先探索用户意图、需求和设计。.

jnMetaCode/superpowers-zh · 40 tokens

chinese-code-review

中文 review 沟通参考——话术模板、分级标注(必须修复/建议修改/仅供参考)、国内团队常见反模式应对。仅在用户显式 /chinese-code-review 时调用,不要根据上下文自动触发。.

jnMetaCode/superpowers-zh · 62 tokens

chinese-commit-conventions

中文 commit 与 changelog 配置参考——Conventional Commits 中文适配、commitlint/husky/commitizen 中文模板、conventional-changelog 中文配置。仅在用户显式 /chinese-commit-conventions 时调用,不要根据上下文自动触发。.

jnMetaCode/superpowers-zh · 65 tokens

mcp-builder

MCP 服务器构建方法论 — 系统化构建生产级 MCP 工具,让 AI 助手连接外部能力.

jnMetaCode/superpowers-zh · 32 tokens