endpoint-implementation
Use this skill to implement endpoints in the API
When & Why to Use This Skill
This Claude skill automates the implementation of API endpoints by following a structured feature-slice architecture. It streamlines the creation of C# record classes for commands, responses, and events while ensuring that endpoint logic adheres to specific coding guidelines, such as using Wolverine attributes for HTTP mapping and standardized 'Handle' methods for business logic.
Use Cases
- Scaffolding new API endpoints: Automatically generate the boilerplate code for new feature slices, including command/response records and the endpoint handler class.
- Standardizing architectural patterns: Ensure all new API features follow the 'feature group' and 'feature slice' directory structure as defined in the project's architecture documentation.
- Implementing Wolverine-based routing: Quickly map business logic to HTTP methods (GET, POST, PUT, DELETE) using Wolverine attributes and ensuring the correct return tuple structure.
- Enforcing coding best practices: Automatically apply naming conventions (e.g., 'Endpoint' postfix) and structure custom validation methods to maintain a clean and consistent codebase.
| name | endpoint-implementation |
|---|---|
| description | Use this skill to implement endpoints in the API |
Structure of an endpoint slice
Read the docs/architecture/05-building-block-view.md file to understand how feature groups and feature slices are structured. Each endpoint is a feature slice with a specific structure described below.
File structure
- Users/ # Feature group
- Prompts/ # Feature group
- Repositories/ # Feature group
- OnboardUserRepository.cs # Feature slice
- Repository.cs # Aggregate root
- UserRepositoryDetails.cs # Read model
- Skills/ # Feature group
Endpoint code guidelines
- Use a record class to model the command, for example:
OnboardUserRepository - Use a record class to model the response
OnboardUserRepositoryResponse - Use a record class to model any events
UserRepositoryOnboarded - Use a class postfixed with
Endpointe.g.OnboardUserRepositoryEndpointto structure the endpoint - Use a method called
Handlefor the business logic in the endpoint.- Use the
[WolverinePost("<url>")],[WolverineGet("<url>")],[WolverinePutt("<url>")]or[WolverineDelete("<url>")]attributes to enable access via HTTP. - The method should return a tuple where the first element is the response object, the second element the event, and the final element the optional side-effects.
- Use the
- Use a
Validatemethod for any custom validations that you can't model with FluentValidation validators