unity-unitask-design

Enforce source-anchored UniTask design rules for Unity async code.

6|Updated Apr 2, 2026
One-click install
npx skills add https://github.com/dyCuong03/unity-agent-team --skill unity-unitask-design
Or copy as Structured Prompt for Agent
Please help me install this Agent Skill.
Skill: unity-unitask-design
Source: https://github.com/dyCuong03/unity-agent-team/tree/main/.claude/skills/unity-skills/skills/unitask-design
Command: npx skills add https://github.com/dyCuong03/unity-agent-team --skill unity-unitask-design

SYSTEM DOCUMENTATION & REQUIREMENTS

💡 This Skill includes references (resource) components.

What problem does it solve?

This Skill prevents common, costly UniTask mistakes in Unity async code—double-await crashes, forgotten Forget(), wrong PlayerLoopTiming usage, cancellation misuse, and leak-prone subscriptions—by providing source-anchored design rules.

Core Features & Use Cases

  • Guardrails for UniTask correctness: enforces struct single-await semantics and when to use Preserve() to avoid invalid double-await.
  • Operational lifecycle rules: clarifies when to await, when to Forget(), and how exceptions flow through UniTaskScheduler.
  • Timing, cancellation, and interop guidance: explains PlayerLoopTiming slots and correct cancellation token propagation patterns, including GetCancellationTokenOnDestroy and AttachExternalCancellation.
  • Composable architecture for async systems: covers WhenAll/WhenAny patterns, AsyncOperation.ToUniTask, UniTask conversion from coroutines/enumerators, and async trigger usage.
  • Leak prevention and review readiness: consolidates known pitfall patterns (tracker issues, subscription disposal, and enumerator termination) into an actionable checklist for PRs and onboarding.

Quick Start

Load the unity-unitask-design Skill before writing or reviewing any UniTask, UniTaskVoid, cancellation, timing, or conversion code in your Unity project.

Frequently Asked Questions about unity-unitask-design

High-intent search queries and answers about installing and using this skill.

FAQPage Schema
How do I prevent double-await crashes when writing Unity UniTask async code?

To prevent double-await crashes in Unity UniTask async code, enforce struct single-await semantics and use Preserve() when you need to await the same UniTask instance multiple times. This avoids invalid struct re-evaluation and ensures safe async correctness.

When should I use Forget() instead of await in UniTask, and how are exceptions handled?

Use Forget() in UniTask when you need fire-and-forget execution without blocking the calling sequence, while understanding that unhandled exceptions flow through UniTaskScheduler. Awaiting is required when the caller must suspend until the async operation completes for proper operational lifecycle management.

What is the correct way to propagate cancellation tokens in Unity UniTask async methods?

Correct Unity UniTask cancellation token propagation involves using GetCancellationTokenOnDestroy for component lifecycle tracking and AttachExternalCancellation to link external tokens. Proper propagation ensures async operations terminate cleanly and prevents leak-prone subscriptions when GameObjects are destroyed.

How does PlayerLoopTiming affect UniTask async scheduling in Unity?

PlayerLoopTiming determines the exact Unity lifecycle slot where UniTask async continuations execute, such as Update or LateUpdate. Selecting the correct timing slot ensures async operations synchronize properly with the Unity frame loop and avoid execution order conflicts.

How do I convert coroutines and AsyncOperations to UniTask in Unity?

Convert Unity coroutines and enumerators to UniTask using built-in conversion APIs, and wrap AsyncOperations with AsyncOperation.ToUniTask to enable direct awaiting. This composable architecture allows seamless interoperability between traditional Unity async patterns and UniTask workflows.

What common leak patterns should I check when reviewing Unity UniTask code in a PR?

When reviewing Unity UniTask code in a PR, check for tracker issues, undisposed subscription leaks, and improper enumerator termination. Consolidate these pitfall patterns into an actionable checklist to ensure cancellation requirements are met and async correctness is maintained.