Api design
Skill gagandeepp/software-agent-teams/.claude/skills/api-design
Use when designing or adding ASP.NET Core Web API endpoints in the LMS backend — Clean Architecture with CQRS, MediatR, FluentValidation, and IdentityServer4 JWT auth. Triggers on new controller actions, request/handler/DTO creation, or URL naming decisions.From its SKILL.md
npx -y skills add gagandeepp/software-agent-teams --skill api-designAssembled from the repository path, not quoted from the project. Check it against their README if it does not work.
2 things to look at
- no licenseNo license file was found in the repository. Code published without one is not open source by default, so using it at work is a question for whoever answers licensing questions where you are.
- 0 stars0 stars. Stars are a popularity signal and not a quality one, but at this level it is likely that nobody has read this closely except its author, and you would be relying on your own review.
SKILL.md
4.5 KB, as published. Nobody here has run it
Skill: API Design Conventions
Overview
Ensure consistent, well-structured ASP.NET Core Web API endpoints aligned with Clean Architecture and CQRS patterns. Controllers are thin — all logic lives in MediatR handlers.
Stack: .NET 9 · MediatR · FluentValidation · Mapster · Swashbuckle · IdentityServer4
Controller Design
Controllers delegate everything to MediatR. No business logic.
[ApiController]
[Route("api/v1/[controller]")]
public class CoursesController : ControllerBase
{
private readonly IMediator _mediator;
public CoursesController(IMediator mediator) => _mediator = mediator;
[HttpPost]
[ProducesResponseType(typeof(CourseDto), StatusCodes.Status201Created)]
[ProducesResponseType(StatusCodes.Status400BadRequest)]
public async Task<IActionResult> Create([FromBody] CreateCourseRequest request)
{
var result = await _mediator.Send(request);
return CreatedAtAction(nameof(GetById), new { id = result.Id }, result);
}
}
Naming Conventions
| Artifact | Convention | Example |
|---|---|---|
| Command request | {Verb}{Entity}Request | CreateCourseRequest |
| Query request | Get{Entity}Request | GetCourseByIdRequest |
| Handler | {Verb}{Entity}RequestHandler | CreateCourseRequestHandler |
| Validator | {RequestName}Validator | CreateCourseRequestValidator |
| DTO | {Entity}Dto | CourseDto |
| Store | I{Entity}Store / {Entity}Store | ICourseStore |
URL Design
- Plural nouns:
/api/v1/courses,/api/v1/tracks - Kebab-case:
/api/v1/learning-tracks,/api/v1/audit-logs - Always prefix
/api/v1/ - Max 2 levels of nesting:
/api/v1/tracks/{trackId}/topics/{topicId}✅ - Never use GET for side-effecting operations
HTTP Methods
| Method | Use | Idempotent? |
|---|---|---|
| GET | Read | Yes |
| POST | Create | No |
| PUT | Full replace | Yes |
| PATCH | Partial update | No |
| DELETE | Remove | Yes |
Validation
All validation via FluentValidation — never in controllers or handlers.
public class CreateCourseRequestValidator : AbstractValidator<CreateCourseRequest>
{
public CreateCourseRequestValidator()
{
RuleFor(x => x.Title).NotEmpty().MaximumLength(200);
RuleFor(x => x.Type).IsInEnum();
}
}
Validators are auto-discovered by RequestValidationBehavior. Failures return 400 before handler runs.
Response Codes
Success:
| Code | When |
|---|---|
| 200 | GET, PUT, PATCH |
| 201 | POST — use CreatedAtAction |
| 204 | DELETE |
Errors:
| Code | When |
|---|---|
| 400 | Validation failure |
| 401 | Not authenticated |
| 403 | Not authorized |
| 404 | Not found |
| 409 | Conflict / duplicate |
| 422 | Semantic validation failure |
| 500 | Unhandled (global middleware) |
Never return 200 with an error body.
Pagination
public class GetCoursesRequest : IRequest<PaginatedResult<CourseDto>>
{
public int Page { get; set; } = 1;
public int PageSize { get; set; } = 20; // max 100
public string? SearchTerm { get; set; }
}
Adding a New Endpoint (Checklist)
- Domain entity in
LMS.Domain/Entities/ - DTO in
LMS.Application/DTOs/ - Request in
LMS.Application/{Mutables|Immutables}/ - Handler in
LMS.Application/Handler/{Mutables|Immutables}/ - FluentValidation validator in
LMS.Application/Rules/ - Thin controller action in
LMS.API/Controllers/ -
[ProducesResponseType]for all response codes - Register services in
ServiceCollectionExtensionsif needed - Unit tests in
UnitTests/(mock deps, AAA) - Integration tests in
IntegrationTests/(Testcontainers + WebApplicationFactory)
Quality Gates
- Resources use plural nouns and kebab-case
- Correct HTTP method per operation
- All validation via FluentValidation (not in controllers/handlers)
- Controllers are thin — no business logic
- Pagination on all collection endpoints
-
[ProducesResponseType]on all actions - No sensitive data in URL query params
- No breaking changes — add a new version instead
- Async/await on all I/O
- Serilog logging on errors