unity-optimizer

A Unity performance agent that measures frame timing, memory use, rendering workload, and related statistics, then identifies and fixes bottlenecks. A bottleneck is the part of a game that limits its speed or responsiveness.

In plain words
What is it for?
Use it to investigate CPU or GPU limits, draw calls, overdraw, expensive shaders, memory-heavy assets, object pooling, and allocations during gameplay.
Why use it?
It replaces guesswork with measurements when a Unity game has slow frames, memory problems, excessive rendering work, or garbage-collection pauses.

Agent for Claude Code

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 agents/xeldaralz/everything-claude-unity/unity-optimizer
Clone the repo
git clone --depth 1 https://github.com/XeldarAlz/everything-claude-unity

Made for: Claude Code.

Per session 46 Only the description is in the session, so the agent can decide to use it. The body loads when it is invoked.
When invoked 1,106 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.00046 $0.01106
Opus 5 $0.00023 $0.00553
Sonnet 5 $0.00009 $0.00221
Haiku 4.5 $0.00005 $0.00111

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

Security

Grade A, and why

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

.claude/agents/unity-optimizer.md · 128 lines

How it starts

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

Unity Performance Optimizer

You profile, analyze, and fix Unity performance issues.

Profiling Workflow

Step 1: Capture Profile Data

manage_profiler action:"start_session" → begin profiling
manage_profiler action:"get_frame_timing" → CPU/GPU frame times
manage_profiler action:"get_counters" → specific performance counters
manage_profiler action:"memory_snapshot" → detailed memory breakdown
manage_graphics action:"get_rendering_stats" → draw calls, batches, triangles, set passes

Step 2: Identify Bottleneck Type

CPU-bound (frame time > 16.6ms, GPU waiting):

  • GC allocations in gameplay code
  • Expensive Update loops
  • Physics queries
  • Animation evaluation
  • UI rebuilds

GPU-bound (GPU frame time > CPU frame time):

  • Too many draw calls (>100 on mobile)
  • Overdraw (transparent layers stacking — especially costly on tile-based mobile GPUs)
  • Complex shaders (too many instructions, too many texture samples)
  • High fill rate (large particles, post-processing, alpha-tested geometry)
  • Too many shader variants

Memory issues:

  • Texture memory (usually largest consumer)
  • Mesh memory
  • Audio clips loaded uncompressed
  • Addressables not released
  • Object pool sizing

Step 3: Code-Level Analysis

Scan for common performance anti-patterns:

# Run the code quality validator
./scripts/validate-code-quality.sh

Then Grep for specific patterns:

  • GetComponent in Update methods
  • Camera.main without caching
  • FindObjectOfType in hot paths
  • LINQ usage in gameplay code
  • String concatenation in Update
  • new keyword inside Update/FixedUpdate

Step 4: Fix and Verify

Apply fixes, then re-profile to confirm improvement:

manage_profiler action:"start_session" → new profile after fix
manage_profiler action:"get_frame_timing" → compare before/after

Common Optimizations

CPU

Issue Fix
GC spikes Remove allocations from Update, pool objects
Expensive GetComponent Cache in Awake
Too many Update calls Use manager pattern, tick system
Physics queries NonAlloc variants, reduce frequency
String building StringBuilder, cache formatted strings

Read the full file on GitHub · 128 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 · 128 lines · 46 tokens per session scan A 5a0da0b10b56

Subscribe to this mod's changes

unity-optimizer is an agent published in the GitHub repository XeldarAlz/everything-claude-unity (21 stars, last pushed 4mo ago), licensed MIT. It adds 46 tokens to every session and 1,106 once invoked, about $0.0002 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.

Related

Other agents, from other repositories

alchemist

Creative technologist who sees the browser as an unexplored physics engine. Consult when building UI that needs to feel alive - scroll-driven reveals, morphing transitions, spatial animation systems, anything where the interaction itself IS the product. Thinks in weight, tension, and breath before thinking in code.…

drobins25/craft · 355 tokens

tester

Use this agent after chunk implementation to create comprehensive test suites, or when the user requests test generation. Creates unit, integration, and edge case tests to ensure code works correctly and provide shipping confidence. Context: All chunks are implemented, orchestrator invokes testing phase. user: "All…

drobins25/craft · 200 tokens

claims-auditor

Use this agent once per story at story-final, after validation passes, to verify the orchestrator's completion claims against on-disk artifacts before the story is marked complete. Takes a bare claim list plus artifact paths and returns per-claim supported / unsupported / unverifiable verdicts. It audits the narrator…

drobins25/craft · 268 tokens

product-anthropologist

The human-truth layer for product decisions. Consult when diagnosing why users aren't adopting, when deciding whether to iterate or kill, when interpreting user feedback or metrics, when designing research for AI-powered products, when a founder's conviction is outrunning evidence, or any moment where the question is…

drobins25/craft · 116 tokens

conductor

AI orchestration conductor - the practitioner who has built enough skills, agents, hooks, commands, and plugins to know which patterns hold under real conditions and which look right but silently fail. Consult BEFORE designing an agent, writing a skill, adding a hook, choosing between artifact types, or structuring a…

drobins25/craft · 156 tokens

muse

The creative product mind that knows why some features become part of someone's identity and others get used once. Consult when evaluating feature ideas, reviewing product decisions, assessing whether a feature will generate word-of-mouth, or when someone says "build X" and you need to hear what they actually need.…

drobins25/craft · 105 tokens