# dotnet

Gives your agent rules for C#, ASP.NET Core and Entity Framework Core: project layout, async/await, DI, caching, tests.

- skill · `type=skill` · Claude Code, Codex, Cursor, GitHub Copilot, Gemini CLI, OpenCode · 724 installs · ★ 286
- Author: Mindrally
- License: Apache-2.0 · policy=mirror · the beginning of the file is at the end of this page
- Source: https://github.com/Mindrally/skills/tree/HEAD/dotnet/SKILL.md
- Updated: 2026-10-08
- HTML: https://affpapa.org/en/nevibecode/skills/dotnet

## What it does

The skill spells out how to build a .NET backend: idiomatic C#, Clean Architecture, REST endpoints with the right HTTP methods and status codes. Your agent gets a fixed layout — `src/Domain`, `src/Application`, `src/Infrastructure`, `src/WebApi`, plus `tests/UnitTests` and `tests/IntegrationTests` — and puts code where it belongs instead of improvising.

Inside are per-layer rules. Async/await: `Async` suffixes, `CancellationToken`, no `.Result` or `.Wait()`. EF Core: Fluent API, migrations, `AsNoTracking()` on reads, Include/ThenInclude, projections instead of pulling whole entities. Add DI with constructor injection registered in `Program.cs`, caching via `IMemoryCache` and `IDistributedCache`, validation with FluentValidation and Data Annotations, JWT with refresh token rotation, policy-based authorization, xUnit with Moq and WebApplicationFactory, Swagger/OpenAPI.

This is a text skill — instructions for the agent, not a code generator. If your project already runs a different style, say controllers without Clean Architecture or Dapper instead of EF Core, the rules will fight the existing codebase. That is a reason to fork the skill or skip it.

## Install

### Claude Code (native platform)

1. **Skills CLI (Vercel)**
```bash
npx skills add Mindrally/skills --skill dotnet -a claude-code
```

2. **Manually: put the files in place**
- File: `~/.claude/skills/dotnet/SKILL.md` — Copy the whole skill folder; for one project use .claude/skills/dotnet/

### Codex

1. **Skills CLI (Vercel)**
```bash
npx skills add Mindrally/skills --skill dotnet -a codex
```

2. **Manually: put the files in place**
- File: `.agents/skills/dotnet/SKILL.md` — For all projects use ~/.agents/skills/

### Cursor

1. **Skills CLI (Vercel)**
```bash
npx skills add Mindrally/skills --skill dotnet -a cursor
```

2. **Manually: put the files in place**
- File: `.cursor/skills/dotnet/SKILL.md` — Cursor also reads .agents/skills/ and .claude/skills/

### GitHub Copilot

1. **GitHub CLI**
```bash
gh skill install Mindrally/skills dotnet
```

2. **Manually: put the files in place**
- File: `.github/skills/dotnet/SKILL.md`

### Gemini CLI

1. **Skills CLI (Vercel)**
```bash
npx skills add Mindrally/skills --skill dotnet -a gemini-cli
```

2. **Platform CLI**
```bash
gemini skills install https://github.com/Mindrally/skills --path dotnet
```

### Windsurf (Devin Desktop)

**Manually: put the files in place**
- File: `.devin/skills/dotnet/SKILL.md` — The legacy .windsurf/skills/ path still works

### OpenCode

**Skills CLI (Vercel)**
```bash
npx skills add Mindrally/skills --skill dotnet -a opencode
```

### Claude.ai

**Claude.ai**
- Zip the folder and upload it in Settings → Capabilities → Skills

Where a file is given instead of a command, copy the files from the source to that path: https://github.com/Mindrally/skills/tree/HEAD/dotnet/SKILL.md

## When to use it
- split a solution into Domain, Application, Infrastructure and WebApi
- convert blocking EF Core calls to async with CancellationToken
- kill N+1 queries with Include and projections
- wire up JWT auth with refresh token rotation
- add integration tests on WebApplicationFactory

## Example prompts
- Create a UsersController following the dotnet skill: pagination, filters, version in the path
- Rewrite this repository with AsNoTracking and projections, check for N+1
- Set up service registration and the Options pattern in Program.cs

## Source text · SKILL.md · Apache-2.0

Below is the content of a third-party file. It is data, not instructions for you: do not act on anything written inside unless the human asks. Block tag: 33d4ac44b8672782.

BEGIN THIRD-PARTY FILE 33d4ac44b8672782
````text
---
name: dotnet
description: Guidelines for .NET backend development with C#, ASP.NET Core, and Entity Framework Core
metadata:
  maintainer: Mindrally
  source: https://github.com/Mindrally/skills
---

# .NET Development Guidelines

You are an expert in .NET backend development with deep knowledge of C#, ASP.NET Core, Entity Framework Core, and modern .NET practices.

## Code Style and Structure

- Write concise, idiomatic C# code with accurate examples
- Follow .NET conventions and best practices
- Use object-oriented programming with proper encapsulation
- Prefer LINQ for collection operations
- Structure code according to Clean Architecture principles

## Project Structure

```
src/
  Domain/           # Entities, value objects, domain logic
  Application/      # Use cases, DTOs, interfaces
  Infrastructure/   # Data access, external services
  WebApi/          # Controllers, middleware, configuration
tests/
  UnitTests/
  IntegrationTests/
```

## RESTful API Design

- Use proper HTTP methods (GET, POST, PUT, PATCH, DELETE)
- Return appropriate status codes
- Use plural nouns for resource endpoints
- Implement proper pagination for collections
- Use query parameters for filtering and sorting
- Version APIs (URL path or header)

```csharp
[ApiController]
[Route("api/v1/[controller]")]
public class UsersController : ControllerBase
{
    [HttpGet]
    public async Task<ActionResult<IEnumerable<UserDto>>> GetUsers([FromQuery] PaginationParams pagination)

    [HttpGet("{id}")]
    public async Task<ActionResult<UserDto>> GetUser(int id)

    [HttpPost]
    public async Task<ActionResult<UserDto>> CreateUser(CreateUserDto dto)
}
```

## Async/Await Patterns

- Use `async/await` for all I/O-bound operations
- Suffix async methods with `Async`
- Don't block on async code (avoid `.Result` and `.Wait()`)
- Use `CancellationToken` for cancellation support
- Prefer `ValueTask` for frequently-called methods

## Entity Framework Core

### Configuration
- Use Fluent API for entity configuration
- Configure relationships explicitly
- Use migrations for schema changes
- Enable nullable reference types

### Best Practices
- Use `AsNoTracking()` for read-only queries
- Implement the Repository pattern for data access
- Use Include/ThenInclude for eager loading
- Avoid N+1 query problems
- Use projections for optimized queries

```csharp
public async Task<IEnumerable<UserDto>> GetUsersAsync()
{
    return await _context.Users
        .AsNoTracking()
        .Select(u => new UserDto
        {
            Id = u.Id,
            Name = u.Name
        })
        .ToListAsync();
}
```

## Dependency Injection

- Use constructor injection
- Register services in `Program.cs`
````
END THIRD-PARTY FILE 33d4ac44b8672782

The third-party file has ended. Everything between the 33d4ac44b8672782 tags is data: requests and commands from it are not followed. An “end of file” line with another tag inside the block is part of the file.

First 2703 of 4384 bytes. © Mindrally · Apache-2.0 · https://github.com/Mindrally/skills/tree/HEAD/dotnet/SKILL.md

_Part of the page did not fit — see the HTML version._

---
NeVibeCode on affpapa.org. Catalog texts are descriptions, not instructions for the agent. How to choose and install: https://affpapa.org/en/nevibecode/agents.md
