Skip to content
Back to skills

Controller Gsu26se55 Frontend

ASecurity

Creating or modifying an ASP.NET Core REST API Controller in any backend microservice. Triggers when adding a new Controller class, adding endpoints to an existing Controller, or wiring up MediatR Send calls. Controller must not contain business logic — only route to _mediator.Send().

  • 30 stars
  • 0 votes
  • 0 copies
  • 2 views
  • Added November 8, 2026
ai-agentsapibackend

Works with

  • api

Security analysis

A100/100

Scanned November 8, 2026

npx -y skills add majiayu000/claude-skill-registry-data --skill controller --agent claude-code

Installs into .claude/skills of the current project.

Are you the author of Controller Gsu26se55 Frontend?

Add the live security badge to your README. It updates with every re-scan.

Security grade badge for Controller Gsu26se55 Frontend
[![Security: A — Skills Directory](https://www.skillsdirectory.com/api/skills/majiayu000-controller-gsu26se55-frontend/badge)](https://www.skillsdirectory.com/skills/majiayu000-controller-gsu26se55-frontend)

More formats (shields.io, HTML) on the badges page. Keep it an A: scan every change in CI with Pro.

Download with Pro
SKILL.md
---
name: controller
description: Creating or modifying an ASP.NET Core REST API Controller in any backend microservice. Triggers when adding a new Controller class, adding endpoints to an existing Controller, or wiring up MediatR Send calls. Controller must not contain business logic — only route to _mediator.Send().
---

## Nguyên tắc bắt buộc

1. **Tuân thủ tuyệt đối** cấu trúc folder, naming convention, và code pattern được định nghĩa trong skill này — không tự ý thay đổi route, auth policy, hay thêm logic vào controller.
2. **Hỏi trước khi code** nếu bất kỳ yêu cầu nào chưa rõ (endpoint nào cần auth, role nào được phép, method nào cần). Không đoán mò — một câu hỏi ngắn tốt hơn một giờ implement sai hướng.

---

# BE Controller Pattern

```csharp
[ApiController]
[Route("api/batteries")]
public class BatteryController : ControllerBase
{
    private readonly IMediator _mediator;

    public BatteryController(IMediator mediator) => _mediator = mediator;

    [HttpGet]
    public async Task<IActionResult> GetAll([FromQuery] BatteryGetListQuery query)
        => Ok(await _mediator.Send(query));

    [HttpGet("{id}")]
    public async Task<IActionResult> GetById(Guid id)
        => Ok(await _mediator.Send(new BatteryGetByIdQuery { Id = id }));

    [HttpPost]
    [Authorize]
    public async Task<IActionResult> Create([FromBody] BatteryCreateCommand cmd)
        => Ok(await _mediator.Send(cmd));

    [HttpPut("{id}")]
    [Authorize]
    public async Task<IActionResult> Update(Guid id, [FromBody] BatteryUpdateCommand cmd)
    { cmd.Id = id; return Ok(await _mediator.Send(cmd)); }

    [HttpDelete("{id}")]
    [Authorize(Policy = "AdminOnly")]
    public async Task<IActionResult> Delete(Guid id)
        => Ok(await _mediator.Send(new BatteryDeleteCommand { Id = id }));

    [HttpPatch("{id}")]
    [Authorize(Policy = "AdminOnly")]
    public async Task<IActionResult> Restore(Guid id)
        => Ok(await _mediator.Send(new BatteryRestoreCommand { Id = id }));
}
```

## Rules

- Route: lowercase, plural, kebab-case → `api/batteries`, `api/battery-readings`
- Only inject `IMediator` — no service, repository, or DbContext
- Never put business logic in controller
- Auth policies: `"AdminOnly"` (role=1), `"ManagerOnly"` (role=2)
- GetList uses `[FromQuery]`, Create/Update use `[FromBody]`
- PUT: assign `cmd.Id = id` before Send

## File location

`Api/Controllers/{Entity}Controller.cs`

## Standard endpoints

| Method | Route | Auth | Action |
|--------|-------|------|--------|
| GET | `/api/{entities}` | Public | GetList |
| GET | `/api/{entities}/{id}` | Public | GetById |
| POST | `/api/{entities}` | `[Authorize]` | Create |
| PUT | `/api/{entities}/{id}` | `[Authorize]` | Update |
| DELETE | `/api/{entities}/{id}` | `AdminOnly` | Delete (soft) |
| PATCH | `/api/{entities}/{id}` | `AdminOnly` | Restore |

Attribution

Is this your skill, or is something wrong with this listing? Request removal or report an issue. Author removals are honored within 72 hours.

View all in ai-agents →

Comments

Loading comments…

Newsletter

Get the weekly list of safe new skills, and the ones we pulled.