skills/dotnet/patterns/execution-tracking/SKILL.md
Track handler execution for observability, auditing, and debugging in .NET applications. Use when: - Implementing observability and monitoring - Tracking handler execution for performance analysis - Building audit trails for business operations - Debugging production issues - Implementing distributed tracing Triggers: "execution tracking", "observability", "audit trail", "performance monitoring", "tracing", "correlation id"
npx skillsauth add yeeehaooo/WorkSpace execution-trackingInstall this skill globally with one command. Works with Claude Code, Cursor, and Windsurf.
3 of 9 scanners reported clean
Some scanners were skipped, did not run, or reported a non-clean status. Review each row below.
Track handler execution for observability, auditing, and debugging.
Applies to:
// Application Layer
public interface IExecutionTracker
{
Task TrackAsync(string operation, object? input, object? output, TimeSpan duration, string? correlationId = null);
Task TrackErrorAsync(string operation, object? input, Exception error, TimeSpan duration, string? correlationId = null);
}
// Infrastructure Layer
public class LoggingExecutionTracker : IExecutionTracker
{
private readonly ILogger<LoggingExecutionTracker> _logger;
public async Task TrackAsync(string operation, object? input, object? output, TimeSpan duration, string? correlationId = null)
{
_logger.LogInformation(
"Operation {Operation} completed in {DurationMs}ms. CorrelationId: {CorrelationId}",
operation, duration.TotalMilliseconds, correlationId);
}
public async Task TrackErrorAsync(string operation, object? input, Exception error, TimeSpan duration, string? correlationId = null)
{
_logger.LogError(
error,
"Operation {Operation} failed after {DurationMs}ms. CorrelationId: {CorrelationId}",
operation, duration.TotalMilliseconds, correlationId);
}
}
// Usage in Decorator
public class ExecutionTrackingDecorator<TCommand> : CommandHandlerDecorator<TCommand>
{
private readonly IExecutionTracker _tracker;
private readonly ICorrelationIdProvider _correlationIdProvider;
public override async Task<Result> HandleAsync(TCommand command, CancellationToken ct = default)
{
var correlationId = _correlationIdProvider.GetCorrelationId();
var stopwatch = Stopwatch.StartNew();
try
{
var result = await _next.HandleAsync(command, ct);
stopwatch.Stop();
await _tracker.TrackAsync(
typeof(TCommand).Name,
SanitizeInput(command),
SanitizeOutput(result),
stopwatch.Elapsed,
correlationId);
return result;
}
catch (Exception ex)
{
stopwatch.Stop();
await _tracker.TrackErrorAsync(
typeof(TCommand).Name,
SanitizeInput(command),
ex,
stopwatch.Elapsed,
correlationId);
throw;
}
}
private object? SanitizeInput(TCommand command)
{
// Remove sensitive data before tracking
return command;
}
private object? SanitizeOutput(Result result)
{
// Sanitize output if needed
return result.IsSuccess ? "Success" : result.Error;
}
}
development
Create reusable .NET atomic capability code snippets that can be directly copied and pasted. Use when: - Creating single-purpose code snippets - Building reusable code templates - Implementing atomic technical capabilities - Creating copy-pasteable code blocks - Building snippet library for common patterns Triggers: "create snippet", "code snippet", "reusable snippet", "atomic snippet", "copy-paste code"
development
Create Docker Compose configuration for containerized .NET application development and deployment. Use when: - Containerizing .NET applications - Setting up local development environment with dependencies - Creating multi-container setups (API + DB + Redis) - Defining service dependencies and networking - Building docker-compose.yml for development or production Triggers: "docker compose", "containerize", "multi-container", "docker-compose.yml", "docker setup"
tools
Create adapter structure for integrating third-party APIs in Clean Architecture applications. Use when: - Integrating external APIs or services - Creating HTTP client adapters for third-party services - Implementing API integration with error handling - Setting up adapter pattern for external dependencies - Building resilient external service integrations Triggers: "api adapter", "third-party api", "external service", "http client adapter", "api integration"
development
Enterprise backend structure built on Clean Architecture, DDD, CQRS, and Vertical Slice API Design with Dapper-first persistence. Use when: - Creating new enterprise backend projects - Implementing Clean Architecture with DDD and CQRS - Building vertical slice API endpoints - Using Dapper as primary persistence mechanism - Organizing modules by UseCase-driven and Model-driven separation Triggers: "dmis structure", "clean architecture", "enterprise backend", "DDD CQRS", "vertical slice", "dapper"