dotnet-exception-handling
БесплатноБез исполняемых скриптовНе проверенComprehensive .NET exception handling quality improvement workflow. Auto-detects .NET projects, investigates 10 common exception handling mistakes, generates…
от rysweet★ 77 звёзд на GitHubОб этом скилле
.NET Exception Handling Quality Improvement
Purpose
Systematic investigation and remediation of .NET exception handling anti-patterns. Detects, documents, and fixes the 10 most common exception handling mistakes in .NET applications.
Use when: Preparing for production, code quality audits, security reviews, or onboarding to a .NET codebase.
Usage
# Investigation only (default)
/dotnet-exception-handling <path-to-dotnet-project>
# Filter by severity
/dotnet-exception-handling <project-path> --priority critical
# Auto-implement all fixes
/dotnet-exception-handling <project-path> --fix-all
Arguments:
project-path: Directory containing .csproj or .sln (default: current directory)--priority:critical|high|medium|low|all(default:all)--fix-all: Implement fixes automatically (default: investigate only)
The 10 Common Mistakes
- Catching Exception Too Broadly - Base
Exceptioninstead of specific types - Swallowing Exceptions Silently - Empty catch blocks hiding errors
- Using
throw ex;- Resets stack traces (usethrow;) - Wrapping Everything in Try/Catch - Defensive coding clutter
- Exceptions for Control Flow - Performance overhead for expected conditions
- Forgetting to Await Async - Unhandled exceptions on background threads
- Ignoring Background Task Exceptions - Fire-and-forget losing errors
- Generic Exception Types - Vague
new Exception()instead of specific types - Losing Inner Exceptions - Breaking exception chains
- Missing Global Handler - No centralized error handling (stack traces exposed)
Detailed descriptions, detection patterns, and fix templates → see reference.md
Execution Workflow
Phase 1: Investigation (6 Steps)
Step 1: Project Detection
- Scan for .csproj, .sln files
- Identify project types (ASP.NET Core, worker services, libraries)
- Count C# files for scope estimation
Step 2: Parallel Analysis
- Deploy 5 specialized agents:
- Background Worker Specialist
- API Layer Specialist
- Service Layer Specialist
- Data Layer Specialist
- Infrastructure Specialist
Step 3: Violation Detection
Use
rg -P(ripgrep PCRE mode) for pattern matching:# Mistake #1: Broad catches rg -P 'catch\s*\(Exception\b' --glob '*.cs' # Mistake #2: Empty catches rg -P 'catch[^{]*\{\s*(//[^\n]*)?\s*\}' --glob '*.cs' # Mistake #3: throw ex rg 'throw\s+ex;' --glob '*.cs'See
reference.mdfor complete pattern list
Step 4: Severity Classification
- CRITICAL: Security (stack trace exposure, missing global handler)
- HIGH: Reliability (swallowed exceptions, broad catches)
- MEDIUM: Code quality (excessive try/catch)
- LOW: Style issues
Step 5: Findings Report
- Generate markdown with file:line references
- Code snippets + recommended fixes
- Priority-based roadmap
Step 6: Knowledge Capture
- Store in
.claude/runtime/logs/EXCEPTION_INVESTIGATION_YYYY-MM-DD.md - Update project memory
Phase 2: Development (If --fix-all)
Step 7: Orchestrate Default Workflow
- Create GitHub issue with findings
- Set up worktree for fixes
- Implement GlobalExceptionHandler, Result
, etc. - Write comprehensive tests (TDD)
- Three-agent review (reviewer, security, philosophy)
Step 8: Validation
- All tests pass
- Security: Zero stack traces
- Performance: <5ms p99 overhead
Quick Start Examples
Example 1: Investigation Only
/dotnet-exception-handling ./src/MyApi
Output: Investigation report with 23 violations (1 CRITICAL, 8 HIGH, 12 MEDIUM, 2 LOW)
Example 2: Fix Critical Only
/dotnet-exception-handling ./src/MyApi --priority critical --fix-all
Output: GitHub issue + PR implementing GlobalExceptionHandler + 15 tests
Example 3: Complete Fix
/dotnet-exception-handling ./src/MyApi --fix-all
Output: 23 violations fixed, 67 tests, PR ready (CI passing)
Core Architecture Patterns
GlobalExceptionHandler (IExceptionHandler)
Centralized exception-to-HTTP mapping for ASP.NET Core:
public class GlobalExceptionHandler : IExceptionHandler
{
public async ValueTask<bool> TryHandleAsync(
HttpContext httpContext,
Exception exception,
CancellationToken cancellationToken)
{
var (statusCode, title) = exception switch
{
ArgumentException => (400, "Invalid request"),
NotFoundException => (404, "Not found"),
ConflictException => (409, "Conflict"),
_ => (500, "Internal server error")
};
httpContext.Response.StatusCode = statusCode;
await httpContext.Response.WriteAsJsonAsync(new ProblemDetails
{
Status = statusCode,
Title = title,
Detail = statusCode >= 500
? "An error occurred"
: exception.Message
}, cancellationToke
Установить dotnet-exception-handling в Claude Code и Claude Desktop
Зарегайся, чтобы установить скилл
Создай бесплатный аккаунт, чтобы открыть команду установки и сохранить скилл в библиотеку.
- Открой команду установки в одну строку
- Сохраняй скиллы в синхронизируемую библиотеку
- Уведомления, когда скиллы обновляются
Разрешённые инструменты
Инструменты, которые скиллу разрешено вызывать.
Без ограничений — скилл может использовать любой инструмент.
Вложенные файлы
FAQ
Что делает скилл dotnet-exception-handling?
Comprehensive .NET exception handling quality improvement workflow. Auto-detects .NET projects, investigates 10 common exception handling mistakes, generates prioritized findings, and orchestrates fixes following best practices.
Как установить скилл dotnet-exception-handling?
Скопируй папку скилла в ~/.claude/skills (вкладка Claude Code выше делает это одной командой), либо поставь как плагин.
Скилл dotnet-exception-handling запускает скрипты?
Нет, скилл состоит только из инструкций (SKILL.md), без исполняемых скриптов.
Похожие скиллы
theme-factory
Toolkit for styling artifacts with a theme. These artifacts can be slides, docs, reportings, HTML landing pages, etc. There are 10 pre-set themes with…
от Anthropicaccess
Manage Discord channel access — approve pairings, edit allowlists, set DM/group policy. Use when the user asks to pair, approve someone, check who's allowed…
от Anthropicconfigure
Set up the Discord channel — save the bot token and review access policy. Use when the user pastes a Discord bot token, asks to configure Discord, asks "how…
от Anthropicaccess
Manage iMessage channel access — approve pairings, edit allowlists, set DM/group policy. Use when the user asks to pair, approve someone, check who's allowed…
от Anthropic