dotnet-techne-qa-pipel…
Use when the user asks to verify a story or ticket implementation against its spec - per-AC verdicts, code reuse and design…
Use when choosing .NET concurrency patterns for async I/O, queues, pipelines, or thread safety. Keywords: async/await, channels, dataflow, Rx, lock contention, producer consumer, parallel processing.
Claude Code
$ npx -y skills add Metalnib/dotnet-episteme-skills --skill dotnet-techne-csharp-concurrency-patterns --agent claude-code
Codex
$ npx skills add Metalnib/dotnet-episteme-skills --skill dotnet-techne-csharp-concurrency-patterns -a codex -y
Cursor
$ npx skills add Metalnib/dotnet-episteme-skills --skill dotnet-techne-csharp-concurrency-patterns -a cursor -y
Gemini CLI
$ npx skills add Metalnib/dotnet-episteme-skills --skill dotnet-techne-csharp-concurrency-patterns -a gemini-cli -y
GitHub Copilot
$ npx skills add Metalnib/dotnet-episteme-skills --skill dotnet-techne-csharp-concurrency-patterns -a github-copilot -y
OpenCode
$ npx skills add Metalnib/dotnet-episteme-skills --skill dotnet-techne-csharp-concurrency-patterns -a opencode -y
Windsurf
$ npx skills add Metalnib/dotnet-episteme-skills --skill dotnet-techne-csharp-concurrency-patterns -a windsurf -y
name: dotnet-techne-csharp-concurrency-patterns
description: "Use when choosing .NET concurrency patterns for async I/O, queues, pipelines, or thread safety. Keywords: async/await, channels, dataflow, Rx, lock contention, producer consumer, parallel processing."
disable-model-invocation: false
user-invocable: true
metadata:
author: Metalnib
version: "1.0.0"
trigger_keywords:
- async/await
- channels
- dataflow
- rx
- lock contention
- producer consumer
- parallel processingUse this skill when:
**Start simple, escalate only when needed.**
Most concurrency problems can be solved with `async/await`. Only reach for more sophisticated tools when you have a specific need that async/await can't address cleanly.
**Try to avoid shared mutable state.** The best way to handle concurrency is to design it away. Immutable data, message passing, and isolated state (like actors) eliminate entire categories of bugs.
**Locks should be the exception, not the rule.** When you can't avoid shared mutable state: 1. **First choice:** Redesign to avoid it (immutability, message passing, single-consumer isolation) 2. **Second choice:** Use `System.Collections.Concurrent` (ConcurrentDictionary, etc.) 3. **Third choice:** Use `Channel<T>` to serialize access through message passing 4. **Last resort:** Use `lock` for simple, short-lived critical sections
---
What are you trying to do?
│
├─► Wait for I/O (HTTP, database, file)?
│ └─► Use async/await
│
├─► Process a collection in parallel (CPU-bound)?
│ └─► Use Parallel.ForEachAsync
│
├─► Producer/consumer pattern (work queue)?
│ └─► Use System.Threading.Channels
│
├─► Need backpressure + multi-stage pipeline?
│ └─► Use TPL Dataflow
│
├─► UI event handling (debounce, throttle, combine)?
│ └─► Use Reactive Extensions (Rx)
│
├─► Coordinate multiple async operations?
│ └─► Use Task.WhenAll / Task.WhenAny
│
└─► None of the above fits?
└─► Ask yourself: "Do I really need shared mutable state?"
├─► Yes → Consider redesigning to avoid it
└─► Truly unavoidable → Use Channels or a dedicated single-consumer worker---
**Use for:** I/O-bound operations, non-blocking waits, most everyday concurrency.
// Simple async I/O
public async Task<Order> GetOrderAsync(string orderId, CancellationToken ct)
{
var order = await _database.GetAsync(orderId, ct);
var customer = await _customerService.GetAsync(order.CustomerId, ct);
return order with { Customer = customer };
}
// Parallel async operations (when independent)
public async Task<Dashboard> LoadDashboardAsync(string userId, CancellationToken ct)
{
var ordersTask = _orderService.GetRecentOrdersAsync(userId, ct);
var notificationsTask = _notificationService.GetUnreadAsync(userId, ct);
var statsTask = _statsService.GetUserStatsAsync(userId, ct);
await Task.WhenAll(ordersTask, notificationsTask, statsTask);
return new Dashboard(
Orders: await ordersTask,
Notifications: await notificationsTask,
Stats: await statsTask);
}**Key principles:** Always accept `CancellationToken`. Use `ConfigureAwait(false)` in library code. Don't block on async code.
---
**Use for:** Processing collections in parallel when work is CPU-bound or you need controlled concurrency.
public async Task ProcessOrdersAsync(
IEnumerable<Order> orders,
CancellationToken ct)
{
await Parallel.ForEachAsync(
orders,
new ParallelOptions
{
MaxDegreeOfParallelism = Environment.ProcessorCount,
CancellationToken = ct
},
async (order, token) =>
{
await ProcessOrderAsync(order, token);
});
}**When NOT to use:** Pure I/O operations, when order matters, when you need backpressure.
---
**Use for:** Work queues, producer/consumer patterns, decoupling producers from consumers.
public class OrderProcessor
{
private readonly Channel<Order> _channel;
public OrderProcessor()
{
_channel = Channel.CreateBounded<Order>(new BoundedChannelOptions(100)
{
FullMode = BoundedChannelFullMode.Wait
});
}
// Producer
public async Task EnqueueOrderAsync(Order order, CancellationToken ct)
{
await _channel.Writer.WriteAsync(order, ct);
}
// Consumer (run as background task)
public async Task ProcessOrdersAsync(CancellationToken ct)
{
await foreach (var order in _channel.Reader.ReadAllAsync(ct))
{
await ProcessOrderAsync(order, ct);
}
}
public void Complete() => _channel.Writer.Complete();
}**Channels are good for:** Decoupling speed, buffering with backpressure, fan-out to workers, background queues.
**Channels are NOT good for:** Complex stream operations (batching, windowing), stateful per-entity processing, sophisticated supervision.
---
For advanced scenarios requiring stream processing, UI event composition, or stateful worker orchestration, see [advanced-concurrency.md](advanced-concurrency.md).
**TPL Dataflow** excels at server-sid
DotNet Episteme Skills - a curated, manual-first .NET AI skills library rooted in systematic knowledge (episteme) and shaped by disciplined craft (techne), designed for engineers who prioritise precision over hype.
Use when the user asks to verify a story or ticket implementation against its spec - per-AC verdicts, code reuse and design…
Use when the user asks for a phase-gated refactoring or redesign loop - session-blind workers map and trace the area, empirical…
Use when the user asks for a multi-agent .NET code review - five parallel reviewers (correctness, performance,…
Use when reviewing PRs/diffs/branches/documents for .NET quality, correctness, performance, security, data access, messaging, and…
Use when you need CRAP score and coverage risk analysis to find high-risk code before refactoring or release. Keywords: CRAP…
Use when reviewing a .NET pull request for breaking changes that may affect other microservice repositories. Detects cross-repo…
You MUST use this before any creative work - creating features, building components, adding functionality, modifying behavior, or…
Ask which skill or flow fits your situation. A router over the skills in this repo.