agentleFS
batihandevbatihandev/unity-mcp-skills/skills/script/SKILL.md

unity-script

Skill7 starsChanged 7 months agoMITView on GitHub

Use when creating, reading, editing, searching, validating, or deleting C# scripts in a Unity project.

The file

We split this skill into the rules it gives an agent

8 rules. About 0 are common, 3 are distinctive, and 5 are very specific to this project.

  • ≈0

    Common · estimate

    Many files like this have a rule of this kind.

  • ≈3

    Distinctive · estimate

    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
  1. Very specific:

    When creating a script, pass the scriptName without .cs.

    line 28
  2. Distinctive:

    When renaming a class, rename the file in the same operation.

    line 29
  3. Very specific:

    After any script create / edit / delete, Unity triggers a Domain Reload (compilation + assembly swap).

    line 33
  4. Very specific:

    If the response reports isCompiling: true, wait for it to settle before the next script edit.

    line 35
  5. Distinctive:

    Prefer explicit dependencies + small responsibilities + event-driven notifications over hidden globals.

    line 44
  6. Very specific:

    Avoid Update-loop polling, repeated GameObject.Find calls, reflection in hot paths, avoidable allocations.

    line 45
  7. Distinctive:

    Start from the minimum structure that solves the need — don't dump boilerplate.

    line 46
  8. Very specific:

    After any edit, run Unity_ValidateScript and fix reported errors before marking a task done.

    line 47

≈ “Common” is an estimate: at least 1 in 5 of the 350,495 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.

Keep what fits and drop the rest. Your version, ready for your agents.
Files
SKILL.md

Script Management

Do not use Unity_RunCommand for script operations. The Unity MCP server exposes dedicated tools for every common script operation. Use them directly — they handle Domain Reload coordination and diagnostics natively.

Routing

OperationToolTypical use
Create a new C# scriptUnity_CreateScriptWrites a new file under Assets/; sets up the MonoBehaviour/ScriptableObject/Editor template.
Delete a C# scriptUnity_DeleteScriptBy URI (unity://path/...) or by Assets/... path.
List script filesUnity_ListResourcesCommonly filtered to *.cs under Assets/.
Search inside a scriptUnity_FindInFileRegex-level matches with line numbers.
Structured editsUnity_ScriptApplyEditsMethod-level replace / insert / remove. Prefer this over raw text edits.
Syntax + diagnostics checkUnity_ValidateScriptCall before and after edits; surfaces compile errors before they trigger a Domain Reload.
Hash for concurrencyUnity_GetShaCompare against your expected hash to detect conflicting edits before writing.

Install-once Editor scripts (screenshot helpers, custom Editor windows, build steps, exporters): check ../tooling/SKILL.md for ready-to-paste templates before writing one from scratch.

Filename must match class name

The .cs filename (without extension) must exactly match the top-level class name. Unity's asset database relies on the 1:1 mapping — mismatches silently break MonoBehaviour attachment and asset references.

  • When creating a script, pass the scriptName without .cs.
  • When renaming a class, rename the file in the same operation.

Domain Reload coordination

After any script create / edit / delete, Unity triggers a Domain Reload (compilation + assembly swap). Tools return a compilation block where applicable — check it before issuing the next operation.

  1. If the response reports isCompiling: true, wait for it to settle before the next script edit.
  2. Once compilation completes, call Unity_ValidateScript on the affected file to surface any errors.
  3. Group related edits in a single task where possible — fewer edits = fewer Domain Reloads.

Style guardrails

  • Meaningful, domain-specific class names.
  • Group scripts by feature under Assets/Scripts/<Feature>/.
  • Decide the class role first: MonoBehaviour, ScriptableObject, or plain C# helper.
  • Prefer explicit dependencies + small responsibilities + event-driven notifications over hidden globals.
  • Avoid Update-loop polling, repeated GameObject.Find calls, reflection in hot paths, avoidable allocations.
  • Start from the minimum structure that solves the need — don't dump boilerplate.
  • After any edit, run Unity_ValidateScript and fix reported errors before marking a task done.

Download now (ZIP)

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
What did you use it for? e.g. Reviewing pull requests in a Rails app

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.