unity-ecs

A set of Unity rules for the Entity Component System and DOTS, where game data is stored in components and systems process that data, often in parallel.

In plain words
What is it for?
Use it when implementing performance-sensitive game systems with ISystem, IJobEntity, components, jobs, and Burst. It also covers system update requirements and Microsoft-style naming.
Why use it?
It standardizes the newer Unity performance-oriented approach and specifies how systems, jobs, Burst compilation, and component naming should be written.

Cursor rule for Cursor

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 rules/common-ka/ai-agent-unity-rules/unity-ecs
Clone the repo
git clone --depth 1 https://github.com/Common-ka/ai-agent-unity-rules

Made for: Cursor.

Per session 16 Only the description is in the session, so the agent can decide to use it. The body loads when it is invoked.
When invoked 592 The whole file, excluding the scripts and references it only reads on demand.
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.00016 $0.00592
Opus 5 $0.00008 $0.00296
Sonnet 5 $0.00003 $0.00118
Haiku 4.5 $0.00002 $0.00059

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

Security

Grade A, and why

unity-ecs 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.

.cursor/rules/unity-ecs.mdc · 101 lines

What it actually says

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;
    }
}
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 · 101 lines · 16 tokens per session scan A 39e0e85c2e41

Subscribe to this mod's changes

unity-ecs is a cursor rule published in the GitHub repository Common-ka/ai-agent-unity-rules (39 stars, last pushed 8mo ago), licensed MIT. It adds 16 tokens to every session and 592 once invoked, about $0.0001 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.