dotnet-aspnetcore-service
БесплатноБез исполняемых скриптовНе проверенUse when building or extending a C# service on ASP.NET Core - Minimal APIs or controllers, DI and options, EF Core with Npgsql, ProblemDetails…
от makifbaysal★ 123 звезды на GitHubОб этом скилле
ASP.NET Core Service (C#)
Overview
ASP.NET Core is the .NET backend stack: one host for HTTP, DI, configuration, logging and background work. Build in layers so the framework stays at the edges and the domain stays plain C#.
Core principle: the repository's shape wins. Minimal APIs or MVC controllers, EF Core or Dapper, Clean Architecture projects or one project — follow what is there. The patterns below are for new code and for the gaps.
Layers
| Layer | Responsibility | ASP.NET Core surface |
|---|---|---|
| Endpoint | HTTP in/out, binding, status codes | MapGroup + MapPost (Minimal APIs) or [ApiController] controllers |
| Application service | Use-case orchestration, business rules | a class registered in DI, constructor-injected, CancellationToken on every async method |
| Domain | Entities, value objects, invariants | plain C#, no ASP.NET or EF attributes driving behaviour |
| Infrastructure | Persistence, outbound HTTP, queues | DbContext, typed HttpClient, BackgroundService |
Dependencies point inward: an endpoint calls a service, a service depends on an interface the infrastructure implements. An endpoint never contains business rules; a service never takes HttpContext.
Patterns
- Target framework: keep the repository's
TargetFramework. A new service targets the current LTS (net10.0); never move a repository to a preview SDK in a feature task.global.jsonpins the SDK when the repository has one. - Nullable reference types on (
<Nullable>enable</Nullable>); treat a new nullable warning as a bug, not noise. RespectTreatWarningsAsErrorsand.editorconfiganalyzers. - Constructor injection (primary constructors are fine):
public sealed class TaskService(ITaskRepository repo, TimeProvider clock). Lifetimes:DbContextscoped, stateless services scoped or singleton, never a scoped dependency captured by a singleton. - Options pattern for configuration:
builder.Services.AddOptions<SmtpOptions>().BindConfiguration("Smtp").ValidateDataAnnotations().ValidateOnStart();— never readIConfiguration["..."]in a service, never hardcode. - DTOs at the edge (records), mapped to and from the domain in the service. Never bind a request onto an EF entity or return one.
- Validation at the boundary: DataAnnotations on the request record with
builder.Services.AddValidation()(Minimal APIs, .NET 10) or[ApiController]model validation; FluentValidation where the repository already uses it. The domain enforces its own invariants too. - Errors in one shape:
builder.Services.AddProblemDetails(),app.UseExceptionHandler()and anIExceptionHandlerthat maps domain exceptions to 400/404/409. Endpoints returnTypedResults(Results<Created<TaskResponse>, ValidationProblem>), not ad-hoc anonymous objects. No stack trace in a response body. - Async all the way:
awaitevery I/O call and pass the request'sCancellationTokendown to EF andHttpClient. Never.Result,.Wait()orasync void(outside event handlers). - EF Core:
AsNoTracking()for reads, projection (Select) to DTOs instead of loading graphs,Includeonly for what the response needs. Postgres viaNpgsql.EntityFrameworkCore.PostgreSQL. Raw SQL only throughFromSql/SqlQuerywith interpolated parameters (they are parameterized) — neverFromSqlRawwith string concatenation. - Migrations:
dotnet ef migrations add <Name>, review the generatedUp/Down, commit the migration and the model snapshot together. Deploys apply an idempotent script (dotnet ef migrations script --idempotent) or a migration bundle;Database.Migrate()at startup races when several instances start andEnsureCreated()never belongs outside tests. postgres-migrations covers safe DDL. - Outbound HTTP: a typed client from
IHttpClientFactory(builder.Services.AddHttpClient<PaymentsClient>()) withAddStandardResilienceHandler()(Microsoft.Extensions.Http.Resilience) for timeouts, retries and circuit breaking. Nevernew HttpClient()per call. - Background work: a
BackgroundServicethat creates a scope per unit of work (IServiceScopeFactory) and honoursstoppingToken. - Logging:
ILogger<T>with message templates (logger.LogInformation("Task {TaskId} created", id)), never string interpolation in a log call;[LoggerMessage]source-generated methods on hot paths. No secrets or PII in a log or a ProblemDetails body. - Time and ids: inject
TimeProviderinstead ofDateTime.UtcNowso tests control the clock;Guid.CreateVersion7()for new time-ordered ids where the repository has no id scheme. - OpenAPI: the built-in
builder.Services.AddOpenApi()/app.MapOpenApi()document; keep it in step with api-contract-openapi. New code does not add Swashbuckle.
Worked Example
POST /tasks creating a task:
public sealed record CreateTaskRequest([property: Required, StringLength(200)] s
Установить dotnet-aspnetcore-service в Claude Code и Claude Desktop
Зарегайся, чтобы установить скилл
Создай бесплатный аккаунт, чтобы открыть команду установки и сохранить скилл в библиотеку.
- Открой команду установки в одну строку
- Сохраняй скиллы в синхронизируемую библиотеку
- Уведомления, когда скиллы обновляются
Разрешённые инструменты
Инструменты, которые скиллу разрешено вызывать.
Без ограничений — скилл может использовать любой инструмент.
FAQ
Что делает скилл dotnet-aspnetcore-service?
Use when building or extending a C# service on ASP.NET Core - Minimal APIs or controllers, DI and options, EF Core with Npgsql, ProblemDetails, HttpClientFactory resilience, async and cancellation
Как установить скилл dotnet-aspnetcore-service?
Скопируй папку скилла в ~/.claude/skills (вкладка Claude Code выше делает это одной командой), либо поставь как плагин.
Скилл dotnet-aspnetcore-service запускает скрипты?
Нет, скилл состоит только из инструкций (SKILL.md), без исполняемых скриптов.
Похожие скиллы
theme-factory
Toolkit for styling artifacts with a theme. These artifacts can be slides, docs, reportings, HTML landing pages, etc. There are 10 pre-set themes with…
от Anthropicaccess
Manage Discord channel access — approve pairings, edit allowlists, set DM/group policy. Use when the user asks to pair, approve someone, check who's allowed…
от Anthropicconfigure
Set up the Discord channel — save the bot token and review access policy. Use when the user pastes a Discord bot token, asks to configure Discord, asks "how…
от Anthropicaccess
Manage iMessage channel access — approve pairings, edit allowlists, set DM/group policy. Use when the user asks to pair, approve someone, check who's allowed…
от Anthropic