
Springboot Patterns
Scaffold production-style Spring Boot APIs with layered controllers, services, repositories, validation, and environment profiles.
Overview
springboot-patterns is an agent skill most often used in Build (also Ship) that documents Spring Boot REST layering, data access, caching, async, and profile-ready API design for Java services.
Install
npx skills add https://github.com/affaan-m/everything-claude-code --skill springboot-patternsWhat is this skill?
- When to activate: REST with MVC/WebFlux, layer separation, JPA, caching, async, validation, pagination, profiles
- REST API structure with @RestController, validated DTOs, Pageable list endpoints, and 201 create responses
- Covers layered controller → service → repository design for scalable services
- Event-driven options with Spring Events or Kafka for decoupled processing
Adoption & trust: 7k installs on skills.sh; 210k GitHub stars; 3/3 security scanners passed (skills.sh audits).
What problem does it solve?
You are starting a Spring Boot API but lack a consistent layered layout, validation, pagination, and environment split.
Who is it for?
Solo builders creating new Spring Boot REST or WebFlux services who want production-grade structure without reading entire framework manuals first.
Skip if: Greenfield teams committed to non-JVM stacks or trivial scripts that do not need layered HTTP APIs.
When should I use this skill?
Building REST APIs with Spring MVC or WebFlux, structuring layers, JPA, caching, async, validation, pagination, profiles, or Kafka-style events.
What do I get? / Deliverables
You get controller-service-repository templates with validated DTOs and listing patterns you can extend before hardening for staging and production profiles.
- Layered REST controller and service sketches
- Pagination and validation request/response patterns
- Notes for profiles, caching, and async/event integration
Recommended Skills
Journey fit
Spans multiple journey phases - primary shelf plus alternate fits below.
Primary shelf is Build for implementing Java services; patterns also support Ship prep via profiles, exception handling, and async/event hooks. Backend subphase matches REST controllers, Spring Data JPA, caching, async, and Kafka-style event patterns described in the skill.
Where it fits
Stand up a paginated markets API with validated create requests and MarketResponse mapping.
Add global exception handling and input validation before exposing endpoints publicly.
Split configuration across dev/staging/production profiles for safer deployments.
How it compares
Architecture and code-pattern skill for Spring Boot, not a Terraform or container deploy pack.
Common Questions / FAQ
Who is springboot-patterns for?
Indie Java developers using Claude-style agents to implement Spring Boot backends with clear REST, JPA, and cross-cutting patterns.
When should I use springboot-patterns?
In Build when designing controllers and services; in Ship when adding validation, exception handling, profiles, and async or event hooks before release.
Is springboot-patterns safe to install?
It suggests standard Spring patterns only; review the Security Audits panel on this page and vet generated code like any other dependency.
SKILL.md
READMESKILL.md - Springboot Patterns
# Spring Boot Development Patterns Spring Boot architecture and API patterns for scalable, production-grade services. ## When to Activate - Building REST APIs with Spring MVC or WebFlux - Structuring controller → service → repository layers - Configuring Spring Data JPA, caching, or async processing - Adding validation, exception handling, or pagination - Setting up profiles for dev/staging/production environments - Implementing event-driven patterns with Spring Events or Kafka ## REST API Structure ```java @RestController @RequestMapping("/api/markets") @Validated class MarketController { private final MarketService marketService; MarketController(MarketService marketService) { this.marketService = marketService; } @GetMapping ResponseEntity<Page<MarketResponse>> list( @RequestParam(defaultValue = "0") int page, @RequestParam(defaultValue = "20") int size) { Page<Market> markets = marketService.list(PageRequest.of(page, size)); return ResponseEntity.ok(markets.map(MarketResponse::from)); } @PostMapping ResponseEntity<MarketResponse> create(@Valid @RequestBody CreateMarketRequest request) { Market market = marketService.create(request); return ResponseEntity.status(HttpStatus.CREATED).body(MarketResponse.from(market)); } } ``` ## Repository Pattern (Spring Data JPA) ```java public interface MarketRepository extends JpaRepository<MarketEntity, Long> { @Query("select m from MarketEntity m where m.status = :status order by m.volume desc") List<MarketEntity> findActive(@Param("status") MarketStatus status, Pageable pageable); } ``` ## Service Layer with Transactions ```java @Service public class MarketService { private final MarketRepository repo; public MarketService(MarketRepository repo) { this.repo = repo; } @Transactional public Market create(CreateMarketRequest request) { MarketEntity entity = MarketEntity.from(request); MarketEntity saved = repo.save(entity); return Market.from(saved); } } ``` ## DTOs and Validation ```java public record CreateMarketRequest( @NotBlank @Size(max = 200) String name, @NotBlank @Size(max = 2000) String description, @NotNull @FutureOrPresent Instant endDate, @NotEmpty List<@NotBlank String> categories) {} public record MarketResponse(Long id, String name, MarketStatus status) { static MarketResponse from(Market market) { return new MarketResponse(market.id(), market.name(), market.status()); } } ``` ## Exception Handling ```java @ControllerAdvice class GlobalExceptionHandler { @ExceptionHandler(MethodArgumentNotValidException.class) ResponseEntity<ApiError> handleValidation(MethodArgumentNotValidException ex) { String message = ex.getBindingResult().getFieldErrors().stream() .map(e -> e.getField() + ": " + e.getDefaultMessage()) .collect(Collectors.joining(", ")); return ResponseEntity.badRequest().body(ApiError.validation(message)); } @ExceptionHandler(AccessDeniedException.class) ResponseEntity<ApiError> handleAccessDenied() { return ResponseEntity.status(HttpStatus.FORBIDDEN).body(ApiError.of("Forbidden")); } @ExceptionHandler(Exception.class) ResponseEntity<ApiError> handleGeneric(Exception ex) { // Log unexpected errors with stack traces return ResponseEntity.status(HttpStatus.INTERNAL_SERVER_ERROR) .body(ApiError.of("Internal server error")); } } ``` ## Caching Requires `@EnableCaching` on a configuration class. ```java @Service public class MarketCacheService { private final MarketRepository repo; public MarketCacheService(MarketRepository repo) { this.repo = repo; } @Cacheable(value = "market", key = "#id") public Market getById(Long id) { return repo.findById(i