Skip to main content
skill CX Codex

springboot-patterns · rohitg00 — Claude Code skill: what it does, how to install

springboot-patterns lays out a layered Spring Boot package structure with templates for controllers, services and repositories, plus common mistakes to avoid.

Apache-2.0 ★ 2,858 updated 2026-05-12

Install into Claude Code · Skills CLI (Vercel) All methods and platforms ↓
npx skills add rohitg00/awesome-claude-code-toolkit --skill springboot-patterns -a claude-code
Open on GitHub

What springboot-patterns does

The skill splits a Java package into config, controller, service, repository, model (entity, dto, mapper), exception and security folders, keeping controllers limited to HTTP handling while services hold business logic. Its code samples cover a paginated Spring MVC controller, an Order JPA entity with @ManyToOne and @OneToMany relations, a repository using @Query and @EntityGraph to prevent N+1 queries, a transactional service layer, and a global exception handler that returns ProblemDetail per RFC 7807.

A separate list flags pitfalls such as wiring repositories straight into controllers, defaulting relationships to FetchType.EAGER, and exposing JPA entities instead of DTOs from endpoints. The closing checklist expects @Valid on request DTOs and integration tests built with @SpringBootTest and test containers.

Every example is Java with Lombok annotations like @RequiredArgsConstructor and @Getter/@Setter, so the skill targets that combination rather than Kotlin or plain Spring without Lombok.

What it helps with

  • split an order module into controller, service and repository layers
  • prevent N+1 queries with @EntityGraph or JOIN FETCH
  • return errors as ProblemDetail under RFC 7807
  • swap raw JPA entities for DTOs in controller responses
  • scope @Transactional correctly for read and write methods

Example prompts for the agent

  • Split this order service into controller, service and repository layers using this skill
  • Check the Order JPA entity for an unwanted FetchType.EAGER
  • Add a global exception handler that returns ProblemDetail for this controller

How to install springboot-patterns

1Skills CLI (Vercel)

npx skills add rohitg00/awesome-claude-code-toolkit --skill springboot-patterns -a claude-code

2Manually: put the files in place

~/.claude/skills/springboot-patterns/SKILL.md

Copy the whole skill folder; for one project use .claude/skills/springboot-patterns/

Step by step, with commands for each platform: How to install skills in Claude Code: five ways

Questions about springboot-patterns

How to install springboot-patterns in Claude Code?

Run npx skills add rohitg00/awesome-claude-code-toolkit --skill springboot-patterns -a claude-code; the skill lands in ~/.claude/skills/springboot-patterns/SKILL.md.

What does the springboot-patterns skill do?

It lays out a layered Spring Boot architecture and provides templates for a REST controller, a JPA entity with its repository, a transactional service, and an exception handler, together with a list of common mistakes and a review checklist.

What stack does springboot-patterns assume?

The samples are written in Java with Lombok annotations (@RequiredArgsConstructor, @Getter, @Setter) and Spring Data JPA, so the skill is built around that classic Spring Boot combination.

Source text

SKILL.md · Apache-2.0
---
name: springboot-patterns
description: Spring Boot patterns including JPA repositories, REST controllers, layered services, and configuration
---

# Spring Boot Patterns

## Layered Architecture

```
src/main/java/com/example/app/
  config/          # @Configuration beans
  controller/      # @RestController (thin, delegates to service)
  service/         # @Service (business logic)
  repository/      # @Repository (data access via JPA)
  model/
    entity/        # @Entity JPA classes
    dto/           # Request/response DTOs
    mapper/        # MapStruct or manual mapping
  exception/       # @ControllerAdvice, custom exceptions
  security/        # SecurityFilterChain, JWT filters
```

Controllers handle HTTP concerns. Services contain business logic. Repositories handle persistence.

## REST Controller

