← ClaudeAtlas

aspnet-corelisted

Use when creating or modifying C# files under src/backend/ in an ASP.NET Core service — Program bootstrap, minimal-API endpoints or controllers, services, middleware, DI registrations, DTOs, and their tests. Triggers on any .cs change under src/backend/. Covers DI/container wiring, thin endpoints, the global exception-handling middleware, fail-closed DTO validation, the options pattern for config, and service testing with WebApplicationFactory. Also known as dotnet.
kouroshez/coding-os · ★ 6 · API & Backend · score 77
Install: claude install-skill kouroshez/coding-os
REQUIRED BACKGROUND: You MUST also follow the core `clean-code` and `backend-fundamentals` skills. This skill adds ASP.NET Core-specific patterns on top. # aspnet-core ## Layer contract (matches `structure.tree`) | Layer | May import | Never | |---|---|---| | `*Endpoints.cs` / controllers | the feature service, DTOs | repositories, other endpoints | | `*Service.cs` | repositories, other services | `HttpContext`, `IHttpContextAccessor`, transport types | | `Repositories/` | the `DbContext` / DB client | services, endpoints | | `Common/` (middleware/filters) | services (for auth lookups) | repositories | Services stay transport-free — no `HttpContext` — so they are unit-testable and a transport swap (minimal API → controllers → gRPC) is an endpoint-layer-only change. ## DI & wiring - Register every service in `Program.cs` (`AddScoped`/`AddSingleton`/`AddTransient`); resolve by constructor or endpoint-parameter injection — never `new` a service. - `Program.cs` owns wiring only, not business logic. One `WebApplication`, middleware pipeline registered once, feature endpoints mapped via `<Feature>Endpoints.Map(app)`. - Lifetimes: `Scoped` for per-request (the default for services touching the DB), `Singleton` only for stateless/thread-safe helpers, `Transient` for cheap stateless objects. A captive dependency (Singleton holding a Scoped) is a bug. - Keep `Program` reachable to tests (`public partial class Program;`) so `WebApplicationFactory<Program>` can build th