Agent skill

Csharp Async Patterns

by sketch7 in sketch7/FluentlyHttpClient

A skill your agent uses when C async/await patterns including Task, ValueTask, async streams, and cancellation.

MITAuto-check: notesDevelopment

Install Csharp Async Patterns

skills CLI
$ npx skills add sketch7/FluentlyHttpClient --skill csharp-async-patterns -a claude-code

Project install by default; add -g for ~/.claude/skills/.

GitHub CLI
$ gh skill install sketch7/FluentlyHttpClient csharp-async-patterns --agent claude-code

Project scope by default; add --scope user for a personal install. Needs GitHub CLI 2.90.0 or later (public preview).

Manual copy
$ git clone --depth 1 https://github.com/sketch7/FluentlyHttpClient.git skills-src && mkdir -p .claude/skills && cp -r skills-src/.agents/skills/csharp-async-patterns .claude/skills/csharp-async-patterns && rm -rf skills-src

Use ~/.claude/skills/ instead of .claude/skills for a personal install. The folder must contain SKILL.md.

Claude Code skills documentation · loads skills from .claude/skills/

Facts

Skill name
csharp-async-patterns
GitHub stars
121
Used in
1 other repo
Token cost
~5.9k tokens
SKILL.md length
512 words
Files
1
Skills in repo
4
Repo updated
First seen
Licence
MIT

At a glance

A skill your agent uses when C async/await patterns including Task, ValueTask, async streams, and cancellation.

  • Works in 10 steps: Async All the Way: Never block on async… → Use CancellationToken: Always accept… → ConfigureAwait in Libraries: Use… → …
  • C async/await patterns including Task
  • SKILL.md covers Async/Await Fundamentals, Task and Task<T>, ValueTask and ValueTask<T> and Async Void vs Async Task, plus 6 more sections
  • Instructions only: no scripts, shell commands, URLs or credentials in SKILL.md

What it does

Csharp Async Patterns is an agent skill from sketch7/FluentlyHttpClient. Use when C async/await patterns including Task, ValueTask, async streams, and cancellation. Use when writing asynchronous C code.

Its SKILL.md is about 5.9k tokens, which your agent loads only when the skill is triggered. It is a single SKILL.md file with no bundled scripts.

It sits in Development, covering Async programming. It works with C#. The repository describes itself as: Http Client for .NET Standard with fluent APIs which are intuitive, easy to use and also highly extensible. The licence is MIT.

When your agent uses it

  • C async/await patterns including Task
  • Writing asynchronous C code

Example prompts

  • “/csharp-async-patterns”

Requirements

  • Pre-approved tools (allowed-tools): Bash, Read, Write, Edit

Workflow steps

10 steps, taken from the first numbered list in SKILL.md.

  1. Async All the Way: Never block on async code with .Result or .Wait()
  2. Use CancellationToken: Always accept CancellationToken for long-running operations
  3. ConfigureAwait in Libraries: Use ConfigureAwait(false) in library code
  4. Avoid Async Void: Only use async void for event handlers
  5. Return Task Directly: When possible, return the Task directly without await
  6. Use ValueTask for Hot Paths: Consider ValueTask for frequently-called,
  7. Handle All Exceptions: Always handle exceptions in async methods
  8. Don't Mix Blocking and Async: Choose one paradigm per call chain
  9. Dispose Async Resources: Use await using for IAsyncDisposable
  10. Test with Cancellation: Test that cancellation works correctly

What it can do on your machine

Read from SKILL.md and the folder at commit 397ee9b. It shows what the files ask for, not the result of running them.

  • Tool permissions

    Pre-approves these tools, so the agent can use them without asking each time:

    • Bash
    • Read
    • Write
    • Edit

    From allowed-tools in the SKILL.md frontmatter.

  • Runs code

    No scripts in the folder and no shell commands in SKILL.md (its code samples are csharp).

    From the folder's file list and the shell code blocks in SKILL.md.

  • Network

    Links to these hosts (documentation or services it may open):

    • learn.microsoft.com
    • devblogs.microsoft.com

    From URLs in SKILL.md, links to its own repository left out.

  • Credentials

    Names no API keys, tokens, secrets or passwords.

    From names ending in _API_KEY, _TOKEN, _SECRET, _KEY or _PASSWORD in SKILL.md.

Context cost

Csharp Async Patterns loads about 5.9k tokens when it runs. Until then it costs about 38 tokens; SKILL.md has 512 words of instructions outside code blocks.

