|
| 1 | +<!-- standards-version: 1.9.2 --> |
| 2 | + |
| 3 | +# CLAUDE.md |
| 4 | + |
| 5 | +Project documentation for Claude Code and AI assistants working on this repository. |
| 6 | + |
| 7 | +## Project Overview |
| 8 | + |
| 9 | +Unity Developer Tools is a Cursor IDE plugin for Unity game development. It includes 18 skills, 8 rules, 20 code snippets across C# / HLSL / Visual Scripting, 5 starter templates, and a companion Python MCP server with 4 tools for script scaffolding, Unity API lookup, shader patterns, and platform information. |
| 10 | + |
| 11 | +**Works with:** Cursor (plugin), Claude Code (terminal and in-editor), and any MCP-compatible client. |
| 12 | + |
| 13 | +This is a monorepo. Skills, rules, snippets, templates, and the companion MCP server live in the same repository because Unity development crosses all of those layers in a single workflow. |
| 14 | + |
| 15 | +**Version:** 1.4.3 |
| 16 | +**License:** CC-BY-NC-ND-4.0 |
| 17 | +**Author:** TMHSDigital |
| 18 | + |
| 19 | +## Plugin Architecture |
| 20 | + |
| 21 | +``` |
| 22 | +Unity-Developer-Tools/ |
| 23 | + .cursor-plugin/ |
| 24 | + plugin.json # Plugin manifest (version, skills, rules) |
| 25 | + skills/ |
| 26 | + <skill-name>/ |
| 27 | + SKILL.md # One skill per directory (kebab-case) |
| 28 | + rules/ |
| 29 | + <rule-name>.mdc # Cursor rule files |
| 30 | + snippets/ |
| 31 | + csharp/ # C# patterns and examples |
| 32 | + shaders/ # HLSL / ShaderLab patterns |
| 33 | + visual-scripting/ # Visual Scripting graphs and notes |
| 34 | + templates/ # Starter project archetypes |
| 35 | + mcp-server/ |
| 36 | + server.py # MCP server entry point (Python, FastMCP) |
| 37 | + data/ # API reference, deprecated patterns, shader props, platform defines |
| 38 | + requirements.txt |
| 39 | + docs/ # MkDocs Material site (ARCHITECTURE, ROADMAP, GETTING-STARTED) |
| 40 | + .github/ |
| 41 | + workflows/ # CI / release / docs / drift-check automation |
| 42 | +``` |
| 43 | + |
| 44 | +## Skills (18) |
| 45 | + |
| 46 | +| Skill | Description | |
| 47 | +|-------|-------------| |
| 48 | +| `project-setup` | Folder structure, assembly definitions, version control, and package management for Unity projects | |
| 49 | +| `monobehaviour-patterns` | MonoBehaviour lifecycle, async patterns with Awaitable, and common Unity design patterns | |
| 50 | +| `scriptableobjects` | Data-driven design with ScriptableObjects (events, variables, runtime sets, configuration) | |
| 51 | +| `physics-2d-3d` | Collision, raycasting, layers, and rigidbody management for 2D and 3D projects | |
| 52 | +| `ui-development` | UI Toolkit (primary) and Canvas/UGUI, including data binding, styling, responsive layouts | |
| 53 | +| `shader-development` | Shader Graph, HLSL, and ShaderLab for URP and HDRP projects | |
| 54 | +| `animation-systems` | Animator Controller, Timeline, DOTween, and sprite animation for 2D | |
| 55 | +| `audio-systems` | AudioSource, AudioMixer, spatial audio, and audio management patterns | |
| 56 | +| `input-systems` | New Input System package and migration guidance from the legacy Input Manager | |
| 57 | +| `networking` | Multiplayer networking with Netcode for GameObjects, Netcode for Entities, Mirror, Photon Fusion | |
| 58 | +| `editor-scripting` | Custom inspectors, editor windows, property drawers, gizmos, Scene View overlays via UI Toolkit | |
| 59 | +| `performance-optimization` | CPU, GPU, memory, and profiling tools (Profiler, Memory Profiler, Frame Debugger) | |
| 60 | +| `render-pipeline-detection` | Detect and adapt to URP, HDRP, or Built-in pipelines | |
| 61 | +| `ecs-dots` | Entity Component System with Unity Entities, Jobs, and Burst | |
| 62 | +| `visual-scripting` | Script Graphs, State Graphs, Subgraphs, and custom units | |
| 63 | +| `testing` | Unity Test Framework 2.x with Edit Mode and Play Mode tests, async Awaitable support | |
| 64 | +| `addressables-assets` | Async loading, memory management, and remote content delivery via Addressables | |
| 65 | +| `platform-targeting` | Scripting defines, build settings, and cross-platform considerations | |
| 66 | + |
| 67 | +## Rules (8) |
| 68 | + |
| 69 | +| Rule | Scope | Description | |
| 70 | +|------|-------|-------------| |
| 71 | +| `csharp-unity-conventions.mdc` | `**/*.cs` | C# coding conventions for Unity development | |
| 72 | +| `monobehaviour-lifecycle.mdc` | `**/*.cs` | Correct usage of MonoBehaviour lifecycle methods | |
| 73 | +| `performance-rules.mdc` | `**/*.cs` | Performance optimization rules (allocations, FindObject, tight loops) | |
| 74 | +| `naming-conventions.mdc` | `**/*.cs` | Naming conventions for Unity C# code | |
| 75 | +| `serialization-rules.mdc` | `**/*.cs` | Unity serialization best practices (`[SerializeField]`, ISerializationCallbackReceiver) | |
| 76 | +| `shader-conventions.mdc` | `**/*.shader`, `**/*.hlsl`, `**/*.cginc`, `**/*.shadergraph` | Conventions for Unity shader development (HLSLPROGRAM, SRP Batcher) | |
| 77 | +| `visual-scripting-conventions.mdc` | `**/*.asset` | Best practices for Unity Visual Scripting graphs | |
| 78 | +| `security-and-builds.mdc` | `**/*.cs`, `**/*.json`, `**/*.asset` | Security and build configuration rules (no hardcoded secrets, build target hygiene) | |
| 79 | + |
| 80 | +## MCP Server (4 tools) |
| 81 | + |
| 82 | +The companion MCP server is Python-based (FastMCP). It exposes Unity-aware tools that read from local data files (`mcp-server/data/`) and accept agent-supplied parameters. |
| 83 | + |
| 84 | +| Tool | Description | |
| 85 | +|------|-------------| |
| 86 | +| `scaffold_script` | Generate a structured C# script (MonoBehaviour, ScriptableObject, EditorWindow, custom inspector, property drawer, interface, state machine, test) with recommended folder placement | |
| 87 | +| `lookup_api` | Search the Unity API reference (name, namespace, signature, examples) with optional category filter and deprecated-pattern warnings | |
| 88 | +| `shader_helper` | Fetch shader patterns and property setups for common effects (dissolve, outline, toon, water, hologram, fresnel) per render pipeline | |
| 89 | +| `platform_info` | Get platform-specific scripting defines, capabilities, limitations, and recommendations (Windows, macOS, Linux, Android, iOS, WebGL, PS5, Xbox, Switch) | |
| 90 | + |
| 91 | +## Development Workflow |
| 92 | + |
| 93 | +### Plugin development (symlink) |
| 94 | + |
| 95 | +**macOS / Linux:** |
| 96 | +```bash |
| 97 | +ln -s "$(pwd)" ~/.cursor/plugins/unity-developer-tools |
| 98 | +``` |
| 99 | + |
| 100 | +**Windows (PowerShell as Admin):** |
| 101 | +```powershell |
| 102 | +New-Item -ItemType SymbolicLink -Path "$env:USERPROFILE\.cursor\plugins\unity-developer-tools" -Target (Get-Location) |
| 103 | +``` |
| 104 | + |
| 105 | +### MCP server development |
| 106 | + |
| 107 | +```bash |
| 108 | +cd mcp-server |
| 109 | +pip install -r requirements.txt |
| 110 | +python server.py |
| 111 | +``` |
| 112 | + |
| 113 | +### Running validation |
| 114 | + |
| 115 | +```bash |
| 116 | +# JSON schema and content-count checks (run by CI) |
| 117 | +python .github/scripts/validate_plugin.py |
| 118 | +``` |
| 119 | + |
| 120 | +## Release Workflow |
| 121 | + |
| 122 | +Releases are automated. The `release.yml` workflow: |
| 123 | + |
| 124 | +1. Reads conventional commits since the last tag. |
| 125 | +2. Computes the next semver bump (PATCH for `fix:`, MINOR for `feat:`, MAJOR for `BREAKING CHANGE`). |
| 126 | +3. Updates `plugin.json` `version` and the README version badge. |
| 127 | +4. Creates the tag, the GitHub Release, and floating major / minor tags. |
| 128 | +5. Invokes `release-doc-sync` to update `**Version:**` in this file and prepend a CHANGELOG entry. |
| 129 | + |
| 130 | +Do not hand-edit `plugin.json` `version`, the README badge, or the `**Version:**` line above. The release pipeline owns them. |
| 131 | + |
| 132 | +## Key Conventions |
| 133 | + |
| 134 | +- **No em dashes.** Use regular dashes (`-`) or rewrite the sentence. CI flags em and en dashes in markdown. |
| 135 | +- **No hardcoded credentials.** Use environment variables, `EditorUserSettings`, or a secrets store. CI flags suspicious patterns. |
| 136 | +- **Skill frontmatter:** `title`, `description`, `globs` (when path-scoped), and `standards-version`. |
| 137 | +- **Rule frontmatter:** `title`, `description`, `globs`, `alwaysApply`, and `standards-version`. |
| 138 | +- **Snippets:** must compile against Unity 6.x and use modern APIs (Awaitable, `FindFirstObjectByType`, UI Toolkit). No placeholder credentials. |
| 139 | +- **Templates:** every template needs a top-level `README.md` describing usage, scripts, and any project setup notes (assembly definitions, package dependencies). |
| 140 | +- **MCP tool naming:** snake_case Python functions decorated with `@mcp.tool()`. |
| 141 | + |
| 142 | +## Unity Reference Quick Links |
| 143 | + |
| 144 | +| Resource | Use | |
| 145 | +|----------|-----| |
| 146 | +| `docs.unity3d.com/Manual/index.html` | Authoritative Unity manual | |
| 147 | +| `docs.unity3d.com/ScriptReference/index.html` | Scripting API reference | |
| 148 | +| `docs.unity3d.com/Packages/` | Package-specific manuals (URP, HDRP, Input System, Netcode, Entities) | |
| 149 | +| `mcp-server/data/unity_api_common.json` | Local Unity API quick-reference index | |
| 150 | +| `mcp-server/data/deprecated_patterns.json` | Deprecation map (legacy -> replacement) | |
| 151 | +| `mcp-server/data/shader_properties.json` | Shader effect patterns and property setups | |
| 152 | +| `mcp-server/data/platform_defines.json` | Platform scripting defines and capabilities | |
0 commit comments