csharp-async
Installation
SKILL.md
C# Async Programming Best Practices
Apply these practices when writing, reviewing, or refactoring asynchronous C# code.
Naming Conventions
- Suffix all async methods with
Async(e.g.,GetDataAsyncfor a synchronousGetData) - Match names with synchronous counterparts when both exist
Return Types
- Return
Task<T>when the method produces a value - Return
Taskwhen the method has no return value - Use
ValueTask<T>when the method frequently completes synchronously (e.g., cache hits, short-circuit returns) — this avoids aTaskheap allocation on the hot path - Never return
async voidexcept in event handlers —async voidmethods swallow exceptions and cannot be awaited, making errors invisible to the caller
CancellationToken Propagation
CancellationTokens are the cooperative cancellation mechanism in .NET. Dropping a token silently means the user loses the ability to cancel an operation that might be long-running or expensive.