dotnet-legacy-api-controllers
Generates RESTful API Controllers with proper routing, versioning, authorization, and MediatR integration. Follows REST conventions and Clean Architecture patterns.
npx skills add majiayu000/claude-skill-registry --skill 07-1-dotnet-legacy-api-controllers --agent claude-code
Same command for any agent — swap --agent for codex, cursor, copilot.
Weekly change comes from our own snapshots, not the repository page — it measures attention, not adoption.
What it does
Generates RESTful API Controllers following REST conventions and Clean Architecture patterns. It integrates MediatR for sending commands/queries, applies API versioning in the route, and enforces authorization. It produces request/response DTOs and follows a Complete CRUD controller structure with typical HTTP responses.
How it works
- Uses MediatR via ISender to dispatch commands and queries (e.g., GetByIdQuery, GetAllQuery, CreateEntityCommand, UpdateEntityCommand, PatchEntityCommand, DeleteEntityCommand).
- Applies API versioning with ApiVersion attribute and version in the route (api/v{version:apiVersion}/{entities}).
- Enforces authorization globally with [Authorize] on controllers and per-action permissions via [HasPermission(Permissions.{Entities}Write/Read)] and role-based [Authorize(Roles = ...)].
- Provides template implementations for request DTOs (RequestCreate{Entity}, RequestUpdate{Entity}, RequestPatch{Entity}).
- Includes a complete CRUD controller template with actions: GetById, GetAll, GetByOrganizationId, Create, Update, PartialUpdate, and Delete, each returning standard HTTP status codes.
- Defines a permission set in Permissions.cs and example usage across actions.
When to use it
- When you need to scaffold a RESTful API controller for an entity following REST conventions, MediatR integration, and versioned routes.
- When authorization needs to be enforced at both controller and action levels, with support for role-based and permission-based access.
What it can touch
- Files and namespaces under the generated API project, including:
- Controllers: {Entity}Controller.cs and related Request{DTO} files
- Dependency injection and API versioning setup in ApiVersions and DependencyInjection configuration
- Authorization attributes and Permissions definitions
- Template code for CRUD operations and complex operations (e.g., batch, activate/deactivate, search, add/remove child)
Caveats
- Requires MediatR and Asp.Versioning to be present in the project dependencies.
- The skill generates code that assumes the existence of domain/application layers (e.g., Get{Entity}ByIdQuery, Create{Entity}Command, Permissions constants) and will wire to those implementations via ISender.
- The provided templates rely on {name}, {Feature}, {Entity}, and {Entities} placeholders to be substituted by the consumer.
# API Controller Generator ## Overview This skill generates RESTful API Controllers following best practices: - **MediatR integration** - Send commands/queries via ISender - **API versioning** - URL segment versioning - **Authorization** - Role and permission-based - **Consistent responses** - Proper HTTP status codes - **Request/Response DTOs** - Separate from domain ## Quick Reference | HTTP Method | Action | Returns | |-------------|--------|---------| | `GET /{id}` | Get by ID | `200 OK` / `404 Not Found` | | `GET /` | Get all/list | `200 OK` | | `POST /` | Create | `201 Created` / `400 Bad Request` | | `PUT /{id}` | Full update | `200 OK` / `404 Not Found` | | `PATCH /{id}` | Partial update | `200 OK` / `404 Not Found` | | `DELETE /{id}` | Delete | `204 No Content` / `404 Not Found` | --- ## Controller Structure ``` /API/Controllers/ ├── {Feature}/ │ ├── {Entity}Controller.cs │ ├── Request{Action}{Entity}.cs │ └── ... └── ... ``` --- ## Template: Complete CRUD Controller ```csharp // src/{name}.api/Controllers/{Feature}/{Entity}Controller.cs using Asp.Versioning; using MediatR; using Microsoft.AspNetCore.Authorization; using Microsoft.AspNetCore.Mvc; using {name}.application.{
- Overview
- Quick Reference
- Controller Structure
- Template: Complete CRUD Controller
- Template: Request DTOs
- Template: Controller with Complex Operations
- Template: Controller with Role-Based Authorization
- API Versioning Setup
- Permission-Based Authorization
- Global Error Handling
- REST Conventions
- Critical Rules
- Anti-Patterns to Avoid
- Related Skills
What does the dotnet-legacy-api-controllers skill do?
Generates RESTful API Controllers with proper routing, versioning, authorization, and MediatR integration. Follows REST conventions and Clean Architecture patterns.
How do I install it?
Run `npx skills add majiayu000/claude-skill-registry --skill 07-1-dotnet-legacy-api-controllers --agent claude-code` — it drops the skill into your project so the agent can pick it up. Swap the --agent value for codex, cursor or copilot if you use one of those.
Where does this skill come from?
From majiayu000/claude-skill-registry, a repository with 534 stars. We read it straight from the repository tree rather than a submitted listing, so what you see here is what is actually published.
Is a popular skill a good skill?
Not necessarily. Stars measure attention, not adoption — a repository can trend for a week and be abandoned. That is why we show the weekly change from our own snapshots next to the total, instead of a single flattering number.
