spring-boot-idioms

Standardize Spring Boot implementations for idiomatic REST, JPA, and testing patterns.

150|48|Updated Jan 24, 2026
One-click install
npx skills add https://github.com/irahardianto/awesome-agv --skill spring-boot-idioms
Or copy as Structured Prompt for Agent
Please help me install this Agent Skill.
Skill: spring-boot-idioms
Source: https://github.com/irahardianto/awesome-agv/tree/main/.agents/skills/spring-boot-idioms
Command: npx skills add https://github.com/irahardianto/awesome-agv --skill spring-boot-idioms

SYSTEM DOCUMENTATION & REQUIREMENTS

What problem does it solve?

Spring Boot projects often drift into non-idiomatic patterns (field injection, leaky entities, scattered transactions) that reduce testability, observability, and long-term maintainability.

Core Features & Use Cases

  • Constructor-based dependency injection: Enforce constructor injection and prefer strongly typed configuration with @ConfigurationProperties over @Value.
  • Spring Data JPA best practices: Use derived queries and projections to avoid loading full entities, and place @Transactional on service methods rather than repositories.
  • REST controller and error handling conventions: Expose DTOs from @RestController, apply @ControllerAdvice for global exceptions, and structure endpoints with validation-friendly request/response contracts.
  • Production observability guidance: Enable Actuator health/metrics/info, use Micrometer for custom metrics, and adopt structured logging with MDC correlation IDs.
  • Test strategy patterns: Use @SpringBootTest for integration testing, @WebMvcTest for controller slices, and TestContainers for database integration tests.
  • Use Case: Standardize a new Spring Boot API codebase so controllers, services, repositories, tests, and observability align with consistent, maintainable conventions from day one.

Quick Start

Ask the agent to refactor the given Spring Boot project code to follow the spring-boot-idioms skill for dependency injection, REST DTOs, JPA usage, actuator observability, and testing.

Frequently Asked Questions about spring-boot-idioms

High-intent search queries and answers about installing and using this skill.

FAQPage Schema
How do I structure Spring Boot REST controllers and services for better maintainability?

Idiomatic Spring Boot REST controllers expose DTOs via @RestController and delegate to service methods marked with @Transactional. Global exception handling uses @ControllerAdvice to keep controller contracts clean and validation-friendly.

What is the best way to configure Spring Data JPA repositories to avoid loading full entities?

Use Spring Data JPA derived queries and projections to avoid loading full entities. Place @Transactional on service methods rather than repositories to maintain correct transaction boundaries and improve data access efficiency.

Why should I use constructor injection instead of field injection in Spring Boot?

Constructor injection enforces dependency immutability and simplifies unit testing. Pair it with strongly typed configuration via @ConfigurationProperties instead of @Value to eliminate non-idiomatic patterns that harm maintainability.

How do I test Spring Boot slices and database integration with TestContainers?

Use @WebMvcTest for controller slice testing and @SpringBootTest for integration testing. Combine these with TestContainers for database integration tests to ensure aligned, production-ready testing coverage.

Does Spring Boot Actuator need Micrometer for production observability?

Spring Boot Actuator provides health, metrics, and info endpoints, while Micrometer enables custom metrics. Together with structured logging using MDC correlation IDs, they establish complete production observability.

Can I refactor an existing Spring Boot API codebase to follow idiomatic patterns?

Yes, you can standardize an existing Spring Boot API codebase by refactoring dependency injection, REST DTOs, JPA usage, actuator observability, and testing to align controllers, services, and repositories with consistent conventions.