controller-stylelisted
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