unity-architecture-conventions
Skill1 starsChanged 5 months agoMITView on GitHub
Architecture best practices for Unity projects - dependency direction, orchestration, event patterns. ALWAYS Auto-loaded when writing code for Unity Projects.
In this repository9 other files it gives its agents.
- unity-coding-conventionsSkill
- unity-folder-conventionsSkill
- unity-mcp-toolsSkill
- unity-performanceSkill
- unity-testingSkill
- unity-ugui-developmentSkill
- unity-ugui-listSkill
- writing-testsSkill
- zenject-conventionsSkill
The file
We split this skill into the rules it gives an agent
5 rules. About 0 are common, 4 are distinctive, and 1 is very specific to this project.
≈0
Common · estimate
Many files like this have a rule of this kind.
≈4
Distinctive · estimate
This author's own choices. Worth a look.
1
Very specific
Tied to their project's names, files or tools. Probably skip.
- Common
- Distinctive
- Very specific
- Distinctive: line 7
Follow these architectural patterns when designing and structuring Unity project code.
- Distinctive: line 16
If there is no clear "who starts the game?" answer when reading the scene, the architecture is wrong.
- Distinctive: line 23
When injecting, ask: "does this class need to *know about* this system, or should it just *emit an event* that the system reacts to?"
- Very specific: line 28
When a state change should stop event handling, unsubscribe from events rather than guarding every handler with if (IsGameOver) return;.
- Distinctive: line 34
When multiple independent systems react to the same occurrence (e.g., a grade result affecting score, HP, and combo), publish an event …
≈ “Common” is an estimate: at least 1 in 5 of the 408,460 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
Unity Architecture Conventions
Follow these architectural patterns when designing and structuring Unity project code.
Application Startup & Orchestration
CRITICAL: Every scene must have a visible starting point.
- A visible starting point means an explicit orchestrator that controls the startup sequence — e.g.,
GameManager.StartGame(), not logic auto-running inStart(). - MonoBehaviours must NOT perform actions or start processes in Awake/Start on their own. Only resolve references or do simple caching.
- Self-contained objects (like pooled enemies) can initialize on instantiation, but top-level systems need external orchestration.
- If there is no clear "who starts the game?" answer when reading the scene, the architecture is wrong.
Dependency Direction
- Dependencies flow downward: orchestrators → services → leaf components.
- Think of it as a tree: one parent per node, no reaching upward.
- A downstream consumer must not stop, reset, or control systems above it in the hierarchy. If a game-over event needs to stop the beat clock, the game-over owner (or a dedicated orchestrator) should do it — not a downstream consumer that happens to hold a reference.
- When injecting, ask: "does this class need to know about this system, or should it just emit an event that the system reacts to?"
- Watch for excessive injection count — it often means the class has too many responsibilities.
Event Lifecycle
- When a state change should stop event handling, unsubscribe from events rather than guarding every handler with
if (IsGameOver) return;. - The owner of the state transition is responsible for unsubscribing dependents or signaling them to unsubscribe.
- Boolean guards accumulate across the codebase and are easy to forget in new handlers. Unsubscription is a single point of control.
Events vs Direct Calls
- When multiple independent systems react to the same occurrence (e.g., a grade result affecting score, HP, and combo), publish an event rather than injecting and calling each system directly.
- The publisher should not know about its consumers. If adding a new consumer requires modifying the publisher, use an event instead.
- This prevents the publisher from accumulating injections for every new consumer.
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.

