Skip to main content
rule CX Codex

spring-performance · kyy-logs, code-review-gate — Claude Code rule: what it does, how to install

The spring-performance Claude Code rule sets Spring/JPA and performance checks. It flags issues in validation, transactions, queries, and batch operations.

MIT ★ 517 updated 2026-11-16

Install into Claude Code · Manually: put the files in place All methods and platforms ↓
.claude/rules/spring-performance.md
Open on GitHub

What spring-performance does

The rule guides reviews of Spring and JPA code. It checks request validation with @Valid, transaction boundaries, and centralized exception handling through @RestControllerAdvice. For entity relationships, it calls out N+1 queries and points to JOIN FETCH or EntityGraph as alternatives.

It also flags string concatenation inside loops and single-row inserts where batch operations are shown instead. Server guidance covers Linux and JVM settings, including ulimit -n 65535; the Linux default of 1024 file handles is described as insufficient. In Claude Code, place the rule at .claude/rules/spring-performance.md.

What it helps with

  • catch missing validation on Spring request parameters
  • review transaction boundaries in service methods
  • spot N+1 queries when loading related entities
  • replace per-record inserts with batch operations
  • find repeated string concatenation inside loops

Example prompts for the agent

  • Review my Spring controllers for missing request validation.
  • Find N+1 queries in the JPA code and suggest a fix.
  • Check the services for transaction and batch-insert issues.

How to install spring-performance

Manually: put the files in place

.claude/rules/spring-performance.md

The paths frontmatter field limits the files

Step by step, with commands for each platform: AGENTS.md vs CLAUDE.md: what they are and which one to use

Questions about spring-performance

How do I install spring-performance in Claude Code?

Place the rule file in the project at .claude/rules/spring-performance.md.

What does spring-performance do?

It guides Spring/JPA reviews, covering request validation, transaction handling, N+1 queries, string creation, and batch operations.

What does spring-performance check in JPA queries?

It flags N+1 query patterns when loading related entities and points to JOIN FETCH or EntityGraph.

Source text

spring-performance.md · MIT
# Spring/JPA and performance guidelines

## Spring/JPA best practices

### Parameter validation
**Detection mode**: semantic

```java
// Correct: validate with @Valid
@PostMapping("/users")
public UserDTO createUser(@Valid @RequestBody UserCreateRequest request) {
    return userService.create(request);
}

@Data
public class UserCreateRequest {
    @NotBlank(message = "username must not be blank")
    @Size(min = 2, max = 50, message = "username length must be 2-50")
    private String name;
    
    @Email(message = "invalid email format")
    private String email;
    
    @Min(value = 0, message = "age must not be negative")
    private Integer age;
}
```

### Transaction management
**Detection mode**: semantic

```java
// Correct: explicit transaction scope
@Transactional(rollbackFor = Exception.class)
public void createUser(User user, UserProfile profile) {
    userDao.insert(user);
    profile.setUserId(user.getId());
    profileDao.insert(profile);
}

// Note: read-only operations should not use a transaction, or should use a read-only transaction
@Transactional(readOnly = true)
public User getUser(Long id) {
    return userDao.findById(id);
}
```

### N+1 query prevention
**Detection mode**: semantic

```java
// Wrong: N+1 queries
List<User> users = userDao.findAll();
for (User user : users) {
    List<Order> orders = orderDao.findByUserId(user.getId());  // N queries!
    user.setOrders(orders);
}

// Correct: use JOIN FETCH
@Query("SELECT u FROM User u LEFT JOIN FETCH u.orders WHERE u.id IN :ids")
List<User> findWithOrders(@Param("ids") List<Long> ids);

// Or use EntityGraph
@Entity
@NamedEntityGraph(name = "User.withOrders", 
    attributeNodes = @NamedAttributeNode("orders"))
public class User { ... }
```

### Unified exception handling
**Detection mode**: semantic

```java
// Unified exception handling
@RestControllerAdvice
public class GlobalExceptionHandler {
    
    @ExceptionHandler(BusinessException.class)
    public ResponseEntity<ErrorResponse> handleBusiness(BusinessException e) {
        return ResponseEntity.badRequest()
            .body(new ErrorResponse(e.getCode(), e.getMessage()));
    }
    
    @ExceptionHandler(Exception.class)
    public ResponseEntity<ErrorResponse> handleOther(Exception e) {
        log.error("Unexpected error", e);
        return ResponseEntity.internalServerError()
            .body(new ErrorResponse("SYSTEM_ERROR", "system error"));
    }
}
```

