Skip to content

Repository files navigation

CodeMap for Unity

A small, always up-to-date Markdown map of your Unity C# codebase, built so AI coding agents read one index instead of your whole project.

CodeMap parses your scripts with Roslyn and writes docs/INDEX.md: every type and member with its signature, file:line, /// summary, which assembly depends on which, and which classes implement which interfaces. It regenerates on every script import. No build step, no server, no HTML site.

Works with Claude Code, Cursor, GitHub Copilot, Codex, Windsurf, Rider AI, or any agent that can read a file.

Why

In a large project an AI agent spends most of its context finding code: grepping, opening files, reading whole classes to learn one method signature. Then it often writes a helper you already have.

With CodeMap the agent reads the index first, knows what exists and where, and opens only the lines it needs:

  • Fewer tokens, cheaper sessions. One compact file replaces dozens of file reads.
  • More reuse. The agent sees the existing method before it writes a duplicate.
  • Safer changes. "Used by" shows what breaks when a module changes.
  • Readable by humans too. A lightweight API reference for the team, in plain Markdown.

What it looks like

docs/INDEX.md: module table, then everything visible outside its assembly:

## Modules
| Module | Pure C# | Root | Depends on | Used by |
|---|---|---|---|---|
| [Game.Inventory](index/Game.Inventory.md) | yes | Assets/Scripts/Inventory | Game.Items | Game.UI, Game.Save |
| [Game.UI](index/Game.UI.md) |  | Assets/Scripts/UI | Game.Inventory, Unity.TextMeshPro | — |

## Game.Inventory

### interface IInventory — IInventory.cs:6
What the player carries; other modules add, remove and observe items through it.
Implemented by: Inventory (Game.Inventory)
- `bool TryAdd(ItemId item, int count)` :10 — Adds items if there is room; false when full.
- `int CountOf(ItemId item)` :13 — undocumented
- `event Action<ItemId> Changed` :16 — Raised after any add or remove.

docs/index/Game.Inventory.md: the internal and private side of the same module:

### internal class Inventory : IInventory — Inventory.cs:8
undocumented
- `bool TryAdd(ItemId item, int count)` :21 (implements IInventory)
- `private int FreeSlots()` :48 — Slots not holding any stack.

Install

Requires Unity 6 (6000.0 or newer).

1. Add the NuGet registry

CodeMap uses Roslyn (Microsoft.CodeAnalysis.CSharp), served by UnityNuGet. A Unity package can't add registries by itself, so add this to Packages/manifest.json, next to "dependencies":

"scopedRegistries": [
  {
    "name": "Unity NuGet",
    "url": "https://unitynuget-registry.openupm.com",
    "scopes": [ "org.nuget" ]
  }
]

If you already have scopedRegistries, add only the inner object.

2. Add the package

Window → Package Manager → + → Add package from git URL…

https://github.com/olviia/unity-codemap.git

Or pin a version: https://github.com/olviia/unity-codemap.git#v0.2.0

Use

There's nothing to run. The index is rebuilt whenever scripts or .asmdef files are imported. To force a rebuild: Tools → CodeMap → Rebuild Index.

Then tell your agent to read it first. For example, add this to CLAUDE.md, AGENTS.md, .cursor/rules, or .github/copilot-instructions.md:

Before searching the code, read docs/INDEX.md: it lists every module, public type and
member with file:line. Internal and private members are in docs/index/<Module>.md.
Reuse what is listed there before writing new code. Open source files only at the listed lines.

Commit docs/ so the agent and your teammates always see the current map.

What gets indexed

Where What
docs/INDEX.md Module table (Depends on, Used by, engine-free or not) + everything visible outside its assembly: public and protected types and members, public fields included.
docs/index/<Module>.md Internal and private methods, properties, events, constructors and nested types.
Never Private fields, files marked <auto-generated>, code outside Assets/.
  • A module is an assembly: the nearest .asmdef or .asmref. Scripts without one go to Assembly-CSharp / Assembly-CSharp-Editor.
  • No naming or folder conventions. It reads only your code and your asmdefs.
  • One line per member: signature, file:line, the /// summary, or undocumented so gaps stay visible. Overrides and interface implementations show where they come from instead.
  • Incremental: unchanged files come from a cache in Library/CodeMap/.

How it compares

Tool Output For
CodeMap One compact Markdown index + one file per assembly, regenerated on import AI agents and quick human lookup
Doxygen / DocFX Full HTML documentation site, separate build Published API docs
Visual Studio Code Map Interactive dependency diagrams Visual exploration in VS Enterprise
Repo-map tools (e.g. Aider's) Generic, ranked, built per session Any language, not Unity assemblies

You might be looking for this if you searched for

  • How to give Claude Code / Cursor / Copilot context about a large Unity project
  • Reduce AI token usage on a big Unity codebase
  • Unity C# API index / code map / symbol index / project map for LLMs
  • Auto-generate documentation of Unity scripts in Markdown
  • List all classes, methods and interfaces in a Unity project
  • Unity assembly definition (asmdef) dependency graph / table
  • Find which class implements an interface in Unity
  • llms.txt or AGENTS.md context for a Unity game
  • Lightweight Doxygen alternative for Unity

Limitations

  • Syntax-only parsing: implementers and overrides are matched by name and parameter types inside your project, not through a full compile.
  • Output folder is fixed to docs/; only Assets/ is scanned.
  • Roslyn is pinned to 5.6.0 (newer UnityNuGet builds need missing prerelease analyzers).

License

MIT © Olviia Stroivans

About

Auto-generated Markdown map of your Unity C# codebase: every type and member with file:line, docs, assembly dependencies and implementers. AI coding agents (Claude Code, Cursor, Copilot) read one small index instead of the whole project.

Topics

Resources

Stars

0 stars

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages