agentleFS
skysepehruskysepehru/unity-claude-skills/skills/unity-architecture-conventions/SKILL.md

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.

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
  1. Distinctive:

    Follow these architectural patterns when designing and structuring Unity project code.

    line 7
  2. Distinctive:

    If there is no clear "who starts the game?" answer when reading the scene, the architecture is wrong.

    line 16
  3. Distinctive:

    When injecting, ask: "does this class need to *know about* this system, or should it just *emit an event* that the system reacts to?"

    line 23
  4. Very specific:

    When a state change should stop event handling, unsubscribe from events rather than guarding every handler with if (IsGameOver) return;.

    line 28
  5. Distinctive:

    When multiple independent systems react to the same occurrence (e.g., a grade result affecting score, HP, and combo), publish an event …

    line 34

≈ “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.

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

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 in Start().
  • 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.

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.