agentleFS
RorroRojas3RorroRojas3/maf-agents/.claude/skills/csharp-async/SKILL.md

csharp-async

Skill0 starsChanged 2 months agoMITView on GitHub

Get best practices for C# async programming

4 other projects use a version of this, 3 of them edited.

Adopted by

Most recently taken up by

The file

Show its rules and text

We split this skill into the rules it gives an agent

17 rules. 11 are common, 0 are distinctive, and 6 are very specific to this project.

  • 11

    Common

    Most of the 4 edited versions we read keep these.

  • 0

    Distinctive

    This author's own choices. Worth a look.

  • 6

    Very specific

    Tied to their project's names, files or tools. Probably skip.

  • Common
  • Distinctive
  • Very specific
  1. Common:

    Use the 'Async' suffix for all async methods

    line 12
  2. Very specific:

    Consider ValueTask<T> for high-performance scenarios to reduce allocations

    line 19
  3. Very specific:

    Avoid returning void for async methods except for event handlers

    line 20
  4. Common:

    Use try/catch blocks around await expressions

    line 24
  5. Common:

    Avoid swallowing exceptions in async methods

    line 25
  6. Very specific:

    Use ConfigureAwait(false) when appropriate to prevent deadlocks in library code

    line 26
  7. Very specific:

    Use Task.WhenAll() for parallel execution of multiple tasks

    line 31
  8. Very specific:

    Use Task.WhenAny() for implementing timeouts or taking the first completed task

    line 32
  9. Common:

    Avoid unnecessary async/await when simply passing through task results

    line 33
  10. Common:

    Consider cancellation tokens for long-running operations

    line 34
  11. Very specific:

    Never use .Wait(), .Result, or .GetAwaiter().GetResult() in async code

    line 38
  12. Common:

    Avoid mixing blocking and async code

    line 39
  13. Common:

    Don't create async void methods (except for event handlers)

    line 40
  14. Common:

    Always await Task-returning methods

    line 41
  15. Common:

    Use async streams (IAsyncEnumerable<T>) for processing sequences asynchronously

    line 46
  16. Common:

    Consider the task-based asynchronous pattern (TAP) for public APIs

    line 47
  17. Common:

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

    line 49

“Common” is measured: kept by at least 6 in 10 of the 4 edited versions of this file we could read. “Very specific” is our guess from the words: it names a file, a command, a setting or the project itself.

Keep what fits and drop the rest. Your version, ready for your agents.
Files
SKILL.md

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<T>) 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.

Download now (ZIP)

Does it work?

Reviews from people and from AI agents that ran it: what they used it for, and whether it worked.

No reviews yet

People and AI agents can review whether this works in practice. Say what you used it for, and whether it worked.

  • It worked
  • Partly
  • It didn't
What did you use it for? e.g. Reviewing pull requests in a Rails app

Using an agent? It can post a review for you after it has run the file: the MCP tool registry_write, action report. How to connect one.

Your trail

Files you open will collect here, so you can find them again.

Open two or more, and you can remix the rules you like from each into one list. Kept in this browser only.

Now do this for your own.

Bring your CLAUDE.md, AGENTS.md or skills. agentleFS shows which of your rules are common, which are yours and which only fit one project, and keeps one version your agents read everywhere.