godot-autopilot-csharp
Skill1 starsChanged 17 days agoMITView on GitHub
Godot C#/.NET project guide: bootstrapping a csproj from a plain project, creating C# scripts with create_csharp_script, the dotnet_environment probe, the build_csharp_assembly wait loop with compiler output, reading diagnostics.instantiable, running the game and confirming with get_debugger_errors plus the error watermark, C# [GlobalClass] resources via create_resource, [Export] node and typed-array conversion in property_set, and the reflection bridge with csharp_get_property/call_method/subscribe_event. Use when working in a C# Godot project.
In this repository16 other files it gives its agents.
- AGENTS.mdAGENTS.md
- cpp-registrationSkill
- domain-tool-authoringSkill
- gda-demo-e2eSkill
- gda-e2e-analysisSkill
- skill-proposerSkill
- thread-security-gateSkill
- wiki-maintainerSkill
- godot-autopilot-contentSkill
- godot-autopilot-resourcesSkill
- godot-autopilot-runtimeSkill
- godot-autopilot-scene-systemSkill
- godot-autopilot-scriptingSkill
- godot-autopilot-serversSkill
- godot-autopilotSkill
- godot-autopilot-toolsSkill
The file
We split this skill into the rules it gives an agent
7 rules. About 0 are common, 0 are distinctive, and 7 are very specific to this project.
≈0
Common · estimate
Many files like this have a rule of this kind.
≈0
Distinctive · estimate
This author's own choices. Worth a look.
7
Very specific
Tied to their project's names, files or tools. Probably skip.
- Common
- Distinctive
- Very specific
- Very specific: line 23
Run dotnet_environment. On a plain project it returns an error carrying a ready-to-write template: {path, content, target_framework, …
- Very specific: line 26
Write the template with write_file (the content is a Godot.NET.Sdk/<engine-version> project targeting the installed .NET SDK).
- Very specific: line 63
Create or edit the .cs file (create_csharp_script, write_file or patch_script).
- Very specific: line 72
Read the result, not a guess: success, errors and output_digest are the compiler verdict.
- Very specific: line 75
Run the scene with play_editor_current_scene (save it first) and gate on get_game_status.
- Very specific: line 82
Verify with a real observation: capture_game_viewport for the visible result, or read values back with property_get / get_script_property / …
- Very specific: line 120
After an assembly-changing build the editor may re-instantiate script scenes.
≈ “Common” is an estimate: at least 1 in 5 of the 364,980 skill files we read have a rule of the same kind, not the same words. “Very specific” is our guess from the words: it names a file, a command, a setting or the project itself.
Files
C# / .NET Workflows
Invocation: use the native MCP tools first; when that channel is down, follow the calling ladder in the godot-autopilot-tools skill (the gda CLI, via bunx, a global install, or the standalone gda binary); with no CLI available, work through its references/manual-fallback.md.
C# projects run on the editor's .NET assembly, which changes the workflow in
three ways: a build step sits between editing and observing, C# declarations
such as [GlobalClass] and [Export] reach Godot through the assembly, and a
running game never picks up a new assembly on its own. This skill covers the
C#-specific paths. The GDScript execution channels (execute_script,
call_script_node, execute_game_script, code_execute) are unaffected by
.NET assembly state and are documented by godot-autopilot-scripting.
Bootstrap: from a plain project to a C# project
A C# project needs a res:// root .csproj (or .sln) and a matching
[dotnet] project/assembly_name in project.godot.
- Run
dotnet_environment. On a plain project it returns an error carrying a ready-to-write template:{path, content, target_framework, assembly_name}plus ahint. - Write the template with
write_file(the content is aGodot.NET.Sdk/<engine-version>project targeting the installed .NET SDK). - Set
[dotnet] project/assembly_nameto the returnedassembly_name. - Re-run
dotnet_environment; it should now reportproject_file,dotnet_availableanddotnet_version.
dotnet_environment.assembly_loaded only says the .NET module is loaded in
the editor; it does not mean the project assembly is loaded. Use
create_csharp_script.diagnostics.instantiable or a runtime read-back to
verify the project assembly.
Creating and editing C# files
create_csharp_script(path,source_code, optionaloverwrite) is the preferred way to create a.csfile. Three gates fail with an actionable patch instead of a silent ok: the file stem must equal the declared class name, the class must bepartialand derive from a ClassDB-known Godot base, and the root.csprojmust cover the file. It returns the file record plusverified/readbackand adiagnosticsobject.write_filestill works for.cs; it returns adiagnosticsobject for script-like files but has no class-name orpartialgates.patch_scriptedits one anchored spot in an existing file and compiles before writing;copy_resource_fileduplicates a compiling.csas a starting point.create_scriptwrites GDScript only; do not use it for C#.
Diagnostics semantics
diagnostics.ok means the .cs file loads as a script resource.
diagnostics.instantiable means the class is present in the loaded assembly
and can_instantiate() is true. A newly created class normally reports
ok=true, instantiable=false until build_csharp_assembly succeeds; read
instantiable before calling new() or attaching a script that must run in
the editor.
The C# development loop
- Create or edit the
.csfile (create_csharp_script,write_fileorpatch_script). - Build with
build_csharp_assemblyand preferwait=true:{wait: true, timeout_ms?: 1..25000}runsdotnet build --nologoin the foreground and returnsBuildResult:{project_file, project_path, command, exit_code, success, errors, output_digest, output_empty, output_truncated?, errors_truncated?, note, game_running, restart_required?}. Withoutwaitthe call only starts the process and returns{pid, started, game_running}. - Read the result, not a guess:
success,errorsandoutput_digestare the compiler verdict.get_debugger_logremains the place for editor-side script errors that are not compiler output. - Run the scene with
play_editor_current_scene(save it first) and gate onget_game_status; a half-dead process is stopped and restarted, not debugged. - Diagnose while it runs:
get_debugger_errorsreturns structured entries withseq; passsince_seqand use the top-levelnext_seqto read only new errors.get_game_log_entriesreads the on-disk game log when the debug channel may have dropped messages. - Verify with a real observation:
capture_game_viewportfor the visible result, or read values back withproperty_get/get_script_property/csharp_get_property. - Fix and repeat.
The error watermark is not the script error list
new_errors_since_last_call counts tool-response errors and game
runtime_error payloads. It does not count compiler output or GDScript
parse errors logged by the engine. Do not treat it as "the C# fix is clean";
use BuildResult.success / errors, get_debugger_log (editor process) and
get_debugger_errors with since_seq (running game).
Restart rules
- Editor side: after a successful build, new classes can usually be instantiated without restarting the editor; signature changes may still require the editor's own Build action or a restart because GDExtension cannot trigger the engine's .NET assembly reload.
- Game side: a running process keeps the old assembly.
build_csharp_assemblyreportsgame_runningand, for a successfulwait=truebuild, setsrestart_required=true; stop and relaunch the game before judging the new code. reload_game_scriptsreloads GDScript files only.
[Export] properties and save timing
property_set writes C# [Export] fields through the same JSON shapes as
GDScript exports (full table in godot-autopilot-scene-system):
- Node-typed fields accept a node path string;
converted_node_pathconfirms the conversion. An unresolvable path is an error, not a silent ok. - Typed arrays (
[Export] Node[],Array[Resource]) convert element by element; node elements accept a path string or{"__node_ref__": "..."}, resource elements accept ares://path or amemory://locator. - A rejected assignment (read-only property, setter that clears the value) is reported as "value not applied"; the tool attempts to restore the old value and reports whether the restore succeeded.
- After an assembly-changing build the editor may re-instantiate script
scenes. Re-read the exported values before saving, then save and read the
.tscnback; do not assume a value written before the build survived it.
C# resources and script attachment
create_resourceaccepts C#[GlobalClass]classes by name once the class is in the loaded assembly. Passnameto register amemory://locator; abstract or invalid scripts are rejected.set_resource_propertyaddresses an instance bynameorobject_id;save_resourcewrites it to disk before a node property can reference it.attach_script_to_nodeattaches a C# script resource and registers one undo step. Replacing a node's script does not migrate exported references; rewire them withproperty_setafterwards.
Reflection bridge: C# members that GDScript cannot see
property_get and execute_game_script only reach members visible to
GDScript. For C# getters, overloads and events use csharp_list_members to
discover the member, then csharp_get_property, csharp_set_property,
csharp_call_method, csharp_subscribe_event and csharp_unsubscribe_event
with runtime editor (default) or game.
- Editor side needs no manual singleton registration: the plugin loads and
instantiates
res://addons/godot-autopilot/GdaCSharpBridge.cswhen the engine singleton is absent. - Game side requires a
GdaCSharpRuntimenode in the running scene; it creates the__gda_runtimeholder the tools locate. Only scene-path locators cross into the game (object_id,object_id_strandmemoryare editor-process handles). - A locator that resolves to a script resource (for example
res://scripts/Player.cs) is rejected with a precise error; pass a node path orobject_id_strof a live instance. - A running game's
__gda_runtimeholder is excluded fromget_game_status.node_countand reported separately asinstrumentation_node_count.
Endpoints, reflection limits, export-build trimming and subscription token lifetime are documented in references/csharp-bridge.md.
See also
godot-autopilot-scripting- the GDScript execution channels, unaffected by .NET assembly state.godot-autopilot-scene-system- node CRUD, property JSON shapes and the C# notes in its property reference.godot-autopilot-resources- the create/save/duplicate flows behindcreate_resource.godot-autopilot-runtime- launching the game, debug channel semantics and the log/error fallbacks used above.godot-autopilot-tools- tool discovery, the error watermark and retryable soft errors.
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.

