assembly-definitions
Assembly definition management — when to create asmdefs, reference rules, Editor/Runtime/Test separation, platform filters, compilation speed optimization.
UniTask async/await for Unity — zero-alloc async, cancellation tokens, PlayerLoop integration, async LINQ. Use instead of coroutines for cancellation support and cleaner async code.
$ npx -y skills add XeldarAlz/everything-claude-unity --skill unitask --agent claude-codeHow it fires
How this skill gets triggered: by you, by Claude, or both.
/unitaskContext preview
The summary Claude sees to decide when to auto-load this skill.
UniTask async/await for Unity — zero-alloc async, cancellation tokens, PlayerLoop integration, async LINQ. Use instead of coroutines for cancellation support and cleaner async code.
name: unitask description: "UniTask async/await for Unity — zero-alloc async, cancellation tokens, PlayerLoop integration, async LINQ. Use instead of coroutines for cancellation support and cleaner async code." globs: ["**/UniTask*", "**/*Async*.cs", "**/Cysharp*"]
UniTask (Cysharp) provides async/await that integrates natively with Unity's PlayerLoop, produces zero GC allocations, and supports proper cancellation. Prefer UniTask over coroutines and `System.Threading.Tasks.Task` in all Unity projects.
| Feature | Coroutine | Task | UniTask | |---------|-----------|------|---------| | GC allocation | Enumerator + box | Task object + state machine | Zero (struct-based) | | Cancellation | Manual flag | CancellationToken | CancellationToken | | Return values | No | Yes | Yes | | Exception handling | Swallowed silently | try/catch | try/catch | | Runs on thread pool | No | Yes (dangerous in Unity) | No (PlayerLoop) | | Awaitable | No | Yes | Yes |
using Cysharp.Threading.Tasks;
// Awaitable, returns nothing
public async UniTask LoadLevelAsync(CancellationToken ct)
{
await UniTask.Delay(1000, cancellationToken: ct);
}
// Awaitable, returns a value
public async UniTask<int> CalculateScoreAsync(CancellationToken ct)
{
await UniTask.Yield(ct);
return 100;
}
// Fire-and-forget (use sparingly, only at call boundaries)
public async UniTaskVoid OnButtonClickedAsync()
{
await DoSomethingAsync(this.GetCancellationTokenOnDestroy());
}// BAD — exceptions silently swallowed, no cancellation, GC allocation
public async void DoSomething() { ... }
// GOOD — proper error propagation, zero alloc
public async UniTask DoSomethingAsync(CancellationToken ct) { ... }
// GOOD — fire-and-forget with error logging
public async UniTaskVoid DoSomethingFireAndForget() { ... }// Time-based delays
await UniTask.Delay(1000, cancellationToken: ct); // Milliseconds
await UniTask.Delay(TimeSpan.FromSeconds(1.5f), cancellationToken: ct);
// Frame-based waits
await UniTask.Yield(); // Next frame
await UniTask.Yield(PlayerLoopTiming.FixedUpdate); // Next FixedUpdate
await UniTask.NextFrame(ct); // Explicit next frame
await UniTask.DelayFrame(5, cancellationToken: ct); // Wait N frames
// Condition waits
await UniTask.WaitUntil(() => _isReady, cancellationToken: ct);
await UniTask.WaitWhile(() => _isLoading, cancellationToken: ct);
await UniTask.WaitUntilValueChanged(transform, t => t.position, cancellationToken: ct);
// Unity async operation wrappers
await SceneManager.LoadSceneAsync("GameScene").ToUniTask(cancellationToken: ct);
await Resources.LoadAsync<Texture2D>("myTexture").ToUniTask(cancellationToken: ct);
await UnityWebRequest.Get(url).SendWebRequest().ToUniTask(cancellationToken: ct);Async operations that outlive their owning object cause `MissingReferenceException` and undefined behavior. Every async method must accept and respect a `CancellationToken`.
public class SimpleAsync : MonoBehaviour
{
private async UniTaskVoid Start()
{
// Token auto-cancels when this MonoBehaviour is destroyed
CancellationToken ct = this.GetCancellationTokenOnDestroy();
await UniTask.Delay(2000, cancellationToken: ct);
Debug.Log("This won't run if object was destroyed");
}
}public class ManagedAsync : MonoBehaviour
{
private CancellationTokenSource _cts;
private void OnEnable()
{
_cts = new CancellationTokenSource();
RunLoopAsync(_cts.Token).Forget();
}
private void OnDisable()
{
_cts?.Cancel();
_cts?.Dispose();
_cts = null;
}
private async UniTask RunLoopAsync(CancellationToken ct)
{
while (!ct.IsCancellationRequested)
{
await UniTask.Delay(1000, cancellationToken: ct);
DoPeriodicWork();
}
}
}public class LinkedTokenExample : MonoBehaviour
{
private CancellationTokenSource _actionCts;
public async UniTask PerformActionAsync()
{
// Cancel previous action if still running
_actionCts?.Cancel();
_actionCts?.Dispose();
_actionCts = new CancellationTokenSource();
// Link with destroy token so it cancels on either condition
CancellationToken destroyCt = this.GetCancellationTokenOnDestroy();
CancellationTokenSource linked = CancellationTokenSource.CreateLinkedTokenSource(
_actionCts.Token, destroyCt);
try
{
await DoWorkAsync(linked.Token);
}
catch (OperationCanceledException)
{
// Expected on cancellation — do nothing
}
finally
{
linked.Dispose();
}
}
}public async UniTask LoadDataAsync(CancellationToken ct)
{
try
{
await SomeAsyncOperation(ct);
}
catch (OperationCanceledException)
{
// Normal cancellation — cleanup silently
return;
}
catch (Exception ex)
{
// Actual error — log and handle
Debug.LogException(ex);
}
}UniTask hooks into Unity's PlayerLoop for precise timing control.
// Available timing points await UniTask.Yield(PlayerLoopTiming.Initialization); await UniTask.Yield(PlayerLoopTiming.E
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…