← ClaudeAtlas

controller-stylelisted

The house style for Spring MVC REST controllers - `@RestController`, `@RequestMapping`, `@GetMapping` / `@PostMapping`. Load it before writing or rewriting a controller or an endpoint, when choosing a URL, an HTTP verb or a response status for one, when binding path variables, query parameters, a `@RequestBody`, a `@ModelAttribute` filter or a multipart `@RequestPart`, when adding a request record or its `@Valid` constraints, when injecting services into a controller, placing `@PreAuthorize` or getting the current user through `@AuthenticationPrincipal`, when deciding between returning a body and `ResponseEntity`, and when judging whether a controller is thin enough. Not for exception handling and error responses (the separate `controller-advice-style` skill), not for Swagger annotations (the separate `swagger-style` skill), not for the service layer, and not for server-side rendering with views.
dmitriy-iliyov/java-agent-skills · ★ 0 · API & Backend · score 72
Install: claude install-skill dmitriy-iliyov/java-agent-skills
# Controller style House rules for Spring MVC controllers. A controller that breaks one of them is either wrong, or a reason to change the rule here deliberately. [Any controller](#any-controller) holds for every controller, [REST](#rest) for `@RestController` and `@RestControllerAdvice` only; a `@Controller` returning a view follows the first part and nothing more is settled for it. Swagger annotations follow the `swagger-style` skill ([../swagger-style/SKILL.md](../swagger-style/SKILL.md)), which documents the decisions made here - a status chosen here is the status listed there. What happens to an exception once it leaves a controller - the advice, the error body, `401` and `403` - is the `controller-advice-style` skill ([../controller-advice-style/SKILL.md](../controller-advice-style/SKILL.md)). ## Any controller ### Thin **A controller is as thin as it can be made** - an adapter between transport and service that decides nothing. Every line that is not binding, delegating or returning is logic no test of the service will ever see. **A method is one call to the service and nothing else** - no branching on the result, no loop, no mapping between domain types, no transaction, no logging: ```java @PostMapping("/{id}/approve") public Order approve(@CurrentUser UserPrincipal user, @PathVariable("id") UUID id) { return service.approve(user.accountId(), id); } ``` Choosing an implementation is logic too: a registry of strategies, the lookup and the error for a missin