## Performance guidelines

### Server configuration
**Detection mode**: semantic

| Setting | Description | Recommended value |
|-------|------|-------|
| TCP time_wait timeout | Lower it in high-concurrency scenarios | `net.ipv4.tcp_fin_timeout=30` |
| Maximum file handles | The Linux default of 1024 is insufficient | `ulimit -n 65535` |
| JVM HeapDump | Generate a heap dump on OOM | `-XX:+HeapDumpOnOutOfMemoryError` |

### Object creation
**Detection mode**: semantic

```java
// Wrong: create strings in a loop
String result = "";
for (String item : list) {
    result += item + ",";  // creates a new String each time!
}

// Correct: use StringBuilder
StringBuilder sb = new StringBuilder();
for (String item : list) {
    if (sb.length() > 0) sb.append(",");
    sb.append(item);
}
String result = sb.toString();

// Or use String.join
String result = String.join(",", list);
```

### Batch operations
**Detection mode**: semantic

```java
// Wrong: one insert per iteration
for (User user : users) {
    userDao.insert(user);  // N IOs!
}

// Correct: batch insert
userDao.batchInsert(users);
```

© kyy-logs · MIT · kyy-logs/code-review-gate-skill

Similar IDE rules

All IDE rules for Backend and APIs →

spring-performance by other authors comes first.

spring-performance kyy-logs spring-performance is a Claude Code rule for Spring/JPA practices and performance tuning. It guides agents working on Java code, database queries, and server settings. CX Codex +1 ★ 517repo stars 311-frameworks-spring-jdbc Juan Antonio Breña Moral 311-frameworks-spring-jdbc — a skill that reviews and writes Spring JDBC code: pushes JdbcClient, catches SQL injection, fixes transaction boundaries. CX Codex +1 352installs java-spring-boot pluginagentmarketplace java-spring-boot generates production-grade Spring Boot 3.x code, covering REST controllers, Spring Security with JWT, Spring Data JPA repositories, and Actuator metrics. CX Codex +1 11,800installs spring-data-jpa giuseppe-trisciuoglio spring-data-jpa is a Claude Code skill for building Spring Data JPA persistence layers. It comes into play for repository, query, relationship, transaction, audit, and pagination work. CX Codex +1 4,300installs spring-boot-crud-patterns giuseppe-trisciuoglio spring-boot-crud-patterns — a skill that builds the whole CRUD layer for Spring Boot 3 services: aggregates, JPA repositories, DTOs and REST controllers in a feature-based layout. CX Codex +1 4,100installs spring-boot-patterns decebals spring-boot-patterns — a skill that hands your agent the package layout and templates for Spring Boot controllers, services and repositories. Useful when new code gets written or reviewed. CX Codex +1 375installs 312-frameworks-spring-data-jdbc Juan Antonio Breña Moral 312-frameworks-spring-data-jdbc — a skill that applies Spring Data JDBC rules to Java records: entities, repositories, aggregate boundaries, transactions, N+1 avoidance. CX Codex +1 349installs

From the same set10

The whole set →
index The index Claude Code rule describes the built-in code review files and how the tool locates them. A project rule pack replaces the built-in pack instead of merging with it. CX Codex +1 ★ 517repo stars baseline-java The baseline-java Claude Code rule adds Java checks for security, concurrency, and exception handling. It applies during Java code review. CX Codex +1 ★ 517repo stars spring-performance spring-performance is a Claude Code rule for Spring/JPA practices and performance tuning. It guides agents working on Java code, database queries, and server settings. CX Codex +1 ★ 517repo stars concurrency This Claude Code rule sets Java concurrency guidelines. It covers thread pools, locks, shared records, and other sources of concurrent access bugs. CX Codex +1 ★ 517repo stars exception-logging exception-logging — a rule for Claude Code that enforces Java exception handling and logging standards. Runs during code review to catch empty catch blocks, unmasked data, and missing transaction rollbacks. CX Codex +1 ★ 517repo stars naming-format The naming-format Claude Code rule sets Java naming and formatting conventions. It covers classes, methods, constants, and control flow. CX Codex +1 ★ 517repo stars testing-engineering The testing-engineering Claude Code rule sets expectations for unit tests, project structure, and dependencies. It covers application layers, exception handling, and domain models. CX Codex +1 ★ 517repo stars code-review-gate The code-review-gate Claude Code skill reviews code changes before a commit or PR merge. It gathers the diff, checks test quality, and records issues. CX Codex +1 ★ 517repo stars

Project sponsors

Companies that keep this analytics open