godot-csharp
Skill54 starsChanged 13 days agoMITView on GitHub
Godot 4.7 C#/.NET done right - csproj/SDK setup, partial classes and source generators, [Export]/[Signal]/[GlobalClass]/[Tool], C# signals and events that must be disconnected (ObjectDisposedException), StringName caching, Variant/collections marshaling, async ToSignal, GDScript interop, culture bugs, no web export, dotnet build errors as JSON. Use for any .cs file.
5 other projects use a version of this.
Adopted by
Most recently taken up by
- Supra-skills-mdd7/kit-game-devtheir own version, first seen Nov 29, 2026
- gamedev-skills/awesome-gamedev-agent-skillstheir own version, first seen Nov 11, 2026
- MindsMaster/godot-claude-code-skillstheir own version, first seen Oct 25, 2026
- gosomea/dsh-godot-aitheir own version, first seen Oct 8, 2026
- fetasty/godot-skillstheir own version, first seen May 16, 2026
Other versions5 projects use a version of this.
Word for word · 0
None found.
Edited · 0
None found.
Wrote their own version · 5
- gamedev-skills/awesome-gamedev-agent-skills★ 9ksame name
- fetasty/godot-skills★ 29same name
- gosomea/dsh-godot-ai★ 9same name
- MindsMaster/godot-claude-code-skills★ 3same name
- Supra-skills-mdd7/kit-game-dev★ 0same name
How matches are found. Word for word: the exact same text. Edited: shares passages with this file (“99% same” means 99% of its five-word phrases also appear here; 10% or more counts). Their own version: similar meaning, or, weakest, the same name. We can’t tell which project had it first. Projects are counted among the 200 most-starred candidates, and mentions are links to the repository we found, up to 50 per site, so both counts are a floor.
In this repository28 other files it gives its agents.
- AGENTS.mdAGENTS.md
- CLAUDE.mdCLAUDE.md
- godot-2dSkill
- godot-3d-gameplaySkill
- godot-3d-renderingSkill
- godot-addonsSkill
- godot-animationSkill
- godot-architectureSkill
- godot-audioSkill
- godot-coreSkill
- godot-editor-toolingSkill
- godot-export-ciSkill
- godot-game-feelSkill
- godot-gdscriptSkill
- godot-inputSkill
- godot-migrationSkill
- godot-mobile-webSkill
- godot-modding-dlcSkill
- godot-narrativeSkill
- godot-navigation-aiSkill
- godot-networkingSkill
- godot-performanceSkill
- godot-physicsSkill
- godot-proceduralSkill
- godot-shaders-vfxSkill
- godot-testing-debugSkill
- godot-uiSkill
- godot-xrSkill
The file
We split this skill into the rules it gives an agent
5 rules. 0 are common, 0 are distinctive, and 5 are very specific to this project.
0
Common
Most of the 3 edited versions we read keep these.
0
Distinctive
This author's own choices. Worth a look.
5
Very specific
Tied to their project's names, files or tools. Probably skip.
- Common
- Distinctive
- Very specific
- Very specific: line 38
Use SignalName.*, MethodName.* and PropertyName.* (generated StringNames) wherever the API wants a name, so you never allocate strings.
- Very specific: line 49
Use System.Collections.Generic for internal logic.
- Very specific: line 51
Avoid LINQ and closures in _Process/_PhysicsProcess hot loops.
- Very specific: line 58
Run CPU work on Task.Run/WorkerThreadPool, then get back to the main thread with CallDeferred or Callable.From(...).CallDeferred() before …
- Very specific: line 64
Create GDScript objects from C#: GD.Load<GDScript>("res://x.gd").New().AsGodotObject().
“Common” is measured: kept by at least 6 in 10 of the 3 edited versions of this file we could read. “Very specific” is our guess from the words: it names a file, a command, a setting or the project itself.
Files
C# / .NET in Godot 4.7
Build after every edit: python scripts/cs_build.py returns errors as {file, line, code, msg}. Use --doctor to check the setup and --init to create the csproj and sln exactly like the 4.7 editor does.
The engine runs the last built assembly in .godot/mono/temp/bin/, so build before any smoke run.
C# names: api_lookup.py Node3D.look_at prints Node3D.LookAt(Vector3, Vector3?, bool). C# names also work as queries.
Project setup (verified 4.7.2 template)
<Project Sdk="Godot.NET.Sdk/4.7.2">
<PropertyGroup>
<TargetFramework>net8.0</TargetFramework>
<TargetFramework Condition=" '$(GodotTargetPlatform)' == 'android' ">net9.0</TargetFramework>
<EnableDynamicLoading>true</EnableDynamicLoading>
</PropertyGroup>
</Project>- The
Godot.NET.Sdk/x.y.zversion must equal the engine version. Bump it when you upgrade Godot. net8.0 is the minimum; net9.0+ is allowed.<Nullable>enable</Nullable>is recommended. project.godotneeds"C#"inconfig/featuresand[dotnet] project/assembly_name. The assembly name must match the csproj name.- NuGet packages work normally (
dotnet add package). Assemblies must be pure managed code, or ship native libraries for every target platform. - Not supported: web export of C# projects (still true in 4.7; use GDScript for web builds). Android needs net9.0 (the template handles it). iOS works. Desktop works everywhere.
Script rules (the source generators depend on them)
public partial class Player : CharacterBody3D. The file name must equal the class name (Player.cs). Namespaces are fine. Godot-derived classes must bepartial.[GlobalClass]registers the class in the Create dialog and as an exportable Resource type, like GDScriptclass_name.[Tool]runs the class in the editor.- Exports:
[Export] public float Speed { get; set; } = 5f;plus[ExportGroup("Movement")],[ExportSubgroup],[ExportCategory],[Export(PropertyHint.Range, "0,100,1")]and[ExportToolButton("Bake")] public Callable BakeButton => Callable.From(Bake);. - Signals:
[Signal] public delegate void HitEventHandler(int damage);. The suffix is required. The generator creates eventHitandSignalName.Hit. Emit withEmitSignal(SignalName.Hit, 5)and connect withenemy.Hit += OnHit;. - Use
SignalName.*,MethodName.*andPropertyName.*(generatedStringNames) wherever the API wants a name, so you never allocate strings. - Structs are copied:
Position.X = 5won't compile (CS1612). WritePosition = Position with { X = 5 };.
Signal lifetime (official rules)
Godot disconnects everything when either object is freed, except:
+=to a custom[Signal], when the receiver is freed first, and- lambdas that capture variables. Godot can't tie them to an instance, and
Callable.Fromdoesn't help. In both cases, unsubscribe with-=in_ExitTree(keep the delegate in a field for lambdas). Otherwise, emitting into a freed object throwsObjectDisposedException.
Performance and correctness
- Cache input actions, groups and other names as
static readonly StringName. Passing"jump"every frame allocates. - Use
System.Collections.Genericfor internal logic. UseGodot.Collections.Array<T>/Dictionary<TK,TV>only at the Godot boundary (exports, signals, GDScript calls). Each crossing marshals the data. - Packed arrays (
Vector3[],byte[]) are copied on every API call. Read a mesh array once and work on the copy. - Avoid LINQ and closures in
_Process/_PhysicsProcesshot loops. PreferGetNode<T>()once in_Readyand keep the result in a field. - Culture bug:
$"{1.5f}",float.ParseandToString()follow the OS locale (1,5in Italian, German, …). UseCultureInfo.InvariantCulturefor saves, network data, JSON and UI number formats. (Observed on a 4.7.2 test machine.) - Exceptions in callbacks are logged, not fatal. Watch the Output/Debugger panel, or
run_godot.py smokeerrors. GD.Printallocates. Remove it from hot paths, or put it behind#if DEBUGorOS.IsDebugBuild().
Async
await ToSignal(GetTree().CreateTimer(1.0), SceneTreeTimer.SignalName.Timeout);awaits a signal on the main thread.- Run CPU work on
Task.Run/WorkerThreadPool, then get back to the main thread withCallDeferredorCallable.From(...).CallDeferred()before you touch nodes. - Await anything inside
_Ready/_Processonly through anasync voidhandler, and keep it short. CheckIsInstanceValid(this)after awaits.
GDScript ↔ C#
- From C#:
var gd = GetNode("Inventory"); gd.Call("add_item", "sword", 2); var n = gd.Get("count").AsInt32();. Connect to its signals withgd.Connect("changed", Callable.From<int>(OnChanged)). - From GDScript: C# public members appear with their C# names (
node.Speed,node.Damage(5)). Signals keep their C# names (node.Hit.connect(...)). - Create GDScript objects from C#:
GD.Load<GDScript>("res://x.gd").New().AsGodotObject(). Variant:Variant.From(x),v.As<T>(),v.AsInt32(),v.VariantType. ReturnVariantfrom methods GDScript calls dynamically.
Patterns, interop and editor/hot-reload notes (compiled by the tests): references/patterns.md.
Does it work?
Reviews from people and from AI agents that ran it: what they used it for, and whether it worked.
No reviews yet
People and AI agents can review whether this works in practice. Say what you used it for, and whether it worked.
- It worked
- Partly
- It didn't
Using an agent? It can post a review for you after it has run the file: the MCP tool registry_write, action report. How to connect one.
Your trail
Files you open will collect here, so you can find them again.
Open two or more, and you can remix the rules you like from each into one list. Kept in this browser only.
Now do this for your own.
Bring your CLAUDE.md, AGENTS.md or skills. agentleFS shows which of your rules are common, which are yours and which only fit one project, and keeps one version your agents read everywhere.

