Serena MCP is mandatory for C# code. First call
mcp__serena__initial_instructionsto load the Serena tool manual, then use the Serena tools for ALL.csreading / searching / navigation / creation / editing — prefer symbol navigation (get_symbols_overview/find_symbol/find_referencing_symbols) over whole-file reads. NativeEdit/Writeon.csis hook-blocked (the TS/React frontend uses the native tools).
Add a Minimal API endpoint
The procedure for our thin, feature-sliced API layer. Source of truth (the facts — read them):
.claude/rules/backend/api-design.md, result-and-errors.md, cqrs-kommand.md. C# (.cs) edits go through
Serena (native Edit/Write on .cs is blocked).
Steps
- Feature folder, single file. Create
{{ProjectName}}.Api/Features/<Feature>/<UseCase>.csholding the endpoint + request record + response record together (REPR style — one file per use case). - Implement
IEndpoint—void MapEndpoint(IEndpointRouteBuilder app)mapping the verb under aMapGroupfor the feature (.WithTags("<Feature>")). The endpoint auto-registers via the reflection scan (AddEndpoints/MapEndpointsinProgram.cs) — do not editProgram.csto add a route. - Contract validation only — bind the request; validate shape/required fields and authz inferable from
HttpContext.User(JWT/cookie). No database calls here. (Business validation → the KommandIValidator; invariants → the domain.) - Dispatch Kommand — build the command/query and
await mediator.SendAsync(...)(command) orQueryAsync(...)(query). InjectIMediatoronly. The command/query + handler live in the Application layer — author them with thecqrs-kommandskill (and mirror the feature folder there). - Map the result — the handler returns
Result<T>; convert with theToHttpResult/ToProblemextension (TypedResults). Every failure → RFC 9457 ProblemDetails. Success uses the right typed result (TypedResults.Created(...)/Ok(...)). - Build —
dotnet build(warnings = errors); fix before returning.
Conventions (restated)
- No business logic, persistence, or model routing in the endpoint — it binds, validates the contract, dispatches.
- Records for request/response/command/query; rich classes for entities.
- No new library (e.g. FastEndpoints/FluentValidation) — hand-rolled Minimal API only, per the no-library rule.
- Tests for the endpoint go through the
write-testsskill, per the plan's exact test list.