rm-guide-async

Enforce C# async naming, awaiting, and cancellation best practices.

Updated Nov 11, 2023
One-click install
npx skills add https://github.com/michaelvolz/redmuffin.Blazor.StaticWeb --skill rm-guide-async
Or copy as Structured Prompt for Agent
Please help me install this Agent Skill.
Skill: rm-guide-async
Source: https://github.com/michaelvolz/redmuffin.Blazor.StaticWeb/tree/main/.opencode/skills/redmuffin-standards/rm-guide-async
Command: npx skills add https://github.com/michaelvolz/redmuffin.Blazor.StaticWeb --skill rm-guide-async

SYSTEM DOCUMENTATION & REQUIREMENTS

What problem does it solve?

Async methods can become brittle when naming, awaiting, and cancellation patterns diverge, leading to deadlocks, swallowed exceptions, or blocked thread pools. This guidance ensures Task-based code stays non-blocking, configurable, and cancellation-aware across libraries and APIs.

Core Features & Use Cases

  • Naming and Return Values: Append Async to asynchronous method names and return Task or Task<T> to clearly signal their behavior.
  • Awaiting Practices: Never block on asynchronous work and apply ConfigureAwait(false) in library code while leveraging Task.WhenAll/WhenAny for parallel or timeout handling.
  • Cancellation and Ownership: Pass CancellationToken through long-running flows, especially for HTTP, database, and background work, and avoid unmanaged background tasks without clear ownership.
  • Use Case Example: Refactor a data-fetching service to embrace these rules so HTTP clients, timers, and database calls remain cancellable and exception-safe.

Quick Start

Apply the rm-guide-async checklist to this new API method to ensure it returns Task, avoids blocking calls, and propagates its cancellation tokens.

Frequently Asked Questions about rm-guide-async

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

FAQPage Schema
How do I prevent deadlocks in C# async methods?

Prevent deadlocks in C# async methods by avoiding blocking waits, applying ConfigureAwait(false) in library code, and ensuring Task-based operations stay non-blocking across HTTP and database flows.

What are the best practices for CancellationToken propagation in Task-based APIs?

Best practices for CancellationToken propagation require passing the token through long-running flows, especially for HTTP clients, database access, and background work, ensuring tasks remain cancellation-aware.

How do I refactor a data-fetching service to use Task<T> and avoid swallowed exceptions?

Refactor a data-fetching service by returning Task or Task<T>, appending Async to method names, and leveraging Task.WhenAll or WhenAny for parallel timeout handling to keep exception-safe.

When should I apply ConfigureAwait(false) in C# library code?

Apply ConfigureAwait(false) in C# library code whenever asynchronous methods interact with I/O, ensuring non-blocking Task operations and preventing thread pool starvation or deadlocks.

Does this async guidance apply to timers and background flows?

Yes, this async guidance applies to timers and background flows, ensuring they interact with I/O safely by propagating CancellationToken parameters and avoiding unmanaged background tasks without clear ownership.