Imported from shahboura/agents-opencode (
.opencode/skills/java-spring/SKILL.md). Install upstream withnpx skills add shahboura/agents-opencode --skill java-spring. Copyright stays with the author (MIT).
What I do
- Enforce Spring Boot layering and dependency injection conventions
- Guide validation, error handling, and security configuration patterns
- Apply testing standards with JUnit 5 and Spring Boot Test
When to use me
Use this when working on Java Spring Boot projects.
Key Rules
- Constructor injection ONLY — never use
@Autowiredon fields; Spring auto-wires single-constructor beans - Use Java
recordtypes (14+) for all DTOs and request/response objects — not classes with getters/setters - Layer strictly: Controller (HTTP only) → Service (business logic) → Repository (data access)
- Use Bean Validation annotations (
@Valid,@NotBlank,@Email,@Size) at the controller parameter level - Use
@RestControllerAdvicefor global exception handling — never catch exceptions in controllers directly - Extend
JpaRepository<T, ID>for data access; use@Queryfor custom queries, not raw JDBC - Return
Optional<T>from service/repository methods for nullable results — never return null - Use
application.yml(not.properties) for configuration; externalize secrets via${ENV_VAR}syntax - Configure Spring Security via
SecurityFilterChainbean — not by extendingWebSecurityConfigurerAdapter(deprecated) - Use
@Validatedon controllers for method-level validation;@Validon@RequestBodyparameters - Keep controllers thin: no business logic, only HTTP mapping and delegation to services
- Use
ResponseEntitywith explicit status codes and@ApiResponseannotations (Springdoc/Swagger) - Background jobs via
@Asyncor SpringApplicationEvent— not raw threads - Use a verify-fix-verify loop: run the validation commands below, fix any failures, and rerun until all checks pass
Validation Commands
./mvnw clean compile
./mvnw test