Code Review & Quality
Compatible with Cursor, Claude Code, Cline, Roo Code, Antigravity, GitHub Copilot

Spring Boot Service & JPA Code Review

Rigorous code review workflow for Spring Boot services examining transactions, JPA queries, concurrency, and validation.

JavaSpring BootJPAHibernatePostgreSQLBackend
Skill Objective

Review Spring Boot pull requests and service implementations for architectural correctness, transaction integrity, JPA performance traps (N+1 queries), and thread safety before merging.

Execution Workflow Procedure

Ordered steps the coding agent executes when performing this skill.

1

Inspect Changed Files & Entity Relationships

Analyze the diff, entity definitions (@Entity, @Table), and repository interfaces. Identify any relationships (@OneToMany, @ManyToMany) that could trigger eager loading or cascading mutations.

2

Audit Transaction Boundaries & Propagation

Verify @Transactional placement. Ensure long-running network operations (HTTP/gRPC/Email) are NOT executed inside active database transaction blocks holding connection pool leases.

3

Check Concurrency & Spring Bean Scope

Verify that Singleton Spring beans (@Service, @Component) do not store mutable state across requests. Check optimistic locking (@Version) for concurrent update paths.

4

Validate Error Handling & Bean Validation

Ensure inputs are validated with Jakarta annotations (@Valid, @NotNull) and exceptions are translated into RFC 7807 Problem Details via @RestControllerAdvice.

5

Synthesize Findings by Severity

Output prioritized findings categorized as Blockers, Warnings, or Suggestions, accompanied by corrected code snippets and Testcontainers test cases.

Agent Safety Guardrails & Anti-Hallucination Rules

  • DO NOT rewrite unrelated controller or repository methods outside the diff scope.
  • DO NOT assume default JPA fetch types; explicitly verify if relationship mappings are LAZY or EAGER.
  • DO NOT recommend adding synchronized keywords to singleton beans without assessing thread pool contention.

Expected Output Format

Structured markdown report with severity grading and code diffs.

🔴 Blockers (Must Fix): Critical concurrency bugs, unhandled rollbacks, or N+1 queries.
⚠️ Warnings (Recommended): Suboptimal caching, missing validations, or loose transaction boundaries.
💡 Suggestions: Idiomatic Java 21 / Spring Boot 3 clean code enhancements.
🛠️ Corrected Implementation: Complete refactored Java code snippet.

Domain Verification Checks

No Remote I/O in Transactions: Ensures third-party HTTP calls are decoupled from database transactions.
JPA N+1 Elimination: Verifies queries use join fetch or EntityGraph for nested relations.
Bean Immutability: Validates Spring services avoid non-final mutable instance fields.
Problem Details Contract: Enforces standard RFC 7807 error responses.

Example Agent Invocations

"Review the OrderService and OrderRepository changes in this pull request for JPA and concurrency traps."
"Audit this Spring Boot payment webhook handler before we deploy it to staging."

Install / Configure This Skill

# Place in .cursorrules or create .cursor/rules/spring-boot-code-review.mdc
# Trigger: Whenever you perform spring boot service & jpa code review

---
name: spring-boot-code-review
description: Review Spring Boot services, controllers, and repositories for JPA performance, transaction boundaries, concurrency, and validation.
version: 1.2.0
compatibility: [Cursor, Claude Code, Cline, Roo Code, Antigravity]
---

# Spring Boot Service & JPA Code Review

## Objective
Conduct a comprehensive, production-grade code review of Spring Boot changes. Identify subtle JPA traps (N+1 queries), improper transaction scopes, concurrency hazards, and missing validations before code merges.

## Workflow

1. **Context & Entity Discovery**:
   - Inspect all modified `@Entity`, `@Repository`, and `@Service` files.
   - Verify relationship fetch strategies (ensure `FetchType.LAZY` is preferred for `@OneToMany` and `@ManyToOne`).

2. **Transaction Integrity Audit**:
   - Check `@Transactional` annotations for correct propagation (`REQUIRED`, `REQUIRES_NEW`).
   - Flag any remote HTTP requests (e.g. `RestTemplate`, `WebClient`, Stripe API calls) executed inside an active database transaction.

3. **Concurrency & Thread Safety**:
   - Inspect Spring singleton beans for mutable instance fields.
   - For concurrent update operations, verify optimistic locking (`@Version`) or explicit `SELECT ... FOR UPDATE` locking.

4. **Input Validation & Exception Translation**:
   - Enforce Jakarta bean validation (`@Valid`, `@NotBlank`, `@Positive`).
   - Verify exceptions are mapped via `@ControllerAdvice` into standard RFC 7807 Problem Details.

5. **Deliver Structured Findings**:
   - Group findings by severity (Blockers, Warnings, Suggestions) with exact file locations and code diffs.

## Guardrails
- DO NOT rewrite unrelated service code.
- DO NOT assume JPA fetch defaults; inspect entity annotations directly.
- Always provide runnable corrected code with Testcontainers test examples.
Complementary Agent Prompt

Need a quick one-time prompt for chat?

Try the Spring Boot REST Service & JPA Code Review — a lightweight version designed for 1-click copying directly into Claude, ChatGPT, or Cursor chat.

View Prompt

SprintKit Workflow Integrations

Complementary tools and checklists to pair with this agent workflow.

Related Agent Skills

Explore related procedural workflows in this discipline.

All Skills

Strict TypeScript Type Safety & Soundness Audit

Audit TypeScript code for type safety, type narrowing, generics, mutation traps, and runtime boundary validation.

TypeScriptNode.jsClean Code+1
4 workflow stepsView skill

Production Exception & Stack Trace Root-Cause Analysis

Systematic investigation workflow for diagnosing production exceptions and constructing verified patches.

DebuggingObservabilityLogs+2
4 workflow stepsView skill

Safe Legacy Code Modernization with Golden Master Tests

Safely modernize fragile legacy codebases using Martin Fowler refactoring patterns and characterization tests.

RefactoringClean CodeDesign Patterns+1
4 workflow stepsView skill