Skip to content
Back to skills

Stack Dotnet

ASecurity

ASP.NET Core + C# backend — minimal APIs, dependency injection, EF Core, nullable reference types

  • 3 stars
  • 0 votes
  • 0 copies
  • 0 views
  • Added November 6, 2026
ai-agentsgoc#sqlapibackend

Works with

  • api

Security analysis

A100/100

Scanned November 20, 2026

npx -y skills add Snakeblack/ospec-workflow --skill stack-dotnet --agent claude-code

Installs into .claude/skills of the current project.

Are you the author of Stack Dotnet?

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

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

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: stack-dotnet
description: "ASP.NET Core + C# backend — minimal APIs, dependency injection, EF Core, nullable reference types"
license: MIT AND Commons-Clause
metadata:
  author: "affaan-mustafa, manuel-retamozo-garcia"
  version: "1.0"
capabilities: [dotnet]
---

## Critical Rules

- Any executor sub-agent using this skill must first inspect the workspace structure to auto-detect the project's flavor.
- If MVC controllers are present (e.g., `Controllers/` directory or controller classes), it must use controllers and traditional WebAPI routing.
- If routes are mapped inline in `Program.cs` without controllers, it must follow the Minimal APIs pattern.
- If multiple projects/directories exist representing Clean Architecture/DDD (e.g. Domain, Application, Infrastructure layers), it must respect the layered separation and domain patterns.
- Always enable and enforce nullable reference types (`<Nullable>enable</Nullable>`) to prevent null reference exceptions.

## 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);
    }
}
```

### 3. Depend on Abstractions

Use interfaces for service boundaries. Register via DI container.

```csharp
// Good: Interface-based dependency
public interface IOrderRepository
{
    Task<Order?> FindByIdAsync(Guid id, CancellationToken cancellationToken);
    Task<IReadOnlyList<Order>> FindByCustomerAsync(string customerId, CancellationToken cancellationToken);
    Task AddAsync(Order order, CancellationToken cancellationToken);
}

// Registration
builder.Services.AddScoped<IOrderRepository, SqlOrderRepository>();
```

## Async/Await Patterns

### Proper Async Usage

```csharp
// Good: Async all the way, with CancellationToken
public async Task<OrderSummary> GetOrderSummaryAsync(
    Guid orderId,
    CancellationToken cancellationToken)
{
    var order = await _repository.FindByIdAsync(orderId, cancellationToken)
        ?? throw new NotFoundException($"Order {orderId} not found");

    var customer = await _customerService.GetAsync(order.CustomerId, cancellationToken);

    return new OrderSummary(order, customer);
}
```

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.

View all in ai-agents →

Comments

Loading comments…

Newsletter

Get the weekly list of safe new skills, and the ones we pulled.