dev-modular-design

Guides modular C# component architecture for Unity using interfaces, events, and assembly definitions.

Updated Apr 13, 2026
One-click install
npx skills add https://github.com/Unity-UPM-Packages/Antigravity-skills --skill dev-modular-design-unity-upm-packages
Or copy as Structured Prompt for Agent▼
Please help me install this Agent Skill.
Skill: dev-modular-design
Source: https://github.com/Unity-UPM-Packages/Antigravity-skills/tree/main/.agents/skills/dev-modular-design
Command: npx skills add https://github.com/Unity-UPM-Packages/Antigravity-skills --skill dev-modular-design-unity-upm-packages

SYSTEM DOCUMENTATION & REQUIREMENTS

What problem does it solve? Unity codebases often become fragile when MonoBehaviours take on multiple responsibilities, reference concrete classes directly, and leak memory through undisposed event subscriptions. This Skill enforces modular design principles so components stay decoupled, testable, and safe to refactor. ## Core Features & Use Cases - Decoupling Enforcement: Detects hard dependencies between components and replaces them with injected interface contracts, so each script compiles and initializes in isolation. - Architecture Guidance: Applies composition over inheritance, event-driven communication (Action callbacks, EventBus, UniRx/R3), and .asmdef assembly isolation to enforce layer boundaries between Core, Gameplay, and UI. - Over-Engineering Guardrails: Distinguishes Framework systems (interface-first) from Domain systems (concrete classes) to avoid premature abstraction. - Use Case: When reviewing a PlayerController that calls FindObjectOfType<HUDManager> in Awake, the Skill flags the hard dependency and refactors it to an injected IHealthSystem-style contract with proper event cleanup in OnDisable. ## Quick Start Ask the AI to review your MonoBehaviour for modularity issues and refactor any direct component references into interface-based, event-driven designs.

Frequently Asked Questions about dev-modular-design

High-intent search queries and answers about installing and using this skill.

FAQPage Schema
How do I decouple MonoBehaviour components in Unity?▼

Decouple MonoBehaviours by injecting dependencies through interfaces instead of using FindObjectOfType or direct concrete references. Communicate between systems via events like Action<T> or an EventBus, and verify each script compiles and initializes safely in isolation.

When should I use interfaces versus concrete classes in Unity C#?▼

Use interfaces for reusable Framework systems like Save, Audio, and Input where implementations may vary. Use concrete classes for game-specific Domain systems like GridSystem or Spawners, adding interfaces only when needed for mock-based unit testing.

What is composition over inheritance in Unity game development?▼

Composition over inheritance means attaching small focused components like MovementComponent or HealthComponent via RequireComponent instead of building deep inheritance hierarchies. This keeps behavior extensible and prevents base-class changes from breaking subclasses unpredictably.

Why do Unity event subscriptions cause memory leaks?▼

Memory leaks occur when components subscribe to events but never unsubscribe, leaving phantom callbacks after destruction. Always pair subscriptions in OnEnable with unsubscriptions in OnDisable or OnDestroy, or implement Dispose for non-MonoBehaviour classes.

When should I avoid using interfaces and event buses in Unity?▼

Avoid interfaces and event buses for game-specific domain logic, single-use utility classes, systems with only one realistic implementation, and early prototype code. Premature abstraction adds cost without benefit when nothing genuinely needs to vary.