csharp-async-patterns
について
このClaudeスキルは、.NET開発者向けに現代的なC# async/awaitパターンとベストプラクティスを提供します。async/awaitの基本、CancellationTokenの使用方法、ConfigureAwait、エラーハンドリング、Taskの調整、ValueTaskの最適化についてカバーしています。C#アプリケーションでの非同期プログラミングパターンに関するガイダンスが必要な際にご利用ください。
クイックインストール
Claude Code
推奨/plugin add https://github.com/majiayu000/claude-skill-registrygit clone https://github.com/majiayu000/claude-skill-registry.git ~/.claude/skills/csharp-async-patternsこのコマンドをClaude Codeにコピー&ペーストしてスキルをインストールします
ドキュメント
C# Async/Await Patterns
Overview
C# 비동기 프로그래밍 패턴 (POCU 표준 적용)
Foundation Required: csharp-code-style (mPascalCase, Async 접미사 금지, var 금지)
Core Topics:
- async/await 기본
- CancellationToken 패턴
- ConfigureAwait 사용법
- 비동기 에러 처리
- Task 조합 및 조율
- ValueTask 최적화
Quick Start
public class DataService
{
private readonly IDataRepository mRepository;
private readonly ILogger mLogger;
public DataService(IDataRepository repository, ILogger logger)
{
mRepository = repository;
mLogger = logger;
}
// ✅ POCU: Async 접미사 없음
public async Task<Data> LoadData(CancellationToken ct = default)
{
try
{
Data data = await mRepository.Fetch(ct);
return processData(data);
}
catch (OperationCanceledException)
{
mLogger.Info("Operation cancelled");
throw;
}
}
private Data processData(Data data)
{
Debug.Assert(data != null);
// Processing logic
return data;
}
}
Key Rules (POCU)
Async 메서드 명명
// ❌ WRONG: Async 접미사 사용
public async Task<Order> GetOrderAsync(int id);
public async Task SaveOrderAsync(Order order);
// ✅ CORRECT: Async 접미사 없음
public async Task<Order> GetOrder(int id);
public async Task SaveOrder(Order order);
async void 금지
// ❌ WRONG: async void
public async void LoadData()
{
await mRepository.Fetch();
}
// ✅ CORRECT: async Task
public async Task LoadData()
{
await mRepository.Fetch();
}
// ⚠️ EXCEPTION: 이벤트 핸들러만 async void 허용
private async void OnButtonClick(object sender, EventArgs e)
{
try
{
await ProcessClick();
}
catch (Exception ex)
{
mLogger.Error(ex, "Click handler failed");
}
}
명시적 타입 사용
// ❌ WRONG: var 사용
var result = await GetOrder(1);
var tasks = new List<Task>();
// ✅ CORRECT: 명시적 타입
Order result = await GetOrder(1);
List<Task> tasks = new List<Task>();
using 문 사용
// ❌ WRONG: using 선언
using CancellationTokenSource cts = new CancellationTokenSource(timeout);
// ✅ CORRECT: using 문
using (CancellationTokenSource cts = new CancellationTokenSource(timeout))
{
return await LoadData(cts.Token);
}
CancellationToken 패턴
public class OrderProcessor
{
private readonly IOrderRepository mRepository;
// 항상 CancellationToken 지원
public async Task<Order> ProcessOrder(int orderId, CancellationToken ct = default)
{
ct.ThrowIfCancellationRequested();
Order order = await mRepository.GetOrder(orderId, ct);
Debug.Assert(order != null);
await validateOrder(order, ct);
await calculateTotal(order, ct);
await mRepository.SaveOrder(order, ct);
return order;
}
private async Task validateOrder(Order order, CancellationToken ct)
{
Debug.Assert(order != null);
await mRepository.ValidateInventory(order.Items, ct);
}
private async Task calculateTotal(Order order, CancellationToken ct)
{
Debug.Assert(order != null);
decimal total = 0;
foreach (OrderItem item in order.Items)
{
ct.ThrowIfCancellationRequested();
total += item.Price * item.Quantity;
}
order.Total = total;
}
}
Reference Documentation
Best Practices
Essential patterns for async/await:
- CancellationToken 사용 패턴
- ConfigureAwait 가이드라인
- async void 회피
- 예외 처리
Code Examples
Comprehensive code examples:
- 기본 비동기 작업
- 병렬 실행 패턴
- 타임아웃 및 재시도
- 고급 패턴
Anti-Patterns
Common mistakes to avoid:
- .Result, .Wait() 차단
- Fire-and-forget 오류 처리 누락
- CancellationToken 미전파
Key Principles
- Async All the Way: 비동기 호출 체인 유지
- Always Support Cancellation: 장기 실행 작업은 CancellationToken 필수
- ConfigureAwait in Libraries: 라이브러리 코드에서 ConfigureAwait(false) 사용
- No Async Suffix: POCU 표준 - Async 접미사 금지
- No async void: 이벤트 핸들러 외 async void 금지
- Explicit Types: var 대신 명시적 타입 사용
GitHub リポジトリ
関連スキル
content-collections
メタThis skill provides a production-tested setup for Content Collections, a TypeScript-first tool that transforms Markdown/MDX files into type-safe data collections with Zod validation. Use it when building blogs, documentation sites, or content-heavy Vite + React applications to ensure type safety and automatic content validation. It covers everything from Vite plugin configuration and MDX compilation to deployment optimization and schema validation.
creating-opencode-plugins
メタThis skill provides the structure and API specifications for creating OpenCode plugins that hook into 25+ event types like commands, files, and LSP operations. It offers implementation patterns for JavaScript/TypeScript modules that intercept and extend the AI assistant's lifecycle. Use it when you need to build event-driven plugins for monitoring, custom handling, or extending OpenCode's capabilities.
evaluating-llms-harness
テストThis Claude Skill runs the lm-evaluation-harness to benchmark LLMs across 60+ standardized academic tasks like MMLU and GSM8K. It's designed for developers to compare model quality, track training progress, or report academic results. The tool supports various backends including HuggingFace and vLLM models.
sglang
メタSGLang is a high-performance LLM serving framework that specializes in fast, structured generation for JSON, regex, and agentic workflows using its RadixAttention prefix caching. It delivers significantly faster inference, especially for tasks with repeated prefixes, making it ideal for complex, structured outputs and multi-turn conversations. Choose SGLang over alternatives like vLLM when you need constrained decoding or are building applications with extensive prefix sharing.
