expose-a-use-case
Skill4 starsChanged 10 days agoMITView on GitHub
How to put an Application use case on a Web API controller action - controllers on ApiControllerBase, the injected ISender, ActionResult return types, ProducesResponseType metadata, XML docs for Scalar and integration tests. Use when adding or changing an action in this Web 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/CleanGraphQLApitheir own version, first seen Nov 15, 2026
- LeanMeanCleanApps/CleanMinimalApiedited, 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/CleanMinimalApi★ 40026% 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
6 rules. 0 are common, 0 are distinctive, and 6 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.
6
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
Document the action: <summary> (short, title case, shown as the operation name), <remarks> with a sentence or two and a sample request, …
- Very specific: line 29
Add a sample request for the action to src/Presentation/Presentation.http.
- Very specific: line 30
Test it with real requests in tests/Presentation.Tests.Integration/Controllers/<Feature>EndpointTests.cs (presentation-integration-tests).
- Very specific: line 61
Put [Produces] on the base class.
- Very specific: line 63
Put [Authorize] on single actions.
“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 (Web API)
The rule
Controllers live in src/Presentation/Controllers/<Feature>/<Feature>Controller.cs, one per resource, and inherit ApiControllerBase. The base class carries [ApiController], [Consumes("application/json")] and, in a solution with authentication, [Authorize], and takes the ISender through its constructor. Each action builds the Application request, sends it with this.Sender and returns an ActionResult. The action's XML comments become the operation's documentation in Scalar. Actions 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). A new controller takes the sender in its primary constructor and passes it on:
[Route("api/reviews")] public class ReviewsController(ISender sender) : ApiControllerBase(sender)- Give each action its verb and route template,
[EndpointName(nameof(...))], and one[ProducesResponseType]per status with its content type:application/jsonfor success bodies,application/problem+jsonfor errors, none for204. - Parameters: route values by name (
Guid id),[FromQuery]on query values, the body as a request class, thenCancellationToken cancellationToken. Optional query parameters with defaults go last. - Return
ActionResult<T>for actions with a body andIActionResultfor204. Usethis.Ok(...),this.CreatedAtAction(nameof(this.GetReviewById), new { id = response.Id }, response)for creates, andthis.NoContent()for updates and deletes. - Bodies use a request class in
Controllers/<Feature>/Requests/with XML docs and<example>values. Map it to the command in the action. - Document the action:
<summary>(short, title case, shown as the operation name),<remarks>with a sentence or two and a sample request,<param>for each input except the token, and a<response code="...">for each status. - Add a sample request for the action to
src/Presentation/Presentation.http. - Test it with real requests in
tests/Presentation.Tests.Integration/Controllers/<Feature>EndpointTests.cs(presentation-integration-tests). Cover every documented status code (test-design).
Example
// src/Presentation/Controllers/Reviews/ReviewsController.cs
[HttpPost]
[EndpointName(nameof(CreateReview))]
[ProducesResponseType(typeof(Entities.Review), StatusCodes.Status201Created, "application/json")]
[ProducesResponseType(typeof(ValidationProblemDetails), StatusCodes.Status400BadRequest, "application/problem+json")]
[ProducesResponseType(typeof(ProblemDetails), StatusCodes.Status404NotFound, "application/problem+json")]
[ProducesResponseType(typeof(ProblemDetails), StatusCodes.Status500InternalServerError, "application/problem+json")]
public async Task<ActionResult<Entities.Review>> CreateReview(CreateReviewRequest request, CancellationToken cancellationToken)
{
var command = new Commands.CreateReview.CreateReviewCommand
{
AuthorId = request.AuthorId,
MovieId = request.MovieId,
Stars = request.Stars
};
var response = await this.Sender.Send(command, cancellationToken);
return this.CreatedAtAction(nameof(this.GetReviewById), new { id = response.Id }, response);
}Don't
- Resolve services from
HttpContext.RequestServices. Take them through the constructor. - Catch exceptions, check
nullor readModelStatein an action.[ApiController]and the exception handler do that. - Put
[Produces]on the base class. It adds an empty JSON body to204responses; set the content type on each[ProducesResponseType]instead. - Return an entity without
this.Ok(...). Keep every action's result explicit. - Put
[Authorize]on single actions. With authentication the base class protects everything and[AllowAnonymous]is the exception; without it there's nothing to protect (optional-token-auth).
Check
dotnet test tests/Presentation.Tests.Integration
dotnet run --project ./src/Presentation # then read the action at http://localhost:7340/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.

