Skip to content
Back to skills

Dotnet Patterns

ASecurity

Use when idiomatic C# and .NET patterns, conventions, dependency injection, async/await, and best practices for building robust, maintainable .NET applications. Only for C#/.NET — not for other languages. Triggers on \"dotnet-patterns\", \"dotnet patterns\", \"patterns\".

  • 2 stars
  • 0 votes
  • 0 copies
  • 2 views
  • Added September 19, 2026
ai-agentsgoc#refactoring

Security analysis

A100/100

Pro scans all 7 files and shows the line behind each finding

Scanned September 19, 2026

npx -y skills add majinmagros/magros.ai-skills --skill dotnet-patterns --agent claude-code

Installs into .claude/skills of the current project.

Are you the author of Dotnet Patterns?

Add the live security badge to your README. It updates with every re-scan.

Security grade badge for Dotnet Patterns
[![Security: A — Skills Directory](https://www.skillsdirectory.com/api/skills/majinmagros-dotnet-patterns/badge)](https://www.skillsdirectory.com/skills/majinmagros-dotnet-patterns)

More formats (shields.io, HTML) on the badges page. Keep it an A: scan every change in CI with Pro.

Download with Pro
SKILL.md
---
name: dotnet-patterns
description: "Use when idiomatic C# and .NET patterns, conventions, dependency injection, async/await, and best practices for building robust, maintainable .NET applications. Only for C#/.NET — not for other languages. Triggers on \"dotnet-patterns\", \"dotnet patterns\", \"patterns\"."
metadata:
  origin: ECC
---

# .NET Development Patterns

Idiomatic C# and .NET patterns for building robust, performant, and maintainable applications.

## When to Activate

- Writing new C# code
- Reviewing C# code
- Refactoring existing .NET applications
- Designing service architectures with ASP.NET Core

## Core Principles

### 1. Prefer Immutability

Use records and init-only properties for data models. Mutability should be an explicit, justified choice.

```csharp
// Good: Immutable value object
public sealed record Money(decimal Amount, string Currency);

// Good: Immutable DTO with init setters
public sealed class CreateOrderRequest
{
    public required string CustomerId { get; init; }
    public required IReadOnlyList<OrderItem> Items { get; init; }
}

// Bad: Mutable model with public setters
public class Order
{
    public string CustomerId { get; set; }
    public List<OrderItem> Items { get; set; }
}
```

### 2. Explicit Over Implicit

Be clear about nullability, access modifiers, and intent.

```csharp
// Good: Explicit access modifiers and nullability
public sealed class UserService
{
    private readonly IUserRepository _repository;
    private readonly ILogger<UserService> _logger;

    public UserService(IUserRepository repository, ILogger<UserService> logger)
    {
        _repository = repository ?? throw new ArgumentNullException(nameof(repository));
        _logger = logger ?? throw new ArgumentNullException(nameof(logger));
    }

    public async Task<User?> FindByIdAsync(Guid id, CancellationToken cancellationToken)
    {
        return await _repository.FindByIdAsync(id, cancellationToken);
    }
}

Files in this skill

  • SKILL.md1.9 KB
  • references/api-middleware.md1.7 KB
  • references/async.md1.3 KB
  • references/configuration-results.md1.4 KB
  • references/data-access.md1016 B
  • references/guards-antipatterns.md1.2 KB
  • references/principles.md1.9 KB

Attribution

Is this your skill, or is something wrong with this listing? Request removal or report an issue. Author removals are honored within 72 hours.

Comments

Loading comments…