Agent skill

Spring Boot Patterns

by decebals in decebals/claude-code-java

Spring Boot best practices and patterns. An agent skill from decebals/claude-code-java.

MITAuto-check passedBackend & APIs

Install Spring Boot Patterns

skills CLI
$ npx skills add decebals/claude-code-java --skill spring-boot-patterns -a claude-code

Project install by default; add -g for ~/.claude/skills/.

GitHub CLI
$ gh skill install decebals/claude-code-java spring-boot-patterns --agent claude-code

Project scope by default; add --scope user for a personal install. Needs GitHub CLI 2.90.0 or later (public preview).

Manual copy
$ git clone --depth 1 https://github.com/decebals/claude-code-java.git skills-src && mkdir -p .claude/skills && cp -r skills-src/skills/spring-boot-patterns .claude/skills/spring-boot-patterns && rm -rf skills-src

Use ~/.claude/skills/ instead of .claude/skills for a personal install. The folder must contain SKILL.md.

Claude Code skills documentation · loads skills from .claude/skills/

Facts

Skill name
spring-boot-patterns
GitHub stars
750
Token cost
~3.2k tokens
SKILL.md length
254 words
Files
2
Skills in repo
18
Repo updated
First seen
Licence
MIT

At a glance

Spring Boot best practices and patterns. An agent skill from decebals/claude-code-java.

  • Creating controllers
  • SKILL.md covers When to Use, Project Structure, Controller Patterns and Service Patterns, plus 7 more sections
  • Needs DB_PASSWORD and JWT_SECRET
  • The user asks about Spring Boot layering

What it does

Spring Boot Patterns is an agent skill from decebals/claude-code-java. Spring Boot best practices and patterns. Use when creating controllers, services or repositories, or when the user asks about Spring Boot layering, wiring, configuration or exception handling. For JPA and Hibernate behaviour, use jpa-patterns instead.

Its SKILL.md is about 3.2k tokens, which your agent loads only when the skill is triggered. The skill folder holds 1 other file (for example `README.md`).

It sits in Backend & APIs, covering Backend development and Error handling. It works with Spring Boot. The repository describes itself as: Reusable AI development infrastructure for Java projects, optimized for Claude Code. The licence is MIT.

When your agent uses it

  • Creating controllers
  • The user asks about Spring Boot layering
  • Exception handling

Example prompts

  • “/spring-boot-patterns”

Requirements

  • A credential in JWT_SECRET

What it can do on your machine

Read from SKILL.md and the folder at commit 0d98fe9. It shows what the files ask for, not the result of running them.

  • Tool permissions

    Pre-approves nothing: there is no allowed-tools line, so your agent's usual permission prompts apply.

    From allowed-tools in the SKILL.md frontmatter.

  • Runs code

    No scripts in the folder and no shell commands in SKILL.md (its code samples are java and yaml).

    From the folder's file list and the shell code blocks in SKILL.md.

  • Network

    No URLs in SKILL.md.

    From URLs in SKILL.md, links to its own repository left out.

  • Credentials

    Names these keys or tokens, usually read from environment variables:

    • DB_PASSWORD
    • JWT_SECRET

    From names ending in _API_KEY, _TOKEN, _SECRET, _KEY or _PASSWORD in SKILL.md.

Context cost

Spring Boot Patterns loads about 3.2k tokens when it runs. Until then it costs about 68 tokens; SKILL.md has 254 words of instructions outside code blocks.

Always · name and description, kept in context so the agent knows when to use it
~68
When it runs · the whole SKILL.md, loaded when a task matches
~3.2k

Estimates: characters ÷ 4, the usual rule of thumb; real counts depend on the model's tokenizer. Scripts and assets cost tokens only if the agent reads them.

Safety

Auto-check passed

The automated check found no risky patterns in SKILL.md.

Automated static check — not a guarantee. Review scripts before installing. It scans the text of SKILL.md for risky patterns (piping downloads into a shell, reading credential files, hidden Unicode, destructive commands); files beside SKILL.md are not scanned.

SKILL.md

