Latest upstream author date included at this registry's pinned revision.

csharp-async

Synced v1.1.0 License: MIT Source: github/awesome-copilot/skills/csharp-async Commit: 4742f26 Latest included change:

Get best practices for C# async programming

Summary

Purpose
Guides the design and review of C# asynchronous code, with attention to task usage, exception propagation, and efficient concurrency.
When to use
Use it when writing or reviewing C# async methods, coordinating concurrent tasks, handling cancellation, or processing asynchronous streams.
Outputs
It points out async pitfalls and suggests improvements to method naming, return types, exception handling, cancellation, concurrency, and asynchronous patterns.
Upstream changes (7, latest included 2026-02-19)
caab1f6 Convert all prompts to skills and update plugin manifests The patch adds a C# async best-practices skill covering naming, return types, exception handling, performance, common pitfalls, and implementation patterns.
2f9c96d Fix deprecated 'mode' attribute in prompt files by renaming to 'agent' (#441) The prompt front matter renames the `mode` key to `agent` while keeping its value as `'agent'`.
2b45ca4 feat: update deprecated tool names to namespaced versions (#365) The prompt's tool list replaces `codebase` with `search/codebase`.
69cd4fa update `editFiles` to `edit/editFiles` (#319) The prompt's tool list replaces `editFiles` with `edit/editFiles`.
6fb794b Update development instructions and guidelines (#29) The prompt front matter changes the `mode`, `tools`, and `description` values from double-quoted to single-quoted strings.
9872a77 Improving the tools for prompts The prompt's tool list changes from `codebase` and `terminalCommand` to `changes`, `codebase`, `editFiles`, and `problems`.
4c8ad05 Initial setup of repo with prompts and instructions The initial patch adds the C# async best-practices prompt with agent metadata, `codebase`/`terminalCommand` tools, and guidance on naming, return types, exceptions, performance, pitfalls, and implementation patterns.
npx skills add "lettucebo/Skills#v2.2.0@csharp-async" --full-depth

⚠ Available after v2.2.0 is published

C# Async Programming Best Practices

Your goal is to help me follow best practices for asynchronous programming in C#.

Naming Conventions

  • Use the 'Async' suffix for all async methods
  • Match method names with their synchronous counterparts when applicable (e.g., GetDataAsync() for GetData())

Return Types

  • Return Task<T> when the method returns a value
  • Return Task when the method doesn't return a value
  • Consider ValueTask<T> for high-performance scenarios to reduce allocations
  • Avoid returning void for async methods except for event handlers

Exception Handling

  • Use try/catch blocks around await expressions
  • Avoid swallowing exceptions in async methods
  • Use ConfigureAwait(false) when appropriate to prevent deadlocks in library code
  • Propagate exceptions with Task.FromException() instead of throwing in async Task returning methods

Performance

  • Use Task.WhenAll() for parallel execution of multiple tasks
  • Use Task.WhenAny() for implementing timeouts or taking the first completed task
  • Avoid unnecessary async/await when simply passing through task results
  • Consider cancellation tokens for long-running operations

Common Pitfalls

  • Never use .Wait(), .Result, or .GetAwaiter().GetResult() in async code
  • Avoid mixing blocking and async code
  • Don't create async void methods (except for event handlers)
  • Always await Task-returning methods

Implementation Patterns

  • Implement the async command pattern for long-running operations
  • Use async streams (IAsyncEnumerable) for processing sequences asynchronously
  • Consider the task-based asynchronous pattern (TAP) for public APIs

When reviewing my C# code, identify these issues and suggest improvements that follow these best practices.

History

v1.0.0 bootstrap
v1.1.0 baseline-verified 4742f26
v1.1.0 license-refresh 4742f26