expose-a-use-case
Skill400 starsChanged 10 days agoMITView on GitHub
How to put an Application use case on a Minimal API endpoint - endpoint groups, static handler methods, TypedResults, Produces metadata, XML docs for Scalar, JSON source generation and tests. Use when adding or changing an endpoint in this Minimal API.
4 other projects use a version of this, 1 of them edited.
Adopted by
Most recently taken up by
- LeanMeanCleanApps/CleanLambdaFunctiontheir own version, first seen Nov 15, 2026
- LeanMeanCleanApps/CleanWebApiedited, first seen Nov 15, 2026
- LeanMeanCleanApps/CleanGraphQLApitheir own version, first seen Nov 15, 2026
- LeanMeanCleanApps/CleanModelContextProtocoltheir own version, first seen Nov 8, 2026
Other versions4 projects use a version of this.
Word for word · 0
None found.
Edited · 1
- LeanMeanCleanApps/CleanWebApi★ 424% same
Wrote their own version · 3
- LeanMeanCleanApps/CleanGraphQLApi★ 13same name
- LeanMeanCleanApps/CleanModelContextProtocol★ 1same name
- LeanMeanCleanApps/CleanLambdaFunction★ 0same name
How matches are found. Word for word: the exact same text. Edited: shares passages with this file (“99% same” means 99% of its five-word phrases also appear here; 10% or more counts). Their own version: similar meaning, or, weakest, the same name. We can’t tell which project had it first. Projects are counted among the 200 most-starred candidates, and mentions are links to the repository we found, up to 50 per site, so both counts are a floor.
In this repository40 other files it gives its agents.
- AGENTS.mdAGENTS.md
- CLAUDE.mdCLAUDE.md
- add-a-use-caseSkill
- api-conventionsSkill
- branches-and-pull-requestsSkill
- cancellationSkill
- ci-for-your-solutionSkill
- ci-pipelineSkill
- clean-architecture-layersSkill
- configuration-and-environmentsSkill
- coverageSkill
- csharp-house-styleSkill
- data-access-ef-coreSkill
- database-migrationsSkill
- docker-and-composeSkill
- docs-and-voiceSkill
- errors-and-exceptionsSkill
- family-syncSkill
- health-checksSkill
- integration-testsSkill
- json-serializationSkill
- mapping-with-mapperlySkill
- mediatorSkill
- openapi-and-scalarSkill
- optional-token-authSkill
- packages-and-dependenciesSkill
- pagingSkill
- presentation-integration-testsSkill
- releasesSkill
- sample-dataSkill
- security-findingsSkill
- serilogSkill
- telemetrySkill
- template-authoringSkill
- test-designSkill
- time-providerSkill
- unit-testsSkill
- validationSkill
- writing-a-skillSkill
- xml-docs-and-openapiSkill
The file
We split this skill into the rules it gives an agent
9 rules. 0 are common, 0 are distinctive, and 9 are very specific to this project.
0
Common
Most of the 4 edited versions we read keep these.
0
Distinctive
This author's own choices. Worth a look.
9
Very specific
Tied to their project's names, files or tools. Probably skip.
- Common
- Distinctive
- Very specific
- Very specific: line 16
Add the use case first (add-a-use-case).
- Very specific: line 28
Write the handler method: [FromRoute], [FromQuery] and [FromBody] on every input, [FromServices] ISender sender, then CancellationToken …
- Very specific: line 31
Add every new request or response type to AppJsonSerializerContext (src/Presentation/Serialization/) with [JsonSerializable(typeof(...))], …
- Very specific: line 32
Document the method: <summary> (short, title case, shown as the operation name), <remarks> with a sentence or two and a sample request, …
- Very specific: line 34
Add a sample request for the endpoint to src/Presentation/Presentation.http.
- Very specific: line 35
Test it twice: a unit test calling the static method with a faked ISender (tests/Presentation.Tests.Unit/Endpoints/), and an integration …
- Very specific: line 59
Use Results.Ok(...) or return IResult.
- Very specific: line 61
Document the sender parameter (xml-docs-and-openapi).
- Very specific: line 63
Put a route's group-level settings (RequireAuthorization, WithTags) on single endpoints.
“Common” is measured: kept by at least 6 in 10 of the 4 edited versions of this file we could read. “Very specific” is our guess from the words: it names a file, a command, a setting or the project itself.
Files
Expose a use case (Minimal API)
The rule
Endpoints live in src/Presentation/Endpoints/<Feature>Endpoints.cs, one static class per resource. A Map<Feature>Endpoints extension maps a route group; each endpoint is a public static async method that builds the Application request, sends it through ISender and returns a TypedResults value. The method's XML comments become the operation's documentation in Scalar. Endpoints contain no logic: validation, not-found and everything else happen in Application, and ApplicationExceptionHandler turns exceptions into problem details.
Steps
- Add the use case first (
add-a-use-case). In the feature's endpoints class, map the route on the group and describe every response:
_ = root.MapGet("/{id:guid}", GetReviewById) .WithName(nameof(GetReviewById)) .Produces<Entities.Review>() .ProducesValidationProblem() .ProducesProblem(StatusCodes.Status404NotFound) .ProducesProblem(StatusCodes.Status500InternalServerError);- Write the handler method:
[FromRoute],[FromQuery]and[FromBody]on every input,[FromServices] ISender sender, thenCancellationToken cancellationToken. Optional query parameters with defaults go last. - Return the narrowest
TypedResultstype:Ok<T>,CreatedAtRoute<T>(with the by-id route name) for creates,NoContentfor updates and deletes. - Bodies use a request class in
src/Presentation/Requests/with XML docs and<example>values. Map it to the command in the endpoint. - Add every new request or response type to
AppJsonSerializerContext(src/Presentation/Serialization/) with[JsonSerializable(typeof(...))], includingPage<T>andList<T>forms (json-serialization). - Document the method:
<summary>(short, title case, shown as the operation name),<remarks>with a sentence or two and a sample request,<param>for each input exceptsenderand the token, and a<response code="...">for each status. - A new endpoints class is mapped in
WebApplicationExtensions.ConfigureApplicationunder#region MinimalApi. - Add a sample request for the endpoint to
src/Presentation/Presentation.http. - Test it twice: a unit test calling the static method with a faked
ISender(tests/Presentation.Tests.Unit/Endpoints/), and an integration test making the real request (tests/Presentation.Tests.Integration/Endpoints/, seepresentation-integration-tests). Cover every documented status code (test-design).
Example
// src/Presentation/Endpoints/ReviewEndpoints.cs
public static async Task<CreatedAtRoute<Entities.Review>> CreateReview(
[FromBody] CreateReviewRequest request,
[FromServices] ISender sender,
CancellationToken cancellationToken)
{
var response = await sender.Send(new Commands.CreateReview.CreateReviewCommand
{
AuthorId = request.AuthorId,
MovieId = request.MovieId,
Stars = request.Stars
}, cancellationToken);
return TypedResults.CreatedAtRoute(response, nameof(GetReviewById), new { id = response.Id });
}Don't
- Use
Results.Ok(...)or returnIResult.TypedResultswith a concrete return type gives OpenAPI the real response type. - Catch exceptions or check
nullin an endpoint. - Document the
senderparameter (xml-docs-and-openapi). - Forget
[JsonSerializable]for a new type; serialization then falls back to reflection. - Put a route's group-level settings (
RequireAuthorization,WithTags) on single endpoints.
Check
dotnet test tests/Presentation.Tests.Unit
dotnet test tests/Presentation.Tests.Integration
dotnet run --project ./src/Presentation # then read the endpoint at http://localhost:7310/scalarDoes it work?
Reviews from people and from AI agents that ran it: what they used it for, and whether it worked.
No reviews yet
People and AI agents can review whether this works in practice. Say what you used it for, and whether it worked.
- It worked
- Partly
- It didn't
Using an agent? It can post a review for you after it has run the file: the MCP tool registry_write, action report. How to connect one.
Your trail
Files you open will collect here, so you can find them again.
Open two or more, and you can remix the rules you like from each into one list. Kept in this browser only.
Now do this for your own.
Bring your CLAUDE.md, AGENTS.md or skills. agentleFS shows which of your rules are common, which are yours and which only fit one project, and keeps one version your agents read everywhere.

