unity-code-style-guide AGENTS.md

Project-specific coding rules for Unity 6 and C# projects. Unity is a game-development editor and engine; these instructions specify the project’s versions, rendering, input, user-interface, asynchronous-code, and object-pooling choices.

In plain words
What is it for?
Use them when editing Unity code, especially setup, input, UI, asynchronous tasks, pooling, and project files such as Unity metadata.
Why use it?
They prevent code that conflicts with the project’s chosen systems or silently damages Unity files. They also separate required practices from optional style preferences.

Instructions file for CodexOpenCode

Install

Getting it into your agent

One page per mod, every tool's command on it. A separate URL per tool would split the same page into five that compete with each other.

agentmods
npx agentmods add instructions/krogh-jacobsen/unity-code-style-guide/agents-md
Clone the repo
git clone --depth 1 https://github.com/krogh-jacobsen/unity-code-style-guide

Made for: Codex, OpenCode.

Per session 4,528 This file is loaded in full into every session.
When invoked 4,528 The same file — it is already loaded in full.
Security scan A 0 findings. Scan, not verified.
Origin original No closer match found in the catalogue.
Token cost

What it costs to keep this loaded

Counted locally with the o200k_base tokenizer, which is exact for GPT models; Claude uses its own tokenizer and its counts differ. Treat this as one consistent yardstick across the catalogue rather than a bill. Prices are per million input tokens.

ModelPer sessionOnce invoked
Fable 5 $0.04528 $0.04528
Opus 5 $0.02264 $0.02264
Sonnet 5 $0.00906 $0.00906
Haiku 4.5 $0.00453 $0.00453

Measured 2d ago against content hash a7926f6dd7df, method: parsed. Prices are Anthropic first-party input rates as of 2026-08-30, from the pricing page.

Security

Grade A, and why

unity-code-style-guide AGENTS.md scanned grade A with 0 findings against 26 rules in 11 categories — prompt injection, anti-refusal, data exfiltration, privilege escalation, supply chain, agent snooping, system-prompt leakage, SSRF and excessive agency — measured 2d ago.

A static scan of the body, not an audit. Every finding is printed with the line that produced it so you can judge whether it matters here. A mod is markdown that instructs an agent; that is exactly why what it instructs is worth reading.

Nothing flagged

None of the 26 patterns this scan looks for appear in this file: no shell pipes, no recursive deletes, no credential paths, no hidden text, no instruction-override or anti-refusal phrasing, no agent-config snooping. That is not a guarantee, it is the absence of the things that are checkable.

AGENTS.md · 358 lines

How it starts

The opening of the file, as written. The whole thing — 358 lines — stays where its author put it; the contents beside it link to each section on GitHub.

AGENTS.md — Unity 6 C#

Coding conventions for this Unity project. Copy this file into your own repo and edit the Project Setup block below — everything else is ready to use as-is.

Rules marked [opinion] are stylistic preferences, not industry consensus. Change them freely as long as you change them everywhere. Everything unmarked is standard Unity or C# practice and should survive contact with any team.


Project Setup — EDIT THIS BLOCK

Unity version:    6.3 (6000.3.x)
C# version:       9.0
Render pipeline:  URP
Input:            Input System package  (NOT the legacy Input Manager)
UI:               UI Toolkit            (NOT uGUI / Canvas)
Async:            Awaitable             (NOT coroutines, unless per-frame iteration is needed)
Pooling:          UnityEngine.Pool.ObjectPool<T>

Never generate code for a system listed as "NOT". If the project uses something different, change the block above first.


Never do these — they corrupt the project

Style mistakes produce ugly code. These produce a broken Unity project, and the damage is often silent until someone opens the Editor.

  • Never create or hand-edit a .meta file. Unity owns the GUID inside it. A wrong or duplicated GUID breaks every reference to that asset, across every scene and prefab.
  • Never edit .asset, .prefab, .unity, .controller, .mat, or .anim YAML directly. They carry fileID + GUID pairs that must stay internally consistent. Use the Editor, or an Editor script that goes through AssetDatabase / SerializedObject.
  • Never move, rename, or delete an asset with filesystem commands (mv, rm, git mv). The .meta must travel with it. Use the Project window or AssetDatabase.MoveAsset.
  • Never rename a serialized field without [FormerlySerializedAs("oldName")]. Serialization is keyed on the field name — the Inspector value is silently lost on every asset and scene using it.
  • Never reorder or renumber the members of a serialized enum. They persist as integers, so existing assets silently remap to different values. Append new members at the end.
  • ⚠️ Don't edit ProjectSettings/*.asset or Packages/manifest.json while the Editor is open — it may overwrite your change when it regains focus.
  • ⚠️ Library/, Temp/, obj/, Logs/ and UserSettings/ are generated. Never edit them, never commit them.

Read the full file on GitHub · 358 lines

Changes

What this file has done since we first saw it

Hashed on every crawl. A supply-chain change to an agent config is a question of when, not whether, so the history is kept rather than the latest state alone.

  1. 2d ago First seen · 358 lines · 4,528 tokens per session scan A a7926f6dd7df

Subscribe to this mod's changes

unity-code-style-guide AGENTS.md is an instructions file published in the GitHub repository krogh-jacobsen/unity-code-style-guide (20 stars, last pushed 4d ago), licensed MIT. It adds 4,528 tokens to every session, about $0.0226 per session on Opus 5. A static security scan graded it A with 0 findings. No closer match exists in the catalogue, so it is treated as the original; first seen 2026-08-30.