refactor:spring-boot

Refactor Spring Boot 3.x and Java 21+ code into layered, testable structures.

3|Updated Oct 6, 2025
One-click install
npx skills add https://github.com/lgzarturo/springboot-course --skill refactor-spring-boot-lgzarturo
Or copy as Structured Prompt for Agent
Please help me install this Agent Skill.
Skill: refactor:spring-boot
Source: https://github.com/lgzarturo/springboot-course/tree/main/.agents/skills/refactor-spring-boot
Command: npx skills add https://github.com/lgzarturo/springboot-course --skill refactor-spring-boot-lgzarturo

SYSTEM DOCUMENTATION & REQUIREMENTS

What problem does it solve?

Refactor Spring Boot and Java code to improve maintainability, readability, and adherence to enterprise best practices. This skill transforms messy Spring Boot applications into clean, well-structured solutions following SOLID principles and Spring Boot 3.x conventions. It addresses fat controllers, improper transaction boundaries, field injection anti-patterns, and scattered configuration. Leverages Java 21+ features including record patterns, pattern matching for switch, virtual threads, and sequenced collections.

Core Features & Use Cases

  • SRP-driven refactors of controllers, services, and repositories to ensure proper layering.
  • Adoption of Java 21+ features (record patterns, switch pattern matching, virtual threads, sequenced collections) and configuration best practices.
  • Transformation of anti-patterns like fat controllers, improper transaction boundaries, field injection, and scattered configuration across Spring Boot 3.x projects.

Quick Start

Identify a monolithic module and refactor it into a clean, layered service following SRP and modern Spring Boot 3.x patterns.

Frequently Asked Questions about refactor:spring-boot

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

FAQPage Schema
How do I refactor a fat controller in Spring Boot to follow clean architecture and SOLID principles?

To refactor a fat controller in Spring Boot, extract domain logic into separate service components, apply constructor injection, and enforce Single Responsibility Principle layering. This produces properly separated controllers, services, and repositories that are highly testable and maintainable.

How do I fix improper transaction boundaries and field injection anti-patterns in Java?

Fixing improper transaction boundaries requires applying @Transactional annotations strictly at the service layer, while resolving field injection anti-patterns involves converting to constructor injection. This combination enforces Spring Boot 3.x best practices, ensuring immutability, testability, and predictable database transaction management.

What is the best way to apply Java 21+ features like record patterns and virtual threads to a Spring Boot 3.x project?

Applying Java 21+ features to a Spring Boot 3.x project involves replacing boilerplate data classes with record patterns, implementing pattern matching for switch, and adopting virtual threads for concurrency. This modernizes the codebase, reduces verbosity, and improves application scalability and readability.

Does my Spring Boot project need to be on version 3.x and Java 21 to use modern refactoring techniques?

Modern refactoring techniques targeting Spring Boot 3.x conventions and Java 21+ features require those specific versions. Upgrading ensures compatibility with sequenced collections, record patterns, and current enterprise best practices, yielding a production-ready and structurally sound application.

How do I consolidate scattered configuration across Spring Boot projects?

Consolidating scattered configuration in Spring Boot involves centralizing externalized settings and applying configuration best practices. This refactoring eliminates dispersed property definitions, resulting in a cleaner, more manageable application setup that adheres to enterprise standards.

When should I not use field injection in Spring Boot applications?

You should not use field injection in Spring Boot applications when testability, immutability, and adherence to enterprise best practices are required. Refactoring field injection anti-patterns to constructor injection ensures dependencies are explicitly declared, finalized, and verified at compile time.