godot-verify

Validate Godot GDScript files using gdlint, gdformat, gdradon, and LSP diagnostics. Use when users want to: (1) Check code quality after making changes, (2) Validate before committing, (3) Run code metrics analysis, (4) Run export validation, (5) Get real-time LSP diagnostics. Uses command-line tools directly and MCP tools for LSP integration.

Safety Notice

This listing is imported from skills.sh public index metadata. Review upstream SKILL.md and repository scripts before running.

Copy this and send it to your AI assistant to learn

Install skill "godot-verify" with this command: npx skills add chen19007/my_skills/chen19007-my-skills-godot-verify

Godot Verification Skill

Validate Godot project changes using gdlint, gdformat, gdradon, godot export commands, and LSP diagnostics.

排除规则

不要检查和处理 addons 目录下的任何文件。

addons 目录通常包含第三方插件或外部资源,这些代码不由项目维护,不应纳入项目代码质量检查范围。

检查项

检查命令/工具说明
LintgdlintLint GDScript 代码
Formatgdformat格式化/检查格式
Metricsgdradon cc代码指标分析
Exportgodot --export-pack导出验证
LSP Diagnosticsgodot-lsp__diagnostics实时语法检查(通过 MCP)

gdradon 输出

gdradon cc <path>

输出格式:

F <line>:<col> <function_name> - <grade> (<cc>)
字段说明
F函数 (Function)
<line>:<col>行号和列号
<function_name>函数名
<grade>复杂度等级: A(简单), B(中等), C(复杂), D(非常复杂), F(极复杂)
<cc>圈复杂度数值

示例:

.\character_body_2d.gd
    F 13:0 _physics_process - C (15)

使用示例

# Lint 检查
gdlint "D:/project/scripts/Player.gd"

# Format 检查
gdformat --check "D:/project/scripts/Player.gd"

# 代码指标
gdradon cc D:/project/scripts/

# LSP 诊断(DiagnosticsServer 为开机自启动服务)
# 调用 MCP 工具获取诊断(只需 uri 参数)
godot-lsp__diagnostics(uri="file:///D:/project/game/player.gd")

# LSP 诊断(修改代码后使用 refresh=true)
godot-lsp__diagnostics(uri="file:///D:/project/game/player.gd", refresh=true)

# 完整检查
gdlint D:/project/scripts/ && gdformat D:/project/scripts/ && gdradon cc D:/project/scripts/

# 导出验证
godot --headless --path "D:/project" --export-pack "Web" "D:/export.pck"

LSP Diagnostics

Godot LSP 诊断提供实时的语法检查和错误检测,与 Godot 编辑器显示的诊断一致。

前置条件

  1. Godot 编辑器运行(Godot LSP 服务器在编辑器启动时自动开启,默认端口 6005)
  2. DiagnosticsServer 运行(开机自启动服务,提供诊断缓存)

MCP 工具调用

工具名: godot-lsp__diagnostics

参数:

  • uri (必需): file:// URI,例如 file:///D:/project/game/player.gd
  • refresh (可选): 是否强制刷新诊断缓存,默认 false

返回:

{
  "uri": "file:///D:/project/game/player.gd",
  "diagnostics": [
    {
      "range": { "start": { "line": 4, "character": 0 }, "end": { "line": 4, "character": 56 } },
      "severity": 2,
      "code": 9,
      "source": "gdscript",
      "message": "(SHADOWED_GLOBAL_IDENTIFIER): The constant \"AttackType\" has the same name as a global class..."
    }
  ],
  "cached": false  // true 表示从缓存返回,false 表示新打开文件
}

说明:

  • DiagnosticsServer 会自动读取文件内容,无需传递 text 参数
  • 首次查询会打开文件并等待诊断(约 500ms)
  • 后续查询直接从缓存返回,速度更快
  • 修改代码后推荐使用 refresh=true 强制刷新缓存,确保获取最新诊断结果

诊断级别 (severity)

级别说明
Error1错误,必须修复
Warning2警告,建议修复
Information3信息
Hint4提示

常见诊断代码

代码消息说明
1PARSER_ERROR语法错误
9SHADOWED_GLOBAL_IDENTIFIER常量名与全局类冲突
12STATIC_VARIABLE_TYPE_MISMATCH静态变量类型不匹配
21RETURN_VALUE_DISCARDED返回值未使用
30UNSAFE_CALL不安全的函数调用
40UNASSIGNED_VARIABLE_ACCESS访问未赋值的变量

HTTP API(直接访问 DiagnosticsServer)

# 获取诊断
curl "http://127.0.0.1:3457/diagnostics?path=D:/project/game/player.gd"

# 刷新诊断
curl -X POST "http://127.0.0.1:3457/refresh" -d "{\"path\":\"D:/project/game/player.gd\"}"

# 查看状态
curl "http://127.0.0.1:3457/stats"

与 gdlint 对比

特性LSP Diagnosticsgdlint
实时性实时(缓存)需要运行
错误类型语法 + 语义Lint 规则
与编辑器一致完全一致可能不同
速度快(有缓存)慢(需解析)
需要 Godot

建议: 使用 LSP Diagnostics 作为快速检查,gdlint 作为补充 lint 规则检查。

Lint Rules (gdlint)

RuleSeverityDescription
unused-variableErrorVariable declared but never used
shadowed-variableErrorVariable shadows member variable
function-nameErrorFunction name violates naming convention
constant-nameErrorConstant name violates naming convention
trailing-whitespaceWarningLines have trailing whitespace
missing-docstringWarningFunction missing documentation
line-too-longWarningLine exceeds 120 characters

Error Handling

ErrorSolution
No project.godot foundNavigate to project root or provide absolute path
gdlint not foundInstall: pip install gdtoolkit
gdradon not foundInstall: pip install gdradon
godot not foundAdd godot to PATH
Path must be absoluteConvert relative to absolute paths

Common Workflows

After Code Changes

gdlint "D:/project/scripts/Player.gd"

Pre-commit Validation

gdlint D:/project/scripts/ && gdformat D:/project/scripts/

Code Metrics Analysis

gdradon cc D:/project/scripts/

输出示例:

.\character_body_2d.gd
    F 13:0 _physics_process - C (15)

Export Validation

godot --headless --path "D:/project" --export-pack "Web" "D:/export.pck"

安装要求

  • pip install gdtoolkit (gdlint, gdformat)
  • pip install gdradon (code metrics)
  • godot in PATH (export validation)

Tips

  • Use file param to check only changed files (faster)
  • gdformat --check shows what would change without modifying
  • gdradon cc shows complexity and maintainability metrics
  • Export validation catches dependency issues lint misses

Source Transparency

This detail page is rendered from real SKILL.md content. Trust labels are metadata-based hints, not a safety guarantee.

Related Skills

Related by shared tags or category signals.

General

bf-metrics

No summary provided by upstream source.

Repository SourceNeeds Review
General

bf-lead-implement

No summary provided by upstream source.

Repository SourceNeeds Review
General

bf-lead-plan

No summary provided by upstream source.

Repository SourceNeeds Review
General

bf-lead-review

No summary provided by upstream source.

Repository SourceNeeds Review