ai-agent-unity-rules / rules
Cursor rule40 starsChanged 12 months agoMITView on GitHub
DOTS, ECS, Job System, Burst, ISystem, IJobEntity
Where files are headingNew Cursor rule files have more rules about planning and tracking tasks, and fewer about code style.
Of the Cursor rule files we read, the 4,181 first seen in the last six months, against the older ones: the kind of rule that gained most share, and the kind that lost most. About files like this in general, not this one, and an estimate, since a kind is a pattern in the words.
In this repository8 other files it gives its agents.
- .cursor/rules/code-organization.mdcCursor rule
- .cursor/rules/unity-architecture.mdcCursor rule
- .cursor/rules/unity-core.mdcCursor rule
- .cursor/rules/unity-input.mdcCursor rule
- .cursor/rules/unity-networking.mdcCursor rule
- .cursor/rules/unity-performance.mdcCursor rule
- .cursor/rules/unity-testing.mdcCursor rule
- .cursor/rules/unity-ui.mdcCursor rule
The file
We split this unity-ecs.mdc into the rules it gives an agent
2 rules. About 0 are common, 1 is distinctive, and 1 is very specific to this project.
≈0
Common · estimate
Many files like this have a rule of this kind.
≈1
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 13
Follow Microsoft Naming Conventions: Use PascalCase for public fields in Jobs and Components.
- Very specific: line 77
Use this pattern when processing raw memory (NativeArray) outside of the ECS framework.
≈ “Common” is an estimate: at least 1 in 5 of the 6,668 Cursor rule 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
---
description: "DOTS, ECS, Job System, Burst, ISystem, IJobEntity"
alwaysApply: false
---
# Unity ECS & DOTS (Unity 6.2+)
## Core Principles
1. **Prefer `ISystem` (struct)** over `SystemBase` (class) to avoid GC overhead.
2. **Always use `[BurstCompile]`** for Systems and Jobs to unlock native performance.
3. **Use `IJobEntity`** for component iteration; it handles chunking and multithreading automatically.
4. **Follow Microsoft Naming Conventions**: Use **PascalCase** for public fields in Jobs and Components.
## Entity Component System
### 1. Component Data
```
using Unity.Entities;
using Unity.Mathematics;
public struct MovementSpeed : IComponentData
{
public float Value;
}
```
### 2. System (ISystem + IJobEntity)
This is the modern standard. It separates data iteration (Job) from the system lifecycle (System).
```
using Unity.Entities;
using Unity.Transforms;
using Unity.Burst;
using Unity.Mathematics;
[BurstCompile]
partial struct MovementSystem : ISystem
{
[BurstCompile]
public void OnCreate(ref SystemState state)
{
// Prevents the system from running if no entities have MovementSpeed
state.RequireForUpdate<MovementSpeed>();
}
[BurstCompile]
public void OnUpdate(ref SystemState state)
{
// Pass delta time into the job
float deltaTime = SystemAPI.Time.DeltaTime;
// Schedule the job to run in parallel across available worker threads
new MoveJob
{
DeltaTime = deltaTime
}.ScheduleParallel();
}
}
// The Source Generator automatically creates the optimized chunk iteration code for this job
[BurstCompile]
partial struct MoveJob : IJobEntity
{
public float DeltaTime;
// Use 'in' for read-only data to improve performance
private void Execute(ref LocalTransform transform, in MovementSpeed speed)
{
transform.Position += new float3(0, speed.Value * DeltaTime, 0);
}
}
```
## Job System (Native Arrays)
Use this pattern when processing raw memory (`NativeArray`) outside of the ECS framework.
```
using Unity.Jobs;
using Unity.Collections;
using Unity.Burst;
using Unity.Mathematics;
[BurstCompile]
public struct VelocityJob : IJobParallelFor
{
// Microsoft Style: Public fields should be PascalCase
public NativeArray<float3> Velocity;
[ReadOnly]
public NativeArray<float3> Acceleration;
public float DeltaTime;
public void Execute(int index)
{
Velocity[index] += Acceleration[index] * DeltaTime;
}
}
```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.

