Skip to content
Development
Skill

/dotnet-patterns

Use when writing C#/.NET backend code — ASP.NET Core APIs (minimal APIs or MVC), workers, EF Core data access. Builder playbook: layout, DI lifetimes, async/cancellation, EF Core discipline, options pattern, error contract, testing shape. Complements csharp-reviewer.

From plugin
hydraia
852 skills27 agents17 commands6 hooks

Claude Code

$ npx -y skills add jdanigo/hydraia --skill dotnet-patterns --agent claude-code

SKILL.md

dotnet-patterns.SKILL.md
name: dotnet-patterns
description: Use when writing C#/.NET backend code — ASP.NET Core APIs (minimal APIs or MVC), workers, EF Core data access. Builder playbook: layout, DI lifetimes, async/cancellation, EF Core discipline, options pattern, error contract, testing shape. Complements csharp-reviewer.

C#/.NET Backend Patterns

Layout

  • Vertical slices (feature folders: endpoint + handler + models per feature) for API-shaped services; full Clean Architecture layering only when the domain genuinely warrants it — record the choice as an ADR either way.
  • Minimal APIs for small/medium surfaces; MVC controllers when filters/model-binding complexity earns it.

DI lifetimes (the classic traps)

  • Scoped services must NEVER be captured by singletons (captive dependency — resolve via `IServiceScopeFactory` inside the singleton instead).
  • `HttpClient` via `IHttpClientFactory`, never `new HttpClient()` per call (socket exhaustion).
  • Register by interface at the boundary you intend to fake in tests; concrete elsewhere is fine.

Async all the way

  • No `.Result`/`.Wait()`/`GetAwaiter().GetResult()` on async paths — deadlock and threadpool starvation fuel.
  • `CancellationToken` flows from the endpoint through every service and EF call: `await db.Orders.ToListAsync(ct)`. Endpoints accept it; libraries propagate it.
  • `ValueTask` only where profiling justifies it; default is `Task`.

EF Core discipline

  • Reads: `AsNoTracking()` by default; project to DTOs with `Select` — never return entities from queries that don't update.
  • No lazy-loading proxies: load explicitly (`Include`) so every query's shape is visible — N+1 becomes impossible to miss.
  • Migrations: one migration per change, reviewed like code; destructive column changes follow expand-contract (see db-optimization skill).
  • Transactions explicit where multi-write consistency matters (`ExecutionStrategy` + `TransactionScope`-free patterns with `BeginTransactionAsync`).

Config — options pattern

  • `IOptions<T>` with `ValidateDataAnnotations().ValidateOnStart()` — invalid config fails the boot, not the first request.
  • Secrets from user-secrets/KeyVault/env — never appsettings committed values.

Error contract

  • `ProblemDetails` (RFC 9457) via `AddProblemDetails()`; exceptions mapped centrally (exception handler middleware), typed domain exceptions → status codes. No try/catch per controller.
  • Nullable reference types ON project-wide; warnings as errors for new code.

Testing shape

  • xUnit; unit tests fake at the interface boundary.
  • `WebApplicationFactory<Program>` for integration tests over the real pipeline (routing, filters, serialization) with a test database (Testcontainers where Docker exists).
  • Snapshot the API surface where the contract matters (Verify/ApiApprovals) so drift is a failing test.
Read more
@jdanigo
Ships withhydraia

An agentic development harness for Claude Code. **One command runs the entire feature pipeline** — it collaborates with you on the design, then builds autonomously: plan, execute, double-review, and verify.

852 skills27 agents
Get the whole plugin

Stars on GitHub

Momentum

stars in total
8
Star history of jdanigo/hydraia on GitHub, a chart by star-history.com

Other skills on hydraia.

hydraia

hydraia

Use whenever the user asks to build, add, implement, or change a feature or functionality — or brings a user story or ticket to…

@jdanigo@jdanigoInstall Skill
adr

adr

Use when a design decision is made that is expensive to reverse, affects multiple components, or rejects a plausible alternative…

@jdanigo@jdanigoInstall Skill
agency-tier-ui

agency-tier-ui

Teaches the AI to design like a high-end agency. Defines the exact fonts, spacing, shadows, card structures, and animations that…

@jdanigo@jdanigoInstall Skill
api-design

api-design

Use when designing or reviewing an API surface — REST, GraphQL, or gRPC. Contract-first methodology: the contract artifact…

@jdanigo@jdanigoInstall Skill
banner-design

banner-design

Design banners for social media, ads, website heroes, creative assets, and print. Multiple art direction options with…

@jdanigo@jdanigoInstall Skill
brainstorming

brainstorming

You MUST use this before any creative work - creating features, building components, adding functionality, or modifying behavior.…

@jdanigo@jdanigoInstall Skill

More skills from other plugins.

brainstorming
Auto-invoked

brainstorming

You MUST use this before any creative work - creating features, building components, adding functionality, modifying behavior, or…

@obra@obraInstall Skill
ask-matt

ask-matt

Ask which skill or flow fits your situation. A router over the skills in this repo.

skills11d309k
@mattpocock@mattpocockInstall Skill
accessibility
Auto-invoked

accessibility

Design, implement, and audit accessible UI to WCAG 2.2 Level AA across Web, iOS, and Android — semantic ARIA roles and labels,…

ecc13d293k
@affaan-m@affaan-mInstall Skill
compiler-commit

compiler-commit

Use when you want to verify compiler changes and commit with the correct convention. Runs tests, lint, and format, then commits…

react2d252k
@facebook@facebookInstall Skill

Questions about dotnet-patterns.

Which coding agents can use dotnet-patterns?
dotnet-patterns installs in Claude Code, Codex, Cursor, Gemini CLI, GitHub Copilot, OpenCode and Windsurf with the skills CLI, using each agent's flag shown on this page. Flowy's auto-invocation, which fires a skill when your prompt matches, runs in Claude Code only.