🎯

spring-boot

🎯Skill
g1joshi/agent-skills2 Installs9Last Updated Feb 10, 2026

Installation

$npx skills add g1joshi/agent-skills --skill spring-boot

Run it in a terminal; it asks which AI coding tools to install it for (Claude Code, Codex, Cursor and more).

Uses skills.sh Β· Node.js 22.20+

After installing

Ask for related work and the agent uses it on its own, or call it yourself.

Run it (Claude Code)/spring-boot
Install by hand

Copy the whole skill folder from GitHub to the place below. Copying only SKILL.md can leave out files the skill uses.

Open the skill folder β†’
  • This project .claude/skills/spring-boot/
  • All projects ~/.claude/skills/spring-boot/

These paths are for Claude Code. For other tools, the command above puts it in the right place.

Expert Spring Boot assistance covering Java enterprise microservices, auto-configuration, Spring Data JPA, Spring Security, actuator observability, and REST controllers. Use when building production-grade enterprise Java backends, configuring Spring Boot applications, or tuning JVM performance.

Spring Boot

Java framework for building production-ready microservices.

When to Use

  • Enterprise Java applications
  • Microservices architecture
  • REST APIs with Java/Kotlin
  • Cloud-native applications

Quick Start

@RestController
@RequestMapping("/api/users")
public class UserController {
    private final UserService userService;

    public UserController(UserService userService) {
        this.userService = userService;
    }

    @GetMapping("/{id}")
    public ResponseEntity<User> getUser(@PathVariable Long id) {
        return userService.findById(id)
            .map(ResponseEntity::ok)
            .orElse(ResponseEntity.notFound().build());
    }

    @PostMapping
    public ResponseEntity<User> createUser(@Valid @RequestBody CreateUserRequest request) {
        User user = userService.create(request);
        return ResponseEntity.created(URI.create("/api/users/" + user.getId())).body(user);
    }
}

Core Concepts

Dependency Injection

@Service
@Transactional(readOnly = true)
public class UserService {
    private final UserRepository repository;
    private final PasswordEncoder passwordEncoder;

    public UserService(UserRepository repository, PasswordEncoder passwordEncoder) {
        this.repository = repository;
        this.passwordEncoder = passwordEncoder;
    }

    @Transactional
    public User create(CreateUserRequest request) {
        User user = new User();
        user.setEmail(request.email());
        user.setPassword(passwordEncoder.encode(request.password()));
        return repository.save(user);
    }

    public Optional<User> findById(Long id) {
        return repository.findById(id);
    }
}

Spring Data JPA

@Entity
@Table(name = "users")
public class User {
    @Id
    @GeneratedValue(strategy = GenerationType.IDENTITY)
    private Long id;

    @Column(nullable = false, unique = true)
    private String email;

    @OneToMany(mappedBy = "author", cascade = CascadeType.ALL)
    private List<Post> posts = new ArrayList<>();
}

public interface UserRepository extends JpaRepository<User, Long> {
    Optional<User> findByEmail(String email);

    @Query("SELECT u FROM User u WHERE u.active = true")
    List<User> findActiveUsers();
}

Common Patterns

Centralized Global Exception Handling

Problem: Unhandled exceptions leaking internal stack traces and creating inconsistent HTTP error responses.

Solution:

@RestControllerAdvice
public class GlobalExceptionHandler {

    @ExceptionHandler(ResourceNotFoundException.class)
    public ResponseEntity<ErrorResponse> handleNotFound(ResourceNotFoundException ex) {
        return ResponseEntity.status(404)
            .body(new ErrorResponse(ex.getMessage()));
    }

    @ExceptionHandler(MethodArgumentNotValidException.class)
    public ResponseEntity<ErrorResponse> handleValidation(MethodArgumentNotValidException ex) {
        Map<String, String> errors = ex.getBindingResult().getFieldErrors().stream()
            .collect(Collectors.toMap(
                FieldError::getField,
                FieldError::getDefaultMessage
            ));
        return ResponseEntity.badRequest().body(new ErrorResponse("Validation failed", errors));
    }
}

Best Practices

Do:

  • Use constructor injection
  • Use Spring Data repositories
  • Implement proper error handling
  • Use profiles for environments

Don't:

  • Use field injection (@Autowired on fields)
  • Expose entities directly
  • Skip validation annotations
  • Hardcode configuration

Troubleshooting

ErrorCauseSolution
Bean not foundMissing @ComponentAdd stereotype annotation
Circular dependencyConstructor circularUse setter or @Lazy
N+1 queriesMissing fetch joinUse @EntityGraph or JOIN FETCH

References

More from this repository10