- Home
- Skills
- APIs & Backend
- Modern Java Guidance (Java 21+ & Spring Boot 3.x+)
Modern Java Guidance (Java 21+ & Spring Boot 3.x+)
by 장준민
Stop AI coding agents from generating legacy Java 8 and Spring Boot 2.x patterns. Version-aware guidance for Java 17/21/25+ and Spring Boot 3.x+, with a companion CLI scanner and PostToolUse hook available on GitHub.
Free
Modern Java Guidance (Java 21+ & Spring Boot 3.x+)
Example session with this skill installed
Example task: This project targets Java 21 and Spring Boot 3.2. Keep the configured versions. Replace the immutable UserDto POJO with a record and modernize this service using constructor injection and RestClient. Assume spring-boot-starter-web is present.
@Service
class UserService {
@Autowired private RestTemplate restTemplate;
public UserDto getUser(long id) {
return restTemplate.getForObject("https://api.example.com/users/" + id, UserDto.class);
}
}
UserDto has two immutable fields: Long id and String email.
- Read your context and instructions
- Compiled the modern java guidance
Illustrative output
This is a worked example for the versions supplied in the prompt, not a recorded test run. In a real repository, inspect the build files or run mjg detect . before editing.
| Area | Applied change |
|---|---|
| DTO | Record for immutable data; do not apply this to a JPA entity |
| Dependency injection | Constructor injection with a final client |
| HTTP client | RestClient, suitable for Spring Boot 3.2+ |
UserDto.java
package com.example.api;
public record UserDto(Long id, String email) {}
UserService.java
package com.example.api;
import java.util.Objects;
import org.springframework.stereotype.Service;
import org.springframework.web.client.RestClient;
@Service
public class UserService {
private final RestClient client;
public UserService(RestClient.Builder builder) {
this.client = builder.baseUrl("https://api.example.com").build();
}
public UserDto getUser(long id) {
return Objects.requireNonNull(
client.get()
.uri("/users/{id}", id)
.retrieve()
.body(UserDto.class),
"User response body must not be empty"
);
}
}
Next steps
- Configure the real service URL, authentication, timeouts, and error handling for your application.
- With the separately installed CLI, run
mjg check src/main/javafor supported pattern findings. - Compile the project and run relevant tests, including empty-body and HTTP-error cases. No build or test result is claimed for this illustrative output.
Connects securely to your tools. The creator never sees your data.
About this skill
Modern Java Guidance (mjg) steers AI coding agents toward modern Java 17/21/25+ and Spring Boot 3.x+ idioms while respecting the project's configured versions.
What it solves
Coding agents can fall back to Java 8 and Spring Boot 2.x patterns. This skill guides them toward suitable modern alternatives for Jakarta EE imports, Spring Security configuration, HTTP clients, dependency injection, immutable DTOs, and blocking I/O concurrency.
Key features
- Lightweight SKILL.md: Guidance for
record,sealed interface, pattern matching forswitch,SequencedCollection, virtual threads,SecurityFilterChainLambda DSL,RestClient,@HttpExchange, and RFC 9457ProblemDetail. - Version-aware workflow: Inspect build files or use
mjg detectto identify Java and Spring Boot versions before suggesting changes. Java 21 features are gated accordingly;RestClientguidance targets Boot 3.2+. Legacy projects retain their configured baseline unless migration is requested. - Companion CLI and PostToolUse hook:
mjg checkscans Java files for supported legacy patterns;mjg hookintegrates post-edit checks. The CLI uses the Python 3.11+ standard library and runs locally. The repository reports an approximately 31 ms median hook subprocess time on Apple Silicon; results depend on the environment. - On-demand lookup:
mjg searchandmjg retrieveprovide Before/After snippets and caveats by keyword or rule ID.
Included in this free download
modern-java-guidance/SKILL.mdmodern-java-guidance/references/java-21-25-core.mdmodern-java-guidance/references/spring-boot-3x.md
The CLI and hook are not bundled in this ZIP. Install them separately from the GitHub repository to use mjg detect, check, hook, search, and retrieve. The repository also contains setup instructions and an evaluation suite.
Compatibility and caveats
Use with agents that support SKILL.md, including Claude Code, Cursor, Codex CLI, and compatible Copilot workflows. Hook support depends on the host agent. Use records for suitable immutable DTOs, not JPA entities; prefer virtual threads for blocking I/O while retaining bounded pools where CPU or concurrency limits require them. Guidance and pattern scans complement project builds, tests, and review.
GitHub repository and CLI installer
The ZIP contains instructions and references; the mjg CLI and PostToolUse hook require separate installation. Hook support depends on the host agent. Pattern checks cover supported rules and do not replace builds, tests, or review. Legacy baselines are preserved unless migration is requested.
How to use
- 1
Connect your agent to the Agensi MCP
Copy the prompt and paste it into Claude, ChatGPT, Cursor or any agent that supports MCP. It sets up the connection for you. Manual setup
- 2
Sign in to Agensi
Your agent shows a sign-in link. Sign in and click Allow.
- 3
Ask for what you need
Your agent loads this skill and uses it on your task. It always asks before buying a skill.
Reviews
No reviews yet
Be one of the first to try it. Every listed skill goes through the trust checks below.
Security scanned
Checked by our 8-point scan before listing
Fresh listing
Recently published to Agensi
Free to use
No account required to browse
Trust & safety
Security scan
Security scan passed 18 days ago
- Free with an Agensi account
- Software
Python 3.11+mjg CLI (install separately from GitHub)
The ZIP contains SKILL.md and two references. Install the companion mjg CLI from the linked GitHub repository for automated checks and hook setup. Manual guidance can be read without the CLI.
Permissions
Reads Java source and build configuration to identify project versions; uses the local mjg CLI for supported pattern checks. The coding agent needs file-write access when applying requested refactors. No connected service account is required.
What's inside
Creator
장준민
Frequently Asked Questions
New in APIs & Backend
Find more skills like this on the Claude Skills Marketplace, the Codex Skills Marketplace and the Gemini Skills Marketplace, or browse Claude Skills for APIs & Backend.