Back to Skills

spring-boot-rest-api-standards

Provides REST API design standards and best practices for Spring Boot projects. Use when creating or reviewing REST endpoints, DTOs, error handling, pagination, security headers, HATEOAS and architecture patterns.

303stars34forksUpdated 7/9/2026

Security Assessment

Low Risk(70/100)

Detected risks:

Secret Exposure([references/security-headers.md] Token =, [references/security-headers.md] token =)
Security Score70/100

About spring-boot-rest-api-standards

REST API design standards and best practices for Spring Boot projects, intended for use when creating or reviewing endpoints, DTOs, error handling, pagination, and security configuration. It lays out resource-based URL design (plural nouns, conventions like GET /users and POST /users, avoiding action URLs such as /getUserList), correct use of HTTP methods with their safety and idempotency semantics, and an appropriate mapping of status codes (200, 201 with a Location header, 204, 400, 404, 409, 500). Request and response DTOs are recommended to separate API contracts from domain entities, implemented as Java records or Lombok @Data/@Value types and annotated with Jakarta validation constraints such as @NotBlank, @Email, and @Size, applied through @Valid on @RequestBody parameters. Error handling is centralized with a @RestControllerAdvice global handler that returns standardized responses (status, error, message, timestamp) and handles MethodArgumentNotValidException and ResponseStatusException. Pagination guidance uses Spring's Pageable with page, size, and sort parameters and returns metadata like total elements and total pages, and security guidance covers CORS, content security policy, and headers such as X-Frame-Options and X-Content-Type-Options. Worked examples include a full CRUD controller, request/response DTOs, and a global exception handler, plus best practices for constructor injection, immutable DTOs, and transaction management with @Transactional (including readOnly queries). The skill defines validation checkpoints between steps and a set of constraints and warnings — never expose entities directly, follow REST conventions, handle all exceptions globally, always paginate large result sets, validate all input, and never expose sensitive data such as passwords, tokens, or PII. A references directory and pointers to related dependency-injection and test-pattern skills provide further material.

FAQ

Why use DTOs instead of exposing entities?

DTOs separate API contracts from domain models; the standard warns never to expose entities directly and recommends immutable DTOs implemented as Java records or Lombok @Value types.

How is error handling structured?

A global @RestControllerAdvice handler returns standardized error responses with status, error, message, and timestamp, handling cases like MethodArgumentNotValidException and ResponseStatusException.

How should input validation be done?

Apply Jakarta validation annotations (@NotBlank, @Email, @Size, etc.) on request DTOs and use @Valid on @RequestBody parameters, with failures caught by the global exception handler.

What status codes are recommended?

200 OK for successful GET/PUT/PATCH, 201 Created with a Location header for POST, 204 No Content for DELETE, and 400/404/409/500 for bad requests, missing resources, conflicts, and unexpected errors.

How does it handle large result sets?

It recommends always paginating with Spring's Pageable using page, size, and sort parameters and returning metadata such as total elements and total pages, to avoid performance and DDoS issues.

All Files

8 files
references/examples.md17.6 KB
View
references/spring-web-annotations.md7.6 KB
View
references/pagination-and-filtering.md10.8 KB
View
references/references.md10.2 KB
View
references/http-reference.md2.8 KB
View
SKILL.md7.8 KB
View
references/architecture-patterns.md20.9 KB
View
references/security-headers.md18.3 KB
View

Install spring-boot-rest-api-standards

Download and extract the skill files to your .claude/skills/ directory.

Quick Setup:

  1. Copy the skill folder to .claude/skills/
  2. Claude will automatically detect and use the skill