The full file from decebals/claude-code-java at commit 0d98fe9, republished under its MIT licence (© decebals). 254 words, ~3,157 tokens.

Download SKILL.mdSave it as .claude/skills/spring-boot-patterns/SKILL.md (or your agent's skills folder). This skill also uses 1 other file; get the full folder from GitHub.
name
spring-boot-patterns
description
Spring Boot best practices and patterns. Use when creating controllers, services or repositories, or when the user asks about Spring Boot layering, wiring, configuration or exception handling. For JPA and Hibernate behaviour, use jpa-patterns instead.
license
MIT

Spring Boot Patterns Skill

Best practices and patterns for Spring Boot applications.

When to Use

  • User says "create controller" / "add service" / "Spring Boot help"
  • Reviewing Spring Boot code
  • Setting up new Spring Boot project structure

Project Structure

src/main/java/com/example/myapp/
├── MyAppApplication.java          # @SpringBootApplication
├── config/                        # Configuration classes
│   ├── SecurityConfig.java
│   └── WebConfig.java
├── controller/                    # REST controllers
│   └── UserController.java
├── service/                       # Business logic
│   ├── UserService.java
│   └── impl/
│       └── UserServiceImpl.java
├── repository/                    # Data access
│   └── UserRepository.java
├── model/                         # Entities
│   └── User.java
├── dto/                           # Data transfer objects
│   ├── request/
│   │   └── CreateUserRequest.java
│   └── response/
│       └── UserResponse.java
├── exception/                     # Custom exceptions
│   ├── ResourceNotFoundException.java
│   └── GlobalExceptionHandler.java
└── util/                          # Utilities
    └── DateUtils.java

Controller Patterns

REST Controller Template
java
@RestController
@RequestMapping("/api/v1/users")
@RequiredArgsConstructor  // Lombok for constructor injection
public class UserController {

    private final UserService userService;

    @GetMapping
    public ResponseEntity<List<UserResponse>> getAll() {
        return ResponseEntity.ok(userService.findAll());
    }

    @GetMapping("/{id}")
    public ResponseEntity<UserResponse> getById(@PathVariable Long id) {
        return ResponseEntity.ok(userService.findById(id));
    }

    @PostMapping
    public ResponseEntity<UserResponse> create(
            @Valid @RequestBody CreateUserRequest request) {
        UserResponse created = userService.create(request);
        URI location = ServletUriComponentsBuilder.fromCurrentRequest()
            .path("/{id}")
            .buildAndExpand(created.getId())
            .toUri();
        return ResponseEntity.created(location).body(created);
    }

    @PutMapping("/{id}")
    public ResponseEntity<UserResponse> update(
            @PathVariable Long id,
            @Valid @RequestBody UpdateUserRequest request) {
        return ResponseEntity.ok(userService.update(id, request));
    }

    @DeleteMapping("/{id}")
    public ResponseEntity<Void> delete(@PathVariable Long id) {
        userService.delete(id);
        return ResponseEntity.noContent().build();
    }
}
Controller Best Practices
PracticeExample
Versioned API/api/v1/users
Plural nouns/users not /user
HTTP methodsGET=read, POST=create, PUT=update, DELETE=delete
Status codes200=OK, 201=Created, 204=NoContent, 404=NotFound
Validation@Valid on request body
❌ Anti-patterns
java
// ❌ Business logic in controller
@PostMapping
public User create(@RequestBody User user) {
    user.setCreatedAt(LocalDateTime.now());  // Logic belongs in service
    return userRepository.save(user);         // Direct repo access
}

// ❌ Returning entity directly (exposes internals)
@GetMapping("/{id}")
public User getById(@PathVariable Long id) {
    return userRepository.findById(id).get();
}

Service Patterns

Service Interface + Implementation
java
// Interface
public interface UserService {
    List<UserResponse> findAll();
    UserResponse findById(Long id);
    UserResponse create(CreateUserRequest request);
    UserResponse update(Long id, UpdateUserRequest request);
    void delete(Long id);
}

// Implementation
@Service
@RequiredArgsConstructor
@Transactional(readOnly = true)  // Default read-only
public class UserServiceImpl implements UserService {

    private final UserRepository userRepository;
    private final UserMapper userMapper;

    @Override
    public List<UserResponse> findAll() {
        return userRepository.findAll().stream()
            .map(userMapper::toResponse)
            .toList();
    }

    @Override
    public UserResponse findById(Long id) {
        return userRepository.findById(id)
            .map(userMapper::toResponse)
            .orElseThrow(() -> new ResourceNotFoundException("User", id));
    }

    @Override
    @Transactional  // Write transaction
    public UserResponse create(CreateUserRequest request) {
        User user = userMapper.toEntity(request);
        User saved = userRepository.save(user);
        return userMapper.toResponse(saved);
    }

    @Override
    @Transactional
    public void delete(Long id) {
        if (!userRepository.existsById(id)) {
            throw new ResourceNotFoundException("User", id);
        }
        userRepository.deleteById(id);
    }
}
Service Best Practices
  • Interface + Impl for testability
  • @Transactional(readOnly = true) at class level
  • @Transactional for write methods
  • Throw domain exceptions, not generic ones
  • Use mappers (MapStruct) for entity ↔ DTO conversion

Repository Patterns

JPA Repository
java
public interface UserRepository extends JpaRepository<User, Long> {

    // Derived query
    Optional<User> findByEmail(String email);

    List<User> findByActiveTrue();

    // Custom query
    @Query("SELECT u FROM User u WHERE u.department.id = :deptId")
    List<User> findByDepartmentId(@Param("deptId") Long departmentId);

    // Native query (use sparingly)
    @Query(value = "SELECT * FROM users WHERE created_at > :date",
           nativeQuery = true)
    List<User> findRecentUsers(@Param("date") LocalDate date);

    // Exists check (more efficient than findBy)
    boolean existsByEmail(String email);

    // Count
    long countByActiveTrue();
}
Repository Best Practices
  • Use derived queries when possible
  • Optional for single results
  • existsBy instead of findBy for existence checks
  • Avoid native queries unless necessary
  • Use @EntityGraph for fetch optimization

DTO Patterns

Request/Response DTOs
java
// Request DTO with validation
public record CreateUserRequest(
    @NotBlank(message = "Name is required")
    @Size(min = 2, max = 100)
    String name,

    @NotBlank
    @Email(message = "Invalid email format")
    String email,

    @NotNull
    @Min(18)
    Integer age
) {}

// Response DTO
public record UserResponse(
    Long id,
    String name,
    String email,
    LocalDateTime createdAt
) {}
MapStruct Mapper
java
@Mapper(componentModel = "spring")
public interface UserMapper {

    UserResponse toResponse(User entity);

    List<UserResponse> toResponseList(List<User> entities);

    @Mapping(target = "id", ignore = true)
    @Mapping(target = "createdAt", ignore = true)
    User toEntity(CreateUserRequest request);
}

Exception Handling

Custom Exceptions
java
public class ResourceNotFoundException extends RuntimeException {

    public ResourceNotFoundException(String resource, Long id) {
        super(String.format("%s not found with id: %d", resource, id));
    }
}

public class BusinessException extends RuntimeException {

    private final String code;

    public BusinessException(String code, String message) {
        super(message);
        this.code = code;
    }
}
Global Exception Handler
java
@RestControllerAdvice
@Slf4j
public class GlobalExceptionHandler {

    @ExceptionHandler(ResourceNotFoundException.class)
    public ResponseEntity<ErrorResponse> handleNotFound(ResourceNotFoundException ex) {
        log.warn("Resource not found: {}", ex.getMessage());
        return ResponseEntity.status(HttpStatus.NOT_FOUND)
            .body(new ErrorResponse("NOT_FOUND", ex.getMessage()));
    }

    @ExceptionHandler(MethodArgumentNotValidException.class)
    public ResponseEntity<ErrorResponse> handleValidation(
            MethodArgumentNotValidException ex) {
        List<String> errors = ex.getBindingResult().getFieldErrors().stream()
            .map(e -> e.getField() + ": " + e.getDefaultMessage())
            .toList();
        return ResponseEntity.badRequest()
            .body(new ErrorResponse("VALIDATION_ERROR", errors.toString()));
    }

    @ExceptionHandler(Exception.class)
    public ResponseEntity<ErrorResponse> handleGeneric(Exception ex) {
        log.error("Unexpected error", ex);
        return ResponseEntity.status(HttpStatus.INTERNAL_SERVER_ERROR)
            .body(new ErrorResponse("INTERNAL_ERROR", "An unexpected error occurred"));
    }
}

public record ErrorResponse(String code, String message) {}

Configuration Patterns

Application Properties
yaml
# application.yml
spring:
  datasource:
    url: jdbc:postgresql://localhost:5432/mydb
    username: ${DB_USER}
    password: ${DB_PASSWORD}
  jpa:
    hibernate:
      ddl-auto: validate  # Never 'create' in production!
    show-sql: false

app:
  jwt:
    secret: ${JWT_SECRET}
    expiration: 86400000
Configuration Properties Class
java
@Configuration
@ConfigurationProperties(prefix = "app.jwt")
@Validated
public class JwtProperties {

    @NotBlank
    private String secret;

    @Min(60000)
    private long expiration;

    // getters and setters
}
Profile-Specific Configuration
src/main/resources/
├── application.yml           # Common config
├── application-dev.yml       # Development
├── application-test.yml      # Testing
└── application-prod.yml      # Production

Common Annotations Quick Reference

AnnotationPurpose
@RestControllerREST controller (combines @Controller + @ResponseBody)
@ServiceBusiness logic component
@RepositoryData access component
@ConfigurationConfiguration class
@RequiredArgsConstructorLombok: constructor injection
@TransactionalTransaction management
@ValidTrigger validation
@ConfigurationPropertiesBind properties to class
@Profile("dev")Profile-specific bean
@ScheduledScheduled tasks

Testing Patterns

Controller Test (MockMvc)
java
@WebMvcTest(UserController.class)
class UserControllerTest {

    @Autowired
    private MockMvc mockMvc;

    @MockBean
    private UserService userService;

    @Test
    void shouldReturnUser() throws Exception {
        when(userService.findById(1L))
            .thenReturn(new UserResponse(1L, "John", "john@example.com", null));

        mockMvc.perform(get("/api/v1/users/1"))
            .andExpect(status().isOk())
            .andExpect(jsonPath("$.name").value("John"));
    }
}
Service Test
java
@ExtendWith(MockitoExtension.class)
class UserServiceImplTest {

    @Mock
    private UserRepository userRepository;

    @Mock
    private UserMapper userMapper;

    @InjectMocks
    private UserServiceImpl userService;

    @Test
    void shouldThrowWhenUserNotFound() {
        when(userRepository.findById(1L)).thenReturn(Optional.empty());

        assertThatThrownBy(() -> userService.findById(1L))
            .isInstanceOf(ResourceNotFoundException.class);
    }
}
Integration Test
java
@SpringBootTest
@AutoConfigureMockMvc
@Testcontainers
class UserIntegrationTest {

    @Container
    static PostgreSQLContainer<?> postgres = new PostgreSQLContainer<>("postgres:15");

    @Autowired
    private MockMvc mockMvc;

    @Test
    void shouldCreateUser() throws Exception {
        mockMvc.perform(post("/api/v1/users")
                .contentType(MediaType.APPLICATION_JSON)
                .content("""
                    {"name": "John", "email": "john@example.com", "age": 25}
                    """))
            .andExpect(status().isCreated());
    }
}

Quick Reference Card

LayerResponsibilityAnnotations
ControllerHTTP handling, validation@RestController, @Valid
ServiceBusiness logic, transactions@Service, @Transactional
RepositoryData access@Repository, extends JpaRepository
DTOData transferRecords with validation annotations
ConfigConfiguration@Configuration, @ConfigurationProperties
ExceptionError handling@RestControllerAdvice

© decebals, MIT. Rendered from Markdown: HTML in the file is shown as text, images as links, and headings moved down two levels. Raw file

Files

SKILL.md and 1 other file in skills/spring-boot-patterns of decebals/claude-code-java.

  • SKILL.md
  • README.md

Open the folder on GitHubat commit 0d98fe9

Compare with similar skills

Spring Boot Patterns next to the 5 skills that share the most tags, products or categories with it. Stars are the repository's; “used in” counts other GitHub owners with a copy.

Spring Boot Patterns compared with similar skills
SkillStarsUsed inTokensAuto-checkLicenceRepo updated
Spring Boot Patterns this skilldecebals/claude-code-java750—~3.2kAutomated safety check: PassMIT
Restclient Migrationbenchflow-ai/skillsbench1.8k—~2.1kAutomated safety check: PassApache-2.0
Spring Boot Resilience4jgiuseppe-trisciuoglio/developer-kit355—~3.5kAutomated safety check: NotesMIT
Node Backend Development Guidelinesdiet103/claude-code-infrastructure-showcase10k2 repos~2kAutomated safety check: PassMIT
cmux Backend Rulesmanaflow-ai/cmux28k1 repos~682Automated safety check: PassCustom licence
Twenty Syncable Entity Wiringtwentyhq/twenty58k—~2.9kAutomated safety check: PassCustom licence

Similar skills

  • Restclient Migration

    benchflow-ai/skillsbench

    Migrate RestTemplate to RestClient in Spring Boot 3.2+. An agent skill from benchflow-ai/skillsbench.

    1.8k GitHub stars~2.1k tokensUpdated 2 mo ago
    Backend & APIsAuto-check passed
  • Spring Boot Resilience4j

    giuseppe-trisciuoglio/developer-kit

    Provides fault tolerance patterns for Spring Boot 3.x using Resilience4j.

    355 GitHub stars~3.5k tokensUpdated 27 days ago
    Backend & APIsAuto-check: notes
  • Node Backend Development Guidelines

    diet103/claude-code-infrastructure-showcase

    Sets layered architecture and coding rules for Node.js, Express and TypeScript microservices, covering routes, controllers, services, repositories, Prisma, Sentry and Zod.

    10k GitHub starsUsed in 2 repos~2k tokens
    Backend & APIsAuto-check passed
  • cmux Backend Rules

    manaflow-ai/cmux

    Sets the backend TypeScript and Cloud VM rules for cmux: Effect-based services, thin route handlers, Postgres as source of truth, migrations and provider secrets.

    28k GitHub starsUsed in 1 repo~682 tokens
    Backend & APIsAuto-check passed
  • Registers a new syncable entity in three NestJS modules and adds its service and GraphQL resolver layers when contributing to the Twenty server.

    58k GitHub stars~2.9k tokensUpdated today
    Backend & APIsAuto-check passed
  • Spring Boot

    piomin/claude-ai-spring-boot

    Spring Boot 3.x development - REST APIs, JPA, Security, Testing, and Cloud-native patterns.

    1.3k GitHub stars~2k tokensUpdated 5 mo ago
    Backend & APIsAuto-check passed

More from decebals/claude-code-java

All 18 skills in this repo
  • REST API Contract Review

    decebals/claude-code-java

    Reviews REST API design for correct HTTP verbs, versioning, DTO use, consistent responses and backward compatibility before an API change ships.

    750 GitHub starsUsed in 1 repo~2.8k tokens
    Auto-check passed
  • Java Architecture Review

    decebals/claude-code-java

    Reviews a Java project's architecture at the macro level: package structure, module boundaries, dependency direction and layering.

    750 GitHub starsUsed in 1 repo~2.2k tokens
    Auto-check passed
  • Java Design Patterns Reference

    decebals/claude-code-java

    A practical Java reference for Builder, Factory, Singleton, Strategy, Observer and other patterns, with a table matching problems to patterns.

    750 GitHub starsUsed in 1 repo~4.4k tokens
    Auto-check passed
  • Jpa Patterns

    decebals/claude-code-java

    JPA/Hibernate patterns and common pitfalls (N+1, lazy loading, transactions, queries).

    750 GitHub starsUsed in 1 repo~4k tokens
    Auto-check passed
  • Logging Patterns

    decebals/claude-code-java

    Java logging best practices with SLF4J, structured logging (JSON), and MDC for request tracing.

    750 GitHub starsUsed in 1 repo~3.3k tokens
    Auto-check passed
  • Changelog Generator for Java

    decebals/claude-code-java

    Builds changelog entries from conventional commits in a Java project, after working out whether it uses SemVer, two-part versions or calendar versions.

    750 GitHub stars~2.1k tokensUpdated 1 mo ago
    Auto-check passed

Works with

Categories

Questions about Spring Boot Patterns

What does Spring Boot Patterns do?

Spring Boot best practices and patterns. An agent skill from decebals/claude-code-java. Spring Boot Patterns is an agent skill from decebals/claude-code-java. Spring Boot best practices and patterns.

When should I use Spring Boot Patterns?

Spring Boot Patterns fits situations like: creating controllers; the user asks about Spring Boot layering; exception handling.

How do I install Spring Boot Patterns in Claude Code?

Run `npx skills add decebals/claude-code-java --skill spring-boot-patterns -a claude-code`. Or copy the skill folder (skills/spring-boot-patterns in decebals/claude-code-java) into .claude/skills/spring-boot-patterns in your project. Claude Code loads it when a task matches its description.

How do I install Spring Boot Patterns in Codex?

Run `npx skills add decebals/claude-code-java --skill spring-boot-patterns -a codex`. Or copy the skill folder (skills/spring-boot-patterns in decebals/claude-code-java) into .agents/skills/spring-boot-patterns in your project. Codex loads it when a task matches its description.

Can I use Spring Boot Patterns in Cursor, Gemini CLI or GitHub Copilot?

Cursor, Gemini CLI, GitHub Copilot and OpenCode also load SKILL.md folders. With the skills CLI, run `npx skills add decebals/claude-code-java --skill spring-boot-patterns -a cursor` (or -a gemini-cli, github-copilot or opencode for the others). To copy it by hand, put the folder in .cursor/skills/spring-boot-patterns, .gemini/skills/spring-boot-patterns, .github/skills/spring-boot-patterns and .opencode/skills/spring-boot-patterns in your project.

What does Spring Boot Patterns need to run?

Going by SKILL.md and its folder, Spring Boot Patterns needs credentials named DB_PASSWORD and JWT_SECRET. Our summary lists: A credential in JWT_SECRET.

Does Spring Boot Patterns access the network?

SKILL.md contains no URLs. Any network use would come from the scripts or tools the agent runs. This is read from the text; nothing was executed.

Is Spring Boot Patterns safe to install?

Our automated static check of SKILL.md found no risky patterns, such as piping downloads into a shell, reading credential files or hidden Unicode. It is not a guarantee. Review the folder before installing.

What licence does Spring Boot Patterns use?

Spring Boot Patterns is published under the MIT licence (declared in SKILL.md). It allows redistribution, so the full SKILL.md is shown on this page.

How many tokens does Spring Boot Patterns use?

About 3.2k tokens (SKILL.md is roughly 13k characters). Agents keep only the skill's name and description in context until a task matches; then they load SKILL.md in full.

What are the alternatives to Spring Boot Patterns?

Skills that share tags, products or a category with Spring Boot Patterns: Restclient Migration (benchflow-ai/skillsbench, 1.8k stars), Spring Boot Resilience4j (giuseppe-trisciuoglio/developer-kit, 355 stars), Node Backend Development Guidelines (diet103/claude-code-infrastructure-showcase, 10k stars) and cmux Backend Rules (manaflow-ai/cmux, 28k stars). The comparison table on this page puts their stars, adoption, token cost, safety result and licence side by side.

Who maintains Spring Boot Patterns?

decebals (a GitHub user) maintains it in decebals/claude-code-java, which has 750 GitHub stars. The repository holds 18 skills in this directory. The repository was last updated on September 6, 2026.

Source: decebals/claude-code-java on GitHub. Facts on this page come from the repository at the commit we read; the author's words are quoted as theirs.