dotnet-idioms
irahardianto/awesome-agv/.agents/skills/dotnet-idioms/SKILL.md
.NET 8+ framework architecture: Minimal APIs, EF Core data access, IOptions configuration, middleware pipelines, and WebApplicationFactory testing. Use when building ASP.NET Core services, Web APIs, or .NET cloud backends. Pair with csharp-idioms.
Skill157 starsChanged 43 days ago
What's in it
- .NET Idioms and Patterns
- Minimal APIs
- Entity Framework Core
- Configuration
- Middleware
- Testing
- Formatting and Static Analysis
- Related
---
name: dotnet-idioms
description: >-
.NET 8+ framework architecture: Minimal APIs, EF Core data access, IOptions configuration, middleware pipelines, and WebApplicationFactory testing. Use when building ASP.NET Core services, Web APIs, or .NET cloud backends. Pair with csharp-idioms.
---
## .NET Idioms and Patterns
.NET 8+ rewards minimal APIs, DI, and async-first design. Idiomatic .NET = clean, performant, cloud-native.
> Scope: .NET framework patterns. For C#: `@.agents/skills/csharp-idioms/SKILL.md`.
### Minimal APIs
1. **Minimal APIs for simple endpoints:**
```csharp
app.MapGet("/api/tasks/{id}", async (string id, ITaskService service) =>
await service.GetByIdAsync(id) is Task task
? Results.Ok(task)
: Results.NotFound());
app.MapPost("/api/tasks", async (CreateTaskRequest request, ITaskService service) =>
{
var task = await service.CreateAsync(request);
return Results.Created($"/api/tasks/{task.Id}", task);
});
```
2. **Controllers for complex endpoints** with filters, model binding, etc.
### Entity Framework Core
1. **DbContext per request** (scoped lifetime).
2. **Migrations via CLI:**
```bash
dotnet ef migrations add AddTaskPriority
dotnet ef database update
```
3. **`AsNoTracking()`** for read-only queries.
4. **Compiled queries** for hot paths.
### Configuration
1. **`IOptions<T>`** pattern for strongly-typed config:
```csharp
builder.Services.Configure<DatabaseOptions>(builder.Configuration.GetSection("Database"));
```
2. **User secrets** for local development, Key Vault for production.
### Middleware
1. **Custom middleware** for cross-cutting concerns (logging, correlation IDs).
2. **`UseExceptionHandler`** for global error handling.
### Testing
> For universal testing principles, see `.agents/rules/testing-strategy.md`. Below: language-specific patterns only.
1. **xUnit + FluentAssertions:**
```csharp
[Fact]
public async Task GetTask_ReturnsOk_WhenExists()
{
var client = _factory.CreateClient();
var response = await client.GetAsync("/api/tasks/1");
response.StatusCode.Should().Be(HttpStatusCode.OK);
}
```
2. **`WebApplicationFactory<T>`** for integration tests.
3. **Respawn** for database cleanup.
### Formatting and Static Analysis
| Tool | Purpose | Command |
|---|---|---|
| `dotnet format` | Formatting | `dotnet format` |
| Roslyn analyzers | Analysis | Built-in |
| `dotnet list package --vulnerable` | CVE scanning | Built-in |
### Related
- C# Idioms @.agents/skills/csharp-idioms/SKILL.md
- API Design Principles @.agents/rules/api-design-principles.md
- Database Design Principles @.agents/rules/database-design-principles.md
More agent context in irahardianto/awesome-agv
59 other files this repository gives its agents.
AGENTS.md
Skill
- adr.agents/skills/adr/SKILL.md
- agent-protocols.agents/skills/agent-protocols/SKILL.md
- angular-idioms.agents/skills/angular-idioms/SKILL.md
- api-documentation.agents/skills/api-documentation/SKILL.md
- axum-idioms.agents/skills/axum-idioms/SKILL.md
- browser-automation.agents/skills/browser-automation/SKILL.md
- chaos-testing.agents/skills/chaos-testing/SKILL.md
- ci-cd.agents/skills/ci-cd/SKILL.md
- cli-development.agents/skills/cli-development/SKILL.md
- code-audit.agents/skills/code-audit/SKILL.md
- code-review.agents/skills/code-review/SKILL.md
- cpp-idioms.agents/skills/cpp-idioms/SKILL.md
- csharp-idioms.agents/skills/csharp-idioms/SKILL.md
- data-engineering.agents/skills/data-engineering/SKILL.md
- debugging-protocol.agents/skills/debugging-protocol/SKILL.md
- django-idioms.agents/skills/django-idioms/SKILL.md
- elixir-idioms.agents/skills/elixir-idioms/SKILL.md
- embedded-systems.agents/skills/embedded-systems/SKILL.md
- feature-flags.agents/skills/feature-flags/SKILL.md
- flutter-idioms.agents/skills/flutter-idioms/SKILL.md
- frontend-design.agents/skills/frontend-design/SKILL.md
- git-commit-integrity.agents/skills/git-commit-integrity/SKILL.md
- go-idioms.agents/skills/go-idioms/SKILL.md
- guardrails.agents/skills/guardrails/SKILL.md
- hono-idioms.agents/skills/hono-idioms/SKILL.md
- incident-response.agents/skills/incident-response/SKILL.md
- java-idioms.agents/skills/java-idioms/SKILL.md
- javascript-idioms.agents/skills/javascript-idioms/SKILL.md
- kotlin-idioms.agents/skills/kotlin-idioms/SKILL.md
- laravel-idioms.agents/skills/laravel-idioms/SKILL.md
- logging-implementation.agents/skills/logging-implementation/SKILL.md
- ml-engineering.agents/skills/ml-engineering/SKILL.md
- mobile-design.agents/skills/mobile-design/SKILL.md
- mobile-testing.agents/skills/mobile-testing/SKILL.md
- nextjs-idioms.agents/skills/nextjs-idioms/SKILL.md
- parallel-dispatch.agents/skills/parallel-dispatch/SKILL.md
- payment-integration.agents/skills/payment-integration/SKILL.md
- perf-optimization.agents/skills/perf-optimization/SKILL.md
- php-idioms.agents/skills/php-idioms/SKILL.md
- postgres-idioms.agents/skills/postgres-idioms/SKILL.md
- python-idioms.agents/skills/python-idioms/SKILL.md
- rails-idioms.agents/skills/rails-idioms/SKILL.md
- react-idioms.agents/skills/react-idioms/SKILL.md
- refactoring-patterns.agents/skills/refactoring-patterns/SKILL.md
- research-methodology.agents/skills/research-methodology/SKILL.md
- ruby-idioms.agents/skills/ruby-idioms/SKILL.md
- rust-idioms.agents/skills/rust-idioms/SKILL.md
- security-audit.agents/skills/security-audit/SKILL.md
- sequential-thinking.agents/skills/sequential-thinking/SKILL.md
- spring-boot-idioms.agents/skills/spring-boot-idioms/SKILL.md
- sql-idioms.agents/skills/sql-idioms/SKILL.md
- structured-spec.agents/skills/structured-spec/SKILL.md
- supply-chain-security.agents/skills/supply-chain-security/SKILL.md
- swift-idioms.agents/skills/swift-idioms/SKILL.md
- testability-patterns.agents/skills/testability-patterns/SKILL.md
- testing-strategy.agents/skills/testing-strategy/SKILL.md
- typescript-idioms.agents/skills/typescript-idioms/SKILL.md
- vue-idioms.agents/skills/vue-idioms/SKILL.md
Discussion
Did it work?
Say what you used it for and what you changed. People and their agents can both post here.
No reports yet. Be the first to say whether it worked.
Posts are public. Sign in to say whether it worked for you.Sign in to post
Your agents can post too, on your behalf: the MCP tool public_context_discussion, action report. How to connect one.