```java
@RestController
@RequestMapping("/api/v1/orders")
@RequiredArgsConstructor
public class OrderController {

    private final OrderService orderService;

    @GetMapping
    public Page<OrderResponse> list(
            @RequestParam(defaultValue = "0") int page,
            @RequestParam(defaultValue = "20") int size) {
        return orderService.findAll(PageRequest.of(page, size));
    }

    @PostMapping
    @ResponseStatus(HttpStatus.CREATED)
    public OrderResponse create(@Valid @RequestBody CreateOrderRequest request) {
        return orderService.create(request);
    }

    @GetMapping("/{id}")
    public OrderResponse getById(@PathVariable UUID id) {
        return orderService.findById(id);
    }
}
```

## JPA Entity and Repository

```java
@Entity
@Table(name = "orders")
@Getter @Setter @NoArgsConstructor
public class Order {
    @Id
    @GeneratedValue(strategy = GenerationType.UUID)
    private UUID id;

    @ManyToOne(fetch = FetchType.LAZY)
    @JoinColumn(name = "customer_id", nullable = false)
    private Customer customer;

    @OneToMany(mappedBy = "order", cascade = CascadeType.ALL, orphanRemoval = true)
    private List<OrderItem> items = new ArrayList<>();

    @Enumerated(EnumType.STRING)
    private OrderStatus status = OrderStatus.PENDING;

    @CreationTimestamp
    private Instant createdAt;
}

public interface OrderRepository extends JpaRepository<Order, UUID> {
    @Query("SELECT o FROM Order o JOIN FETCH o.items WHERE o.customer.id = :customerId")
    List<Order> findByCustomerWithItems(@Param("customerId") UUID customerId);

    @EntityGraph(attributePaths = {"customer", "items"})
    Optional<Order> findWithDetailsById(UUID id);
}
```

## Service Layer

```java
@Service
@Transactional(readOnly = true)
@RequiredArgsConstructor
public class OrderService {

    private final OrderRepository orderRepository;
    private final OrderMapper orderMapper;
    private final EventPublisher eventPublisher;

    public OrderResponse findById(UUID id) {
        Order order = orderRepository.findWithDetailsById(id)
                .orElseThrow(() -> new ResourceNotFoundException("Order", id));
        return orderMapper.toResponse(order);
    }

    @Transactional
    public OrderResponse create(CreateOrderRequest request) {
        Order order = orderMapper.toEntity(request);
        order = orderRepository.save(order);
        eventPublisher.publish(new OrderCreatedEvent(order.getId()));
        return orderMapper.toResponse(order);
    }
}
```

## Global Exception Handler

```java
@RestControllerAdvice
public class GlobalExceptionHandler {

    @ExceptionHandler(ResourceNotFoundException.class)
    @ResponseStatus(HttpStatus.NOT_FOUND)
    public ProblemDetail handleNotFound(ResourceNotFoundException ex) {
        return ProblemDetail.forStatusAndDetail(HttpStatus.NOT_FOUND, ex.getMessage());
    }

    @ExceptionHandler(MethodArgumentNotValidException.class)
    @ResponseStatus(HttpStatus.BAD_REQUEST)
    public ProblemDetail handleValidation(MethodArgumentNotValidException ex) {
        ProblemDetail detail = ProblemDetail.forStatus(HttpStatus.BAD_REQUEST);
        Map<String, String> errors = ex.getFieldErrors().stream()
                .collect(Collectors.toMap(FieldError::getField, FieldError::getDefaultMessage));
        detail.setProperty("errors", errors);
        return detail;
    }
}
```

## Anti-Patterns

- Injecting repositories directly into controllers (bypassing service layer)
- Using `FetchType.EAGER` on entity relationships by default
- Returning JPA entities directly from controllers instead of DTOs
- Missing `@Transactional(readOnly = true)` on read-only service methods
- Catching generic `Exception` instead of specific types
- Hardcoding configuration values instead of using `@Value` or `@ConfigurationProperties`

## Checklist

