Instructions for this repo
Project overview
- Spring Boot WebFlux (Reactive) application with AI-assisted development workflows.
- See
README.mdandspring-boot-development-best-practices.mdfor full details. - Best practices are documented in
spring-boot-development-best-practices.md. - Reusable examples live in
./snippets/.
How to use this guide
- Use these instructions as persistent session context for Claude.
- Before large changes, scan the "Best Practices" doc.
- Prefer patterns and examples from
./snippets/when generating code or reviews. - When uncertain, ask for solutions that align with these docs.
Code style & architecture
- Follow the architecture and patterns described in
spring-boot-development-best-practices.md. - Prefer established Spring WebFlux patterns (reactive layers, configuration, testing strategies) from that doc.
- Do not introduce new frameworks or libraries unless explicitly requested.
Commands
- Build:
./mvnw clean package - Tests:
./mvnw test - Run:
./mvnw spring-boot:run
Safety & scope
- Propose a plan before changing more than a few files.
- Keep changes within the described architecture and conventions.
- If instructions conflict, prefer the Best Practices guide.
Development expectations
- Follow the layering and patterns from the Best Practices guide.
- Prefer existing libraries and approaches already used in the codebase.
- Suggest tests for new behavior, using the testing patterns from the guide.
- Keep snippets short and align with the surrounding file style.
What to Include
- Project overview - app purpose, key domains
- Tech stack - Spring Boot version, database, security, messaging
- Layering rules - controller/service/repo boundaries
- Spring-specific patterns - constructor injection,
@Transactional, test slices - Maven/Gradle commands - build, test, run, profiles
- DTO/validation patterns - request/response separation
Key Spring Boot Conventions Section
Spring Boot Conventions
Architecture:
- Layered: Controller → Service → Repository
- Controllers thin: validation + delegation only
- Services: business logic + reactive transactions when needed (e.g., using Spring’s
TransactionalOperatoror other reactive transaction management) - Repositories: Spring Data R2DBC or ReactiveMongoRepository
Dependency Injection:
- Constructor injection only (no
@Autowiredfields) @Service,@Repository,@RestControllerstereotypes@ConfigurationPropertiesfor external config
DTOs:
- Separate request/response DTOs from entities
@Valid+ Bean Validation on controllers- MapStruct/Lombok for entity↔DTO mapping
Services:
- Keep business logic in services; controllers only validate and delegate.
- Use constructor injection and reactive transactions when needed.
- Return
Mono/Fluxfrom service methods; avoid blocking calls.
Testing:
@WebFluxTestfor controllers@ExtendWith(MockitoExtension.class)for service unit tests@DataR2dbcTestor reactive test slices for repositories@SpringBootTestfor integration only- Use
WebTestClientfor HTTP layer tests
HTTP:
@RestControllerAdviceglobal exception handling- RESTful paths:
/api/v1/resources
Reactive:
- End-to-end
Mono/Fluxin controllers/services/repos - Avoid blocking calls (
block(),subscribe()in production paths) - Use reactive drivers (R2DBC, Reactive Mongo)
Security:
- Method security:
@PreAuthorize - Use reactive security (
SecurityWebFilterChain) - Secrets via env vars / Vault
Claude Code Skills for Spring Boot
Reactive skills are in snippets/skills/:
spring-controllerspring-servicespring-repositoryspring-exceptionspring-testspring-configspring-security
Usage examples (Claude):
/spring-controller UserController --feature users
/spring-service UserService
/spring-test UserController.javaArchitecture Patterns and Code Snippets
Recommended Project Structure
src/main/java/com/example/demo/
├── config/ # @Configuration classes
├── controller/ # @RestController (WebFlux)
├── dto/ # Request/response DTOs
│ ├── request/
│ └── response/
├── service/ # @Service business logic (reactive)
├── repository/ # Reactive repositories (R2DBC/Mongo)
├── model/ # Domain entities/documents
├── exception/ # Custom exceptions
└── Application.java
src/test/java/
├── controller/ # @WebFluxTest + WebTestClient
├── service/ # @ExtendWith(MockitoExtension.class) unit tests
├── repository/ # @DataR2dbcTest / reactive repo tests
└── integration/ # @SpringBootTestREST Controller + DTO Pattern
java
// dto/request/CreateUserRequest.java
public record CreateUserRequest(
@NotBlank String name,
@Email String email,
@Size(min=8) String password
) {}
// dto/response/UserResponse.java
record UserResponse(String id, String name, String email) {}
@RestController
@RequestMapping("/api/v1/users")
class UserController {
private final UserService userService;
public UserController(UserService userService) {
this.userService = userService;
}
@PostMapping
public Mono<ResponseEntity<UserResponse>> create(
@Valid @RequestBody Mono<CreateUserRequest> request) {
return request
.flatMap(userService::create)
.map(user -> ResponseEntity.created(URI.create("/api/v1/users/" + user.id()))
.body(user));
}
}Commands
- Build:
./mvnw clean package - Tests:
./mvnw test - Run:
./mvnw spring-boot:run
Review behavior
- When reviewing code, check alignment with the Best Practices guide.
- Highlight deviations and suggest concrete alternatives.
- Call out blocking or non-reactive code in WebFlux paths.