spring-boot-scaffold
Installation
SKILL.md
Scaffold a Spring Boot feature
This skill covers the basic entity/repository/service/controller shape assuming JPA over a relational database. For MySQL/PostgreSQL-specific ID generation, dialects, or JSON columns once past this basic shape, see spring-boot-jpa. If the feature's data is document-shaped rather than relational, use spring-boot-mongodb's modeling guidance in place of step 1–2 below instead. For where the new feature's files should physically live (a new top-level feature package vs. dropping classes into existing layer packages), see spring-boot-architecture's "Package structure" section — the order below assumes the feature gets its own package.
Generation order
Build in this order — each layer depends on the one before it:
- Entity —
@Entity,@Table,@Idwith@GeneratedValue, relationships default tofetch = FetchType.LAZY, preferSetoverListfor collections where duplicates aren't meaningful. - Repository — extend
JpaRepository<Entity, IdType>. Add derived query methods or@QuerywithJOIN FETCHfor anything that will load a collection — don't let a defaultfindAll()-shaped method return entities with lazy collections un-fetched (that's the N+1 setup; seespring-boot-review). On Spring Boot 4.x,@ConfigurationPropertiesclasses must use private fields or a record — public-field binding was removed; a record is the preferred style for new code (see theBillingPropertiesexample below). - Service — constructor-injected repository dependencies,
@Transactionalon methods that span more than one repository call, business rules live here. - Controller — thin, delegates to the service, maps DTOs at the boundary.
- DTOs — Java records, validated with Jakarta Bean Validation annotations.