controller

Creates ASP.NET Core REST API controllers that route requests through MediatR.

1|Updated Apr 27, 2026
One-click install
npx skills add https://github.com/GSU26SE55/backend --skill controller-gsu26se55
Or copy as Structured Prompt for Agent▼
Please help me install this Agent Skill.
Skill: controller
Source: https://github.com/GSU26SE55/backend/tree/main/.codex/skills/be/controller
Command: npx skills add https://github.com/GSU26SE55/backend --skill controller-gsu26se55

SYSTEM DOCUMENTATION & REQUIREMENTS

What problem does it solve? When adding or modifying REST API endpoints in the backend microservices, controllers must follow a strict convention: thin controllers with no business logic, only IMediator injection, standardized routes, and correct authorization policies. This Skill enforces that pattern so every controller stays consistent with the project's Clean Architecture. ## Core Features & Use Cases - Standard Controller Scaffolding: Generates a complete controller with GetList, GetById, Create, Update, Delete (soft), and Restore endpoints following the canonical pattern. - Convention Enforcement: Applies lowercase kebab-case plural routes (e.g., api/batteries), [FromQuery] for list queries, [FromBody] for commands, and cmd.Id assignment on PUT before Send. - Authorization Rules: Wires [Authorize] for write operations and AdminOnly/ManagerOnly policies for delete and restore actions. - Use Case: You need a new TicketController for the TicketService. The Skill generates Api/Controllers/TicketController.cs with all six standard endpoints, each delegating to _mediator.Send() with the correct query or command objects. ## Quick Start Ask the AI to create a new controller for an entity, for example: create a BatteryController with the standard CRUD endpoints following the controller pattern.

Frequently Asked Questions about controller

High-intent search queries and answers about installing and using this skill.

FAQPage Schema
How do I create a new ASP.NET Core controller with MediatR?▼

Create a class in Api/Controllers/{Entity}Controller.cs that injects only IMediator and exposes endpoints that call _mediator.Send() with query or command objects. Each action returns Ok(await _mediator.Send(...)) with no business logic inside the controller.

What route naming convention should REST API controllers use?▼

Routes must be lowercase, plural, and kebab-case, such as api/batteries or api/battery-readings. The route is declared once at the controller level with [Route("api/batteries")] and individual actions use HttpGet, HttpPost, and similar attributes.

Should controllers contain business logic in Clean Architecture?▼

No, controllers must never contain business logic. They only inject IMediator and route requests to handlers via _mediator.Send(), keeping all logic in command and query handlers. Services, repositories, and DbContext are never injected into controllers.

How do I pass the route id to an update command in MediatR?▼

For PUT requests, assign the route id to the command before sending: cmd.Id = id; then call _mediator.Send(cmd). The command body comes from [FromBody] while the id comes from the route parameter.

Which authorization policies apply to delete and restore endpoints?▼

DELETE (soft delete) and PATCH (restore) endpoints use [Authorize(Policy = "AdminOnly")] for role 1 users. Create and update endpoints use plain [Authorize], while GET list and get-by-id endpoints remain public.