Backend .NET
Use this pack for .NET backend work: ASP.NET Core APIs, service layers, auth flows, background processing, data access, and server-side delivery patterns that live in the C# ecosystem.
Defer first-pass route choice and lane selection to ../../reference/routing-matrix.md.
This is the general .NET backend pack for the repo. Use the overlay in reference/aspnet-core.md to tune decisions for controllers, minimal APIs, middleware pipelines, and hosted-service behavior while preserving the same quality bar for contracts, validation, documentation, and runtime clarity.
Setup posture
- Prefer modernizing, refining, or extending an existing project in place.
- Treat scaffold,
create, init, or new flows as greenfield-only and explicit-request-only. Defer to .opencode/reference/project-setup-policy.md.
Core focus
- Design API contracts that are stable across controllers, minimal APIs, filters, and client integrations.
- Keep validation, model binding, and error responses explicit so failures are predictable.
- Choose authentication and authorization flows deliberately: cookies, JWTs, OAuth2, policy-based auth, claims, or service credentials.
- Treat async I/O, hosted services, queue consumers, and cancellation as part of the service design.
- Keep OpenAPI, health signals, and failure semantics visible at the backend edge.
Shared .NET backend standards
- Keep endpoints thin and move orchestration plus business rules into services that are not coupled to transport or EF internals.
- Decide deliberately between controllers and minimal APIs based on surface area, reuse, and clarity.
- Use request models, validation rules, and
ProblemDetails-style errors so contracts stay consistent under change.
- Keep dependency-injection lifetimes explicit and make background work, retries, and scheduled execution easy to trace.
- Honor
CancellationToken, timeouts, and graceful shutdown expectations on I/O-heavy paths.
- Document shared APIs with OpenAPI and keep auth policies, claims, and role checks close to the endpoint surface.
Default workflow
- Inspect the current endpoint style, DI setup, and hosting model.
- Choose the ASP.NET Core overlay in
reference/aspnet-core.md.
- Define contracts, validation, auth flow, background behavior, and cancellation boundaries before widening the implementation.
- Implement endpoints, services, and docs together so runtime behavior stays legible.
- Run
review-work after substantial backend changes.
Collaboration in this repo
- Use
Explore before editing so the new work matches local endpoint, middleware, and service patterns.
- Use
Librarian or Context7 when framework APIs, auth configuration, or hosting behavior need a source-of-truth check.
- Pair with
architecture-integration when the hard part is really service boundaries, contracts, or client coordination.
Overlays
reference/aspnet-core.md for controllers, minimal APIs, middleware pipelines, endpoint filters, EF-adjacent services, and hosted background work.
Guardrails
- Do not leak EF entities, request objects, or framework-specific state through the whole service layer.
- Do not ignore cancellation, retry, and graceful shutdown semantics on long-running paths.
- Do not let DI lifetime mistakes turn background or request behavior into production-only bugs.
1---2name: backend-dotnet3description: Deliver C# and .NET backends with explicit API, validation, auth, async, and operational patterns centered on ASP.NET Core.4---56# Backend .NET78Use this pack for .NET backend work: ASP.NET Core APIs, service layers, auth flows, background processing, data access, and server-side delivery patterns that live in the C# ecosystem.910Defer first-pass route choice and lane selection to `../../reference/routing-matrix.md`.1112This is the general .NET backend pack for the repo. Use the overlay in `reference/aspnet-core.md` to tune decisions for controllers, minimal APIs, middleware pipelines, and hosted-service behavior while preserving the same quality bar for contracts, validation, documentation, and runtime clarity.1314## Setup posture1516- Prefer modernizing, refining, or extending an existing project in place.17- Treat scaffold, `create`, `init`, or `new` flows as greenfield-only and explicit-request-only. Defer to `.opencode/reference/project-setup-policy.md`.1819## Core focus2021- Design API contracts that are stable across controllers, minimal APIs, filters, and client integrations.22- Keep validation, model binding, and error responses explicit so failures are predictable.23- Choose authentication and authorization flows deliberately: cookies, JWTs, OAuth2, policy-based auth, claims, or service credentials.24- Treat async I/O, hosted services, queue consumers, and cancellation as part of the service design.25- Keep OpenAPI, health signals, and failure semantics visible at the backend edge.2627## Shared .NET backend standards2829- Keep endpoints thin and move orchestration plus business rules into services that are not coupled to transport or EF internals.30- Decide deliberately between controllers and minimal APIs based on surface area, reuse, and clarity.31- Use request models, validation rules, and `ProblemDetails`-style errors so contracts stay consistent under change.32- Keep dependency-injection lifetimes explicit and make background work, retries, and scheduled execution easy to trace.33- Honor `CancellationToken`, timeouts, and graceful shutdown expectations on I/O-heavy paths.34- Document shared APIs with OpenAPI and keep auth policies, claims, and role checks close to the endpoint surface.3536## Default workflow37381. Inspect the current endpoint style, DI setup, and hosting model.392. Choose the ASP.NET Core overlay in `reference/aspnet-core.md`.403. Define contracts, validation, auth flow, background behavior, and cancellation boundaries before widening the implementation.414. Implement endpoints, services, and docs together so runtime behavior stays legible.425. Run `review-work` after substantial backend changes.4344## Collaboration in this repo4546- Use `Explore` before editing so the new work matches local endpoint, middleware, and service patterns.47- Use `Librarian` or `Context7` when framework APIs, auth configuration, or hosting behavior need a source-of-truth check.48- Pair with `architecture-integration` when the hard part is really service boundaries, contracts, or client coordination.4950## Overlays5152- `reference/aspnet-core.md` for controllers, minimal APIs, middleware pipelines, endpoint filters, EF-adjacent services, and hosted background work.5354## Guardrails5556- Do not leak EF entities, request objects, or framework-specific state through the whole service layer.57- Do not ignore cancellation, retry, and graceful shutdown semantics on long-running paths.58- Do not let DI lifetime mistakes turn background or request behavior into production-only bugs.