java-adr
Creates, lists, and manages Architecture Decision Records for Java projects. Use when user asks to "create an ADR", "document this decision", "write an…
Reviews Spring Data JPA for N+1 queries, fetch strategies, projections, and Specifications. Use when user asks to "review JPA", "check for N+1", "JPA performance", "review my entities", "check fetch strategy", or "review my repositories".
$ npx -y skills add ducpm2303/claude-java-plugins --skill java-jpa --agent claude-codeHow it fires
How this skill gets triggered: by you, by Claude, or both.
/java-jpaContext preview
The summary Claude sees to decide when to auto-load this skill.
Reviews Spring Data JPA for N+1 queries, fetch strategies, projections, and Specifications. Use when user asks to "review JPA", "check for N+1", "JPA performance", "review my entities", "check fetch strategy", or "review my repositories".
description: Reviews Spring Data JPA for N+1 queries, fetch strategies, projections, and Specifications. Use when user asks to "review JPA", "check for N+1", "JPA performance", "review my entities", "check fetch strategy", or "review my repositories". argument-hint: "[file or class to review, optional]"
You are a Spring Data JPA specialist. Review JPA code for common performance and correctness problems.
Check `pom.xml` or `build.gradle` for:
If neither is found, ask the user.
If the user provided a file or class name, focus on that. Otherwise, scan for:
Look for:
For each N+1 found, show:
⚠️ N+1 DETECTED: UserService.getUsersWithOrders()
Problem: orders collection loaded lazily inside a loop (line 42)
Fix:
Option A — @EntityGraph on the repository method:
@EntityGraph(attributePaths = {"orders"})
List<User> findAll();
Option B — JOIN FETCH in JPQL:
@Query("SELECT u FROM User u JOIN FETCH u.orders")
List<User> findAllWithOrders();Check if entities are returned where only a subset of fields is needed:
💡 PROJECTION OPPORTUNITY: UserRepository.findAllForList()
Returns full User entity but only id, name, email are used in UserListDto.
Fix: Use an interface projection or record projection (Java 16+):
// Interface projection (Java 8+)
public interface UserSummary {
Long getId();
String getName();
String getEmail();
}
List<UserSummary> findAllBy();
// Record projection (Java 16+, Spring Boot 2.6+)
public record UserSummary(Long id, String name, String email) {}
@Query("SELECT new com.example.UserSummary(u.id, u.name, u.email) FROM User u")
List<UserSummary> findAllSummaries();If dynamic queries are constructed with string concatenation or if/else JPQL building:
💡 SPECIFICATION OPPORTUNITY: ProductRepository
Dynamic query built with string concatenation is brittle and not type-safe.
Fix: Use JpaSpecificationExecutor<Product> + Specification<Product>:
public static Specification<Product> hasCategory(String category) {
return (root, query, cb) ->
category == null ? null : cb.equal(root.get("category"), category);
}
public static Specification<Product> priceBetween(BigDecimal min, BigDecimal max) {
return (root, query, cb) ->
cb.between(root.get("price"), min, max);
}
// Usage:
repo.findAll(hasCategory(cat).and(priceBetween(min, max)));Produce a structured report:
## JPA Review — [ClassName or scope] ### Critical Issues [N+1 problems, missing transactions on writes] ### Performance Improvements [Fetch strategies, projections, pagination] ### Design Suggestions [Entity design, Specifications, equals/hashCode] ### Minor Notes [readOnly transactions, GenerationType, etc.] ### Summary X critical · Y performance · Z design · W minor
For each issue include: what was found, why it matters, and the exact fix with code.
After the report, offer:
A Claude Code plugin marketplace with 3 focused plugins for Java developers. All plugins support Java 8 through Java 21 and tailor advice to your target Java version.
Creates, lists, and manages Architecture Decision Records for Java projects. Use when user asks to "create an ADR", "document this decision", "write an…
Reviews Java REST API design including HTTP methods, status codes, naming, and versioning. Use when user asks to "review my API", "check REST design", "is this…
Reviews or implements Clean Architecture / Hexagonal Architecture (Ports & Adapters) and DDD tactical patterns for Java projects. Use when user asks to "apply…
Generates a Conventional Commits message for staged Java changes. Use when user asks to "write a commit message", "help me commit", "what should my commit…
Reviews Java code for thread safety, race conditions, deadlocks, and Java 21 virtual thread compatibility. Use when user asks to "review concurrency", "is this…
Detects GoF patterns in Java code or recommends the right pattern for a problem. Use when user asks to "what pattern is this", "detect design patterns",…