assembly-definitions
Assembly definition management — when to create asmdefs, reference rules, Editor/Runtime/Test separation, platform filters, compilation speed optimization.
Object pooling patterns — Unity ObjectPool<T>, custom ComponentPool, warm-up strategies, return-to-pool lifecycle. Eliminates runtime Instantiate/Destroy overhead.
$ npx -y skills add XeldarAlz/everything-claude-unity --skill object-pooling --agent claude-codeHow it fires
How this skill gets triggered: by you, by Claude, or both.
/object-poolingContext preview
The summary Claude sees to decide when to auto-load this skill.
Object pooling patterns — Unity ObjectPool<T>, custom ComponentPool, warm-up strategies, return-to-pool lifecycle. Eliminates runtime Instantiate/Destroy overhead.
name: object-pooling description: "Object pooling patterns — Unity ObjectPool<T>, custom ComponentPool, warm-up strategies, return-to-pool lifecycle. Eliminates runtime Instantiate/Destroy overhead." alwaysApply: true
Every `Instantiate()` allocates memory. Every `Destroy()` triggers GC. Pool objects you create and destroy frequently: projectiles, particles, enemies, pickups, audio sources.
using UnityEngine.Pool;
public sealed class ProjectilePool : MonoBehaviour
{
[SerializeField] private Projectile _prefab;
[SerializeField] private int _defaultCapacity = 20;
[SerializeField] private int _maxSize = 100;
private ObjectPool<Projectile> _pool;
private void Awake()
{
_pool = new ObjectPool<Projectile>(
createFunc: CreateProjectile,
actionOnGet: OnGetProjectile,
actionOnRelease: OnReleaseProjectile,
actionOnDestroy: OnDestroyProjectile,
collectionCheck: false,
defaultCapacity: _defaultCapacity,
maxSize: _maxSize
);
}
public Projectile Get() => _pool.Get();
public void Release(Projectile projectile) => _pool.Release(projectile);
private Projectile CreateProjectile()
{
Projectile projectile = Instantiate(_prefab);
projectile.SetPool(this);
return projectile;
}
private void OnGetProjectile(Projectile projectile)
{
projectile.gameObject.SetActive(true);
}
private void OnReleaseProjectile(Projectile projectile)
{
projectile.gameObject.SetActive(false);
}
private void OnDestroyProjectile(Projectile projectile)
{
Destroy(projectile.gameObject);
}
}
// Projectile returns itself to pool
public sealed class Projectile : MonoBehaviour
{
private ProjectilePool _pool;
public void SetPool(ProjectilePool pool) => _pool = pool;
public void ReturnToPool()
{
_pool.Release(this);
}
}Pre-instantiate objects during loading to avoid runtime hitches:
private void Start()
{
// Pre-warm the pool
List<Projectile> temp = new List<Projectile>();
for (int i = 0; i < _defaultCapacity; i++)
{
temp.Add(_pool.Get());
}
for (int i = 0; i < temp.Count; i++)
{
_pool.Release(temp[i]);
}
temp.Clear();
}The key contract: **objects must reset their state when returned to pool.**
private void OnReleaseProjectile(Projectile projectile)
{
// Reset state
projectile.transform.position = Vector3.zero;
projectile.transform.rotation = Quaternion.identity;
projectile.ResetState(); // Clear velocity, damage flags, timers
// Deactivate
projectile.gameObject.SetActive(false);
}**Pool these:**
**Don't pool these:**
public sealed class PoolManager : MonoBehaviour
{
private readonly Dictionary<GameObject, ObjectPool<GameObject>> _pools = new();
public GameObject Get(GameObject prefab, Vector3 position, Quaternion rotation)
{
if (!_pools.ContainsKey(prefab))
{
_pools[prefab] = new ObjectPool<GameObject>(
() => Instantiate(prefab),
obj => obj.SetActive(true),
obj => obj.SetActive(false),
obj => Destroy(obj),
false, 10, 100
);
}
GameObject obj = _pools[prefab].Get();
obj.transform.SetPositionAndRotation(position, rotation);
return obj;
}
public void Release(GameObject prefab, GameObject instance)
{
_pools[prefab].Release(instance);
}
}Don't forget to pool `WaitForSeconds`:
// BAD — allocates every time yield return new WaitForSeconds(0.5f); // GOOD — cache and reuse private readonly WaitForSeconds _halfSecond = new WaitForSeconds(0.5f); yield return _halfSecond;
The ultimate Claude Code toolkit for Unity game development. A production-ready, plug-and-play system that gives Claude Code deep Unity expertise — from writing performant C# to building scenes, profiling performance, and triggering iOS/Android builds — all
Assembly definition management — when to create asmdefs, reference rules, Editor/Runtime/Test separation, platform filters, compilation speed optimization.
Structured commit trailers — adds Constraint, Rejected, Scope-risk, and Not-tested metadata to commit messages. Captures architectural decisions and known gaps…
Ambiguity gating — detects vague feature requests and forces structured requirements gathering with scoring across scope, platform, performance, integration,…
Event system patterns — C# events, UnityEvent, SO event channels, static EventBus. When to use each, zero-allocation patterns, memory leak prevention.
Configures Claude Code's statusline to display Unity workflow state — current phase, active agent, files modified, and session duration.
Post-debugging knowledge extraction — captures non-obvious, codebase-specific learnings that pass quality gates. Invoke after resolving tricky bugs or…