Always · name and description, kept in context so the agent knows when to use it
~38
When it runs · the whole SKILL.md, loaded when a task matches
~5.9k

Estimates: characters ÷ 4, the usual rule of thumb; real counts depend on the model's tokenizer. Scripts and assets cost tokens only if the agent reads them.

Safety

Auto-check: notes

The automated check noted patterns worth knowing about, such as sudo or a known installer.

  • NotePre-approves every shell command (allowed-tools: Bash)SKILL.md
    allowed-tools: Bash, Read, Write, Edit

Automated static check — not a guarantee. Review scripts before installing. It scans the text of SKILL.md for risky patterns (piping downloads into a shell, reading credential files, hidden Unicode, destructive commands); files beside SKILL.md are not scanned.

SKILL.md

The full file from sketch7/FluentlyHttpClient at commit 397ee9b, republished under its MIT licence (© sketch7). 512 words, ~5,852 tokens.

Download SKILL.mdSave it as .claude/skills/csharp-async-patterns/SKILL.md (or your agent's skills folder).
name
csharp-async-patterns
description
Use when C# async/await patterns including Task, ValueTask, async streams, and cancellation. Use when writing asynchronous C# code.
allowed-tools
Bash, Read, Write, Edit
user-invocable
false

C# Async Patterns

Master asynchronous programming in C# using async/await, Task, ValueTask, async streams, and cancellation patterns. This skill covers modern asynchronous patterns from C# 8-12 for building responsive, scalable applications.

Async/Await Fundamentals

The async/await pattern provides a simple way to write asynchronous code that looks and behaves like synchronous code.

Basic Async Method
csharp
public async Task<string> FetchDataAsync(string url)
{
    using var client = new HttpClient();
    string result = await client.GetStringAsync(url);
    return result;
}

// Calling the async method
public async Task ProcessAsync()
{
    string data = await FetchDataAsync("https://api.example.com/data");
    Console.WriteLine(data);
}
Async Method Signature Rules
csharp
// ✅ Correct - Returns Task
public async Task ProcessDataAsync()
{
    await Task.Delay(1000);
}

// ✅ Correct - Returns Task<T>
public async Task<int> CalculateAsync()
{
    await Task.Delay(1000);
    return 42;
}

// ⚠️ Only for event handlers - Returns void
public async void Button_Click(object sender, EventArgs e)
{
    await ProcessDataAsync();
}

// ❌ Wrong - Not async but returns Task
public Task WrongAsync()
{
    // Should be async or use Task.FromResult
    return Task.CompletedTask;
}

Task and Task<T>

Task represents an asynchronous operation. Task<T> represents an operation that returns a value.

Creating Tasks
csharp
// Task.Run for CPU-bound work
public async Task<int> CalculateSumAsync(int[] numbers)
{
    return await Task.Run(() => numbers.Sum());
}

// Task.FromResult for already-computed values
public Task<string> GetCachedValueAsync(string key)
{
    if (_cache.TryGetValue(key, out var value))
    {
        return Task.FromResult(value);
    }
    return FetchFromDatabaseAsync(key);
}

// Task.CompletedTask for void async methods
public Task ProcessIfNeededAsync(bool condition)
{
    if (!condition)
    {
        return Task.CompletedTask;
    }
    return DoActualWorkAsync();
}
Task Composition
csharp
public async Task<Result> ProcessOrderAsync(Order order)
{
    // Sequential execution
    await ValidateOrderAsync(order);
    await ChargePaymentAsync(order);
    await ShipOrderAsync(order);

    return new Result { Success = true };
}

public async Task<Result> ProcessOrderParallelAsync(Order order)
{
    // Parallel execution
    var validationTask = ValidateOrderAsync(order);
    var inventoryTask = CheckInventoryAsync(order);
    var pricingTask = CalculatePricingAsync(order);

    await Task.WhenAll(validationTask, inventoryTask, pricingTask);

    return new Result
    {
        IsValid = await validationTask,
        InStock = await inventoryTask,
        Price = await pricingTask
    };
}

ValueTask and ValueTask<T>

ValueTask is a performance optimization for scenarios where the result is often available synchronously.

When to Use ValueTask
csharp
public class CachedRepository
{
    private readonly Dictionary<int, User> _cache = new();
    private readonly IDatabase _database;

    // ✅ Good use of ValueTask - often returns synchronously
    // from cache
    public ValueTask<User> GetUserAsync(int id)
    {
        if (_cache.TryGetValue(id, out var user))
        {
            return ValueTask.FromResult(user);
        }

        return new ValueTask<User>(FetchUserFromDatabaseAsync(id));
    }

    private async Task<User> FetchUserFromDatabaseAsync(int id)
    {
        var user = await _database.QueryAsync<User>(id);
        _cache[id] = user;
        return user;
    }
}
ValueTask Best Practices
csharp
public class BufferedReader
{
    private readonly byte[] _buffer = new byte[4096];
    private int _position;
    private int _length;

    // ValueTask for hot path optimization
    public async ValueTask<byte> ReadByteAsync()
    {
        if (_position < _length)
        {
            // Synchronous path - no allocation
            return _buffer[_position++];
        }

        // Asynchronous path - read more data
        await FillBufferAsync();
        return _buffer[_position++];
    }

    private async Task FillBufferAsync()
    {
        _length = await _stream.ReadAsync(_buffer);
        _position = 0;
    }
}

// ⚠️ ValueTask rules
public async Task ConsumeValueTaskAsync()
{
    var reader = new BufferedReader();

    // ✅ Correct - await once
    byte b = await reader.ReadByteAsync();

    // ❌ Wrong - don't store ValueTask
    var task = reader.ReadByteAsync();
    await task; // Potential issues

    // ❌ Wrong - don't await multiple times
    var vt = reader.ReadByteAsync();
    await vt;
    await vt; // NEVER do this
}

Async Void vs Async Task

Understanding when to use async void (rarely) versus async Task (almost always).

The Async Void Problem
csharp
// ❌ Bad - Cannot await, exceptions unhandled
public async void ProcessDataBadAsync()
{
    await Task.Delay(1000);
    throw new Exception("Unhandled!"); // Crashes app
}

// ✅ Good - Can await, exceptions handled
public async Task ProcessDataGoodAsync()
{
    await Task.Delay(1000);
    throw new Exception("Handled!"); // Can be caught
}

// Usage
public async Task CallerAsync()
{
    try
    {
        // Cannot await async void
        ProcessDataBadAsync(); // Fire and forget - DANGEROUS

        // Can await async Task
        await ProcessDataGoodAsync(); // Exception caught here
    }
    catch (Exception ex)
    {
        Console.WriteLine($"Caught: {ex.Message}");
    }
}
The Only Valid Use of Async Void
csharp
// ✅ Event handlers - the ONLY valid use case
public partial class MainWindow : Window
{
    public async void SaveButton_Click(object sender, RoutedEventArgs e)
    {
        try
        {
            await SaveDataAsync();
            MessageBox.Show("Saved successfully!");
        }
        catch (Exception ex)
        {
            MessageBox.Show($"Error: {ex.Message}");
        }
    }

    private async Task SaveDataAsync()
    {
        await _repository.SaveAsync(_data);
    }
}

ConfigureAwait(false)

Control synchronization context capture for performance in library code.

Understanding ConfigureAwait
csharp
// Library code - use ConfigureAwait(false)
public class DataService
{
    public async Task<Data> GetDataAsync(int id)
    {
        // ConfigureAwait(false) - don't capture context
        var json = await _httpClient.GetStringAsync($"/api/data/{id}")
            .ConfigureAwait(false);

        var data = await DeserializeAsync(json)
            .ConfigureAwait(false);

        return data;
    }
}

// UI code - DON'T use ConfigureAwait(false)
public class ViewModel
{
    public async Task LoadDataAsync()
    {
        var data = await _dataService.GetDataAsync(42);
        // Need UI context here
        this.DataProperty = data; // Update UI
    }
}
ConfigureAwait Patterns
csharp
public class AsyncLibrary
{
    // ✅ Library method with ConfigureAwait(false)
    public async Task<Result> ProcessAsync(string input)
    {
        var step1 = await Step1Async(input).ConfigureAwait(false);
        var step2 = await Step2Async(step1).ConfigureAwait(false);
        var step3 = await Step3Async(step2).ConfigureAwait(false);
        return step3;
    }

    // ✅ ASP.NET Core - ConfigureAwait(false) safe everywhere
    [HttpGet]
    public async Task<IActionResult> GetData(int id)
    {
        // ASP.NET Core has no synchronization context
        var data = await _repository.GetAsync(id).ConfigureAwait(false);
        return Ok(data);
    }
}

CancellationToken Patterns

Proper cancellation support for long-running operations.

Basic Cancellation
csharp
public async Task<List<Result>> ProcessItemsAsync(
    IEnumerable<Item> items,
    CancellationToken cancellationToken = default)
{
    var results = new List<Result>();

    foreach (var item in items)
    {
        // Check for cancellation
        cancellationToken.ThrowIfCancellationRequested();

        var result = await ProcessItemAsync(item, cancellationToken);
        results.Add(result);
    }

    return results;
}

// Usage with timeout
public async Task<List<Result>> ProcessWithTimeoutAsync(IEnumerable<Item> items)
{
    using var cts = new CancellationTokenSource(TimeSpan.FromSeconds(30));

    try
    {
        return await ProcessItemsAsync(items, cts.Token);
    }
    catch (OperationCanceledException)
    {
        Console.WriteLine("Operation timed out");
        throw;
    }
}
Advanced Cancellation Patterns
csharp
public class BackgroundProcessor
{
    private CancellationTokenSource? _cts;

    public async Task StartAsync()
    {
        _cts = new CancellationTokenSource();
        await ProcessLoopAsync(_cts.Token);
    }

    public void Stop()
    {
        _cts?.Cancel();
    }

    private async Task ProcessLoopAsync(CancellationToken cancellationToken)
    {
        while (!cancellationToken.IsCancellationRequested)
        {
            try
            {
                await ProcessBatchAsync(cancellationToken);
                await Task.Delay(1000, cancellationToken);
            }
            catch (OperationCanceledException)
            {
                // Expected when cancelled
                break;
            }
        }
    }

    // Linked cancellation tokens
    public async Task ProcessWithMultipleTokensAsync(
        CancellationToken userToken,
        CancellationToken systemToken)
    {
        using var linkedCts = CancellationTokenSource
            .CreateLinkedTokenSource(userToken, systemToken);

        await DoWorkAsync(linkedCts.Token);
    }
}

Async Streams (IAsyncEnumerable)

Stream data asynchronously using IAsyncEnumerable<T> (C# 8+).

Basic Async Streams
csharp
public async IAsyncEnumerable<LogEntry> ReadLogsAsync(
    string filePath,
    [EnumeratorCancellation] CancellationToken cancellationToken = default)
{
    await using var stream = File.OpenRead(filePath);
    using var reader = new StreamReader(stream);

    string? line;
    while ((line = await reader.ReadLineAsync(cancellationToken)) != null)
    {
        if (TryParseLog(line, out var entry))
        {
            yield return entry;
        }
    }
}

// Consuming async streams
public async Task ProcessLogsAsync(string filePath)
{
    await foreach (var log in ReadLogsAsync(filePath))
    {
        Console.WriteLine($"{log.Timestamp}: {log.Message}");
    }
}
Advanced Async Stream Patterns
csharp
public class DataStreamProcessor
{
    // Async stream with filtering
    public async IAsyncEnumerable<Event> GetEventsAsync(
        DateTime startDate,
        [EnumeratorCancellation] CancellationToken cancellationToken = default)
    {
        int page = 0;

        while (true)
        {
            var events = await FetchPageAsync(page++, cancellationToken);

            if (events.Count == 0)
                yield break;

            foreach (var evt in events.Where(e => e.Date >= startDate))
            {
                yield return evt;
            }
        }
    }

    // LINQ-style operations on async streams
    public async IAsyncEnumerable<TResult> SelectAsync<TSource, TResult>(
        IAsyncEnumerable<TSource> source,
        Func<TSource, TResult> selector)
    {
        await foreach (var item in source)
        {
            yield return selector(item);
        }
    }

    // Buffering async streams
    public async IAsyncEnumerable<List<T>> BufferAsync<T>(
        IAsyncEnumerable<T> source,
        int bufferSize)
    {
        var buffer = new List<T>(bufferSize);

        await foreach (var item in source)
        {
            buffer.Add(item);

            if (buffer.Count >= bufferSize)
            {
                yield return buffer;
                buffer = new List<T>(bufferSize);
            }
        }

        if (buffer.Count > 0)
        {
            yield return buffer;
        }
    }
}

Parallel Async Operations

Execute multiple async operations concurrently.

Task.WhenAll and Task.WhenAny
csharp
public async Task<Summary> GetDashboardDataAsync()
{
    // Start all operations concurrently
    var userTask = GetUserDataAsync();
    var ordersTask = GetOrdersAsync();
    var analyticsTask = GetAnalyticsAsync();

    // Wait for all to complete
    await Task.WhenAll(userTask, ordersTask, analyticsTask);

    return new Summary
    {
        User = await userTask,
        Orders = await ordersTask,
        Analytics = await analyticsTask
    };
}

// Handle partial failures
public async Task<Results> ProcessWithPartialFailuresAsync()
{
    var tasks = new[]
    {
        ProcessTask1Async(),
        ProcessTask2Async(),
        ProcessTask3Async()
    };

    await Task.WhenAll(tasks.Select(async t =>
    {
        try
        {
            await t;
        }
        catch (Exception ex)
        {
            // Log but don't throw
            Console.WriteLine($"Task failed: {ex.Message}");
        }
    }));

    // Collect successful results
    var results = tasks
        .Where(t => t.IsCompletedSuccessfully)
        .Select(t => t.Result)
        .ToList();

    return new Results { Successful = results };
}
Task.WhenAny for Timeouts and Racing
csharp
public async Task<T> WithTimeoutAsync<T>(Task<T> task, TimeSpan timeout)
{
    var delayTask = Task.Delay(timeout);
    var completedTask = await Task.WhenAny(task, delayTask);

    if (completedTask == delayTask)
    {
        throw new TimeoutException("Operation timed out");
    }

    return await task;
}

// Racing multiple sources
public async Task<Data> GetFastestDataAsync()
{
    var primaryTask = GetFromPrimaryAsync();
    var secondaryTask = GetFromSecondaryAsync();
    var cacheTask = GetFromCacheAsync();

    var completedTask = await Task.WhenAny(primaryTask, secondaryTask, cacheTask);
    return await completedTask;
}

// Throttled parallel processing
public async Task<List<Result>> ProcessWithThrottlingAsync(
    IEnumerable<Item> items,
    int maxConcurrency)
{
    var semaphore = new SemaphoreSlim(maxConcurrency);
    var tasks = items.Select(async item =>
    {
        await semaphore.WaitAsync();
        try
        {
            return await ProcessItemAsync(item);
        }
        finally
        {
            semaphore.Release();
        }
    });

    return (await Task.WhenAll(tasks)).ToList();
}

Exception Handling in Async Code

Proper exception handling patterns for async methods.

Basic Exception Handling
csharp
public async Task<Result> ProcessWithErrorHandlingAsync()
{
    try
    {
        var data = await FetchDataAsync();
        return await ProcessDataAsync(data);
    }
    catch (HttpRequestException ex)
    {
        _logger.LogError(ex, "Network error occurred");
        throw;
    }
    catch (Exception ex)
    {
        _logger.LogError(ex, "Unexpected error occurred");
        return Result.Failed(ex.Message);
    }
}

// Exception handling with Task.WhenAll
public async Task ProcessMultipleAsync()
{
    var tasks = new[] { Task1Async(), Task2Async(), Task3Async() };

    try
    {
        await Task.WhenAll(tasks);
    }
    catch (Exception ex)
    {
        // Only first exception is thrown
        _logger.LogError(ex, "At least one task failed");

        // To get all exceptions:
        var exceptions = tasks
            .Where(t => t.IsFaulted)
            .Select(t => t.Exception)
            .ToList();

        foreach (var exception in exceptions)
        {
            _logger.LogError(exception, "Task failed");
        }
    }
}
AggregateException Handling
csharp
public async Task HandleAllExceptionsAsync()
{
    var tasks = Enumerable.Range(1, 10)
        .Select(i => ProcessItemAsync(i))
        .ToArray();

    try
    {
        await Task.WhenAll(tasks);
    }
    catch
    {
        // Examine all exceptions
        var aggregateException = new AggregateException(
            tasks.Where(t => t.IsFaulted)
                .SelectMany(t => t.Exception?.InnerExceptions ?? Array.Empty<Exception>())
        );

        aggregateException.Handle(ex =>
        {
            if (ex is HttpRequestException)
            {
                _logger.LogWarning(ex, "Network error - retrying");
                return true; // Handled
            }
            return false; // Rethrow
        });
    }
}

Deadlock Prevention

Avoid common deadlock scenarios in async code.

Common Deadlock Patterns
csharp
// ❌ DEADLOCK - blocking on async code
public void DeadlockExample()
{
    // This will deadlock in UI or ASP.NET contexts
    var result = GetDataAsync().Result;

    // This will also deadlock
    GetDataAsync().Wait();
}

// ✅ CORRECT - async all the way
public async Task CorrectExample()
{
    var result = await GetDataAsync();
}

// ✅ CORRECT - use ConfigureAwait(false) in library code
public async Task<Data> LibraryMethodAsync()
{
    var data = await FetchAsync().ConfigureAwait(false);
    return ProcessData(data);
}
Avoiding Deadlocks
csharp
public class DeadlockFreeService
{
    // ✅ Async all the way
    public async Task<Result> ProcessAsync()
    {
        var data = await GetDataAsync();
        var processed = await ProcessDataAsync(data);
        return processed;
    }

    // ✅ If you must block, use Task.Run
    public Result ProcessSync()
    {
        return Task.Run(async () => await ProcessAsync()).GetAwaiter().GetResult();
    }

    // ✅ Use async disposal
    public async Task UseResourceAsync()
    {
        await using var resource = new AsyncDisposableResource();
        await resource.ProcessAsync();
    }
}

Async in ASP.NET Core

Best practices for async code in ASP.NET Core applications.

Controller Async Patterns
csharp
[ApiController]
[Route("api/[controller]")]
public class ProductsController : ControllerBase
{
    private readonly IProductRepository _repository;

    // ✅ Async action methods
    [HttpGet("{id}")]
    public async Task<ActionResult<Product>> GetProduct(
        int id,
        CancellationToken cancellationToken)
    {
        var product = await _repository.GetByIdAsync(id, cancellationToken);

        if (product == null)
            return NotFound();

        return Ok(product);
    }

    [HttpPost]
    public async Task<ActionResult<Product>> CreateProduct(
        [FromBody] CreateProductRequest request,
        CancellationToken cancellationToken)
    {
        var product = await _repository.CreateAsync(request, cancellationToken);
        return CreatedAtAction(nameof(GetProduct), new { id = product.Id }, product);
    }

    // ✅ Streaming responses with IAsyncEnumerable
    [HttpGet("stream")]
    public async IAsyncEnumerable<Product> StreamProducts(
        [EnumeratorCancellation] CancellationToken cancellationToken)
    {
        await foreach (var product in _repository.GetAllStreamAsync(cancellationToken))
        {
            yield return product;
        }
    }
}
Background Services
csharp
public class DataProcessorService : BackgroundService
{
    private readonly IServiceProvider _serviceProvider;
    private readonly ILogger<DataProcessorService> _logger;

    protected override async Task ExecuteAsync(CancellationToken stoppingToken)
    {
        _logger.LogInformation("Data processor service starting");

        while (!stoppingToken.IsCancellationRequested)
        {
            try
            {
                await ProcessDataBatchAsync(stoppingToken);
                await Task.Delay(TimeSpan.FromMinutes(5), stoppingToken);
            }
            catch (OperationCanceledException)
            {
                // Expected when stopping
                break;
            }
            catch (Exception ex)
            {
                _logger.LogError(ex, "Error processing data batch");
                await Task.Delay(TimeSpan.FromSeconds(30), stoppingToken);
            }
        }

        _logger.LogInformation("Data processor service stopped");
    }

    private async Task ProcessDataBatchAsync(CancellationToken cancellationToken)
    {
        using var scope = _serviceProvider.CreateScope();
        var repository = scope.ServiceProvider.GetRequiredService<IDataRepository>();

        await repository.ProcessBatchAsync(cancellationToken);
    }
}

Best Practices

  1. Async All the Way: Never block on async code with .Result or .Wait()
  2. Use CancellationToken: Always accept CancellationToken for long-running operations
  3. ConfigureAwait in Libraries: Use ConfigureAwait(false) in library code
  4. Avoid Async Void: Only use async void for event handlers
  5. Return Task Directly: When possible, return the Task directly without await
  6. Use ValueTask for Hot Paths: Consider ValueTask for frequently-called, often-synchronous methods
  7. Handle All Exceptions: Always handle exceptions in async methods
  8. Don't Mix Blocking and Async: Choose one paradigm per call chain
  9. Dispose Async Resources: Use await using for IAsyncDisposable
  10. Test with Cancellation: Test that cancellation works correctly
Show full SKILL.md (166 more words)Show less

Common Pitfalls

  1. Blocking on Async Code: Using .Result or .Wait() causes deadlocks
  2. Forgetting ConfigureAwait: Can cause performance issues in libraries
  3. Async Void Methods: Cannot be awaited and swallow exceptions
  4. Not Handling Cancellation: Ignoring CancellationToken parameter
  5. Over-using Task.Run: Don't wrap already-async code in Task.Run
  6. Capturing Context Unnecessarily: Wastes resources when context not needed
  7. Fire and Forget: Starting async operations without awaiting
  8. Mixing Sync and Async: Creates confusion and potential deadlocks
  9. Not Using ValueTask Correctly: Awaiting ValueTask multiple times
  10. Ignoring Exceptions in Task.WhenAll: Only catching first exception

When to Use

Use this skill when:

  • Writing asynchronous code in C#
  • Implementing I/O-bound operations (database, network, file system)
  • Building responsive UI applications
  • Creating scalable web services
  • Working with streams of data
  • Implementing cancellation support
  • Optimizing async performance with ValueTask
  • Handling parallel async operations
  • Preventing deadlocks in async code
  • Working with ASP.NET Core async patterns

Resources

© sketch7, MIT. Rendered from Markdown: HTML in the file is shown as text, images as links, and headings moved down two levels. Raw file

Files

Just SKILL.md in .agents/skills/csharp-async-patterns of sketch7/FluentlyHttpClient.

Open the folder on GitHubat commit 397ee9b

Used in 1 other repository

We found 1 copy of this SKILL.md (exact, near-identical or edited) in other folders, from 1 other GitHub owner. This page covers the copy in sketch7/FluentlyHttpClient, which our catalogue first saw on October 7, 2026.

Compare with similar skills

Csharp Async Patterns next to the 5 skills that share the most tags, products or categories with it. Stars are the repository's; “used in” counts other GitHub owners with a copy.

Csharp Async Patterns compared with similar skills
SkillStarsUsed inTokensAuto-checkLicenceRepo updated
Csharp Async Patterns this skillsketch7/FluentlyHttpClient1211 repos~5.9kAutomated safety check: NotesMIT
Akka.NET Best PracticesAaronontheweb/dotnet-skills1.2k1 repos~3.3kAutomated safety check: PassMIT
Dotnet Csharpnovotnyllc/dotnet-artisan233—~1.7kAutomated safety check: PassMIT
Csharp Concurrency PatternsAaronontheweb/dotnet-skills1.2k1 repos~2.2kAutomated safety check: PassMIT
Csharp Prodavila7/claude-code-templates32k7 repos~538Automated safety check: PassMIT
Dotnet Patternsaffaan-m/ECC274k1 repos~2.3kAutomated safety check: PassMIT

Similar skills

  • Akka.NET Best Practices

    Aaronontheweb/dotnet-skills

    Guidance for Akka.NET actor systems covering EventStream versus DistributedPubSub, supervision, Props versus DependencyResolver, work distribution and testable cluster code.

    1.2k GitHub starsUsed in 1 repo~3.3k tokens
    DevelopmentAuto-check passed
  • Dotnet Csharp

    novotnyllc/dotnet-artisan

    Baseline C skill loaded for every .NET code path. An agent skill from novotnyllc/dotnet-artisan.

    233 GitHub stars~1.7k tokensUpdated 1 mo ago
    DevelopmentAuto-check passed
  • Csharp Concurrency Patterns

    Aaronontheweb/dotnet-skills

    Choosing the right concurrency abstraction in .NET - from async/await for I/O to Channels for producer/consumer to Akka.NET for stateful entity management.

    1.2k GitHub starsUsed in 1 repo~2.2k tokens
    DevelopmentAuto-check passed
  • Csharp Pro

    davila7/claude-code-templates

    Write modern C code with advanced features like records, pattern matching, and async/await.

    32k GitHub starsUsed in 7 repos~538 tokens
    DevelopmentAuto-check passed
  • Dotnet Patterns

    affaan-m/ECC

    Idiomatic C and .NET patterns, conventions, dependency injection, async/await, and best practices for building robust, maintainable .NET applications.

    274k GitHub starsUsed in 1 repo~2.3k tokens
    DevelopmentAuto-check passed
  • Csharp Async

    github/awesome-copilot

    Official

    Get best practices for C async programming. An agent skill from github/awesome-copilot.

    40k GitHub starsUsed in 2 repos~466 tokens
    DevelopmentAuto-check passed

More from sketch7/FluentlyHttpClient

  • Modern Csharp Coding Standards

    sketch7/FluentlyHttpClient

    Write modern, high-performance C code using records, pattern matching, value objects, async/await, Span<T/Memory<T, and best-practice API design patterns.

    121 GitHub starsUsed in 3 repos~2.7k tokens
    Auto-check passed
  • Dotnet 10 Csharp 14

    sketch7/FluentlyHttpClient

    A skill your agent uses when building .NET 10 or C 14 applications; when using minimal APIs, modular monolith patterns, or feature folders; when implementing HTTP resilience, Options pattern…

    121 GitHub stars~2.2k tokensUpdated 19 days ago
    Auto-check passed
  • Csharp Nullable Types

    sketch7/FluentlyHttpClient

    A skill your agent uses when C nullable reference types, null safety patterns, and migration strategies.

    121 GitHub starsUsed in 1 repo~5.7k tokens
    Auto-check: notes

Works with

Categories

Questions about Csharp Async Patterns

What does Csharp Async Patterns do?

A skill your agent uses when C async/await patterns including Task, ValueTask, async streams, and cancellation. Csharp Async Patterns is an agent skill from sketch7/FluentlyHttpClient. Use when C async/await patterns including Task, ValueTask, async streams, and cancellation.

When should I use Csharp Async Patterns?

Csharp Async Patterns fits situations like: C async/await patterns including Task; writing asynchronous C code.

How do I install Csharp Async Patterns in Claude Code?

Run `npx skills add sketch7/FluentlyHttpClient --skill csharp-async-patterns -a claude-code`. Or copy the skill folder (.agents/skills/csharp-async-patterns in sketch7/FluentlyHttpClient) into .claude/skills/csharp-async-patterns in your project. Claude Code loads it when a task matches its description.

How do I install Csharp Async Patterns in Codex?

Run `npx skills add sketch7/FluentlyHttpClient --skill csharp-async-patterns -a codex`. Or copy the skill folder (.agents/skills/csharp-async-patterns in sketch7/FluentlyHttpClient) into .agents/skills/csharp-async-patterns in your project. Codex loads it when a task matches its description.

Can I use Csharp Async Patterns in Cursor, Gemini CLI or GitHub Copilot?

Cursor, Gemini CLI, GitHub Copilot and OpenCode also load SKILL.md folders. With the skills CLI, run `npx skills add sketch7/FluentlyHttpClient --skill csharp-async-patterns -a cursor` (or -a gemini-cli, github-copilot or opencode for the others). To copy it by hand, put the folder in .cursor/skills/csharp-async-patterns, .gemini/skills/csharp-async-patterns, .github/skills/csharp-async-patterns and .opencode/skills/csharp-async-patterns in your project.

What does Csharp Async Patterns need to run?

SKILL.md names no scripts, command-line tools or credentials: Csharp Async Patterns is instructions for the agent only. Its frontmatter pre-approves these tools: Bash, Read, Write, Edit.

Does Csharp Async Patterns access the network?

SKILL.md names 2 domains. As links in the text: learn.microsoft.com and devblogs.microsoft.com. This is read from the text; nothing was executed.

Is Csharp Async Patterns safe to install?

Our automated static check of SKILL.md found notes only (pre-approves every shell command (allowed-tools: bash)), nothing it rates as a warning. It is not a guarantee. Review the folder before installing.

What licence does Csharp Async Patterns use?

Csharp Async Patterns is published under the MIT licence (the repository's licence). It allows redistribution, so the full SKILL.md is shown on this page.

How many tokens does Csharp Async Patterns use?

About 5.9k tokens (SKILL.md is roughly 23k characters). Agents keep only the skill's name and description in context until a task matches; then they load SKILL.md in full.

What are the alternatives to Csharp Async Patterns?

Skills that share tags, products or a category with Csharp Async Patterns: Akka.NET Best Practices (Aaronontheweb/dotnet-skills, 1.2k stars), Dotnet Csharp (novotnyllc/dotnet-artisan, 233 stars), Csharp Concurrency Patterns (Aaronontheweb/dotnet-skills, 1.2k stars) and Csharp Pro (davila7/claude-code-templates, 32k stars). The comparison table on this page puts their stars, adoption, token cost, safety result and licence side by side.

Who maintains Csharp Async Patterns?

sketch7 (a GitHub organization) maintains it in sketch7/FluentlyHttpClient, which has 121 GitHub stars. The repository holds 4 skills in this directory. The repository was last updated on September 18, 2026.

Source: sketch7/FluentlyHttpClient on GitHub. Facts on this page come from the repository at the commit we read; the author's words are quoted as theirs.