- [ ] Controllers are thin and delegate to services
- [ ] All JPA relationships use `FetchType.LAZY` by default
- [ ] DTOs used for request/response, never raw entities
- [ ] `@Transactional` applied at service level with correct read/write scoping
- [ ] Validation annotations (`@Valid`, `@NotNull`, `@Size`) on request DTOs
- [ ] Global exception handler returns `ProblemDetail` (RFC 7807)
- [ ] Entity graphs or `JOIN FETCH` used to avoid N+1 queries
- [ ] Integration tests use `@SpringBootTest` with test containers

© rohitg00 · Apache-2.0 · rohitg00/awesome-claude-code-toolkit

Similar skills

All skills for Backend and APIs →

springboot-patterns by other authors comes first.

springboot-patterns affaan-m springboot-patterns — a skill for Java Spring Boot architecture and REST API work. Use it when building or reviewing controllers, services, data access, caching, or async processing. CX Codex +1 6,900installs spring-boot-crud-patterns giuseppe-trisciuoglio spring-boot-crud-patterns — a skill that builds the whole CRUD layer for Spring Boot 3 services: aggregates, JPA repositories, DTOs and REST controllers in a feature-based layout. CX Codex +1 4,100installs spring-boot-patterns decebals spring-boot-patterns — a skill that hands your agent the package layout and templates for Spring Boot controllers, services and repositories. Useful when new code gets written or reviewed. CX Codex +1 375installs java-springboot official github java-springboot writes and reviews code in an existing Spring Boot 3 or 4 project: controllers, validation, data access, configuration. Triggers when you add or change a feature, not when scaffolding a new one. CX Codex +1 21,272installs java-springboot-jpa-cursorrules-prompt-file PatrickJS The java-springboot-jpa-cursorrules-prompt-file rule guides Cursor when building Java Spring Boot projects with JPA, DTOs, and layered APIs. Use it when generated code should follow a fixed structure. CX Codex +1 ★ 41,178repo stars jpa-patterns affaan-m jpa-patterns provides JPA and Hibernate patterns for entity design, N+1 query prevention, and HikariCP pooling in Spring Boot. Helps write repositories and tune database performance. CX Codex +1 6,400installs spring-boot-engineer https://github.com/Jeffallan spring-boot-engineer generates Spring Boot 3.x code, JPA repositories, REST controllers, and Spring Security 6 configurations. Useful when writing Java microservices and reactive endpoints. CX Codex +1 8,900installs

From the same set178

The whole set →
rust-systems This skill guides Rust systems code, from ownership and error handling to traits and async work. Use it when shaping a library or service. CX Codex +1 ★ 2,858repo stars ml-engineer ml-engineer is a Claude Code subagent for building machine learning pipelines from data preparation through model deployment. It handles work on training, evaluation, and monitoring. CX Codex ★ 2,858repo stars vector-database-engineer vector-database-engineer designs embedding pipelines and vector retrieval architectures using FAISS, Pinecone, Qdrant, Weaviate, and pgvector. Useful when tuning chunking, indexes, and hybrid search. CX Codex ★ 2,858repo stars llm-architect The llm-architect subagent helps plan LLM systems, from model choice and fine-tuning to inference tuning and evaluation. Use it when you need to compare candidates on your own data. CX Codex ★ 2,858repo stars database-admin database-admin guides schema architecture, query optimization, migrations, and backup routines across PostgreSQL, MySQL, and MongoDB. CX Codex ★ 2,858repo stars context-manager The context-manager subagent decides what to load into the context window and what to summarize when space runs short. It helps keep task-specific code and decisions in view. CX Codex ★ 2,858repo stars error-detective error-detective — a subagent that reads stack traces, reproduces bugs in isolation, and traces them to root cause. Turns vague error reports into actionable fixes. CX Codex ★ 2,858repo stars test-architect test-architect designs test pyramids, guides TDD workflows, and sets up integration, property-based, and mutation tests in Claude Code. CX Codex ★ 2,858repo stars

Project sponsors

Companies that keep this analytics open