home / skills / dev-gom / claude-code-marketplace / unity-template-generator

This skill generates production-ready Unity C# script templates (MonoBehaviour, ScriptableObject, Editor, tests) following Unity conventions and best practices.

npx playbooks add skill dev-gom/claude-code-marketplace --skill unity-template-generator

Review the files below or copy the command above to add this skill to your agents.

Files (1)
SKILL.md
2.2 KB
---
name: Unity Template Generator
description: Generates production-ready C# script templates (MonoBehaviour, ScriptableObject, Editor, tests). Use when creating new scripts or setting up project structure.
allowed-tools: Write, Read, Glob
---

# Unity Template Generator

Assists with generating production-ready Unity C# script templates that follow best practices and Unity conventions.

## Available Templates

**MonoBehaviour** - GameObject components with lifecycle methods, serialized fields, component caching, and Gizmo helpers.

**ScriptableObject** - Data assets with `[CreateAssetMenu]`, validation, encapsulation, and clone methods.

**Editor Script** - Custom inspectors or windows. Asks for UGUI vs UI Toolkit preference (see [unity-ui-selector](../unity-ui-selector/SKILL.md)).

**Test Script** - NUnit/PlayMode tests with Setup/TearDown, `[UnityTest]`, performance tests, and Arrange-Act-Assert pattern.

## Template Features

All templates include:
- Unity coding conventions (`[SerializeField]`, PascalCase, XML docs)
- Performance patterns (component caching, no GetComponent in Update)
- Code organization (#region directives, consistent ordering)
- Safety features (null checks, OnValidate, Gizmos)

Placeholders: `{{CLASS_NAME}}`, `{{NAMESPACE}}`, `{{DESCRIPTION}}`, `{{MENU_PATH}}`, `{{FILE_NAME}}`

See [template-reference.md](template-reference.md) for detailed customization options.

## When to Use vs Other Components

**Use this Skill when**: Discussing template options, understanding template features, or getting guidance on script structure

**Use @unity-scripter agent when**: Writing custom scripts with specific requirements or implementing complex Unity features

**Use @unity-refactor agent when**: Improving existing scripts or restructuring code for better maintainability

**Use /unity:new-script command when**: Actually generating script files from templates with specific parameters

**Use /unity:setup-test command when**: Setting up complete test environments with test scripts

## Related Skills

- **unity-script-validator**: Validates generated scripts
- **unity-ui-selector**: Helps choose UI system for Editor scripts
- **unity-uitoolkit**: Assists with UI Toolkit implementation when generating Editor scripts

Overview

This skill generates production-ready Unity C# script templates for common needs: MonoBehaviour components, ScriptableObjects, Editor scripts, and test files. Templates follow Unity conventions, include performance and safety patterns, and come with configurable placeholders for quick project integration. Use it to standardize new files and accelerate boilerplate creation.

How this skill works

The generator produces templated C# files populated with placeholders like {{CLASS_NAME}}, {{NAMESPACE}}, and {{DESCRIPTION}} so you can quickly instantiate properly structured scripts. Each template embeds best practices: serialized fields, component caching, OnValidate checks, XML docs, and organized regions. For Editor scripts it asks your UI preference (UGUI or UI Toolkit) and for tests it scaffolds NUnit/PlayMode patterns with Setup/TearDown and Arrange-Act-Assert sections.

When to use it

  • Creating new MonoBehaviour components with lifecycle boilerplate
  • Defining ScriptableObject assets with validation and asset menus
  • Scaffolding custom Editor inspectors or editor windows
  • Generating unit and playmode test skeletons
  • Setting up consistent script structure across a project

Best practices

  • Pick descriptive class names and proper namespaces to avoid collisions
  • Use serialized private fields with properties for encapsulation
  • Cache component references in Awake/OnEnable; avoid GetComponent in Update
  • Include OnValidate and null checks to catch issues early in the editor
  • Choose UI system (UGUI vs UI Toolkit) for editor scripts before generating to match project style

Example use cases

  • Add a new enemy MonoBehaviour with cached components and Gizmo helpers
  • Create a configurable GameSettings ScriptableObject with CreateAssetMenu and cloning
  • Generate a custom inspector using UI Toolkit or UGUI to speed iteration
  • Produce NUnit PlayMode tests with Arrange-Act-Assert and performance assertions
  • Bootstrap a consistent file layout when onboarding new developers

FAQ

Can I customize placeholders and defaults?

Yes. Templates use placeholders like {{CLASS_NAME}} and {{NAMESPACE}} so you can supply values or adjust template files to change defaults.

Which template should I use for editor customization?

Use the Editor Script template. It prompts for your UI choice (UGUI or UI Toolkit) and outputs a ready-made inspector or window scaffold.